CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
RungeKuttaClassicalSolver.cc
Go to the documentation of this file.
1
#include "
CLHEP/GenericFunctions/RungeKuttaClassicalSolver.hh
"
2
#include "
CLHEP/GenericFunctions/RKIntegrator.hh
"
3
namespace
Classical {
4
//
5
// This is the private innards of RungeKuttaSolver
6
//
7
class
RungeKuttaSolver::Clockwork
{
8
public
:
9
Clockwork
(
Genfun::GENFUNCTION
H
,
const
PhaseSpace
&
phaseSpace
):H(H),phaseSpace(phaseSpace){}
10
Genfun::GENFUNCTION
H
;
11
const
Classical::PhaseSpace
&
phaseSpace
;
12
Genfun::RKIntegrator
integrator
;
13
std::vector<Genfun::Parameter*>
startingQ
;
14
std::vector<Genfun::Parameter*>
startingP
;
15
Genfun::EnergyFunction
*
energy
;
16
};
17
18
RungeKuttaSolver::RungeKuttaSolver
(
Genfun::GENFUNCTION
H,
const
PhaseSpace
& phaseSpace):c(new
Clockwork
(H,phaseSpace)){
19
//
20
// Dimension (of coords, or phase space)
21
//
22
const
unsigned
int
DIM=c->
phaseSpace
.
dim
();
23
//
24
// Equations of motion via hamilton's equations:
25
//
26
const
Classical::PhaseSpace::Component
&
X
=c->
phaseSpace
.
coordinates
();
27
const
Classical::PhaseSpace::Component
& P=c->
phaseSpace
.
momenta
();
28
29
for
(
unsigned
int
i=0;i<DIM;i++) {
30
Genfun::GENFUNCTION
DXDT = c->
H
.
partial
(P[i].index());
31
c->
startingQ
.push_back(c->
integrator
.
addDiffEquation
(&DXDT,
"X"
,c->
phaseSpace
.
startValue
(X[i])));
32
}
33
for
(
unsigned
int
i=0;i<DIM;i++) {
34
Genfun::GENFUNCTION
DPDT = -c->
H
.
partial
(X[i].index());
35
c->
startingP
.push_back(c->
integrator
.
addDiffEquation
(&DPDT,
"P"
,c->
phaseSpace
.
startValue
(P[i])));
36
}
37
c->
energy
=NULL;
38
39
}
40
RungeKuttaSolver::~RungeKuttaSolver
(){
41
delete
c->
energy
;
42
delete
c;
43
}
44
45
Genfun::GENFUNCTION
RungeKuttaSolver::equationOf
(
const
Genfun::Variable
& v)
const
{
46
return
*c->
integrator
.
getFunction
(v.
index
());
47
}
48
Genfun::GENFUNCTION
RungeKuttaSolver::hamiltonian
()
const
{
49
return
c->
H
;
50
}
51
const
Classical::PhaseSpace
&
RungeKuttaSolver::phaseSpace
()
const
{
52
return
c->
phaseSpace
;
53
}
54
Genfun::GENFUNCTION
RungeKuttaSolver::energy
()
const
{
55
if
(!c->
energy
) c->
energy
=
new
Genfun::EnergyFunction
(*
this
);
56
return
*c->
energy
;
57
}
58
59
Genfun::Parameter
*
RungeKuttaSolver::createControlParameter
(
const
std::string & variableName,
60
double
defStartingValue,
61
double
startingValueMin,
62
double
startingValueMax)
const
{
63
return
c->
integrator
.
createControlParameter
(variableName, defStartingValue, startingValueMin, startingValueMax) ;
64
}
65
66
Genfun::Parameter
*
RungeKuttaSolver::takeQ0
(
unsigned
int
index) {
67
return
c->
startingQ
[index];
68
}
69
Genfun::Parameter
*
RungeKuttaSolver::takeP0
(
unsigned
int
index) {
70
return
c->
startingP
[index];
71
}
72
73
}
Generated on Sun Jun 17 2012 08:08:27 for CLHEP by
1.8.1.1