C API Documentation
Public Member Functions | Static Public Member Functions | Friends | List of all members
rr::CVODEIntegrator Class Reference

A RoadRunner integrator based on CVODE; serves as RoadRunner's main integrator for ODEs. More...

#include <CVODEIntegrator.h>

Inheritance diagram for rr::CVODEIntegrator:
rr::Integrator rr::Solver

Public Member Functions

 CVODEIntegrator (ExecutableModel *oModel)
 Constructor: takes an executable model, does not own the pointer. More...
 
 ~CVODEIntegrator () override
 Destructor. More...
 
void syncWithModel (ExecutableModel *m) override
 Called whenever a new model is loaded to allow integrator to reset internal state. More...
 
void loadConfigSettings () override
 
void loadSBMLSettings (const std::string &filename) override
 Load an SBML settings file and apply the configuration options. More...
 
std::string getName () const override
 Get the name for this integrator. More...
 
std::string getDescription () const override
 Get the description for this integrator. More...
 
std::string getHint () const override
 Get the hint for this integrator. More...
 
IntegrationMethod getIntegrationMethod () const override
 Always deterministic for CVODE. More...
 
void setValue (std::string setting, const Variant &value) override
 Sets the value of an integrator setting (e.g. absolute_tolerance) More...
 
void setIndividualTolerance (string sid, double value) override
 Sets tolerance for individual species. More...
 
void setConcentrationTolerance (const Variant &value) override
 Sets tolerance based on concentration of species. More...
 
std::vector< double > getConcentrationTolerance () override
 Gets tolerance based on concentration of species. More...
 
void resetSettings () override
 Reset all integrator settings to their respective default values. More...
 
void tweakTolerances () override
 Fix tolerances for SBML tests. More...
 
double integrate (double t0, double tf) override
 Main integration routine. More...
 
void restart (double timeStart) override
 Reset time to zero and reinitialize model. More...
 
IntegratorListenerPtr getListener () override
 Gets the integrator listener. More...
 
void setListener (IntegratorListenerPtr) override
 Sets the integrator listener. More...
 
void checkType () const
 Does a RT type check which throws if it fails, EVEN IF RTTI IS DISABLED. More...
 
void checkVectorSize (int expected, size_t real) const
 Does a size check which throws if it fails. More...
 
void checkIndex (int index, int size) const
 Does a index check which throws if it is out of bound. More...
 
std::string ToString (int val) const
 Converts integer to string for error print. More...
 
std::string ToString (size_t val) const
 Converts size_t to string for error print. More...
 
std::string cvodeDecodeError (int cvodeError, bool exInfo=true)
 decode the cvode error code to a string
 
N_Vector getStateVector () const
 getter for the internal state vector More...
 
SUNNonlinearSolver getSolver () const
 getter for the internal Sundials linear solver object More...
 
void * getCvodeMemory () const
 getter for the internal CVode memory buffer More...
 
- Public Member Functions inherited from rr::Integrator
std::string toString () const
 Return a string representation of the solver. More...
 
virtual std::string toRepr () const
 Return string representation a la Python repr method. More...
 
virtual void setValue (std::string key, const Variant &value)
 
- Public Member Functions inherited from rr::Solver
std::vector< std::string > getSettings () const
 Get a list of all settings for this solver. More...
 
virtual Variant getValue (std::string key) const
 Get the value of an integrator setting. More...
 
virtual Variant hasValue (std::string key) const
 Return true if this setting is supported by the integrator. More...
 
virtual size_t getNumParams () const
 Get the number of parameters. More...
 
virtual std::string getParamName (size_t n) const
 Get the name of the parameter at index n. More...
 
virtual std::string getParamDisplayName (int n) const
 Get the display name of the parameter at index n. More...
 
virtual std::string getParamHint (int n) const
 Get the hint of the parameter at index n. More...
 
virtual std::string getParamDesc (int n) const
 Get the description of the parameter at index n. More...
 
