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

RungeKuttaClassicalSolver.cc
Go to the documentation of this file.
3 namespace Classical {
4  //
5  // This is the private innards of RungeKuttaSolver
6  //
8  public:
9  Clockwork(Genfun::GENFUNCTION H, const PhaseSpace & phaseSpace):H(H),phaseSpace(phaseSpace){}
13  std::vector<Genfun::Parameter*> startingQ;
14  std::vector<Genfun::Parameter*> startingP;
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  //
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  }
41  delete c->energy;
42  delete c;
43  }
44 
46  return *c->integrator.getFunction(v.index());
47  }
49  return c->H;
50  }
52  return c->phaseSpace;
53  }
55  if (!c->energy) c->energy=new Genfun::EnergyFunction(*this);
56  return *c->energy;
57  }
58 
60  double defStartingValue,
61  double startingValueMin,
62  double startingValueMax) const {
63  return c->integrator.createControlParameter(variableName, defStartingValue, startingValueMin, startingValueMax) ;
64  }
65 
67  return c->startingQ[index];
68  }
70  return c->startingP[index];
71  }
72 
73 }