COPASI API
4.40.278
|
#include <CRungeKutta.h>
Public Types | |
enum | RKMethodStatus { INITIALIZE , RESTART , CONTINUE , ROOTFOUND , END , ERROR } |
Public Member Functions | |
CRungeKutta () | |
std::string | getErrorMesssage () const |
RKMethodStatus | operator() (const size_t *pDim, C_FLOAT64 *pY, C_FLOAT64 *pTime, C_FLOAT64 *pEndTime, const size_t rootCount, C_INT *pRoots, const RKMethodStatus &status, const bool &oneStep, C_FLOAT64 *rtol, C_FLOAT64 *atol, unsigned C_INT32 *pMaxSteps, EvalDeriv pEvalDerivatives, EvalRoot pEvalRoots) |
~CRungeKutta () | |
Private Member Functions | |
void | advanceStep () |
void | allocateSpace () |
bool | checkODEState (const RKMethodStatus &status) |
bool | checkParameter (const size_t *pDim, C_FLOAT64 *pY, C_FLOAT64 *pTime, C_FLOAT64 *pEndTime, const size_t rootCount, C_INT *pRoots, const RKMethodStatus &status, C_FLOAT64 *rtol, C_FLOAT64 *atol, unsigned C_INT32 *pMaxSteps, EvalDeriv pEvalDerivatives, EvalRoot pEvalRoots) |
void | checkRoots () |
C_FLOAT64 | deps (const C_FLOAT64 &) |
void | doOneStep () |
C_FLOAT64 | estimateError () |
C_FLOAT64 | infNorm (const size_t &, const C_FLOAT64 *) |
void | initialize (const size_t *pDim, C_FLOAT64 *pY, C_FLOAT64 *pTime, C_FLOAT64 *pEndTime, const size_t rootCount, C_INT *pRoots, const RKMethodStatus &status, C_FLOAT64 *rtol, C_FLOAT64 *atol, unsigned C_INT32 *pMaxSteps, EvalDeriv pEvalDerivatives, EvalRoot pEvalRoots) |
void | interpolation (const C_FLOAT64, C_FLOAT64 *) |
C_FLOAT64 | rootValue (const C_FLOAT64 &time) |
void | setCoeff () |
void | setInitialStepSize () |
void | setStatRecord () |
Private Attributes | |
C_FLOAT64 | mA [8][8] |
C_FLOAT64 | mAbsTol |
size_t | mAcceptNum |
C_FLOAT64 | mB [8] |
C_FLOAT64 | mC [8] |
bool | mContinueFromInterpolation |
C_FLOAT64 | mE [8] |
std::stringstream | mErrorMessage |
C_FLOAT64 | mFac |
C_FLOAT64 | mFacMax |
C_FLOAT64 | mFacMaxRej |
C_FLOAT64 | mFacMin |
size_t | mfEvalNum |
C_FLOAT64 | mh |
C_FLOAT64 | mhMax |
C_FLOAT64 | mhMin |
bool | mhNoFailed |
C_FLOAT64 | mI [8][8] |
C_FLOAT64 ** | mK |
unsigned C_INT32 | mMaxSteps |
RKMethodStatus | mMethodStatus |
size_t | mOrderY |
size_t | mOrderYp |
size_t | mP |
EvalDeriv | mpDerivFunc |
const size_t * | mpDim |
EvalRoot | mpEventFunc |
CBrent::Eval * | mpRootValueCalculator |
C_FLOAT64 * | mpY |
size_t | mRejectNum |
C_FLOAT64 | mRelTol |
size_t | mrEvalNum |
CVectorCore< C_INT > | mRootFound |
size_t | mRootNum |
C_FLOAT64 * | mRootValueRight |
C_FLOAT64 * | mRootValuesLeft |
C_FLOAT64 * | mRootValueTmp |
size_t | mStage |
size_t | mStepNum |
C_FLOAT64 | mTEnd |
C_FLOAT64 | mTLeft |
C_FLOAT64 | mTRight |
C_FLOAT64 * | mYLeft |
C_FLOAT64 * | mYRight |
C_FLOAT64 * | mZ1 |
C_FLOAT64 * | mZ2 |
C_FLOAT64 * | mZ3 |
CRungeKutta::CRungeKutta | ( | ) |
Default constructor
This class is the ODE solver in terms Ronge-Kutta Method ODE45.
File name: CRungeKutta.cpp Author: Shuo Wang Email: shuow ang. learn er@g mail. com
Last change: 07, July 2014
References ERROR, mAbsTol, mAcceptNum, mContinueFromInterpolation, mFac, mFacMax, mFacMaxRej, mFacMin, mfEvalNum, mh, mhMax, mhMin, mhNoFailed, mK, mMaxSteps, mMethodStatus, mOrderY, mOrderYp, mP, mpDerivFunc, mpDim, mpEventFunc, mpRootValueCalculator, mpY, mRejectNum, mRelTol, mrEvalNum, mRootNum, mRootValueRight, mRootValuesLeft, mRootValueTmp, mStage, mStepNum, mTEnd, mTLeft, mTRight, mYLeft, mYRight, mZ1, mZ2, mZ3, and rootValue().
CRungeKutta::~CRungeKutta | ( | ) |
Default destructor
References mK, mpDerivFunc, mpEventFunc, mRootValueRight, mRootValuesLeft, mRootValueTmp, mStage, mYLeft, mYRight, mZ1, mZ2, mZ3, and pdelete.
|
private |
Update time, results and other necessary stuff
References C_FLOAT64, mContinueFromInterpolation, mK, mpDim, mStage, mTLeft, mTRight, mYLeft, and mYRight.
Referenced by operator()().
|
private |
Allocate space for arrays used
Update time, results and other necessary stuff
References C_FLOAT64, MAX_STAGE, mK, mpDim, mRootNum, mRootValueRight, mRootValuesLeft, mRootValueTmp, mStage, mYLeft, mYRight, mZ1, mZ2, mZ3, and pdelete.
Referenced by initialize().
|
private |
Check status of this ODE solver
Check the state attribute mODEState. If mODEState=0, first call of this method, initialization are required If mODEState=1, restart this method, method key parameters should be checked If mODEState=2, continue from last step which has an event (mODEState=3). First check if events left. If not, continue, else return with next event Else, method has error.
References CONTINUE, ERROR, INITIALIZE, mErrorMessage, mMethodStatus, and RESTART.
Referenced by operator()().
|
private |
Check parameters used in the integration
Check whether a slow function fired in this step Check parameters used in the integration
References mErrorMessage.
Referenced by initialize().
|
private |
Check whether there is a root
References CVectorCore< CType >::array(), C_FLOAT64, C_INT, fatalError, CBrent::findRoot(), interpolation(), mContinueFromInterpolation, mMethodStatus, mpDim, mpRootValueCalculator, mpY, mRelTol, mrEvalNum, mRootFound, mRootNum, mRootValueRight, mRootValuesLeft, mRootValueTmp, mTLeft, mTRight, mYLeft, mYRight, mZ1, and ROOTFOUND.
Referenced by operator()().
Calculate eps of a given value
Referenced by operator()(), and setInitialStepSize().
|
private |
|
private |
std::string CRungeKutta::getErrorMesssage | ( | ) | const |
References mErrorMessage.
Referenced by CHybridMethodODE45::integrateDeterministicPart().
|
private |
Initialize all the stuff used in this class
References allocateSpace(), checkParameter(), ERROR, CVectorCore< CType >::initialize(), INITIALIZE, mAbsTol, mContinueFromInterpolation, mErrorMessage, mMaxSteps, mMethodStatus, mpDerivFunc, mpDim, mpEventFunc, mpY, mRelTol, mRootFound, mRootNum, mTEnd, mTLeft, RESTART, setCoeff(), and setStatRecord().
Referenced by operator()().
CRungeKutta::RKMethodStatus CRungeKutta::operator() | ( | const size_t * | pDim, |
C_FLOAT64 * | pY, | ||
C_FLOAT64 * | pTime, | ||
C_FLOAT64 * | pEndTime, | ||
const size_t | rootCount, | ||
C_INT * | pRoots, | ||
const RKMethodStatus & | status, | ||
const bool & | oneStep, | ||
C_FLOAT64 * | rtol, | ||
C_FLOAT64 * | atol, | ||
unsigned C_INT32 * | pMaxSteps, | ||
EvalDeriv | pEvalDerivatives, | ||
EvalRoot | pEvalRoots | ||
) |
Do an integration step from the current state (pY, pTime) to the end time pEndTime
const | size_t * pDim, |
C_FLOAT64 | * pY, |
C_FLOAT64 | * pTime, |
C_FLOAT64 | * pEndTime, |
const | size_t rootCount, |
C_INT | * pRoots, |
const | RKMethodStatus & status, |
C_FLOAT64 | * rtol, |
C_FLOAT64 | * atol, |
EvalDeriv | pEvalDerivatives, |
EvalRoot | pEvalRoots |
Main function processing integration along time
References advanceStep(), C_FLOAT64, C_INT32, checkODEState(), checkRoots(), CONTINUE, deps(), doOneStep(), END, ERROR, estimateError(), INITIALIZE, initialize(), mAcceptNum, max, mContinueFromInterpolation, mErrorMessage, mFac, mFacMax, mFacMaxRej, mFacMin, mfEvalNum, mh, mhMin, mhNoFailed, min, mK, mMaxSteps, mMethodStatus, mP, mpDerivFunc, mpDim, mpY, mRejectNum, mRootNum, mRootValuesLeft, mStage, mStepNum, mTEnd, mTLeft, mTRight, mYLeft, mYRight, RESTART, ROOTFOUND, and setInitialStepSize().
Calculate the maximum root value for the given time for all roots changing sign between mRootValueLeft and mRootValueRight. rootValue is a continuous function which is positive at the right and negative at the left.
const | C_FLOAT64 & time |
References C_FLOAT64, interpolation(), mpDim, mrEvalNum, mRootNum, mRootValueRight, mRootValuesLeft, mRootValueTmp, and mZ1.
Referenced by CRungeKutta().
|
private |
|
private |
|
private |
Set statistic parameters
References mAcceptNum, mfEvalNum, mRejectNum, mrEvalNum, and mStepNum.
Referenced by initialize().
|
private |
mA, a C_FLOAT64 two dimension array, recording coefficients a_ij
Referenced by doOneStep(), and setCoeff().
|
private |
mAbsTol, absolute error tolerance mRelTol. relative error tolerance
Referenced by CRungeKutta(), estimateError(), and initialize().
|
private |
mAcceptNum, a size_t variable, recording how many successful steps
Referenced by CRungeKutta(), operator()(), and setStatRecord().
|
private |
mB, a C_FLOAT64 array, recording coefficients b_i
Referenced by doOneStep(), and setCoeff().
|
private |
mC, a C_FLOAT64 array, recording coefficients c_i
Referenced by doOneStep(), and setCoeff().
|
private |
Referenced by advanceStep(), checkRoots(), CRungeKutta(), initialize(), and operator()().
|
private |
mE, a C_FLOAT64 array, recording coefficients e_i for absolute error calculation
Referenced by estimateError(), and setCoeff().
|
private |
Referenced by checkODEState(), checkParameter(), getErrorMesssage(), initialize(), and operator()().
|
private |
mFac, a number as a factor for step size control
Referenced by CRungeKutta(), operator()(), and setInitialStepSize().
|
private |
mFacMax, maximum factor value
Referenced by CRungeKutta(), operator()(), and setInitialStepSize().
|
private |
mFacMaxRej, maximum factor value after a rejected step
Referenced by CRungeKutta(), operator()(), and setInitialStepSize().
|
private |
mFacMin, minimum factor value
Referenced by CRungeKutta(), operator()(), and setInitialStepSize().
|
private |
mfEvalNum, a size_t variable, recording how many times mDerivFunc are called
Referenced by CRungeKutta(), operator()(), and setStatRecord().
|
private |
mh, step size
Referenced by CRungeKutta(), doOneStep(), estimateError(), operator()(), and setInitialStepSize().
|
private |
mhMax, maximum step size
Referenced by CRungeKutta(), and setInitialStepSize().
|
private |
mhMin, minimum step size
Referenced by CRungeKutta(), operator()(), and setInitialStepSize().
|
private |
mhNoFailed, a boolean variable mhNoFailed == true, success after a reject step mhNoFailed == false, previous step is accepted
Referenced by CRungeKutta(), and operator()().
|
private |
mI, a two dimension C_FLOAT64 array, for interpolation
Referenced by interpolation(), and setCoeff().
|
private |
mK, a C_FLOAT64 pointer of a two dimension array, recording approximated derivatives (mStage*mDim)
Referenced by advanceStep(), allocateSpace(), CRungeKutta(), doOneStep(), estimateError(), interpolation(), operator()(), and ~CRungeKutta().
|
private |
Referenced by CRungeKutta(), initialize(), and operator()().
|
private |
mODEState, an int variable, recording the state of the solver Input: mODEState == 0, ODE solver is called firstly, need to be initialized mODEState == 1, ODE solver starts a new integration, without initialization mODEState == 2, ODE solver continues integration, coming back from event has been found
Output: mODEState == -2, some errors happened mODEState == 3, ODE solver stops at time t < tEnd, indicating having events mODEState == 4, ODE solver finishes integration at t == tEnd;
Referenced by checkODEState(), checkRoots(), CRungeKutta(), initialize(), and operator()().
|
private |
mOrderY, the order of Y interpolation can achieve
Referenced by CRungeKutta(), interpolation(), and setCoeff().
|
private |
mOrderYp, the order of Y prime interpolation can achieve
Referenced by CRungeKutta(), and setCoeff().
|
private |
mP, the order this solver provides
Referenced by CRungeKutta(), operator()(), setCoeff(), and setInitialStepSize().
|
private |
mpDerivFunc, function pointer of function calculating derivatives
Referenced by CRungeKutta(), doOneStep(), initialize(), operator()(), setInitialStepSize(), and ~CRungeKutta().
|
private |
mDim, dimension of this problem
Referenced by advanceStep(), allocateSpace(), checkRoots(), CRungeKutta(), doOneStep(), estimateError(), initialize(), interpolation(), operator()(), rootValue(), and setInitialStepSize().
|
private |
mpEventFunc, function pointer of function calculating event values
Referenced by CRungeKutta(), initialize(), and ~CRungeKutta().
|
private |
Pointer to method used for function evaluations for the Brent root finding method.
Referenced by checkRoots(), and CRungeKutta().
|
private |
mY, a C_FLOAT64 pointer pointing to an array recording system values at previous step
Referenced by checkRoots(), CRungeKutta(), initialize(), and operator()().
|
private |
mRejectNum, a size_t variable, recording how many rejected steps
Referenced by CRungeKutta(), operator()(), and setStatRecord().
|
private |
Referenced by checkRoots(), CRungeKutta(), estimateError(), and initialize().
|
private |
mrEvalNum, a size_t variable, recording how many times mEventFunc are called
Referenced by checkRoots(), CRungeKutta(), rootValue(), and setStatRecord().
|
private |
Referenced by checkRoots(), and initialize().
|
private |
mRootNum, a size_t variable, number of roots
Referenced by allocateSpace(), checkRoots(), CRungeKutta(), initialize(), operator()(), and rootValue().
|
private |
mRootValueRight, a C_FLOAT64 array pointer, recording root value at current time mT
Referenced by allocateSpace(), checkRoots(), CRungeKutta(), rootValue(), and ~CRungeKutta().
|
private |
mRootValueLeft, a C_FLOAT64 array pointer, recording root values at previous step
Referenced by allocateSpace(), checkRoots(), CRungeKutta(), operator()(), rootValue(), and ~CRungeKutta().
|
private |
mRootValueRight, a C_FLOAT64 array pointer, recording root value at current time mT
Referenced by allocateSpace(), checkRoots(), CRungeKutta(), rootValue(), and ~CRungeKutta().
|
private |
mStage, the stage of this method
Referenced by advanceStep(), allocateSpace(), CRungeKutta(), doOneStep(), estimateError(), interpolation(), operator()(), setCoeff(), and ~CRungeKutta().
|
private |
mStepNum, a size_t variable, recording how many steps are executed
Referenced by CRungeKutta(), operator()(), and setStatRecord().
|
private |
mTEnd, terminal time this solver will reach
Referenced by CRungeKutta(), initialize(), operator()(), and setInitialStepSize().
|
private |
Referenced by advanceStep(), checkRoots(), CRungeKutta(), doOneStep(), initialize(), interpolation(), operator()(), and setInitialStepSize().
|
private |
mTNew, new time in the next step
Referenced by advanceStep(), checkRoots(), CRungeKutta(), doOneStep(), interpolation(), and operator()().
|
private |
mYOld, a C_FLOAT64 pointer pointing to an array recording mY
Referenced by advanceStep(), allocateSpace(), checkRoots(), CRungeKutta(), doOneStep(), estimateError(), interpolation(), operator()(), setInitialStepSize(), and ~CRungeKutta().
|
private |
mYNew, a C_FLOAT64 pointer pointing to an array recording system values at new step
Referenced by advanceStep(), allocateSpace(), checkRoots(), CRungeKutta(), doOneStep(), estimateError(), operator()(), and ~CRungeKutta().
|
private |
Referenced by allocateSpace(), checkRoots(), CRungeKutta(), doOneStep(), rootValue(), setInitialStepSize(), and ~CRungeKutta().
|
private |
Referenced by allocateSpace(), CRungeKutta(), estimateError(), setInitialStepSize(), and ~CRungeKutta().
|
private |
Referenced by allocateSpace(), CRungeKutta(), estimateError(), setInitialStepSize(), and ~CRungeKutta().