-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathTuesday Apr 14 2015 - Lorenz Flow.py
104 lines (67 loc) · 1.84 KB
/
Tuesday Apr 14 2015 - Lorenz Flow.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from pyndamics import *
# <markdowncell>
# http://en.wikipedia.org/wiki/Lorenz_system
# <codecell>
sim=Simulation()
sim.add("x'=sigma*(y-x)",14,plot=True)
sim.add("y'=x*(rho-z)-y",8.1,plot=True)
sim.add("z'=x*y-beta*z",45,plot=True)
sim.params(sigma=10,beta=8.0/3,rho=15)
sim.run(0,50)
# <codecell>
phase_plot(sim,'x','y')
# <codecell>
sim.run(0,50,num_iterations=10000)
# <codecell>
phase_plot(sim,'x','y')
# <markdowncell>
# ## Larger $\rho$
# <codecell>
sim=Simulation()
sim.add("x'=sigma*(y-x)",14,plot=True)
sim.add("y'=x*(rho-z)-y",8.1,plot=True)
sim.add("z'=x*y-beta*z",45,plot=True)
sim.params(sigma=10,beta=8.0/3,rho=28)
sim.run(0,50,num_iterations=10000)
# <codecell>
phase_plot(sim,'x','y')
# <markdowncell>
# ## What happens in the case of starting with slightly different initial conditions?
# <codecell>
sim=Simulation()
sim.add("x'=sigma*(y-x)",14,plot=1)
sim.add("y'=x*(rho-z)-y",8.1,plot=2)
sim.add("z'=x*y-beta*z",45,plot=3)
sim.add("x2'=sigma*(y2-x2)",16,plot=1)
sim.add("y2'=x2*(rho-z2)-y2",8.1,plot=2)
sim.add("z2'=x2*y2-beta*z2",45,plot=3)
sim.params(sigma=10,beta=8.0/3,rho=15)
sim.run(0,50,num_iterations=10000)
subplot(1,2,1)
phase_plot(sim,'x','y')
phase_plot(sim,'x2','y2')
subplot(1,2,2)
phase_plot(sim,'x','z')
phase_plot(sim,'x2','z2')
# <markdowncell>
# ## changing $\rho$
# <codecell>
sim=Simulation()
sim.add("x'=sigma*(y-x)",14,plot=1)
sim.add("y'=x*(rho-z)-y",8.1,plot=2)
sim.add("z'=x*y-beta*z",45,plot=3)
sim.add("x2'=sigma*(y2-x2)",14.001,plot=1)
sim.add("y2'=x2*(rho-z2)-y2",8.1,plot=2)
sim.add("z2'=x2*y2-beta*z2",45,plot=3)
sim.params(sigma=10,beta=8.0/3,rho=28)
sim.run(0,50,num_iterations=10000)
subplot(1,2,1)
phase_plot(sim,'x','y')
phase_plot(sim,'x2','y2')
subplot(1,2,2)
phase_plot(sim,'x','z')
phase_plot(sim,'x2','z2')
# <codecell>