summaryrefslogtreecommitdiff
path: root/packages/sundials/src/Numeric
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2018-04-06 17:54:38 +0100
committerDominic Steinitz <dominic@steinitz.org>2018-04-06 17:54:38 +0100
commit4c15bd8e57e64bec38059d632e0de437aad06309 (patch)
treee922c26d490e703112beea891f71efbbc043e23f /packages/sundials/src/Numeric
parentad4eb127ba8d71d88f1dc5a4de072c66a36ce3a7 (diff)
Remove redundant lists and improve documentation
Diffstat (limited to 'packages/sundials/src/Numeric')
-rw-r--r--packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs36
1 files changed, 25 insertions, 11 deletions
diff --git a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs
index a7e302d..e95ca3f 100644
--- a/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs
+++ b/packages/sundials/src/Numeric/Sundials/ARKode/ODE.hs
@@ -217,13 +217,13 @@ odeSolveV
217odeSolveV meth _hi epsAbs epsRel f y0 ts = 217odeSolveV meth _hi epsAbs epsRel f y0 ts =
218 case odeSolveVWith meth (XX' epsAbs epsRel 1 1) epsAbs epsAbs g y0 ts of 218 case odeSolveVWith meth (XX' epsAbs epsRel 1 1) epsAbs epsAbs g y0 ts of
219 Left c -> error $ show c -- FIXME 219 Left c -> error $ show c -- FIXME
220 -- FIXME: Can we do better than using lists?
220 Right (v, d) -> trace (show d) $ (nR >< nC) (V.toList v) 221 Right (v, d) -> trace (show d) $ (nR >< nC) (V.toList v)
221 where 222 where
222 us = toList ts 223 us = toList ts
223 nR = length us 224 nR = length us
224 nC = size y0 225 nC = size y0
225 -- FIXME: via a list - really? 226 g t x0 = coerce $ f t x0
226 g t x0 = V.fromList $ toList $ f t x0
227 227
228-- | A version of 'odeSolveV' with reasonable default parameters and 228-- | A version of 'odeSolveV' with reasonable default parameters and
229-- system of equations defined using lists. FIXME: we should say 229-- system of equations defined using lists. FIXME: we should say
@@ -274,8 +274,7 @@ odeSolveVWith method _control relTol absTol f y0 tt =
274 Left c -> Left $ fromIntegral c 274 Left c -> Left $ fromIntegral c
275 Right (v, d) -> Right (coerce v, d) 275 Right (v, d) -> Right (coerce v, d)
276 where 276 where
277 -- FIXME: Can we do better than going via a list? 277 jacH = fmap (\g t v -> matrixToSunMatrix $ g (coerce t) (coerce v)) $
278 jacH = fmap (\g t v -> matrixToSunMatrix $ g (coerce t) (coerce $ V.fromList $ toList v)) $
279 getJacobian method 278 getJacobian method
280 matrixToSunMatrix m = T.SunMatrix { T.rows = nr, T.cols = nc, T.vals = vs } 279 matrixToSunMatrix m = T.SunMatrix { T.rows = nr, T.cols = nc, T.vals = vs }
281 where 280 where
@@ -584,10 +583,25 @@ getButcherTable method = unsafePerformIO $ do
584 else do 583 else do
585 return $ Left res 584 return $ Left res
586 585
587-- | Adaptive step-size control functions. FIXME: It may not be 586-- | Adaptive step-size control
588-- possible to scale the tolerances for the derivatives in sundials so 587-- functions.
589-- for now we ignore them and emit a warning. 588--
590data StepControl = X Double Double -- ^ abs. and rel. tolerance for x(t) 589-- [GSL](https://www.gnu.org/software/gsl/doc/html/ode-initval.html#adaptive-step-size-control)
591 | X' Double Double -- ^ abs. and rel. tolerance for x'(t) 590-- allows the user to control the step size adjustment using
592 | XX' Double Double Double Double -- ^ include both via rel. tolerance scaling factors a_x, a_x' 591-- \(D_i = \epsilon^{abs}s_i + \epsilon^{rel}(a_{y} |y_i| + a_{dy/dt} h |y'_i|)\) where
593 | ScXX' Double Double Double Double (Vector Double) -- ^ scale abs. tolerance of x(t) components 592-- \(\epsilon^{abs}\) is the required absolute error, \(\epsilon^{rel}\)
593-- is the required relative error, \(s_i\) is a vector of scaling
594-- factors, \(a_{y}\) is a scaling factor for the solution \(y\) and
595-- \(a_{dydt}\) is a scaling factor for the derivative of the solution \(dy/dt\).
596--
597-- [ARKode](https://computation.llnl.gov/projects/sundials/arkode)
598-- allows the user to control the step size adjustment using
599-- \(\epsilon^{rel}|y_i| + \epsilon^{abs}_i\). For compatibility with
600-- [hmatrix-gsl](https://hackage.haskell.org/package/hmatrix-gsl),
601-- tolerances for \(y\) and \(\dot{y}\) can be specified but the latter have no
602-- effect.
603data StepControl = X Double Double -- ^ absolute and relative tolerance for \(y\)
604 | X' Double Double -- ^ absolute and relative tolerance for \(\dot{y}\)
605 | XX' Double Double Double Double -- ^ include both via relative tolerance
606 -- scaling factors \(a_y\), \(a_{{dy}/{dt}}\)
607 | ScXX' Double Double Double Double (Vector Double) -- ^ scale absolute tolerance of \(y_i\)