summaryrefslogtreecommitdiff
path: root/packages/sundials/src/Main.hs
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2018-04-07 13:58:27 +0100
committerDominic Steinitz <dominic@steinitz.org>2018-04-07 13:58:27 +0100
commit35a8e1f9d942af92eac7c9340c91ffb3d5e710a0 (patch)
tree203d5b706a26b87a5a8cf509348b8edd273128c0 /packages/sundials/src/Main.hs
parent5b3a99d6be39981dbae52bd4d6cb594b3593e103 (diff)
Pass through tolerances
Diffstat (limited to 'packages/sundials/src/Main.hs')
-rw-r--r--packages/sundials/src/Main.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs
index 9978aa5..6d6a397 100644
--- a/packages/sundials/src/Main.hs
+++ b/packages/sundials/src/Main.hs
@@ -69,6 +69,12 @@ stiffish t v = [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ]
69 lamda = -100.0 69 lamda = -100.0
70 u = v !! 0 70 u = v !! 0
71 71
72stiffishV :: Double -> Vector Double -> Vector Double
73stiffishV t v = fromList [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ]
74 where
75 lamda = -100.0
76 u = v ! 0
77
72stiffJac :: Double -> Vector Double -> Matrix Double 78stiffJac :: Double -> Vector Double -> Matrix Double
73stiffJac _t _v = (1><1) [ lamda ] 79stiffJac _t _v = (1><1) [ lamda ]
74 where 80 where
@@ -143,6 +149,10 @@ main = do
143 (D.dims2D 500.0 500.0) 149 (D.dims2D 500.0 500.0)
144 (renderAxis $ kSaxis $ zip [0.0, 0.1 .. 10.0] (concat $ toLists res2)) 150 (renderAxis $ kSaxis $ zip [0.0, 0.1 .. 10.0] (concat $ toLists res2))
145 151
152 let res2a = odeSolveV (SDIRK_5_3_4 stiffJac) 0.1 1e-3 1e-6 stiffishV (fromList [0.0]) (fromList [0.0, 0.1 .. 10.0])
153 putStrLn "Lower tolerances"
154 putStrLn $ show res2a
155
146 let res3 = odeSolve' (SDIRK_5_3_4 lorenzJac) lorenz [-5.0, -5.0, 1.0] (fromList [0.0, 0.01 .. 10.0]) 156 let res3 = odeSolve' (SDIRK_5_3_4 lorenzJac) lorenz [-5.0, -5.0, 1.0] (fromList [0.0, 0.01 .. 10.0])
147 putStrLn $ show $ last ((toLists $ tr res3)!!0) 157 putStrLn $ show $ last ((toLists $ tr res3)!!0)
148 158