I have created code that calculates the maximum Lyapunov exponents against two parameters a and b. This plots ok, however there is a chunk of the graph that is white where the graph is collapsing due to my x and y values equalling zero. Therefore, I need to set these equal to say 100 or similar to prevent this from happening and producing a fully coloured meshgrid plot.
I have already tried if statements but I either get a syntax error or another error a.any() a.all() when I substitute one of these into my if statement it returns another error. I have tried if elif and else statements and returning values. There is an error in them statements returning
ValueError: not enough values to unpack (expected 2, got 0)
The equations are in another cell defined as functions.
#diff values of a and b looping
a=np.linspace(0,6,80)
b=np.linspace(0,5,80)
def lyapunov(a,b):
#initial conditions
a,b = np.meshgrid(a,b)
d = 0.1
xold = 0.5
yold = 0.01
ee = 0.000001
#xnew and ynew values
for k in range(1000):
xnew=f(a,b,xold,yold)
ynew=g(b,d,xold,yold)
xold = xnew
yold = ynew
if np.any(xnew<ee) and np.any(ynew<ee):
ml = 100
return ml
elif np.any(xnew>ee) and np.any(ynew<ee):
ml = 50
return ml
else:
ml=0
for l in range(100):
ydash=1
ml = ml + np.log(abs(e(a,b,xold,yold,ydash)))
ydash = yz(a,b,xold,yold,ydash)
xold=f(a,b,xold,yold)
yold=g(b,d,xold,yold)
ml = (ml/(2*100))
return ml
z = lyapunov(a,b)
ax.set_title('Lyapunov Exponent')
c = ax.pcolormesh(z)
fig.colorbar(c)
plt.show()
I expect a completed mesh grid with no white of colour showing the system collapsing therefore very small 0 and therefore halfing the run time. At present only half the plot is coloured. ERROR is returning 'ValueError: not enough values to unpack (expected 2, got 0)
Aucun commentaire:
Enregistrer un commentaire