Debian Codegraph @

examples/tvtk/visual/lorenz.py

raw symbols SCIP
1 #!/usr/bin/env python
2
3 # Author: Raashid Baig <[email protected]>
4 # License: BSD Style.
5
6 from tvtk.tools.visual import curve, box, vector, show
7
8 lorenz = curve( color = (1,1,1), radius=0.3 )
9
10 # Draw grid
11 for x in range(0,51,10):
12 curve(points = [[x,0,-25],[x,0,25]], color = (0,0.5,0), radius = 0.3 )
13 box(pos=(x,0,0), axis=(0,0,50), height=0.4, width=0.4, length = 50)
14
15 for z in range(-25,26,10):
16 curve(points = [[0,0,z], [50,0,z]] , color = (0,0.5,0), radius = 0.3 )
17 box(pos=(25,0,z), axis=(50,0,0), height=0.4, width=0.4, length = 50)
18
19 dt = 0.01
20 y = vector(35.0, -10.0, -7.0)
21
22 pts = []
23 for i in range(2000):
24 # Integrate a funny differential equation
25 dydt = vector( -8.0/3*y[0] + y[1]*y[2],
26 - 10*y[1] + 10*y[2],
27 - y[1]*y[0] + 28*y[1] - y[2])
28 y = y + dydt * dt
29
30 pts.append(y)
31 if len(pts) > 20:
32 lorenz.extend(pts)
33 pts[:] = []
34
35 show()