Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
97ff2caf
Commit
97ff2caf
authored
Nov 15, 2012
by
Joseph Boudreau
Browse files
Added some configurability
parent
1a294210
Changes
1
Hide whitespace changes
Inline
Side-by-side
GenericFunctions/src/RungeKuttaClassicalSolver.cc
View file @
97ff2caf
#include "CLHEP/GenericFunctions/RungeKuttaClassicalSolver.hh"
#include "CLHEP/GenericFunctions/RKIntegrator.hh"
#include "CLHEP/GenericFunctions/AdaptiveRKStepper.hh"
namespace
Classical
{
//
// This is the private innards of RungeKuttaSolver
//
class
RungeKuttaSolver
::
Clockwork
{
public:
Clockwork
(
Genfun
::
GENFUNCTION
gH
,
const
PhaseSpace
&
mphaseSpace
)
:
H
(
gH
),
phaseSpace
(
mphaseSpace
){}
Clockwork
(
Genfun
::
GENFUNCTION
gH
,
const
PhaseSpace
&
mphaseSpace
)
:
H
(
gH
),
phaseSpace
(
mphaseSpace
),
integrator
(
NULL
){
}
Genfun
::
GENFUNCTION
H
;
const
Classical
::
PhaseSpace
&
phaseSpace
;
Genfun
::
RKIntegrator
integrator
;
Genfun
::
RKIntegrator
*
integrator
;
std
::
vector
<
Genfun
::
Parameter
*>
startingQ
;
std
::
vector
<
Genfun
::
Parameter
*>
startingP
;
Genfun
::
EnergyFunction
*
energy
;
};
RungeKuttaSolver
::
RungeKuttaSolver
(
Genfun
::
GENFUNCTION
gH
,
const
PhaseSpace
&
mphaseSpace
)
:
c
(
new
Clockwork
(
gH
,
mphaseSpace
)){
RungeKuttaSolver
::
RungeKuttaSolver
(
Genfun
::
GENFUNCTION
gH
,
const
PhaseSpace
&
mphaseSpace
,
const
Genfun
::
RKIntegrator
::
RKStepper
*
stepper
)
:
c
(
new
Clockwork
(
gH
,
mphaseSpace
)){
c
->
integrator
=
new
Genfun
::
RKIntegrator
(
stepper
);
//
// Dimension (of coords, or phase space)
//
...
...
@@ -28,22 +32,23 @@ namespace Classical {
for
(
unsigned
int
i
=
0
;
i
<
DIM
;
i
++
)
{
Genfun
::
GENFUNCTION
DXDT
=
c
->
H
.
partial
(
P
[
i
].
index
());
c
->
startingQ
.
push_back
(
c
->
integrator
.
addDiffEquation
(
&
DXDT
,
"X"
,
c
->
phaseSpace
.
startValue
(
X
[
i
])));
c
->
startingQ
.
push_back
(
c
->
integrator
->
addDiffEquation
(
&
DXDT
,
"X"
,
c
->
phaseSpace
.
startValue
(
X
[
i
])));
}
for
(
unsigned
int
i
=
0
;
i
<
DIM
;
i
++
)
{
Genfun
::
GENFUNCTION
DPDT
=
-
c
->
H
.
partial
(
X
[
i
].
index
());
c
->
startingP
.
push_back
(
c
->
integrator
.
addDiffEquation
(
&
DPDT
,
"P"
,
c
->
phaseSpace
.
startValue
(
P
[
i
])));
c
->
startingP
.
push_back
(
c
->
integrator
->
addDiffEquation
(
&
DPDT
,
"P"
,
c
->
phaseSpace
.
startValue
(
P
[
i
])));
}
c
->
energy
=
NULL
;
}
RungeKuttaSolver
::~
RungeKuttaSolver
(){
delete
c
->
integrator
;
delete
c
->
energy
;
delete
c
;
}
Genfun
::
GENFUNCTION
RungeKuttaSolver
::
equationOf
(
const
Genfun
::
Variable
&
v
)
const
{
return
*
c
->
integrator
.
getFunction
(
v
.
index
());
return
*
c
->
integrator
->
getFunction
(
v
.
index
());
}
Genfun
::
GENFUNCTION
RungeKuttaSolver
::
hamiltonian
()
const
{
return
c
->
H
;
...
...
@@ -60,7 +65,7 @@ namespace Classical {
double
defStartingValue
,
double
startingValueMin
,
double
startingValueMax
)
const
{
return
c
->
integrator
.
createControlParameter
(
variableName
,
defStartingValue
,
startingValueMin
,
startingValueMax
)
;
return
c
->
integrator
->
createControlParameter
(
variableName
,
defStartingValue
,
startingValueMin
,
startingValueMax
)
;
}
Genfun
::
Parameter
*
RungeKuttaSolver
::
takeQ0
(
unsigned
int
index
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment