diff options
Diffstat (limited to 'examples/ode.hs')
-rw-r--r-- | examples/ode.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/ode.hs b/examples/ode.hs index 060d4c2..dc6e0ec 100644 --- a/examples/ode.hs +++ b/examples/ode.hs | |||
@@ -35,13 +35,16 @@ main = do | |||
35 | harmonic 1 0.1 | 35 | harmonic 1 0.1 |
36 | kepler 0.3 60 | 36 | kepler 0.3 60 |
37 | kepler 0.4 70 | 37 | kepler 0.4 70 |
38 | vanderpol' 2 | ||
38 | 39 | ||
40 | -- example of odeSolveV with jacobian | ||
39 | vanderpol' mu = do | 41 | vanderpol' mu = do |
40 | let xdot mu t (toList->[x,v]) = fromList [v, -x + mu * v * (1-x^2)] | 42 | let xdot mu t (toList->[x,v]) = fromList [v, -x + mu * v * (1-x^2)] |
41 | jac t (toList->[x,v]) = debug $ (2><2) [ 0 , 1 | 43 | jac t (toList->[x,v]) = (2><2) [ 0 , 1 |
42 | , -1-2*x*v*mu, mu*(1-x**2) ] | 44 | , -1-2*x*v*mu, mu*(1-x**2) ] |
43 | ts = linspace 1000 (0,50) | 45 | ts = linspace 1000 (0,50) |
44 | hi = (ts@>1 - ts@>0)/100 | 46 | hi = (ts@>1 - ts@>0)/100 |
45 | sol = toColumns $ odeSolveV BSimp hi 1E-8 1E-8 (xdot mu) (Just jac) (fromList [1,0]) ts | 47 | sol = toColumns $ odeSolveV (MSBDF jac) hi 1E-8 1E-8 (xdot mu) (fromList [1,0]) ts |
46 | mplot sol | 48 | mplot sol |
47 | 49 | ||
50 | |||