#include <BackwardEulerIvpOdeSolver.hpp>
Public Member Functions | |
BackwardEulerIvpOdeSolver (unsigned sizeOfOdeSystem) | |
~BackwardEulerIvpOdeSolver () | |
void | SetEpsilonForNumericalJacobian (double epsilon) |
void | ForceUseOfNumericalJacobian () |
unsigned | GetSystemSize () const |
Protected Member Functions | |
void | CalculateNextYValue (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rNextYValues) |
Private Member Functions | |
template<class Archive> | |
void | serialize (Archive &archive, const unsigned int version) |
void | ComputeResidual (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess) |
void | ComputeJacobian (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess) |
void | SolveLinearSystem () |
double | ComputeNorm (double *pVector) |
void | ComputeNumericalJacobian (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rCurrentGuess) |
Private Attributes | |
unsigned | mSizeOfOdeSystem |
double | mNumericalJacobianEpsilon |
bool | mForceUseOfNumericalJacobian |
double * | mResidual |
double ** | mJacobian |
double * | mUpdate |
Friends | |
class | boost::serialization::access |
Definition at line 47 of file BackwardEulerIvpOdeSolver.hpp.
BackwardEulerIvpOdeSolver::BackwardEulerIvpOdeSolver | ( | unsigned | sizeOfOdeSystem | ) |
Constructor.
sizeOfOdeSystem | the number of state variables in the ODE system |
Definition at line 203 of file BackwardEulerIvpOdeSolver.cpp.
References mForceUseOfNumericalJacobian, mJacobian, mNumericalJacobianEpsilon, mResidual, mSizeOfOdeSystem, and mUpdate.
BackwardEulerIvpOdeSolver::~BackwardEulerIvpOdeSolver | ( | ) |
Destructor.
Definition at line 222 of file BackwardEulerIvpOdeSolver.cpp.
References mJacobian, mResidual, mSizeOfOdeSystem, and mUpdate.
void BackwardEulerIvpOdeSolver::serialize | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Archive the abstract IVP Solver, never used directly - boost uses this.
archive | the archive | |
version | the current version of this class |
Reimplemented from AbstractOneStepIvpOdeSolver.
Definition at line 59 of file BackwardEulerIvpOdeSolver.hpp.
References mForceUseOfNumericalJacobian, and mNumericalJacobianEpsilon.
void BackwardEulerIvpOdeSolver::ComputeResidual | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
double | timeStep, | |||
double | time, | |||
std::vector< double > & | rCurrentYValues, | |||
std::vector< double > & | rCurrentGuess | |||
) | [private] |
Compute the current residual.
pAbstractOdeSystem | the ODE system to solve | |
timeStep | dt | |
time | the current time | |
rCurrentYValues | the current (initial) state | |
rCurrentGuess | current guess for the state at the next timestep |
Definition at line 33 of file BackwardEulerIvpOdeSolver.cpp.
References AbstractOdeSystem::EvaluateYDerivatives(), mResidual, and mSizeOfOdeSystem.
Referenced by CalculateNextYValue(), and ComputeNumericalJacobian().
void BackwardEulerIvpOdeSolver::ComputeJacobian | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
double | timeStep, | |||
double | time, | |||
std::vector< double > & | rCurrentYValues, | |||
std::vector< double > & | rCurrentGuess | |||
) | [private] |
Compute the Jacobian of the ODE system.
pAbstractOdeSystem | the ODE system to solve | |
timeStep | dt | |
time | the current time | |
rCurrentYValues | the current (initial) state | |
rCurrentGuess | current guess for the state at the next timestep |
Definition at line 47 of file BackwardEulerIvpOdeSolver.cpp.
References AbstractOdeSystemWithAnalyticJacobian::AnalyticJacobian(), ComputeNumericalJacobian(), AbstractOdeSystem::GetUseAnalyticJacobian(), mForceUseOfNumericalJacobian, mJacobian, and mSizeOfOdeSystem.
Referenced by CalculateNextYValue().
void BackwardEulerIvpOdeSolver::SolveLinearSystem | ( | ) | [private] |
Solve a linear system of equations to update the current guess for the solution to the ODE system at the next timestep. Used by the method CalculateNextYValue.
Definition at line 78 of file BackwardEulerIvpOdeSolver.cpp.
References mJacobian, mResidual, mSizeOfOdeSystem, and mUpdate.
Referenced by CalculateNextYValue().
double BackwardEulerIvpOdeSolver::ComputeNorm | ( | double * | pVector | ) | [private] |
Compute the infinity/maximum norm of a vector. Used by the method CalculateNextYValue.
pVector | a pointer to a vector |
Definition at line 105 of file BackwardEulerIvpOdeSolver.cpp.
References mSizeOfOdeSystem.
Referenced by CalculateNextYValue().
void BackwardEulerIvpOdeSolver::ComputeNumericalJacobian | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
double | timeStep, | |||
double | time, | |||
std::vector< double > & | rCurrentYValues, | |||
std::vector< double > & | rCurrentGuess | |||
) | [private] |
Compute the Jacobian of the ODE system numerically.
pAbstractOdeSystem | the ODE system to solve | |
timeStep | dt | |
time | the current time | |
rCurrentYValues | the current (initial) state | |
rCurrentGuess | current guess for the state at the next timestep |
Definition at line 118 of file BackwardEulerIvpOdeSolver.cpp.
References ComputeResidual(), mJacobian, mNumericalJacobianEpsilon, mResidual, and mSizeOfOdeSystem.
Referenced by ComputeJacobian().
void BackwardEulerIvpOdeSolver::CalculateNextYValue | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
double | timeStep, | |||
double | time, | |||
std::vector< double > & | rCurrentYValues, | |||
std::vector< double > & | rNextYValues | |||
) | [protected, virtual] |
Calculate the solution to the ODE system at the next timestep.
A usage example: BackwardEulerIvpOdeSolver mySolver; OdeSolution solution = mySolver.Solve(pMyOdeSystem, yInit, StartTime, EndTime, TimeStep, SamplingTime);
pAbstractOdeSystem | the ODE system to solve | |
timeStep | dt | |
time | the current time | |
rCurrentYValues | the current (initial) state | |
rNextYValues | the state at the next timestep |
Implements AbstractOneStepIvpOdeSolver.
Definition at line 160 of file BackwardEulerIvpOdeSolver.cpp.
References ComputeJacobian(), ComputeNorm(), ComputeResidual(), AbstractOdeSystem::GetNumberOfStateVariables(), mSizeOfOdeSystem, mUpdate, and SolveLinearSystem().
void BackwardEulerIvpOdeSolver::SetEpsilonForNumericalJacobian | ( | double | epsilon | ) |
Set the epsilon to use in calculating the numerical Jacobian of the ODE system.
epsilon |
Definition at line 235 of file BackwardEulerIvpOdeSolver.cpp.
References mNumericalJacobianEpsilon.
void BackwardEulerIvpOdeSolver::ForceUseOfNumericalJacobian | ( | ) |
Force the solver to use the numerical Jacobian even if the ODE system object provides an analytical Jacobian.
Definition at line 241 of file BackwardEulerIvpOdeSolver.cpp.
References mForceUseOfNumericalJacobian.
unsigned BackwardEulerIvpOdeSolver::GetSystemSize | ( | ) | const [inline] |
Public method used in archiving.
Definition at line 211 of file BackwardEulerIvpOdeSolver.hpp.
References mSizeOfOdeSystem.
friend class boost::serialization::access [friend] |
Needed for serialization.
Reimplemented from AbstractOneStepIvpOdeSolver.
Definition at line 51 of file BackwardEulerIvpOdeSolver.hpp.
unsigned BackwardEulerIvpOdeSolver::mSizeOfOdeSystem [private] |
The number of state variables in the ODE system.
Definition at line 69 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), CalculateNextYValue(), ComputeJacobian(), ComputeNorm(), ComputeNumericalJacobian(), ComputeResidual(), GetSystemSize(), SolveLinearSystem(), and ~BackwardEulerIvpOdeSolver().
double BackwardEulerIvpOdeSolver::mNumericalJacobianEpsilon [private] |
The epsilon to use in calculating the numerical Jacobian of the ODE system.
Definition at line 72 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), ComputeNumericalJacobian(), serialize(), and SetEpsilonForNumericalJacobian().
bool BackwardEulerIvpOdeSolver::mForceUseOfNumericalJacobian [private] |
Whether to force the solver to use the numerical Jacobian even if the ODE system object provides an analytical Jacobian.
Definition at line 78 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), ComputeJacobian(), ForceUseOfNumericalJacobian(), and serialize().
double* BackwardEulerIvpOdeSolver::mResidual [private] |
Working memory : residual vector
Definition at line 87 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), ComputeNumericalJacobian(), ComputeResidual(), SolveLinearSystem(), and ~BackwardEulerIvpOdeSolver().
double** BackwardEulerIvpOdeSolver::mJacobian [private] |
Working memory : Jacobian matrix
Definition at line 90 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), ComputeJacobian(), ComputeNumericalJacobian(), SolveLinearSystem(), and ~BackwardEulerIvpOdeSolver().
double* BackwardEulerIvpOdeSolver::mUpdate [private] |
Working memory : update vector
Definition at line 93 of file BackwardEulerIvpOdeSolver.hpp.
Referenced by BackwardEulerIvpOdeSolver(), CalculateNextYValue(), SolveLinearSystem(), and ~BackwardEulerIvpOdeSolver().