In [1]:
def TStep(f,x,dt=.00001):
x=[f(x)[i]*dt+x[i] for i in range(3)]
return x
class Dynamics():
x0=[1,1,1]
n=10000
dt=.0001
params=[10.,8./3,28]
def f(self,x):
return [self.params[0]*(x[1]-x[0]),x[0]*(self.params[2]-x[2])-x[1],x[0]*x[1]-self.params[1]*x[2]]
def Traj(self):
traj=[]
for i in range(self.n):
self.x0=TStep(self.f,self.x0,dt=self.dt)
traj.append(self.x0)
return traj
In [3]:
lor=Dynamics()
In [11]:
lor.n=100000
lor.dt=.01
traj=lor.Traj()
In [12]:
lor.x0
Out[12]:
In [16]:
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
mpl.rcParams['legend.fontsize'] = 10
traj=np.array(traj)
traj=traj.transpose()
fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z = np.linspace(-2, 2, 100)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(traj[0], traj[1], traj[2], label='parametric curve')
ax.legend()
plt.show()
In [6]:
import ROOT as rt
In [5]:
ROOT.TH1F
Out[5]:
In [ ]: