CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Genfun::EmbeddedRKStepper Class Reference

#include <EmbeddedRKStepper.hh>

+ Inheritance diagram for Genfun::EmbeddedRKStepper:

Public Member Functions

 EmbeddedRKStepper (const ExtendedButcherTableau &tableau=CashKarpXtTableau())
 
virtual ~EmbeddedRKStepper ()
 
virtual void step (const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &sdata, RKIntegrator::RKData::Data &ddata, std::vector< double > &errors) const
 
virtual EmbeddedRKStepperclone () const
 
virtual unsigned int order () const
 
- Public Member Functions inherited from Genfun::AdaptiveRKStepper::EEStepper
virtual ~EEStepper ()
 
virtual void step (const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &sdata, RKIntegrator::RKData::Data &ddata, std::vector< double > &errors) const =0
 
virtual EEStepperclone () const =0
 
virtual unsigned int order () const =0
 

Detailed Description

Definition at line 11 of file EmbeddedRKStepper.hh.

Constructor & Destructor Documentation

◆ EmbeddedRKStepper()

Genfun::EmbeddedRKStepper::EmbeddedRKStepper ( const ExtendedButcherTableau tableau = CashKarpXtTableau())

Definition at line 9 of file EmbeddedRKStepper.cc.

9 :
10 tableau(mtableau){
11 }

◆ ~EmbeddedRKStepper()

Genfun::EmbeddedRKStepper::~EmbeddedRKStepper ( )
virtual

Definition at line 13 of file EmbeddedRKStepper.cc.

13 {
14 }

Member Function Documentation

◆ clone()

EmbeddedRKStepper * Genfun::EmbeddedRKStepper::clone ( ) const
virtual

Implements Genfun::AdaptiveRKStepper::EEStepper.

Definition at line 57 of file EmbeddedRKStepper.cc.

57 {
58 return new EmbeddedRKStepper(*this);
59 }
EmbeddedRKStepper(const ExtendedButcherTableau &tableau=CashKarpXtTableau())

◆ order()

unsigned int Genfun::EmbeddedRKStepper::order ( ) const
virtual

Implements Genfun::AdaptiveRKStepper::EEStepper.

Definition at line 61 of file EmbeddedRKStepper.cc.

61 {
62 return tableau.order();
63 }
unsigned int order() const

◆ step()

void Genfun::EmbeddedRKStepper::step ( const RKIntegrator::RKData data,
const RKIntegrator::RKData::Data sdata,
RKIntegrator::RKData::Data ddata,
std::vector< double > &  errors 
) const
virtual

Implements Genfun::AdaptiveRKStepper::EEStepper.

Definition at line 16 of file EmbeddedRKStepper.cc.

19 {
20
21 // First step:
22 double h = d.time - s.time;
23 if (h<=0) throw std::runtime_error ("Runtime error in RKIntegrator (zero or negative stepsize)");
24 unsigned int nvar = (unsigned int)s.variable.size();
25
26 // Compute all of the k's..:
27 //
28 std::vector<std::vector<double> >k(tableau.nSteps());
29 for (unsigned int i=0;i<tableau.nSteps();i++) {
30 k[i].resize(nvar,0);
31 Argument arg(nvar);
32 for (unsigned int v=0;v<nvar;v++) arg[v]=s.variable[v];
33 for (unsigned int j=0;j<i;j++) {
34 for (unsigned int v=0;v<nvar;v++) arg[v] += h*tableau.A(i,j)*k[j][v];
35 }
36 for (unsigned int v=0;v<nvar;v++) k[i][v]=(*data->_diffEqn[v])(arg);
37 }
38 //
39 // Final result.
40 //
41 for (unsigned int v=0;v<nvar;v++) d.firstDerivative[v] = 0;
42 for (unsigned int i=0;i<tableau.nSteps();i++) {
43 for (unsigned int v=0;v<nvar;v++) d.firstDerivative[v] += tableau.b(i)*k[i][v];
44 }
45 for (unsigned int v=0;v<nvar;v++) d.variable[v] =s.variable[v]+h*d.firstDerivative[v];
46 //
47 //
48 //
49 errors.resize(nvar);
50 for (unsigned int v=0;v<nvar;v++) errors[v] = 0;
51 for (unsigned int i=0;i<tableau.nSteps();i++) {
52 for (unsigned int v=0;v<nvar;v++) errors[v] += (h*(tableau.bHat(i)-tableau.b(i))*k[i][v]);
53 }
54 return;
55 }
unsigned int nSteps() const
double & A(unsigned int i, unsigned int j)
double & bHat(unsigned int i)
double & b(unsigned int i)

The documentation for this class was generated from the following files: