Stability | experimental |
---|---|
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Safe Haskell | Safe-Inferred |
Tested with: GHC 7.6.3
This module defines a variable that is bound up with the event queue and that keeps the history of changes storing the values in an array, which allows using the variable in differential and difference equations under some conditions.
Documentation
Like the Ref
reference but keeps the history of changes in
different time points. The Var
variable is usually safe in the hybrid
simulation, for example, when it can be used in the differential or
difference equations unless you update the variable twice in the
same integration time point. Only this variable is much slower than
the reference.
varChanged :: Var a -> Signal aSource
Return a signal that notifies about every change of the variable state.
varChanged_ :: Var a -> Signal ()Source
Return a signal that notifies about every change of the variable state.
newVar :: a -> Simulation (Var a)Source
Create a new variable.
readVar :: Var a -> Event aSource
Read the value of a variable.
It is safe to run the resulting computation with help of the runEventWith
function using modes CurrentEventsOrFromPast
and EarlierEventsOrFromPast
,
which is necessary if you are going to use the variable in the differential
or difference equations. Only it is preferrable if the variable is not updated twice
in the same integration time point; otherwise, different values can be returned
for the same point.
freezeVar :: Var a -> Event (Array Int Double, Array Int a)Source
Freeze the variable and return in arrays the time points and corresponded values when the variable had changed in different time points: (1) the last actual value per each time point is provided and (2) the time points are sorted in ascending order.
If you need to get all changes including those ones that correspond to the same
simulation time points then you can use the newSignalHistory
function passing
in the varChanged
signal to it and then call function readSignalHistory
.