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

#include <StepDoublingRKStepper.hh>

+ Inheritance diagram for Genfun::StepDoublingRKStepper:

Public Member Functions

 StepDoublingRKStepper (const ButcherTableau &tableau)
 
virtual ~StepDoublingRKStepper ()
 
virtual void step (const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &sdata, RKIntegrator::RKData::Data &ddata, std::vector< double > &errors) const
 
virtual StepDoublingRKStepperclone () const
 
void doStep (const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &s, RKIntegrator::RKData::Data &d) 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 StepDoublingRKStepper.hh.

Constructor & Destructor Documentation

◆ StepDoublingRKStepper()

Genfun::StepDoublingRKStepper::StepDoublingRKStepper ( const ButcherTableau tableau)

Definition at line 8 of file StepDoublingRKStepper.cc.

8 :tableau(xtableau) {
9 }

◆ ~StepDoublingRKStepper()

Genfun::StepDoublingRKStepper::~StepDoublingRKStepper ( )
virtual

Definition at line 11 of file StepDoublingRKStepper.cc.

11 {
12 }

Member Function Documentation

◆ clone()

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

Implements Genfun::AdaptiveRKStepper::EEStepper.

Definition at line 73 of file StepDoublingRKStepper.cc.

73 {
74 return new StepDoublingRKStepper(*this);
75 }
StepDoublingRKStepper(const ButcherTableau &tableau)

◆ doStep()

void Genfun::StepDoublingRKStepper::doStep ( const RKIntegrator::RKData data,
const RKIntegrator::RKData::Data s,
RKIntegrator::RKData::Data d 
) const

Definition at line 38 of file StepDoublingRKStepper.cc.

40 {
41 // First step:
42 double h = (d.time - s.time);
43
44
45 if (h<=0) throw std::runtime_error ("SimpleRKStepper: negative stepsize");
46 const unsigned int nvar = (unsigned int)s.variable.size();
47 // Compute all of the k's..:
48 //
49 std::vector<std::vector<double> >k(tableau.nSteps());
50 for (unsigned int i=0;i<tableau.nSteps();i++) {
51 k[i].resize(nvar,0);
52 Argument arg(nvar);
53 for (unsigned int v=0;v<nvar;v++) arg[v]=s.variable[v];
54 for (unsigned int j=0;j<i;j++) {
55 for (unsigned int v=0;v<nvar;v++) arg[v] += h*tableau.A(i,j)*k[j][v];
56 }
57 for (unsigned int v=0;v<nvar;v++) k[i][v]=(*data->_diffEqn[v])(arg);
58 }
59 //
60 // Final result.
61 //
62 for (unsigned int v=0;v<nvar;v++) d.firstDerivative[v] = 0;
63 for (unsigned int i=0;i<tableau.nSteps();i++) {
64 for (unsigned int v=0;v<nvar;v++) d.firstDerivative[v] += tableau.b(i)*k[i][v];
65 }
66 for (unsigned int v=0;v<nvar;v++) d.variable[v] =s.variable[v]+h*d.firstDerivative[v];
67
68 }
unsigned int nSteps() const
double & A(unsigned int i, unsigned int j)
double & b(unsigned int i)

Referenced by step().

◆ order()

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

Implements Genfun::AdaptiveRKStepper::EEStepper.

Definition at line 77 of file StepDoublingRKStepper.cc.

77 {
78 return tableau.order();
79 }
unsigned int order() const

◆ step()

void Genfun::StepDoublingRKStepper::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 14 of file StepDoublingRKStepper.cc.

17 {
18 const unsigned int nvar = (unsigned int)s.variable.size();
19 RKIntegrator::RKData::Data d1(nvar),d2(nvar);
20
21 doStep(data,s,d);
22 double dt = (d.time - s.time);
23 d1.time = s.time + dt/2.0;
24 d2.time = d.time;
25
26 doStep(data, s,d1);
27 doStep(data,d1,d2);
28
29 // Error estimate:
30 errors.resize(nvar);
31 for (size_t v=0;v<nvar;v++) errors[v]=fabs(d2.variable[v]-d.variable[v]);
32
33 // Final correction:
34 for (size_t v=0;v<nvar;v++) d.variable[v] = d2.variable[v] + ((d2.variable[v]-d.variable[v])/double(std::pow(2.,(int)(tableau.order())-1)));
35
36 }
void doStep(const RKIntegrator::RKData *data, const RKIntegrator::RKData::Data &s, RKIntegrator::RKData::Data &d) const

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