CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
RungeKuttaClassicalSolver.cc
Go to the documentation of this file.
1#include "CLHEP/GenericFunctions/RungeKuttaClassicalSolver.hh"
2#include "CLHEP/GenericFunctions/RKIntegrator.hh"
3#include "CLHEP/GenericFunctions/AdaptiveRKStepper.hh"
4
5#include <iostream>
6#include <vector>
7
8namespace Classical {
9 //
10 // This is the private innards of RungeKuttaSolver
11 //
13 public:
14
15 Clockwork(Genfun::GENFUNCTION gH, const PhaseSpace & mphaseSpace):H(gH),phaseSpace(mphaseSpace), integrator(NULL){
16 }
20 std::vector<Genfun::Parameter*> startingQ;
21 std::vector<Genfun::Parameter*> startingP;
23 };
24
26 c->integrator=new Genfun::RKIntegrator(stepper);
27 //
28 // Dimension (of coords, or phase space)
29 //
30 const unsigned int DIM=c->phaseSpace.dim();
31 //
32 // Equations of motion via hamilton's equations:
33 //
36
37 for (unsigned int i=0;i<DIM;i++) {
38 Genfun::GENFUNCTION DXDT = c->H.partial(P[i].index());
39 c->startingQ.push_back(c->integrator->addDiffEquation(&DXDT,"X",c->phaseSpace.startValue(X[i])));
40 }
41 for (unsigned int i=0;i<DIM;i++) {
42 Genfun::GENFUNCTION DPDT = -c->H.partial(X[i].index());
43 c->startingP.push_back(c->integrator->addDiffEquation(&DPDT,"P",c->phaseSpace.startValue(P[i])));
44 }
45 c->energy=NULL;
46
47 }
49 delete c->integrator;
50 delete c->energy;
51 delete c;
52 }
53
55 return *c->integrator->getFunction(v.index());
56 }
58 return c->H;
59 }
61 return c->phaseSpace;
62 }
64 if (!c->energy) c->energy=new Genfun::EnergyFunction(*this);
65 return *c->energy;
66 }
67
69 double defStartingValue,
70 double startingValueMin,
71 double startingValueMax) const {
72 return c->integrator->createControlParameter(variableName, defStartingValue, startingValueMin, startingValueMax) ;
73 }
74
76 return c->startingQ[index];
77 }
79 return c->startingP[index];
80 }
81
82}
const Component & momenta() const
Definition: PhaseSpace.cc:70
const Component & coordinates() const
Definition: PhaseSpace.cc:66
double startValue(const Genfun::Variable &component) const
Definition: PhaseSpace.cc:87
unsigned int dim() const
Definition: PhaseSpace.cc:98
Clockwork(Genfun::GENFUNCTION gH, const PhaseSpace &mphaseSpace)
std::vector< Genfun::Parameter * > startingQ
std::vector< Genfun::Parameter * > startingP
virtual Genfun::GENFUNCTION hamiltonian() const
virtual Genfun::Parameter * createControlParameter(const std::string &variableName="anon", double defStartingValue=0.0, double startingValueMin=0.0, double startingValueMax=0.0) const
virtual Genfun::GENFUNCTION equationOf(const Genfun::Variable &v) const
virtual Genfun::GENFUNCTION energy() const
virtual Genfun::Parameter * takeP0(unsigned int index)
virtual Genfun::Parameter * takeQ0(unsigned int index)
RungeKuttaSolver(Genfun::GENFUNCTION H, const PhaseSpace &phaseSpace, const Genfun::RKIntegrator::RKStepper *stepper=NULL)
virtual const PhaseSpace & phaseSpace() const
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
Parameter * addDiffEquation(const AbsFunction *diffEquation, const std::string &variableName="anon", double defStartingValue=0.0, double startingValueMin=0.0, double startingValueMax=0.0)
Parameter * createControlParameter(const std::string &variableName="anon", double defStartingValue=0.0, double startingValueMin=0.0, double startingValueMax=0.0)
const RKFunction * getFunction(unsigned int i) const
unsigned int index() const
Definition: Variable.cc:34