stepper_wrapper.h Source File
|
CPP API
|
stepper_wrapper.h
Go to the documentation of this file.
32 // #include "boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp" // TODO: reenable once boost bug is fixed
56 template <typename FP, template <class State, class Value, class Deriv, class Time, class Algebra, class Operations,
61 using Operations = typename boost::numeric::odeint::operations_dispatcher<Eigen::VectorX<FP>>::operations_type;
65 // Note: use a reference_wrapper so we can both update dt_max, and replace the stepper to change tolerances
67 ControlledStepper<Eigen::VectorX<FP>, FP, Eigen::VectorX<FP>, FP, Algebra, Operations, Resizer>, ErrorChecker,
69 static constexpr bool is_fsal_stepper = std::is_same_v<typename Stepper::stepper_type::stepper_category,
82 ControlledStepperWrapper(FP abs_tol = 1e-10, FP rel_tol = 1e-5, FP dt_min = std::numeric_limits<FP>::min(),
100 return std::make_unique<ControlledStepperWrapper>(m_abs_tol, m_rel_tol, this->get_dt_min(), this->get_dt_max());
111 bool step(const mio::DerivFunction<FP>& f, Eigen::Ref<const Eigen::VectorX<FP>> yt, FP& t, FP& dt,
122 mio::log_warning("IntegratorCore: Restricting given step size dt = {} to [{}, {}].", dt, this->get_dt_min(),
130 // stop only on a successful step or a failed step size adaption (w.r.t. the minimal step size dt_min)
137 // this is similiar to do_step, but it can adapt the step size dt. If successful, it also updates t.
149 // the last adaptive step (successful or not) may have calculated a new step size smaller than m_dt_min
152 // check whether the last step failed (which means that m_dt_min was still too large to suffice tolerances)
207 template <typename FP, template <class State, class Value, class Deriv, class Time, class Algebra, class Operations,
213 ExplicitStepper<Eigen::VectorX<FP>, FP, Eigen::VectorX<FP>, FP, boost::numeric::odeint::vector_space_algebra,
238 bool step(const mio::DerivFunction<FP>& f, Eigen::Ref<const Eigen::VectorX<FP>> yt, FP& t, FP& dt,
242 // sys=f, inout=y(t) for in-place computation - also, this form is shared by several steppers in boost
void set_dt_max(FP dt_max)
Definition: stepper_wrapper.h:185
Stepper m_stepper
A stepper instance used for integration.
Definition: stepper_wrapper.h:200
bool step(const mio::DerivFunction< FP > &f, Eigen::Ref< const Eigen::VectorX< FP >> yt, FP &t, FP &dt, Eigen::Ref< Eigen::VectorX< FP >> ytp1) const override
Make a single integration step on a system of ODEs and adapt the step size dt.
Definition: stepper_wrapper.h:111
boost::numeric::odeint::default_error_checker< FP, Algebra, Operations > ErrorChecker
Definition: stepper_wrapper.h:63
typename boost::numeric::odeint::operations_dispatcher< Eigen::VectorX< FP > >::operations_type Operations
Definition: stepper_wrapper.h:61
boost::numeric::odeint::controlled_runge_kutta< ControlledStepper< Eigen::VectorX< FP >, FP, Eigen::VectorX< FP >, FP, Algebra, Operations, Resizer >, ErrorChecker, boost::reference_wrapper< StepAdjuster > > Stepper
Definition: stepper_wrapper.h:68
ControlledStepperWrapper & operator=(ControlledStepperWrapper &&other)=delete
boost::numeric::odeint::initially_resizer Resizer
Definition: stepper_wrapper.h:62
void set_abs_tolerance(FP abs_tol)
Definition: stepper_wrapper.h:165
ControlledStepperWrapper & operator=(const ControlledStepperWrapper &other)=delete
Stepper create_stepper()
(Re)initialize the internal stepper.
Definition: stepper_wrapper.h:192
ControlledStepperWrapper(ControlledStepperWrapper &&other)=delete
void set_dt_min(FP dt_min)
Definition: stepper_wrapper.h:179
void set_rel_tolerance(FP rel_tol)
Definition: stepper_wrapper.h:172
std::unique_ptr< OdeIntegratorCore< FP > > clone() const override
Definition: stepper_wrapper.h:98
ControlledStepperWrapper(const ControlledStepperWrapper &other)=delete
boost::numeric::odeint::vector_space_algebra Algebra
Definition: stepper_wrapper.h:60
StepAdjuster m_step_adjuster
Defines step sizing. Holds a copy of dt_max that has to be updated.
Definition: stepper_wrapper.h:199
ControlledStepperWrapper(FP abs_tol=1e-10, FP rel_tol=1e-5, FP dt_min=std::numeric_limits< FP >::min(), FP dt_max=std::numeric_limits< FP >::max())
Set up the integrator.
Definition: stepper_wrapper.h:82
bool step(const mio::DerivFunction< FP > &f, Eigen::Ref< const Eigen::VectorX< FP >> yt, FP &t, FP &dt, Eigen::Ref< Eigen::VectorX< FP >> ytp1) const override
Make a single integration step on a system of ODEs with fixed step size dt.
Definition: stepper_wrapper.h:238
Stepper m_stepper
A stepper instance used for integration.
Definition: stepper_wrapper.h:256
ExplicitStepper< Eigen::VectorX< FP >, FP, Eigen::VectorX< FP >, FP, boost::numeric::odeint::vector_space_algebra, typename boost::numeric::odeint::operations_dispatcher< Eigen::VectorX< FP > >::operations_type, boost::numeric::odeint::initially_resizer > Stepper
Definition: stepper_wrapper.h:215
std::unique_ptr< OdeIntegratorCore< FP > > clone() const override
Definition: stepper_wrapper.h:225
ExplicitStepperWrapper()
Set up the integrator.
Definition: stepper_wrapper.h:220
Interface class defining the integration step used in a SystemIntegrator.
Definition: integrator.h:48
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type min(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2599
static min_max_return_type< ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > >::type max(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &a, const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &b)
Definition: ad.hpp:2596
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
std::function< void(Eigen::Ref< const Eigen::VectorX< FP > > y, FP t, Eigen::Ref< Eigen::VectorX< FP > > dydt)> DerivFunction
Function template to be integrated.
Definition: integrator.h:39
Extends the default_step_adjuster with a setter for dt_max.
Definition: stepper_wrapper.h:42
void set_dt_max(const Time &dt_max)
Definition: stepper_wrapper.h:44
Generated by