CEPS
24.01
Cardiac ElectroPhysiology Simulator
|
Solves ODE systems .
For several numerical schemes, the evolution function is split between a linear and a non linear part.
Class usage:
1./ If used with "free" non-member functions (than can exist on their own), or static member functions:
2./ If used with AbstractIonicModel for cardiac problems, the solver is either for Gate or Misc variables, so the interaction with ionic model and the numerical scheme itself may change. This is why you need to select the right initialization method.
Definition at line 68 of file AbstractOdeSolver.hpp.
#include <AbstractOdeSolver.hpp>
Public Types | |
using | RateFunction = ceps::Function< void(CepsReal, CepsReal *, CepsReal *, CepsUInt)> |
Typedef for function f(t,y) More... | |
Public Member Functions | |
AbstractOdeSolver () | |
Constructor. More... | |
virtual | ~AbstractOdeSolver () |
Destructor. More... | |
virtual void | initialize (CepsReal *y0, CepsUInt n, RateFunction *nonlinearFunc, RateFunction *linearFunc=nullptr, CepsBool copy=false) |
Allocate data arrays and sets initial condition with given data. More... | |
CepsUInt | getNbMultiSteps () const |
Tells how many time steps the method covers. More... | |
CepsUInt | getNbSubSteps () const |
Tells if several intermediate steps are needed to get to . More... | |
CepsReal * | getSolution () const |
Returns a pointer to the solution. Size is the same as y0 argument in initialize. More... | |
virtual void | takeOneStep (CepsReal t, CepsReal dt)=0 |
Make a full ode step : must be defined in every child class. More... | |
virtual void | takeOneSubStep (CepsReal t, CepsReal dt) |
Progress by a substep, for RK methods. Does nothing by default. More... | |
Protected Member Functions | |
virtual void | shiftDataArraysForNextStep () |
Rotates the pointers on data such that yN becomes yN-1, etc... More... | |
void | evaluateDerivative (CepsReal t, CepsReal *y, CepsReal *dty, CepsUInt n, CepsBool nLinPart=true) |
Selects and computes depending on how it was passed to the class. More... | |
CepsReal | phi1 (CepsReal x) const |
Function used in exponential schemes. More... | |
Protected Attributes | |
CepsUInt | m_ySize |
Function used in exponential schemes. Return all phi_n until n, starting at phi0. More... | |
CepsReal * | m_yNp1 |
Solution at time . More... | |
CepsVector< CepsReal * > | m_yNm |
Solution at time and before. More... | |
CepsUInt | m_nbMultiSteps |
Number of steps for multi step solvers. More... | |
CepsUInt | m_nbSubSteps |
Number of sub steps (eg RK solvers) More... | |
CepsUInt | m_currentStep |
Ongoing step. More... | |
RateFunction * | m_fL |
Linear function to call in evaluateDerivative. More... | |
RateFunction * | m_fNL |
Non-linear function to call in evaluateDerivative. More... | |
CepsBool | m_ownedSolData |
Flag for destructor. More... | |
CepsBool | m_initialized |
Check at deallocation. More... | |
using AbstractOdeSolver::RateFunction = ceps::Function<void(CepsReal,CepsReal*,CepsReal*,CepsUInt)> |
Typedef for function f(t,y)
Definition at line 74 of file AbstractOdeSolver.hpp.
AbstractOdeSolver::AbstractOdeSolver | ( | ) |
Constructor.
Definition at line 32 of file AbstractOdeSolver.cpp.
|
virtual |
Destructor.
Definition at line 45 of file AbstractOdeSolver.cpp.
|
protected |
Selects and computes depending on how it was passed to the class.
Either through classes like AbstractIonicModel, or manually via setEvolutionFunction(...)
t | time t^n |
y | values at t^n |
dty | result array |
n | size of arrays |
nLinPart | true to compute the non-linear part of the evolution function, false for the linear part |
Definition at line 136 of file AbstractOdeSolver.cpp.
CepsUInt AbstractOdeSolver::getNbMultiSteps | ( | ) | const |
Tells how many time steps the method covers.
Definition at line 98 of file AbstractOdeSolver.cpp.
CepsUInt AbstractOdeSolver::getNbSubSteps | ( | ) | const |
Tells if several intermediate steps are needed to get to .
Definition at line 104 of file AbstractOdeSolver.cpp.
CepsReal * AbstractOdeSolver::getSolution | ( | ) | const |
Returns a pointer to the solution. Size is the same as y0 argument in initialize.
Definition at line 110 of file AbstractOdeSolver.cpp.
|
virtual |
Allocate data arrays and sets initial condition with given data.
This method assumes a single step ODE solver, and should be overloaded for multi-step solvers.
[in] | y0 | initial data |
[in] | n | allocation size for each array |
[in] | nonLinearFunc | Pointer to ceps::Function f'(t,y) |
[in] | linearFunc | Pointer to ceps::Function f'(t,y) |
[in] | copy | if false, the array y0 will be used to store yn (thus overwritten) be careful with the delete statement! There will be arrays for times and , and, if needed, other arrays for multi-step methods |
Reimplemented in SBDFOdeSolver, RushLarsenOdeSolver, RungeKuttaOdeSolver, FBEOdeSolver, and ExponentialAdamsBashforthOdeSolver.
Definition at line 57 of file AbstractOdeSolver.cpp.
|
protectedvirtual |
Rotates the pointers on data such that yN becomes yN-1, etc...
Reimplemented in ExponentialAdamsBashforthOdeSolver, SBDFOdeSolver, and RushLarsenOdeSolver.
Definition at line 124 of file AbstractOdeSolver.cpp.
Make a full ode step : must be defined in every child class.
[in] | t | time |
[in] | dt | ode time step |
Implemented in SBDFOdeSolver, RushLarsenOdeSolver, RungeKuttaOdeSolver, FBEOdeSolver, and ExponentialAdamsBashforthOdeSolver.
Progress by a substep, for RK methods. Does nothing by default.
Reimplemented in RungeKuttaOdeSolver.
Definition at line 116 of file AbstractOdeSolver.cpp.
|
protected |
Ongoing step.
Definition at line 176 of file AbstractOdeSolver.hpp.
|
protected |
Linear function to call in evaluateDerivative.
Definition at line 178 of file AbstractOdeSolver.hpp.
|
protected |
Non-linear function to call in evaluateDerivative.
Definition at line 179 of file AbstractOdeSolver.hpp.
|
protected |
Check at deallocation.
Definition at line 182 of file AbstractOdeSolver.hpp.
|
protected |
Number of steps for multi step solvers.
Definition at line 174 of file AbstractOdeSolver.hpp.
|
protected |
Number of sub steps (eg RK solvers)
Definition at line 175 of file AbstractOdeSolver.hpp.
|
protected |
Flag for destructor.
Definition at line 181 of file AbstractOdeSolver.hpp.
|
protected |
Solution at time and before.
Definition at line 172 of file AbstractOdeSolver.hpp.
|
protected |
Solution at time .
Definition at line 171 of file AbstractOdeSolver.hpp.
|
protected |
Function used in exponential schemes. Return all phi_n until n, starting at phi0.
Size of solution vector
Definition at line 170 of file AbstractOdeSolver.hpp.