G4ConstRK4.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4ConstRK4.hh 69786 2013-05-15 09:38:51Z gcosmo $
00028 //
00029 // 
00030 // Class G4ConstRK4
00031 //
00032 // class description:
00033 //
00034 // G4ConstRK4 performs the integration of one step with error calculation
00035 // in constant magnetic field. The integration method is the same as in
00036 // ClassicalRK4. The field value is assumed constant for the step.
00037 // This field evaluation is called only once per step.
00038 // G4ConstRK4 can be used only for magnetic fields.
00039 
00040 // History:
00041 // - 18.09.2008 - J.Apostolakis, T.Nikitina - Created
00042 // -------------------------------------------------------------------
00043 
00044 #ifndef G4CONSTRK4_HH
00045 #define G4CONSTRK4_HH
00046 
00047 #include "G4MagErrorStepper.hh"
00048 #include "G4EquationOfMotion.hh"
00049 #include "G4Mag_EqRhs.hh"
00050 
00051 class G4ConstRK4 : public G4MagErrorStepper 
00052 {
00053    public:  // with description
00054 
00055     G4ConstRK4(G4Mag_EqRhs *EquationMotion, G4int numberOfStateVariables=8);
00056     ~G4ConstRK4();
00057 
00058      void Stepper( const G4double y[],
00059                    const G4double dydx[],
00060                          G4double h,
00061                          G4double yout[],
00062                          G4double yerr[]  );
00063      void DumbStepper( const G4double  yIn[],
00064                        const G4double  dydx[],
00065                              G4double  h,
00066                              G4double  yOut[] ) ;
00067      G4double DistChord() const;   
00068  
00069      inline void  RightHandSideConst(const  G4double y[],
00070                                             G4double dydx[] ) const;
00071 
00072      inline void  GetConstField(const G4double y[],G4double Field[]);
00073 
00074    public:  // without description
00075 
00076      G4int IntegratorOrder() const { return 4; }
00077 
00078    private:
00079 
00080      G4ConstRK4(const G4ConstRK4&);
00081      G4ConstRK4& operator=(const G4ConstRK4&);
00082        // Private copy constructor and assignment operator.
00083 
00084    private:
00085 
00086      G4ThreeVector fInitialPoint, fMidPoint, fFinalPoint;
00087      // Data stored in order to find the chord
00088      G4double *dydxm, *dydxt, *yt; // scratch space - not state 
00089      G4double *yInitial, *yMiddle, *dydxMid, *yOneStep;
00090      G4Mag_EqRhs *fEq;
00091      G4double Field[3];
00092 };
00093 
00094 // Inline methods
00095 
00096 inline void G4ConstRK4:: RightHandSideConst(const G4double y[],
00097                                                   G4double dydx[] ) const
00098 {
00099   
00100   G4double momentum_mag_square = y[3]*y[3] + y[4]*y[4] + y[5]*y[5];
00101   G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
00102     
00103   G4double cof =fEq->FCof()*inv_momentum_magnitude;
00104 
00105   dydx[0] = y[3]*inv_momentum_magnitude;       //  (d/ds)x = Vx/V
00106   dydx[1] = y[4]*inv_momentum_magnitude;       //  (d/ds)y = Vy/V
00107   dydx[2] = y[5]*inv_momentum_magnitude;       //  (d/ds)z = Vz/V
00108  
00109   dydx[3] = cof*(y[4]*Field[2] - y[5]*Field[1]) ;   // Ax = a*(Vy*Bz - Vz*By)
00110   dydx[4] = cof*(y[5]*Field[0] - y[3]*Field[2]) ;   // Ay = a*(Vz*Bx - Vx*Bz)
00111   dydx[5] = cof*(y[3]*Field[1] - y[4]*Field[0]) ;   // Az = a*(Vx*By - Vy*Bx)
00112 }
00113 
00114 inline void G4ConstRK4::GetConstField(const G4double y[],G4double B[])
00115 {
00116   G4double  PositionAndTime[4];
00117 
00118   PositionAndTime[0] = y[0];
00119   PositionAndTime[1] = y[1];
00120   PositionAndTime[2] = y[2];
00121   // Global Time
00122   PositionAndTime[3] = y[7];  
00123   fEq -> GetFieldValue(PositionAndTime, B) ;
00124 }
00125 
00126 #endif  // G4CONSTRK4_HH

Generated on Mon May 27 17:47:57 2013 for Geant4 by  doxygen 1.4.7