#include <solver.h>
Inheritance diagram for Solver:
Public Types | |
typedef int(*) | Function (double t, const double y[], double f[], void *params) |
Public Member Functions | |
Solver (int dimension=0, Function function=NULL, void *params=NULL) | |
QString | solverType () const |
int | dimension () const |
virtual void | setDimension (int dimension) |
Function | function () const |
virtual void | setFunction (Function function) |
void * | params () const |
virtual void | setParams (void *params) |
double | toleranceAbs () const |
virtual void | setToleranceAbs (double toleranceAbs) |
double | toleranceRel () const |
virtual void | setToleranceRel (double toleranceRel) |
double | localError () const |
double | localErrorRatio () const |
virtual void | doCalcFn (double *t, double y[], double f[]=0)=0 |
virtual bool | doEvolve (double *t, double t1, double y[], double yerr[])=0 |
const QString & | name () const |
void | setName (const QString &name) |
Provides generic interface suitable for large variety of ordinaty differential equations integration algorithms.
It solves system of the first order differential equations:
Dimension of system is provided via setDimension(), function is provided via setFunction().
It also provides interface for setting allowed local tolerance. It can be defined using two properties: toleranceAbs and toleranceRel.
On each step solver calculates local error estimation (which depends on used integration method) and local error ratio for each variable using the following formula:
Non-adaptive solvers cancel current step if maximal local error ratio is bigger than 1.1 (exact value depends on solver) and doEvolve() function returns false.
Adaptive solvers use maximal local error ratio to change time step until the ratio becomes almost equal 1. If it can't be made smaller than 1.1 (exact value depends on solver), solvers cancel current step and doEvolve() function returns false.
Maximal (over all variables) error estimation and error ratio from last time step can be obtained using localError() and localErrorRatio() methods.
typedef int(*) Function(double t, const double y[], double f[], void *params) |
Callback function type
Cunstructs a solver
QString solverType | ( | ) | const [inline] |
Get solver type
int dimension | ( | ) | const [inline] |
Get ODE dimension
virtual void setDimension | ( | int | dimension | ) | [inline, virtual] |
Set ODE dimension
Reimplemented in GenericEulerSolver, and GslGenericSolver.
Function function | ( | ) | const [inline] |
Get callback function
virtual void setFunction | ( | Function | function | ) | [inline, virtual] |
Set callback function
void* params | ( | ) | const [inline] |
Get callback function params
virtual void setParams | ( | void * | params | ) | [inline, virtual] |
Set callback function params
Reimplemented in GslGenericSolver.
double toleranceAbs | ( | ) | const [inline] |
Get absolute allowed local tolerance
virtual void setToleranceAbs | ( | double | toleranceAbs | ) | [inline, virtual] |
Set absolute allowed local tolerance
Reimplemented in GslGenericSolver.
double toleranceRel | ( | ) | const [inline] |
Get relative allowed local tolerance
virtual void setToleranceRel | ( | double | toleranceRel | ) | [inline, virtual] |
Set relative allowed local tolerance
Reimplemented in GslGenericSolver.
double localError | ( | ) | const [inline] |
Get error estimation from last step
double localErrorRatio | ( | ) | const [inline] |
Get local tolerance calculated at last step
virtual void doCalcFn | ( | double * | t, | |
double | y[], | |||
double | f[] = 0 | |||
) | [pure virtual] |
Calculate function value
Implemented in GenericEulerSolver, and GslGenericSolver.
virtual bool doEvolve | ( | double * | t, | |
double | t1, | |||
double | y[], | |||
double | yerr[] | |||
) | [pure virtual] |
Integrate.
t | Current time (will be updated by the new value) | |
t1 | Target time | |
y[] | Current function value | |
yerr[] | Array to store local errors |
Implemented in GenericEulerSolver, and GslGenericSolver.
const QString& name | ( | ) | const [inline, inherited] |
Returns name of the object
void setName | ( | const QString & | name | ) | [inline, inherited] |
Set name of the object