From 93c28276e163c8c620a3d1461f4270c7a86763cf Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Sun, 22 Apr 2018 08:25:50 +0100 Subject: Fix warnings --- examples/sundials.hs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/sundials.hs b/examples/sundials.hs index 1643540..99f662d 100644 --- a/examples/sundials.hs +++ b/examples/sundials.hs @@ -1,10 +1,14 @@ +{-# OPTIONS_GHC -fno-warn-missing-signatures #-} + {-# LANGUAGE ViewPatterns #-} + import Numeric.Sundials.ARKode.ODE import Numeric.LinearAlgebra import Graphics.Plot vanderpol mu = do - let xdot mu t [x,v] = [v, -x + mu * v * (1-x^2)] + let xdot nu _t [x,v] = [v, -x + nu * v * (1-x*x)] + xdot _ _ _ = error "vanderpol RHS not defined" ts = linspace 1000 (0,50) sol = toColumns $ odeSolve (xdot mu) [1,0] ts mplot (ts : sol) @@ -12,16 +16,18 @@ vanderpol mu = do harmonic w d = do - let xdot w d t [x,v] = [v, a*x + b*v] where a = -w^2; b = -2*d*w + let xdot u dd _t [x,v] = [v, a*x + b*v] where a = -u*u; b = -2*dd*u + xdot _ _ _ _ = error "harmonic RHS not defined" ts = linspace 100 (0,20) sol = odeSolve (xdot w d) [1,0] ts mplot (ts : toColumns sol) kepler v a = mplot (take 2 $ toColumns sol) where - xdot t [x,y,vx,vy] = [vx,vy,x*k,y*k] + xdot _t [x,y,vx,vy] = [vx,vy,x*k,y*k] where g=1 k=(-g)*(x*x+y*y)**(-1.5) + xdot _ _ = error "kepler RHS not defined" ts = linspace 100 (0,30) sol = odeSolve xdot [4, 0, v * cos (a*degree), v * sin (a*degree)] ts degree = pi/180 @@ -37,9 +43,11 @@ main = do -- example of odeSolveV with jacobian vanderpol' mu = do - let xdot mu t (toList->[x,v]) = fromList [v, -x + mu * v * (1-x^2)] - jac t (toList->[x,v]) = (2><2) [ 0 , 1 + let xdot nu _t (toList->[x,v]) = fromList [v, -x + nu * v * (1-x*x)] + xdot _ _ _ = error "vanderpol' RHS not defined" + jac _ (toList->[x,v]) = (2><2) [ 0 , 1 , -1-2*x*v*mu, mu*(1-x**2) ] + jac _ _ = error "vanderpol' Jacobian not defined" ts = linspace 1000 (0,50) hi = pure $ (ts!1 - ts!0) / 100.0 sol = toColumns $ odeSolveV (SDIRK_5_3_4 jac) hi 1E-8 1E-8 (xdot mu) (fromList [1,0]) ts -- cgit v1.2.3