aivika-0.4.2: A multi-paradigm simulation library

Stabilityexperimental
MaintainerDavid Sorokin <david.sorokin@gmail.com>
Safe HaskellNone

Simulation.Aivika.Dynamics.Base

Contents

Description

Tested with: GHC 7.0.3

This module defines basic functions for the Dynamics monad.

Synopsis

Time Parameters

starttime :: Dynamics DoubleSource

Return the start simulation time.

stoptime :: Dynamics DoubleSource

Return the stop simulation time.

dt :: Dynamics DoubleSource

Return the integration time step.

time :: Dynamics DoubleSource

Return the current simulation time.

integTimes :: Simulation [Double]Source

Return the integration time points.

Interpolation and Initial Value

initDynamics :: Dynamics a -> Dynamics aSource

Return the initial value.

discrete :: Dynamics a -> Dynamics aSource

Discretize the computation in the integration time points.

interpolate :: Dynamics a -> Dynamics aSource

Interpolate the computation based on the integration time points only. Unlike the discrete function it knows about the intermediate time points that are used in the Runge-Kutta method.

Memoization

memo :: Dynamics e -> Simulation (Dynamics e)Source

Memoize and order the computation in the integration time points using the interpolation that knows of the Runge-Kutta method.

umemo :: MArray IOUArray e IO => Dynamics e -> Simulation (Dynamics e)Source

This is a more efficient version the memo function which uses an unboxed array to store the values.

memo0 :: Dynamics e -> Simulation (Dynamics e)Source

Memoize and order the computation in the integration time points using the discrete interpolation. It consumes less memory than the memo function but it is not aware of the Runge-Kutta method. There is a subtle difference when we request for values in the intermediate time points that are used by this method to integrate. In general case you should prefer the memo0 function above memo.

umemo0 :: MArray IOUArray e IO => Dynamics e -> Simulation (Dynamics e)Source

This is a more efficient version the memo0 function which uses an unboxed array to store the values.

Iterating

iterateDynamics :: Dynamics () -> Simulation (Dynamics ())Source

Iterate sequentially the dynamic process with side effects in the integration time points. It is equivalent to a call of the memo0 function but significantly more efficient, for the array is not created.

Fold

foldDynamics1 :: (Dynamics a -> Simulation (Dynamics a)) -> (a -> a -> a) -> Dynamics a -> Simulation (Dynamics a)Source

Like the standard foldl1 function but applied to values in the integration time points. The accumulator values are transformed according to the first argument, which should be either function memo0 or umemo0.

foldDynamics :: (Dynamics a -> Simulation (Dynamics a)) -> (a -> b -> a) -> a -> Dynamics b -> Simulation (Dynamics a)Source

Like the standard foldl function but applied to values in the integration time points. The accumulator values are transformed according to the first argument, which should be either function memo0 or umemo0.

Norming

divideDynamics :: Dynamics Double -> Dynamics DoubleSource

Divide the values in integration time points by the number of the current iteration. It can be useful for statistic functions in combination with the fold.