54 "Pointer to ionic model is null"
57 "Pointer to spatial discretization is null"
91 vPde->releaseLocalData();
122 dtv->releaseLocalData();
128 vPde->getLocalData();
131 vPde->releaseLocalData();
171 (mattrs.empty() or dof->hasOneOfAttributes(mattrs) or mattrs.contains(
CepsUniversal)))
180 std::istringstream iss(opts);
183 "Could not read options of ionic model solver"
191 if (type ==
"EULER" or type ==
"EXPLICIT_EULER")
193 m_solver = ceps::getNew<ExplicitEulerOdeSolver>();
196 else if (type ==
"IMPLICIT_EULER" or type ==
"FBE")
198 m_solver = ceps::getNew<FBEOdeSolver>();
201 else if (type ==
"RUSH_LARSEN" or type ==
"RL")
203 order =
ceps::readInt(iss,
"Ionic solver: missing order for Rush-Larsen ODE solver");
204 m_solver = ceps::getNew<RushLarsenOdeSolver>(order);
207 else if (type ==
"EXP_ADAMS_BASHFORTH" or type ==
"EAB")
209 order =
ceps::readInt(iss,
"Ionic solver: missing order for Adams-Bashforth ODE solver");
210 m_solver = ceps::getNew<ExponentialAdamsBashforthOdeSolver>(order);
213 else if (type ==
"RUNGE_KUTTA" or type ==
"RK")
218 "Ionic solver : missing type of Runge-Kutta ODE solver"
220 m_solver = ceps::getNew<RungeKuttaOdeSolver>(opt);
223 else if (type ==
"SBDF" or type ==
"BACKWARD_DIFFERENTIATION")
225 order =
ceps::readInt(iss,
"Ionic solver: missing order for SBDF ODE solver");
226 m_solver = ceps::getNew<SBDFOdeSolver>(order);
230 CEPS_ABORT(
"Unknown solver type. Valid types are \n"
231 <<
" - EXPLICIT_EULER (or just EULER)\n"
232 <<
" - IMPLICIT_EULER (or FBE)\n"
233 <<
" - RUSH_LARSEN <1-4> (or RL <1-4>)\n"
234 <<
" - EXP_ADAMS_BASHFORTH <1-4> (or EAB <1-4>)\n"
235 <<
" - BACKWARD_DIFFERENTIATION <1-4> (or SBDF <1-4>)\n"
236 <<
" - RUNGE_KUTTA <opt> (or RK <opt>)\n"
237 <<
" where opt can be an integer between 1 and 5 or\n"
239 <<
" Ralston3 SSP3 38 Ralston4\n"
240 <<
" Nystrom5 Fehlberg5.");
252 m_y = ceps::newArray<CepsReal>(
m_size*nVars);
#define CEPS_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
constexpr CepsAttribute CepsUniversal
This attribute means "everywhere".
std::shared_ptr< DistributedHaloVector > DHVecPtr
Typedef for pointer on Distributed Halo CepsVector.
Abstract Class for all numerical method (FE, FD, FV etc)
const CepsMap< CepsUnknownIndex, CepsVector< DegreeOfFreedom * > > & getDegreesOfFreedomForUnknown()
Dofs sorted by unknown.
DegreeOfFreedom * getDof(CepsGlobalIndex globalDofId)
Get the dof with given globalID, nullptr if not found.
Represents a ionic model for a group of cells, i.e. multiple systems of ODEs.
Unknown * getUnknown() const
The unknown object of the transmembrane voltage.
virtual CepsReal convertDtvToCepsUnit(const CepsReal &dtv) const
Convert current from ionic model units to ceps units (mV ms-1). Does nothing by default.
virtual void computeRates(CepsReal t, CepsReal *y, CepsReal *v, CepsReal *dtyL, CepsReal *dtyNL, CepsReal *dtv, DegreeOfFreedom *dof) const =0
Get the linear and non linear part of the evolution function f. Also computes the ionic current.
virtual CepsUInt getNbStateVariables() const
The number of state variables, except transmembrane voltage.
virtual CepsReal convertVoltageToCepsUnit(const CepsReal &v) const
Convert voltage from ionic model units to ceps units (mV). Does nothing by default.
virtual CepsReal convertVoltageFromCepsUnit(const CepsReal &v) const
Convert voltage from ceps units (mV) to ionic model units. Does nothing by default.
virtual void getInitialCondition(CepsReal *v, CepsReal *y) const =0
Sets initial values of state variables and transmembrane voltage for a single point....
void setLinkedSolver(IonicSolver *solver)
Links instance to solver.
virtual void takeOneSubStep(CepsReal t, CepsReal dt)
Progress by a substep, for RK methods. Does nothing by default.
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.
virtual void takeOneStep(CepsReal t, CepsReal dt)=0
Make a full ode step : must be defined in every child class.
CepsUInt getNbMultiSteps() const
Tells how many time steps the method covers.
A degree of freedom for any kind of problem The dof can be associated to a geometrical element or not...
CepsUInt m_size
Number of dofs for this solver.
CepsReal * m_y
Values of state variables.
CepsVector< CepsIndex > m_localToGlobal
Mapping between local index of dof and index in PDE.
void computeModelRates(CepsReal t, CepsReal *y)
Computes the evolution function and ionic current on all dofs, calls the model.
CepsBool m_tauOk
Flag to avoid to compute tau and winf twice per iteration.
CepsReal * m_dtv
Total ionic current.
void fillPdeVm(DHVecPtr vPde) const
Fills the linked PDE vector for vm with current values of m_v. Can be used to get initial condition.
CepsUInt getNbMultiSteps() const
Number of multi steps of the inner solver.
AbstractIonicModel * m_model
Link to ionic model equations.
void computeRatesLin(CepsReal t, CepsReal *w, CepsReal *dtw, CepsUInt n)
Call the linear part of evolution function of the model.
void createSolvers(CepsString opts)
Instantiates ODE solvers from options.
~IonicSolver()
Destructor.
CepsReal * m_v
Transmembrane voltage.
void addDtv(DHVecPtr dtv, CepsReal t=0) const
Fills the given distributed vector with values of ionic current from ODE system. Does the unit conver...
void takeOneSubStep(CepsReal t, CepsReal dt, DHVecPtr vPde)
Advance the ODE system by one sub step (for RK solvers)
CepsReal * m_dtyLin
Linear part of rates.
CepsReal * getStates() const
Get pointer on state vars for testing purposes.
CepsReal * getDtv() const
Get pointer on ionic current for testing purposes.
AbstractOdeSolver * m_solver
internal ODE solver
CepsReal * m_dtyNLin
Non-linear part of rates.
void takeOneStep(CepsReal t, CepsReal dt, DHVecPtr vPde)
Advance the ODE system by one full step each (not substep)
void computeIndexMapping()
Sets the map from instance-local indices of points to global indices, then allocates arrays and sets ...
IonicSolver(CepsString opts, AbstractIonicModel *m, AbstractDiscretization *discr)
Constructor with parameters from input file and ionic model to be linked with The constructor also se...
CepsReal getVm(CepsBool convert) const
Get TMV for testing purposes.
void setActionPotential(DHVecPtr vPde)
Copies values of TMV from PDE vector to local array. Call this method prior to takeOneStep or takeOne...
EvolFunction * m_fNLin
Evolution function (non linear part winf/tau + others)
void initializeSolver()
Set the initial conditions and required intermediate arrays of the ODE solvers.
void computeRatesNonLin(CepsReal t, CepsReal *w, CepsReal *dtw, CepsUInt n)
Get the non linear part of evolution function of the model.
AbstractDiscretization * m_sDiscr
Link to spatial discretization.
EvolFunction * m_fLin
Evolution function (linear part -1/tau)
CepsSet< CepsAttribute > & getAttributes()
Returns the attributes of the entity.
auto newFunction(_Class obj, _Res(_Class::*fn)(_Args...)) noexcept
Transforms a member function of class into a MemberFunction struct.
CepsUInt getRank()
Returns current processor rank.
void destroyTabular(_Type &)
Destroy[delete] any type.
CepsInt readInt(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
CepsString toUpper(const CepsString &s)
Switches all characters to upper case.
void destroyObject(_Type &)
Destroy[delete] any type.