4 #include <boost/property_tree/ptree.hpp>
6 #include <cvodes/cvodes.h>
7 #include <nvector/nvector_serial.h>
8 #include <sunmatrix/sunmatrix_dense.h>
9 #include <sunlinsol/sunlinsol_dense.h>
10 #include <sunnonlinsol/sunnonlinsol_newton.h>
11 #include <sunnonlinsol/sunnonlinsol_fixedpoint.h>
35 ODE(std::shared_ptr<ModPiece>
const& rhsIn,
36 Eigen::VectorXd
const& evalTimesIn,
37 boost::property_tree::ptree opts = boost::property_tree::ptree()) :
ODE(rhsIn, evalTimesIn, true, opts){};
39 ODE(std::shared_ptr<ModPiece>
const& rhsIn,
40 Eigen::VectorXd
const& evalTimesIn,
42 boost::property_tree::ptree opts = boost::property_tree::ptree());
64 Eigen::VectorXd
const& sens)
override;
73 Eigen::VectorXd
const& vec)
override;
89 void SetOptions(boost::property_tree::ptree
const& opts);
107 void SetOptions(boost::property_tree::ptree
const& opts);
135 void SetOptions(boost::property_tree::ptree
const& opts);
155 static int RHS(realtype time, N_Vector state, N_Vector deriv,
void *user_data);
156 static int RHSJacobian(realtype time, N_Vector state, N_Vector
rhs, SUNMatrix jac,
void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
157 static int RHSJacobianAction(N_Vector
v, N_Vector Jv, realtype time, N_Vector state, N_Vector
rhs,
void *user_data, N_Vector tmp);
165 static int SensitivityRHS(
int Ns, realtype time, N_Vector y, N_Vector ydot, N_Vector *ys, N_Vector *ySdot,
void *user_data, N_Vector tmp1, N_Vector tmp2);
173 static int AdjointRHS(
double time, N_Vector state, N_Vector lambda, N_Vector deriv,
void *user_data);
174 static int AdjointJacobian(
double time, N_Vector state, N_Vector lambda, N_Vector
rhs, SUNMatrix jac,
void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
176 static int AdjointJacobianAction(N_Vector target, N_Vector output,
double time, N_Vector state, N_Vector lambda, N_Vector adjRhs,
void *user_data, N_Vector tmp);
181 static int AdjointQuad(realtype time, N_Vector state, N_Vector lambda, N_Vector quadRhs,
void *user_data);
192 std::shared_ptr<ModPiece>
rhs;
204 std::pair<SUNLinearSolver, SUNMatrix>
CreateLinearSolver(
void *cvode_mem, N_Vector
const& state);
213 static Eigen::VectorXi
GetInputSizes(std::shared_ptr<ModPiece>
const& rhsIn,
216 static Eigen::VectorXi
GetOutputSizes(std::shared_ptr<ModPiece>
const& rhsIn,
219 static double GetStartTime(Eigen::VectorXd
const& evalTimesIn,
220 boost::property_tree::ptree
const& opts);
223 static void CheckFlag(
void *returnvalue,
const char *funcname,
int opt);
Provides an abstract interface for defining vector-valued model components.
A class for integrating ODEs with CVODES.
const double startTime
The time when this simulation starts – either set in the opts ptree or set to the minimum of evalTime...
static Eigen::VectorXi GetInputSizes(std::shared_ptr< ModPiece > const &rhsIn, bool isAuto)
static void CheckFlag(void *returnvalue, const char *funcname, int opt)
Checks the return value produced by CVODES. Throws and exception if error occured.
SUNNonlinearSolver CreateNonlinearSolver(void *cvode_mem, N_Vector const &state)
std::pair< SUNLinearSolver, SUNMatrix > CreateAdjointLinearSolver(void *cvode_mem, N_Vector const &state, int indexB)
virtual void JacobianImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &inputs) override
static Eigen::VectorXi GetOutputSizes(std::shared_ptr< ModPiece > const &rhsIn, Eigen::VectorXd const &evalTimes)
virtual void GradientImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &inputs, Eigen::VectorXd const &sens) override
IntegratorOptions intOpts
std::shared_ptr< ModPiece > rhs
LinearSolverOptions linOpts
std::pair< SUNLinearSolver, SUNMatrix > CreateLinearSolver(void *cvode_mem, N_Vector const &state)
virtual void ApplyJacobianImpl(unsigned int outWrt, unsigned int inWrt, ref_vector< Eigen::VectorXd > const &inputs, Eigen::VectorXd const &vec) override
SUNNonlinearSolver CreateAdjointNonlinearSolver(void *cvode_mem, N_Vector const &state, int indexB)
const bool isAutonomous
Does the RHS explicitly depend on time?
ODE(std::shared_ptr< ModPiece > const &rhsIn, Eigen::VectorXd const &evalTimesIn, boost::property_tree::ptree opts=boost::property_tree::ptree())
const Eigen::VectorXd evalTimes
NonlinearSolverOptions nonlinOpts
static double GetStartTime(Eigen::VectorXd const &evalTimesIn, boost::property_tree::ptree const &opts)
virtual void EvaluateImpl(ref_vector< Eigen::VectorXd > const &inputs) override
Integrates the ODE forward in time.
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
void SetOptions(boost::property_tree::ptree const &opts)
IntegratorOptions(boost::property_tree::ptree const &opts)
IntegratorOptions()=default
static int RHSJacobianAction(N_Vector v, N_Vector Jv, realtype time, N_Vector state, N_Vector rhs, void *user_data, N_Vector tmp)
static int RHSJacobian(realtype time, N_Vector state, N_Vector rhs, SUNMatrix jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
static int RHS(realtype time, N_Vector state, N_Vector deriv, void *user_data)
LinearSolverOptions()=default
void SetOptions(boost::property_tree::ptree const &opts)
LinearSolverOptions(boost::property_tree::ptree const &opts)
NonlinearSolverOptions(boost::property_tree::ptree const &opts)
NonlinearSolverOptions()=default
void SetOptions(boost::property_tree::ptree const &opts)