A rootfinding initial value problem — find the root of a function along an orbit of an ODE. More...
#include <RootfindingIVP.h>
A rootfinding initial value problem — find the root of a function along an orbit of an ODE.
Definition at line 9 of file RootfindingIVP.h.
Public Member Functions | |
RootfindingIVP (std::shared_ptr< WorkPiece > rhs, std::shared_ptr< WorkPiece > root, boost::property_tree::ptree const &pt, std::shared_ptr< muq::Utilities::AnyAlgebra > algebra=std::make_shared< muq::Utilities::AnyAlgebra >()) | |
virtual | ~RootfindingIVP () |
RootfindingIVP::RootfindingIVP | ( | std::shared_ptr< WorkPiece > | rhs, |
std::shared_ptr< WorkPiece > | root, | ||
boost::property_tree::ptree const & | pt, | ||
std::shared_ptr< muq::Utilities::AnyAlgebra > | algebra = std::make_shared<muq::Utilities::AnyAlgebra>() |
||
) |
The first input is the initial state (at \(t=0\)). It is also the first input to the both right hand side and the root muq::Modeling::WorkPiece. The type must be the same in both sub-models (if it is known). This must a N_Vector type (the vectors that Sundials uses).
The next set of inputs are the inputs to the right hand side muq::Modeling::WorkPiece. If the right hand side input takes 2 inputs besides the state, these correspond to inputs 2 and 3 of the root finder. Their types are known if the types are known by the rhs muq::Modeling::WorkPiece.
The next set of inputs are the inputs to the root muq::Modeling::WorkPiece. If the root input takes 2 inputs besides the state, these correspond to inputs 4 and 5 of the root finder. Their types are known if the types are known by the rhs muq::Modeling::WorkPiece.
An optional final input is a vector of times to save the state. If the user gives muq::Modeling::RootfinderIVP this (optional) input it integrates until it finds a root, saving the state at each of these times.
The first output is the state at the root. This output has the same type as the first input to the right hand side and the root (if either is known). Note that the "the root" is the first state such that any one of the outputs from the root function is zero. It is boost::none if no root was found.
The second output is the time at which the root (first output) was obtained.
The third output exists if the user gives muq::Modeling::RootfinderIVP times to save the state (optional final input). This output is a vector — std::vector<StateType> — of states at the specified times.
Parameters options (for boost::property_tree::ptree):
[in] | rhs | A muq::Modeling::WorkPiece that evaluates the right hand side of the ODE |
[in] | root | A muq::Modeling::WorkPiece whose outputs are double's — we integrate the ODE until we find the first root of one of these outputs |
[in] | pt | A boost::property_tree::ptree with options/tolerances for the ODE integrator |
[in] | algebra | A muq::Utilities::AnyAlgebra used to manipulate the state and input parameters (defaults to the MUQ default) |
Definition at line 12 of file RootfindingIVP.cpp.
References root, and UpdateInputOutputTypes().
|
virtual |
Definition at line 24 of file RootfindingIVP.cpp.
|
overrideprivatevirtual |
Integrate the ODE until we find a root.
[in] | inputs | The inputs (first: state, next group: rhs inputs, next group: root inputs, final: eval times (optional)) |
Definition at line 163 of file RootfindingIVP.cpp.
References FindRoot().
|
staticprivate |
Evaluate the root function.
[in] | t | The current time |
[in] | state | The state |
[out] | root | The roots |
[in] | user_data | A pointer to an muq::Modeling::ODEData |
Definition at line 282 of file RootfindingIVP.cpp.
References muq::Modeling::ODEData::inputs, muq::Modeling::ODEData::rhs, muq::Modeling::ODEData::root, and root.
Referenced by FindRoot().
|
private |
Run the CVODES integrator.
[in] | inputs | The inputs (first: state, next group: rhs inputs, next group: root inputs, final: eval times (optional)) |
[in] | wrtIn | We are computing the derivative with repsect to this parameter |
[in] | wrtOut | We are computing the derivative of this output |
[in] | mode | Are we computing the Jacobian, Jacobian action, or Jacobian transpose action? |
Definition at line 26 of file RootfindingIVP.cpp.
References EvaluateRoot(), maxErrorTests, maxSteps, maxTime, and root.
Referenced by EvaluateImpl(), and JacobianImpl().
|
overrideprivatevirtual |
Compute the Jacobian of the state at the root.
[in] | wrtIn | We are computing the derivative with repsect to this parameter |
[in] | wrtOut | We are computing the derivative of this output |
[in] | inputs | The inputs (first: state, next group: rhs inputs, next group: root inputs, final: eval times (optional)) |
Definition at line 168 of file RootfindingIVP.cpp.
References FindRoot(), and root.
|
private |
Update the input and output types based on the rhs and root muq::Modeling::WorkPiece's.
Add the root input types to the inputs and set the second output type. Note the (optional) third output (the vector of state's at specified times) is std::vector<StateType> but we can't set this.
Definition at line 257 of file RootfindingIVP.cpp.
References root.
Referenced by RootfindingIVP().
|
private |
The maximum number of error test failures.
Definition at line 103 of file RootfindingIVP.h.
Referenced by FindRoot().
|
private |
The maximum number of steps the timesteper can take.
Definition at line 97 of file RootfindingIVP.h.
Referenced by FindRoot().
|
private |
The maximum amount of time to integrate.
Definition at line 100 of file RootfindingIVP.h.
Referenced by FindRoot().
|
private |
The root function.
Definition at line 94 of file RootfindingIVP.h.
Referenced by EvaluateRoot(), FindRoot(), JacobianImpl(), RootfindingIVP(), and UpdateInputOutputTypes().