CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

ClassicalSolver.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:
5 #include <cmath>
6 
7 namespace Genfun {
8 
9  FUNCTION_OBJECT_IMP(EnergyFunction)
10 
11  EnergyFunction::EnergyFunction(const Classical::Solver & solver):
12  solver(solver)
13  {}
14 
16  }
17 
19  :solver(right.solver)
20  { }
21 
22 
23  double EnergyFunction::operator() (double t) const {
24  const Classical::PhaseSpace & phaseSpace=solver.phaseSpace();
25  const unsigned int DIM=phaseSpace.dim();
26  Genfun::Argument arg(2*DIM);
27  for (unsigned int i=0;i<phaseSpace.dim();i++) {
28  arg[i] =solver.equationOf(phaseSpace.coordinates()[i])(t);
29  arg[i+DIM]=solver.equationOf(phaseSpace.momenta()[i])(t);
30  }
31  Genfun::GENFUNCTION H = solver.hamiltonian();
32  return H(arg);
33  }
34 
35 
36 } // namespace Genfun