Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:03:25

0001 // This is a class the creates an N-Dimensional Phase Space     //
0002 
0003 // It is for use in computing the time development of classical //
0004 // Hamiltonian Systems.                                         //
0005 
0006 // Joe Boudreau October 2011                                    //
0007 
0008 //--------------------------------------------------------------//
0009 
0010 #ifndef _ClassicalSolver_h__
0011 #define _ClassicalSolver_h__
0012 
0013 #include "CLHEP/GenericFunctions/PhaseSpace.hh"
0014 #include "CLHEP/GenericFunctions/Variable.hh"
0015 #include "CLHEP/GenericFunctions/Parameter.hh"
0016 
0017 
0018 namespace Genfun {
0019   class EnergyFunction;
0020 }
0021 
0022 
0023 namespace Classical {
0024 
0025 
0026   class Solver {
0027         
0028   public:
0029     //
0030     // Constructor--takes a hamiltonian and a point in p-space: 
0031     //
0032     Solver(){};
0033     //
0034     // Destructor:
0035     //
0036     virtual ~Solver(){};
0037     //
0038     // Returns the time evolution for a variable (q_i or p_i)
0039     //
0040     virtual Genfun::GENFUNCTION equationOf(const Genfun::Variable & v) const=0;
0041     //
0042     // Returns the phase space 
0043     //
0044     virtual const PhaseSpace & phaseSpace() const=0;
0045     //
0046     // Returns the Hamiltonian (function of the 2N phase space variables). 
0047     //
0048     virtual Genfun::GENFUNCTION hamiltonian() const=0;
0049     //
0050     // Returns the energy (function of time).
0051     //
0052     virtual Genfun::GENFUNCTION energy() const=0;
0053     //
0054     // This is in the rare case that the user needs to edit starting values.
0055     // or parameterize the Hamiltonian.  Most users:  can ignore.  
0056     virtual Genfun::Parameter *takeQ0(unsigned int index)=0;
0057     virtual Genfun::Parameter *takeP0(unsigned int index)=0;
0058     virtual Genfun::Parameter *createControlParameter(const std::string & variableName="anon",
0059                               double defStartingValue=0.0,
0060                               double startingValueMin=0.0,
0061                               double startingValueMax=0.0) const = 0;
0062     
0063 
0064 
0065   private:
0066     
0067     // Illegal Operations:
0068     Solver (const Solver &);
0069     Solver & operator=(const Solver &);
0070     
0071   };
0072 }
0073 
0074 namespace Genfun {
0075 
0076   class EnergyFunction: public Genfun::AbsFunction {
0077   
0078     FUNCTION_OBJECT_DEF(EnergyFunction)
0079 
0080       public:
0081 
0082     // Constructor
0083     EnergyFunction(const Classical::Solver &);
0084 
0085     // Destructor
0086     virtual ~EnergyFunction();
0087   
0088     // Copy constructor
0089     EnergyFunction(const EnergyFunction &right);
0090   
0091     // Retreive function value
0092     virtual double operator ()(double argument) const override;
0093     virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
0094 
0095   private:
0096 
0097     // It is illegal to assign a EnergyFunction
0098     const EnergyFunction & operator=(const EnergyFunction &right);
0099 
0100     const Classical::Solver & solver;
0101 
0102   };
0103 
0104 }
0105 
0106 
0107 
0108 #endif