diff options
Diffstat (limited to 'packages/sundials/src/Main.hs')
-rw-r--r-- | packages/sundials/src/Main.hs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs index 3904b09..85928e2 100644 --- a/packages/sundials/src/Main.hs +++ b/packages/sundials/src/Main.hs | |||
@@ -117,15 +117,21 @@ main = do | |||
117 | 117 | ||
118 | let res2b = ARK.odeSolveV (ARK.TRBDF2_3_3_2') Nothing 1e-6 1e-10 stiffishV (fromList [0.0]) (fromList [0.0, 0.1 .. 10.0]) | 118 | let res2b = ARK.odeSolveV (ARK.TRBDF2_3_3_2') Nothing 1e-6 1e-10 stiffishV (fromList [0.0]) (fromList [0.0, 0.1 .. 10.0]) |
119 | 119 | ||
120 | let maxDiff = maximum $ map abs $ | 120 | let maxDiffA = maximum $ map abs $ |
121 | zipWith (-) ((toLists $ tr res2a)!!0) ((toLists $ tr res2b)!!0) | 121 | zipWith (-) ((toLists $ tr res2a)!!0) ((toLists $ tr res2b)!!0) |
122 | |||
123 | hspec $ describe "Compare results" $ do | ||
124 | it "for two different RK methods" $ | ||
125 | maxDiff < 1.0e-6 | ||
126 | 122 | ||
127 | let res2c = CV.odeSolveV (CV.BDF) Nothing 1e-6 1e-10 stiffishV (fromList [0.0]) (fromList [0.0, 0.1 .. 10.0]) | 123 | let res2c = CV.odeSolveV (CV.BDF) Nothing 1e-6 1e-10 stiffishV (fromList [0.0]) (fromList [0.0, 0.1 .. 10.0]) |
128 | putStrLn $ show res2c | 124 | |
125 | let maxDiffB = maximum $ map abs $ | ||
126 | zipWith (-) ((toLists $ tr res2a)!!0) ((toLists $ tr res2c)!!0) | ||
127 | |||
128 | let maxDiffC = maximum $ map abs $ | ||
129 | zipWith (-) ((toLists $ tr res2b)!!0) ((toLists $ tr res2c)!!0) | ||
130 | |||
131 | hspec $ describe "Compare results" $ do | ||
132 | it "for SDIRK_5_3_4' and TRBDF2_3_3_2'" $ maxDiffA < 1.0e-6 | ||
133 | it "for SDIRK_5_3_4' and BDF" $ maxDiffB < 1.0e-6 | ||
134 | it "for TRBDF2_3_3_2' and BDF" $ maxDiffC < 1.0e-6 | ||
129 | 135 | ||
130 | let res3 = ARK.odeSolve lorenz [-5.0, -5.0, 1.0] (fromList [0.0, 0.01 .. 10.0]) | 136 | let res3 = ARK.odeSolve lorenz [-5.0, -5.0, 1.0] (fromList [0.0, 0.01 .. 10.0]) |
131 | 137 | ||