Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:59

0001 // ********************************************************************
0002 // * License and Disclaimer                                           *
0003 // *                                                                  *
0004 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0005 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0006 // * conditions of the Geant4 Software License,  included in the file *
0007 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0008 // * include a list of copyright holders.                             *
0009 // *                                                                  *
0010 // * Neither the authors of this software system, nor their employing *
0011 // * institutes,nor the agencies providing financial support for this *
0012 // * work  make  any representation or  warranty, express or implied, *
0013 // * regarding  this  software system or assume any liability for its *
0014 // * use.  Please see the license in the file  LICENSE  and URL above *
0015 // * for the full disclaimer and the limitation of liability.         *
0016 // *                                                                  *
0017 // * This  code  implementation is the result of  the  scientific and *
0018 // * technical work of the GEANT4 collaboration.                      *
0019 // * By using,  copying,  modifying or  distributing the software (or *
0020 // * any work based  on the software)  you  agree  to acknowledge its *
0021 // * use  in  resulting  scientific  publications,  and indicate your *
0022 // * acceptance of all terms of the Geant4 Software license.          *
0023 // ********************************************************************
0024 //
0025 // G4BorisScheme
0026 //
0027 // Class description:
0028 //
0029 // Implementation of the Boris algorithm for advancing 
0030 // charged particles in an electromagnetic field.
0031 
0032 // Author: Divyansh Tiwari, Google Summer of Code 2022
0033 // Supervision: John Apostolakis,Renee Fatemi, Soon Yung Jun
0034 // --------------------------------------------------------------------
0035 #ifndef G4BORIS_SCHEME_HH
0036 #define G4BORIS_SCHEME_HH
0037 
0038 class G4EquationOfMotion;
0039 
0040 #include "G4Types.hh"
0041 
0042 
0043 // class G4EqMagElectricField;
0044 
0045 // #include "G4FieldTrack.hh"
0046 
0047 #include <CLHEP/Units/PhysicalConstants.h>
0048 
0049 class G4BorisScheme
0050 {
0051   public:
0052 
0053     G4BorisScheme() = default;
0054     G4BorisScheme( // G4EqMagElectricField
0055        G4EquationOfMotion* equation,
0056                         G4int nvar = 6);
0057    ~G4BorisScheme() = default;
0058 
0059     void DoStep( G4double restMass, G4double charge, const G4double yIn[], 
0060                  G4double yOut[], G4double hstep) const;
0061 
0062   protected:
0063     // Used to implement the 'DoStep' method above
0064     void UpdatePosition(const G4double restMass, const G4double charge, const G4double yIn[],
0065                  G4double yOut[], G4double hstep) const;
0066 
0067     void UpdateVelocity(const G4double restMass, const G4double charge, const G4double yIn[],
0068                  G4double yOut[], G4double hstep) const;
0069 
0070   public: 
0071     // - Methods using the Boris Scheme Stepping to estimate integration error
0072     void StepWithErrorEstimate(const G4double yIn[], G4double restMass, G4double charge, G4double hstep,
0073                                G4double yOut[], G4double yErr[]) const;
0074       // Use two half-steps (comparing to a full step) to obtain output and error estimate
0075 
0076    void StepWithMidAndErrorEstimate(const G4double yIn[], G4double restMass, G4double charge, G4double hstep,
0077                                G4double yMid[], G4double yOut[], G4double yErr[]) const;
0078       // Same, and also return mid-point evaluation
0079 
0080     // Auxiliary method
0081     inline G4EquationOfMotion* GetEquationOfMotion();
0082     // inline void SetEquationOfMotion(G4EquationOfMotion* equation);  // Un-needed, dangerous
0083 
0084     inline G4int GetNumberOfVariables() const;
0085    
0086   private:
0087 
0088     void copy(G4double dst[], const G4double src[]) const;
0089 
0090   private:
0091 
0092     G4EquationOfMotion* fEquation = nullptr;
0093     G4int fnvar = 8;
0094     static constexpr G4double c_l = CLHEP::c_light/CLHEP::m*CLHEP::second;
0095 };
0096 
0097 #include "G4BorisScheme.icc"
0098 #endif