From 59a0b914360314f79502a7874d14ed4b0f7b81f7 Mon Sep 17 00:00:00 2001 From: Mathieu Boespflug Date: Sun, 25 Mar 2018 12:08:41 +0200 Subject: Make example --pedantic compliant. --- packages/sundials/src/Main.hs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'packages/sundials/src/Main.hs') diff --git a/packages/sundials/src/Main.hs b/packages/sundials/src/Main.hs index 5e51372..44426f6 100644 --- a/packages/sundials/src/Main.hs +++ b/packages/sundials/src/Main.hs @@ -1,6 +1,5 @@ {-# OPTIONS_GHC -Wall #-} -import qualified Data.Vector.Storable as V import Numeric.Sundials.Arkode.ODE import Numeric.LinearAlgebra @@ -9,11 +8,10 @@ import qualified Diagrams.Prelude as D import Diagrams.Backend.Rasterific import Control.Lens -import Data.List (zip4) - -brusselator _t x = [ a - (w + 1) * u + v * u^2 - , w * u - v * u^2 +brusselator :: a -> [Double] -> [Double] +brusselator _t x = [ a - (w + 1) * u + v * u^(2::Int) + , w * u - v * u^(2::Int) , (b - w) / eps - w * u ] where @@ -24,6 +22,7 @@ brusselator _t x = [ a - (w + 1) * u + v * u^2 v = x !! 1 w = x !! 2 +stiffish :: Double -> [Double] -> [Double] stiffish t v = [ lamda * u + 1.0 / (1.0 + t * t) - lamda * atan t ] where lamda = -100.0 @@ -45,15 +44,14 @@ kSaxis xs = P.r2Axis &~ do main :: IO () main = do - let res = odeSolve brusselator [1.2, 3.1, 3.0] (fromList [0.0, 0.1 .. 10.0]) - putStrLn $ show res - renderRasterific "diagrams/brusselator.png" - (D.dims2D 500.0 500.0) - (renderAxis $ lSaxis $ [0.0, 0.1 .. 10.0]:(toLists $ tr res)) - - let res = odeSolve stiffish [0.0] (fromList [0.0, 0.1 .. 10.0]) - putStrLn $ show res - renderRasterific "diagrams/stiffish.png" - (D.dims2D 500.0 500.0) - (renderAxis $ kSaxis $ zip [0.0, 0.1 .. 10.0] (concat $ toLists res)) - + do let res = odeSolve brusselator [1.2, 3.1, 3.0] (fromList [0.0, 0.1 .. 10.0]) + putStrLn $ show res + renderRasterific "diagrams/brusselator.png" + (D.dims2D 500.0 500.0) + (renderAxis $ lSaxis $ [0.0, 0.1 .. 10.0]:(toLists $ tr res)) + + do let res = odeSolve stiffish [0.0] (fromList [0.0, 0.1 .. 10.0]) + putStrLn $ show res + renderRasterific "diagrams/stiffish.png" + (D.dims2D 500.0 500.0) + (renderAxis $ kSaxis $ zip [0.0, 0.1 .. 10.0] (concat $ toLists res)) -- cgit v1.2.3