Here is my try to calculate lyapunov spectrum of lorenz oscillator. I followed step by step from boost library program, but I can not reproduce the results.
import numpy as np import pylab as pl from copy import copy from numpy import dot, log from numpy.linalg import norm from scipy.integrate import odeint from sys import exit # system with out perturbation----------------------------# def lorenz(x0, t): x, y, z = x0 dxdt = s * (y - x) dydt = x * (r - z) - y dzdt = x * y - b * z return [dxdt, dydt, dzdt] #system with perturbation---------------------------------# def lorenz_with_lyap(x0, t): x,y,z = x0[:3] dxdt = [0.0]*12 dxdt[0] = s * (y - x) dxdt[1] = x * (r - z) - y dxdt[2] = x * y - b * z # this is jacobian*Y for l in range(3): m = 3*l+3 dxdt[m] = -s * x0[m] + s * x0[m+1] dxdt[m+1] = (r - z) * x0[m] -1.0 * x0[m+1] -1.0 * x * x0[m+2] dxdt[m+2] = y * x0[m] + x * x0[m+1] -b * x0[m+2] return dxdt #---------------------------------------------------------# def gram_schmidt(x0, lyap, t): # vectors a = x0[3: 6] b = x0[6: 9] c = x0[9:12] v1 = copy(a) v2 = b - dot(v1, b)/dot(v1, v1) * v1 v3 = c - dot(v1, c)/dot(v1, v1) * v1 -dot(v2, c)/dot(v2, v2) * v2 znorm = [0] * 3 znorm[0] = norm(v1) znorm[1] = norm(v2) znorm[2] = norm(v3) # normalize vectors x0[3:6 ] = v1/znorm[0] x0[6:9 ] = v2/znorm[1] x0[9:12] = v3/znorm[2] for i in range(3): lyap[i] += log(znorm[i])/t # parameters s = 10.0 r = 28.0 b = 8.0/3.0 stept = 1.0 dt = 0.01 n = 3 lyap = [0.0]*n x0 = np.zeros(12) initial_condition = [10.0, 10.0, 5.0] x0[:3] = copy(initial_condition) for i in range(3): x0[n+n*i+i]=1.0 # integrate trantient time t = np.arange(0, 10, 0.1) sol = odeint(lorenz, initial_condition, t) x0[:3] = copy(sol[-1,:]) # new initial condition ti = t[-1] tf = ti + stept for i in range(10): t_interval = np.arange(ti, tf, dt) sol = odeint(lorenz_with_lyap, x0, t_interval) x0 = copy(sol[-1,:]) gram_schmidt(x0, lyap, stept) for xx in lyap: print "%15.9f" % xx, print "" ti = tf tf = ti+stept
I think the problem is in gram_schmidt
function. Is the question clear? Thank you for any guide.
The post lyapunov spectrum of lorenz oscillator appeared first on 100% Private Proxies - Fast, Anonymous, Quality, Unlimited USA Private Proxy!.