From 35a8e1f9d942af92eac7c9340c91ffb3d5e710a0 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Sat, 7 Apr 2018 13:58:27 +0100 Subject: Pass through tolerances --- packages/sundials/src/Main.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'packages/sundials/src/Main.hs') 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 ] lamda = -100.0 u = v !! 0 +stiffishV :: Double -> Vector Double -> Vector Double +stiffishV t v = fromList [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ] + where + lamda = -100.0 + u = v ! 0 + stiffJac :: Double -> Vector Double -> Matrix Double stiffJac _t _v = (1><1) [ lamda ] where @@ -143,6 +149,10 @@ main = do (D.dims2D 500.0 500.0) (renderAxis $ kSaxis $ zip [0.0, 0.1 .. 10.0] (concat $ toLists res2)) + 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]) + putStrLn "Lower tolerances" + putStrLn $ show res2a + let res3 = odeSolve' (SDIRK_5_3_4 lorenzJac) lorenz [-5.0, -5.0, 1.0] (fromList [0.0, 0.01 .. 10.0]) putStrLn $ show $ last ((toLists $ tr res3)!!0) -- cgit v1.2.3