
Definition at line 24 of file NumericalSolver.hpp.
Public Member Functions | |
| NumericalSolver (const unsigned int dimensions) | |
| Constructor. | |
| NumericalSolver (const indii::ml::aux::vector &y0) | |
| Constructor. | |
| virtual | ~NumericalSolver () |
| Destructor. | |
| unsigned int | getDimensions () |
| Get dimensionality of the state space. | |
| double | getTime () |
| Get the current time. | |
| void | setTime (const double t) |
| Set the current time. | |
| double | getVariable (const unsigned int index) |
| Get the value of a state variable at the current time. | |
| void | setVariable (const unsigned int index, const double value) |
| Set the value of a state variable. | |
| indii::ml::aux::vector | getState () |
| Get the state at the current time. | |
| void | setState (const indii::ml::aux::vector &y) |
| Set the state at the current time. | |
| virtual double | step (double upper) |
| Advance the system one time step. | |
| void | stepTo (double to) |
| Advance the system to a particular time. | |
| virtual double | stepBack (double lower) |
| Rewind the system one time step. | |
| void | stepBackTo (double to) |
| Rewind the system to a specific time. | |
| void | setErrorBounds (double maxAbsoluteError=1e-6, double maxRelativeError=1e-6) |
| Set the error bounds. | |
| void | setStepSize (double stepSize) |
| Set the proposed size for the next time step. | |
| double | getStepSize () |
| Get the proposed size for the next time step. | |
| void | setSuggestedStepSize (double stepSize=1.0e-7) |
| Set the suggested step size. | |
| double | getSuggestedStepSize () |
| Get the suggested step size. | |
| void | setMaxStepSize (double stepSize=0.0) |
| Set the maximum step size. | |
| double | getMaxStepSize () |
| Get the maximum step size. | |
| void | setDiscontinuity () |
| Indicates a discontinuity at the current time. | |
| void | setStepType (const gsl_odeiv_step_type *stepType) |
| Set the stepping method. | |
| virtual int | calculateDerivativesForward (double t, const double y[], double dydt[])=0 |
| Calculate derivatives for forwards step. | |
| virtual int | calculateDerivativesBackward (double t, const double y[], double dydt[])=0 |
| Calculate derivatives for backwards step. | |
Protected Member Functions | |
| void | init () |
| Initialise the system. | |
| void | terminate () |
| Terminate the system. | |
| virtual void | reset () |
| Reset the model. | |
Protected Attributes | |
| const size_t | dimensions |
| Dimensionality of the system of differential equations. | |
| double | t |
; the current time | |
| double * | y |
| Array of state variables of the system. | |
| double | base |
| Base time used for backward steps. | |
| double | stepSize |
| Proposed size for the next time step. | |
| double | maxStepSize |
| Maximum step size. | |
| double | suggestedStepSize |
| Suggested step size. | |
| gsl_odeiv_step * | gslStep |
| GSL ordinary differential equations step structure. | |
| gsl_odeiv_control * | gslControl |
| GSL ordinary differential equations control structure. | |
| gsl_odeiv_evolve * | gslEvolve |
| GSL ordinary differential equations evolution structure. | |
| gsl_odeiv_system | gslForwardSystem |
| GSL system of ordinary differential equations for forward steps in time. | |
| gsl_odeiv_system | gslBackwardSystem |
| GSL system of ordinary differential equations for backward steps in time. | |
| NumericalSolver | ( | const unsigned int | dimensions | ) |
Constructor.
| dimensions | Dimensionality of the state space. |
Definition at line 13 of file NumericalSolver.cpp.
| NumericalSolver | ( | const indii::ml::aux::vector & | y0 | ) |
Constructor.
| y0 | Initial state. |
Definition at line 28 of file NumericalSolver.cpp.
| ~NumericalSolver | ( | ) | [virtual] |
| unsigned int getDimensions | ( | ) | [inline] |
| double getTime | ( | ) | [inline] |
| void setTime | ( | const double | t | ) |
Set the current time.
| t | Time. |
Definition at line 49 of file NumericalSolver.cpp.
| double getVariable | ( | const unsigned int | index | ) | [inline] |
Get the value of a state variable at the current time.
| index | Index of the state variable to retrieve. |
Definition at line 390 of file NumericalSolver.hpp.
| void setVariable | ( | const unsigned int | index, | |
| const double | value | |||
| ) |
Set the value of a state variable.
| index | Index of the state variable to set. | |
| value | The value to which to set the state variable. |
Definition at line 158 of file NumericalSolver.cpp.
| indii::ml::aux::vector getState | ( | ) | [inline] |
Get the state at the current time.
Definition at line 398 of file NumericalSolver.hpp.
| void setState | ( | const indii::ml::aux::vector & | y | ) |
Set the state at the current time.
| y | New state of the system. |
Definition at line 167 of file NumericalSolver.cpp.
| double step | ( | double | upper | ) | [virtual] |
Advance the system one time step.
The size of the step is chosen to be optimal given the provided error bounds. State variables are updated to this new time after completion of the step.
| upper | Upper bound on time. This must be greater than the current time. The current time is guaranteed not to exceed this value after the step is complete. It may equal this time, and indeed if step() is continuously called with the same upper bound it will eventually do so. |
Reimplemented in StochasticAdaptiveEulerMaruyama, StochasticAdaptiveRungeKutta, and StochasticEulerMaruyama.
Definition at line 54 of file NumericalSolver.cpp.
| void stepTo | ( | double | to | ) |
Advance the system to a particular time.
This convenience method internally calls step() as many times as necessary to advance the system to the given time. This is useful if fixed time steps are required rather than the variable steps taken by step().
| to | The time to which to advance the system. This must be greater than the current time. The current time is guaranteed to match this value at the end of the call. |
Definition at line 73 of file NumericalSolver.cpp.
| double stepBack | ( | double | lower | ) | [virtual] |
Rewind the system one time step.
This works in the same fashion at step(), except that the step is backwards in time.
| lower | Lower bound on time. This must be less than the current time. The current time is guaranteed not to be below this value after the step is complete. It may equal this time, and indeed if stepBack() is continuously called with the same lower bound it will eventually do so. |
Reimplemented in StochasticAdaptiveEulerMaruyama, StochasticAdaptiveRungeKutta, and StochasticEulerMaruyama.
Definition at line 86 of file NumericalSolver.cpp.
| void stepBackTo | ( | double | to | ) |
Rewind the system to a specific time.
This convenience method internally calls stepBack() as many times as necessary to rewind the system to a given point in time. This is useful if fixed time steps are required rather than the variable steps taken by stepBack().
| to | The time to which to rewind the system. This must be less than the current time. The current time is guaranteed to match this value at the end of the call. |
Definition at line 117 of file NumericalSolver.cpp.
| void setErrorBounds | ( | double | maxAbsoluteError = 1e-6, |
|
| double | maxRelativeError = 1e-6 | |||
| ) |
Set the error bounds.
Smaller error bounds produce more accurate estimates, but reduce the size of time steps, so that more steps are required in order to estimate functions over the same length of time.
| maxAbsoluteError | The maximum permitted absolute error of estimated values compared to real values. | |
| maxRelativeError | The maximum permitted relative error of estimated values compared to real values. |
Definition at line 130 of file NumericalSolver.cpp.
| void setStepSize | ( | double | stepSize | ) |
Set the proposed size for the next time step.
This is useful for handling discontinuities, where step() may be called to advance to the discontinuity, then setStepSize() used to propose a small step size ensuring that the discontinuity is tiptoed across rather than leapt.
It should be called immediately before any call to step() or stepTo(). Any other methods called in between may themselves adjust the proposed step size.
| stepSize | The proposed time step size for the next call to step(). |
Definition at line 141 of file NumericalSolver.cpp.
| double getStepSize | ( | ) | [inline] |
Get the proposed size for the next time step.
Definition at line 408 of file NumericalSolver.hpp.
| void setSuggestedStepSize | ( | double | stepSize = 1.0e-7 |
) |
Set the suggested step size.
The step size is set to this immediately, and subsequently after any calls to setDiscontinuity().
| stepSize | The suggested step size. |
Definition at line 145 of file NumericalSolver.cpp.
| double getSuggestedStepSize | ( | ) | [inline] |
Get the suggested step size.
Definition at line 412 of file NumericalSolver.hpp.
| void setMaxStepSize | ( | double | stepSize = 0.0 |
) |
Set the maximum step size.
| stepSize | The maximum step size. |
Definition at line 150 of file NumericalSolver.cpp.
| double getMaxStepSize | ( | ) | [inline] |
Get the maximum step size.
Definition at line 416 of file NumericalSolver.hpp.
| void setDiscontinuity | ( | ) |
Indicates a discontinuity at the current time.
Internally, this simply calls setStepSize() with the suggested step size.
Definition at line 154 of file NumericalSolver.cpp.
| void setStepType | ( | const gsl_odeiv_step_type * | stepType | ) |
Set the stepping method.
| stepType | The stepping method. |
Definition at line 216 of file NumericalSolver.cpp.
| virtual int calculateDerivativesForward | ( | double | t, | |
| const double | y[], | |||
| double | dydt[] | |||
| ) | [pure virtual] |
Calculate derivatives for forwards step.
Implemented in AdaptiveRungeKutta, StochasticAdaptiveEulerMaruyama, StochasticAdaptiveRungeKutta, and StochasticEulerMaruyama.
| virtual int calculateDerivativesBackward | ( | double | t, | |
| const double | y[], | |||
| double | dydt[] | |||
| ) | [pure virtual] |
Calculate derivatives for backwards step.
Implemented in AdaptiveRungeKutta, StochasticAdaptiveEulerMaruyama, StochasticAdaptiveRungeKutta, and StochasticEulerMaruyama.
| void init | ( | ) | [protected] |
Initialise the system.
Should be called before any calls to step() or stepTo().
Definition at line 178 of file NumericalSolver.cpp.
| void terminate | ( | ) | [protected] |
Terminate the system.
Should be called after work with the system has been finished. Will be called by the destructor if it hasn't been already.
Definition at line 194 of file NumericalSolver.cpp.
| void reset | ( | ) | [protected, virtual] |
Reset the model.
This is used internally to reset GSL structures when the next step will not be a continuation of the last, usually when the time or state is changed with a call to setTime(), setVariable() or setState().
Reimplemented in StochasticNumericalSolver.
Definition at line 210 of file NumericalSolver.cpp.
const size_t dimensions [protected] |
Dimensionality of the system of differential equations.
Definition at line 270 of file NumericalSolver.hpp.
double t [protected] |
double* y [protected] |
double base [protected] |
double stepSize [protected] |
double maxStepSize [protected] |
double suggestedStepSize [protected] |
gsl_odeiv_step* gslStep [protected] |
GSL ordinary differential equations step structure.
Definition at line 305 of file NumericalSolver.hpp.
gsl_odeiv_control* gslControl [protected] |
GSL ordinary differential equations control structure.
Definition at line 310 of file NumericalSolver.hpp.
gsl_odeiv_evolve* gslEvolve [protected] |
GSL ordinary differential equations evolution structure.
Definition at line 315 of file NumericalSolver.hpp.
gsl_odeiv_system gslForwardSystem [protected] |
GSL system of ordinary differential equations for forward steps in time.
Definition at line 321 of file NumericalSolver.hpp.
gsl_odeiv_system gslBackwardSystem [protected] |
GSL system of ordinary differential equations for backward steps in time.
Definition at line 327 of file NumericalSolver.hpp.
1.5.3