forked from tianchuliang/MechanicsSimulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MidTerm_TianchuLiang.py
executable file
·54 lines (49 loc) · 826 Bytes
/
MidTerm_TianchuLiang.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Date: Feb7 2015
#Author: Tianchu(Alex) Liang
#IHRTLUHC
import numpy as np
from scipy.integrate import odeint
#Six Sets of Parameters:
a=0.1
b=0.1
c=14
#
a1=0.1
b1=0.1
c1=4
#
a2=a1
b2=b1
c2=6
#
a3=a1
b3=b1
c3=8.5
#
a4=a1
b4=b1
c4=8.7
#
a5=a1
b5=b1
c5=9
# =======================
#Differential Equations:
def df_dt(f,t):
x,y,z=f
dx_dt=-y-z
dy_dt=x+a5*y
dz_dt=b5+z*(x-c5)
return np.array([dx_dt, dy_dt, dz_dt])
#Define initial conditions of f and t,:
f0 = np.array([-10,0,0], dtype=np.float64)
t = np.linspace(0,1000,100000, dtype=np.float64)
#Solve the differential equations
f = odeint(df_dt, f0, t)
#Write the result to a file:
outfile = open( "R_attractor5.dat","w")
outfile.write( "Rossler Attractor\n")
outfile.write( "x y z\n")
for x,y,z in f:
outfile.write( "{} {} {}\n".format(x, y, z))
outfile.close()