CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
RK2 Class Reference

#include <ConstantStepOdeSolver.h>

Inheritance diagram for RK2:
ConstantStepOdeSolver

Public Member Functions

const char * methodName () const override
 
 RK2 ()
 
 RK2 (const AbsODERHS &rhs)
 
- Public Member Functions inherited from ConstantStepOdeSolver
 ConstantStepOdeSolver ()
 
 ConstantStepOdeSolver (const AbsODERHS &rhs)
 
 ConstantStepOdeSolver (const ConstantStepOdeSolver &r)
 
double getCoordinate (const unsigned which, const unsigned idx) const
 
double getIntegrated (unsigned which, unsigned idx) const
 
double getPeakTime (unsigned which) const
 
AbsODERHSgetRHS ()
 
const AbsODERHSgetRHS () const
 
double getTime (const unsigned idx) const
 
double interpolateCoordinate (unsigned which, double t, bool cubic=false) const
 
double interpolateIntegrated (unsigned which, double t, bool cubic=false) const
 
double lastDeltaT () const
 
unsigned lastDim () const
 
double lastMaxT () const
 
unsigned lastRunLength () const
 
ConstantStepOdeSolveroperator= (const ConstantStepOdeSolver &r)
 
void run (const double *initialConditions, unsigned lenConditions, double dt, unsigned nSteps)
 
void setHistory (double dt, const double *data, unsigned dim, unsigned runLen)
 
void setRHS (const AbsODERHS &rhs)
 
void truncateCoordinate (unsigned which, double minValue, double maxValue)
 
void writeHistory (std::ostream &os, double dt, bool cubic=false) const
 
void writeIntegrated (std::ostream &os, unsigned which, double dt, bool cubic=false) const
 
virtual ~ConstantStepOdeSolver ()
 

Private Member Functions

void step (double t, double dt, const double *x, unsigned lenX, double *coordIncrement) const override
 

Private Attributes

std::vector< double > buf_
 

Additional Inherited Members

- Protected Attributes inherited from ConstantStepOdeSolver
AbsODERHSrhs_
 

Detailed Description

Definition at line 127 of file ConstantStepOdeSolver.h.

Constructor & Destructor Documentation

◆ RK2() [1/2]

RK2::RK2 ( )
inline

Definition at line 129 of file ConstantStepOdeSolver.h.

◆ RK2() [2/2]

RK2::RK2 ( const AbsODERHS rhs)
inlineexplicit

Definition at line 131 of file ConstantStepOdeSolver.h.

131 : ConstantStepOdeSolver(rhs) {}

Member Function Documentation

◆ methodName()

const char* RK2::methodName ( ) const
inlineoverridevirtual

Implements ConstantStepOdeSolver.

Definition at line 133 of file ConstantStepOdeSolver.h.

133 { return "2nd order Runge-Kutta"; }

◆ step()

void RK2::step ( double  t,
double  dt,
const double *  x,
unsigned  lenX,
double *  coordIncrement 
) const
overrideprivatevirtual

Implements ConstantStepOdeSolver.

Definition at line 299 of file ConstantStepOdeSolver.cc.

299  {
300  const double halfstep = dt / 2.0;
301  if (buf_.size() < lenX)
302  buf_.resize(lenX);
303  double* midpoint = &buf_[0];
304  rhs_->calc(t, x, lenX, midpoint);
305  for (unsigned i = 0; i < lenX; ++i) {
306  midpoint[i] *= halfstep;
307  midpoint[i] += x[i];
308  }
309  rhs_->calc(t + halfstep, midpoint, lenX, coordIncrement);
310  for (unsigned i = 0; i < lenX; ++i)
311  coordIncrement[i] *= dt;
312 }

References buf_, AbsODERHS::calc(), dt, mps_fire::i, ConstantStepOdeSolver::rhs_, OrderedSet::t, and x.

Member Data Documentation

◆ buf_

std::vector<double> RK2::buf_
mutableprivate

Definition at line 138 of file ConstantStepOdeSolver.h.

Referenced by step().

RK2::buf_
std::vector< double > buf_
Definition: ConstantStepOdeSolver.h:138
mps_fire.i
i
Definition: mps_fire.py:355
AbsODERHS::calc
virtual void calc(double t, const double *x, unsigned lenX, double *derivative)=0
ConstantStepOdeSolver::rhs_
AbsODERHS * rhs_
Definition: ConstantStepOdeSolver.h:89
DDAxes::x
dt
float dt
Definition: AMPTWrapper.h:136
OrderedSet.t
t
Definition: OrderedSet.py:90
ConstantStepOdeSolver::ConstantStepOdeSolver
ConstantStepOdeSolver()
Definition: ConstantStepOdeSolver.h:16