-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathThursday Feb 19 2015 - intro to Pyndamics.py
More file actions
87 lines (58 loc) · 1.21 KB
/
Thursday Feb 19 2015 - intro to Pyndamics.py
File metadata and controls
87 lines (58 loc) · 1.21 KB
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
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from pyndamics import *
# <codecell>
sim=Simulation()
sim.add("y'=constant",5,plot=True)
sim.params(constant=.1)
sim.run(0,10)
# <markdowncell>
# ## Another example - exponential!
# <codecell>
sim=Simulation()
sim.add("y'=a*y",0.1,plot=True)
sim.params(a=.02)
sim.run(0,90)
# <markdowncell>
# what happens if I run longer?
# <codecell>
sim=Simulation()
sim.add("y'=a*y",0.1,plot=True)
sim.params(a=.02)
sim.run(0,900)
# <markdowncell>
# ## yet another example - logistic!
#
# * $y'=ay\cdot (K-y)$
# * $K=100$
# * $a=0.02$
# * $t$ from 0 to 90
# * initia value of $y=0.1$
# <codecell>
sim=Simulation()
sim.add("y'=a*y*(1-y/K)",0.1,plot=True)
sim.params(a=.02,K=100)
sim.run(0,90)
# <markdowncell>
# what happens when I run longer?
# <codecell>
sim=Simulation()
sim.add("y'=a*y*(1-y/K)",0.1,plot=True)
sim.params(a=.02,K=100)
sim.run(0,900)
# <markdowncell>
# ## Example from HW
# <codecell>
sim=Simulation()
sim.add("x'=v",0,plot=True)
sim.add("v'=k-c*v**2",0,plot=True)
sim.params(k=5,c=.1)
sim.run(0,10)
# <codecell>
sim=Simulation()
sim.add("x'=v",0,plot=True)
sim.add("v'=k-c*v**2",0,plot=True)
sim.params(k=10,c=.1)
sim.run(0,2)
# <codecell>