virtual int getValueAsInt (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual unsigned int getValueAsUInt (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual long getValueAsLong (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual unsigned long getValueAsULong (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual float getValueAsFloat (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual double getValueAsDouble (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual std::vector< double > getValueAsDoubleVector (std::string key)
 Wrapper for getValue which converts output to a specific type.
 
virtual char getValueAsChar (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual unsigned char getValueAsUChar (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual std::string getValueAsString (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
virtual bool getValueAsBool (std::string key)
 Wrapper for getValue which converts output to a specific type. More...
 
const std::string & getDisplayName (std::string key) const
 Gets the hint associated with a given key. More...
 
const std::string & getHint (std::string key) const
 Gets the hint associated with a given key. More...
 
const std::string & getDescription (std::string key) const
 Gets the description associated with a given key. More...
 
const Variant::TypeId getType (std::string key)
 Gets the type associated with a given key. More...
 
std::string getSettingsRepr () const
 Get the solver settings as a string. More...
 
std::string settingsPyDictRepr () const
 Python dictionary-style string representation of settings. More...
 

Static Public Member Functions

static std::string getCVODEIntegratorName ()
 Get the name for this integrator. More...
 
static std::string getCVODEIntegratorDescription ()
 Get the description for this integrator. More...
 
static std::string getCVODEIntegratorHint ()
 Get the hint for this integrator. More...
 

Friends

int cvodeDyDtFcn (double t, N_Vector cv_y, N_Vector cv_ydot, void *f_data)
 
int cvodeRootFcn (double t, N_Vector y, double *gout, void *g_data)
 

Additional Inherited Members

- Public Types inherited from rr::Integrator
enum  IntegrationMethod { Deterministic , Stochastic , Hybrid , Other }
 
- Protected Types inherited from rr::Solver
typedef std::vector< std::string > SettingsList
 
typedef RR_UNORDERED_MAP< std::string, VariantSettingsMap
 
typedef RR_UNORDERED_MAP< std::string, std::string > DisplayNameMap
 
typedef RR_UNORDERED_MAP< std::string, std::string > HintMap
 
typedef RR_UNORDERED_MAP< std::string, std::string > DescriptionMap
 
- Protected Member Functions inherited from rr::Solver
void addSetting (std::string name, Variant val, string display_name, std::string hint, std::string description)
 
- Protected Attributes inherited from rr::Solver
SettingsList sorted_settings
 
SettingsMap settings
 
DisplayNameMap display_names_
 
HintMap hints
 
DescriptionMap descriptions
 

Detailed Description

A RoadRunner integrator based on CVODE; serves as RoadRunner's main integrator for ODEs.

Author
WBC, ETS, MTK

Provides a wrapper around CVODE from the SUNDIALS suite. CVODE has two main solvers: an Adams-Moulton solver for non-stiff problems, and a backward differentiation formula (BDF) solver for stiff problems. See: https://computation.llnl.gov/casc/sundials/documentation/toms_sundials.pdf

Constructor & Destructor Documentation

◆ CVODEIntegrator()

rr::CVODEIntegrator::CVODEIntegrator ( ExecutableModel oModel)
explicit

Constructor: takes an executable model, does not own the pointer.

Author
WBC, ETS, MTK

◆ ~CVODEIntegrator()

rr::CVODEIntegrator::~CVODEIntegrator ( )
override

Destructor.

Author
WBC, ETS, MTK

Member Function Documentation

◆ checkIndex()

void rr::CVODEIntegrator::checkIndex ( int  index,
int  size 
) const

Does a index check which throws if it is out of bound.

Author
FY

◆ checkType()

void rr::CVODEIntegrator::checkType ( ) const

Does a RT type check which throws if it fails, EVEN IF RTTI IS DISABLED.

Author
JKM

◆ checkVectorSize()

void rr::CVODEIntegrator::checkVectorSize ( int  expected,
size_t  real 
) const

Does a size check which throws if it fails.

Author
FY

◆ getConcentrationTolerance()

std::vector<double> rr::CVODEIntegrator::getConcentrationTolerance ( )
overridevirtual

Gets tolerance based on concentration of species.

Author
FY

Reimplemented from rr::Integrator.

◆ getCVODEIntegratorDescription()

static std::string rr::CVODEIntegrator::getCVODEIntegratorDescription ( )
static

Get the description for this integrator.

Author
JKM

◆ getCVODEIntegratorHint()

static std::string rr::CVODEIntegrator::getCVODEIntegratorHint ( )
static

Get the hint for this integrator.

Author
JKM

◆ getCVODEIntegratorName()

static std::string rr::CVODEIntegrator::getCVODEIntegratorName ( )
static

Get the name for this integrator.

Author
JKM

◆ getCvodeMemory()

void* rr::CVODEIntegrator::getCvodeMemory ( ) const

getter for the internal CVode memory buffer

Author
CW
Note
This method was created to enable external access (mostly for tests) to the Sundials memory buffer object. This method should not be exposed at the Python level.

◆ getDescription()

std::string rr::CVODEIntegrator::getDescription ( ) const
overridevirtual

Get the description for this integrator.

Author
WBC
Note
Delegates to getDescription

Implements rr::Solver.

◆ getHint()

std::string rr::CVODEIntegrator::getHint ( ) const
overridevirtual

Get the hint for this integrator.

Author
WBC
Note
Delegates to getHint

Implements rr::Solver.

◆ getIntegrationMethod()

IntegrationMethod rr::CVODEIntegrator::getIntegrationMethod ( ) const
overridevirtual

Always deterministic for CVODE.

Author
WBC, ETS, MTK

Implements rr::Integrator.

◆ getListener()

IntegratorListenerPtr rr::CVODEIntegrator::getListener ( )
overridevirtual

Gets the integrator listener.

Author
WBC, ETS

Implements rr::Integrator.

◆ getName()

std::string rr::CVODEIntegrator::getName ( ) const
overridevirtual

Get the name for this integrator.

Author
WBC
Note
Delegates to getName

Implements rr::Solver.

◆ getSolver()

SUNNonlinearSolver rr::CVODEIntegrator::getSolver ( ) const

getter for the internal Sundials linear solver object

Author
CW
Note
This method was created to enable external access (mostly for tests) to the Sundials SUNLinearSolver object. This method should not be exposed at the Python level.

◆ getStateVector()

N_Vector rr::CVODEIntegrator::getStateVector ( ) const

getter for the internal state vector

Author
CW
Note
This method was created to enable external access (mostly for tests) to the Sundials N_Vector object. This method should not be exposed at the Python level.

◆ integrate()

double rr::CVODEIntegrator::integrate ( double  t0,
double  tf 
)
overridevirtual

Main integration routine.

Author
WBC, ETS, MTK

Implements rr::Integrator.

◆ loadSBMLSettings()

void rr::CVODEIntegrator::loadSBMLSettings ( const std::string &  filename)
overridevirtual

Load an SBML settings file and apply the configuration options.

Author
WBC
Note
Can assign relative and absolute tolerances

Reimplemented from rr::Integrator.

◆ resetSettings()

void rr::CVODEIntegrator::resetSettings ( )
overridevirtual

Reset all integrator settings to their respective default values.

Author
JKM

Reimplemented from rr::Solver.

◆ restart()

void rr::CVODEIntegrator::restart ( double  timeStart)
overridevirtual

Reset time to zero and reinitialize model.

Author
WBC, ETS, MTK

Applies events which occur before time zero. Reinitializes CVODE and the executable model.

Implements rr::Integrator.

◆ setConcentrationTolerance()

void rr::CVODEIntegrator::setConcentrationTolerance ( const Variant value)
overridevirtual

Sets tolerance based on concentration of species.

Author
FY

First converts the concentration tolerances to amount tolerances by multiplying the compartment volume of species. Whichever is smaller will be stored as absolute_tolerance and used in the integration process.

Reimplemented from rr::Integrator.

◆ setIndividualTolerance()

void rr::CVODEIntegrator::setIndividualTolerance ( string  sid,
double  value 
)
overridevirtual

Sets tolerance for individual species.

Author
FY

Reimplemented from rr::Integrator.

◆ setListener()

void rr::CVODEIntegrator::setListener ( IntegratorListenerPtr  )
overridevirtual

Sets the integrator listener.

Author
WBC, ETS

Implements rr::Integrator.

◆ setValue()

void rr::CVODEIntegrator::setValue ( std::string  setting,
const Variant value 
)
overridevirtual

Sets the value of an integrator setting (e.g. absolute_tolerance)

Author
WBC, ETS, MTK

Reimplemented from rr::Solver.

◆ syncWithModel()

void rr::CVODEIntegrator::syncWithModel ( ExecutableModel m)
overridevirtual

Called whenever a new model is loaded to allow integrator to reset internal state.

Author
JKM

Reimplemented from rr::Integrator.

◆ ToString() [1/2]

std::string rr::CVODEIntegrator::ToString ( int  val) const

Converts integer to string for error print.

Author
FY

◆ ToString() [2/2]

std::string rr::CVODEIntegrator::ToString ( size_t  val) const

Converts size_t to string for error print.

Author
LPS

◆ tweakTolerances()

void rr::CVODEIntegrator::tweakTolerances ( )
overridevirtual

Fix tolerances for SBML tests.

Author
JKM, WBC, ETS, MTK

In order to ensure that the results of the SBML test suite remain valid, this method enforces a lower bound on tolerance values. Sets minimum absolute and relative tolerances to Config::CVODE_MIN_ABSOLUTE and Config::CVODE_MIN_RELATIVE resp.

Reimplemented from rr::Integrator.


The documentation for this class was generated from the following file: