|
|
|||
File indexing completed on 2026-09-09 09:08:41
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 (CERN, Google Summer of Code 2022), 05.11.2022 0033 // Supervision: John Apostolakis (CERN), Renee Fatemi, Soon Yung Jun (FNAL) 0034 // -------------------------------------------------------------------- 0035 #ifndef G4BORIS_SCHEME_HH 0036 #define G4BORIS_SCHEME_HH 0037 0038 #include "G4Types.hh" 0039 0040 #include <CLHEP/Units/PhysicalConstants.h> 0041 0042 class G4EquationOfMotion; 0043 0044 /** 0045 * @brief The G4BorisScheme class implements of the Boris algorithm for 0046 * advancing charged particles in an electromagnetic field. 0047 */ 0048 0049 class G4BorisScheme 0050 { 0051 public: 0052 0053 /** 0054 * Default Constructor. 0055 */ 0056 G4BorisScheme() = default; 0057 0058 /** 0059 * Constructor for the equation of motion. 0060 * @param[in] equation Pointer to the equation of motion algorithm. 0061 * @param[in] nvar The number of integration variables. 0062 */ 0063 G4BorisScheme( G4EquationOfMotion* equation, G4int nvar = 6 ); 0064 0065 /** 0066 * Default Destructor. 0067 */ 0068 ~G4BorisScheme() = default; 0069 0070 /** 0071 * Does one step, updating velocity and position. 0072 * @param[in] restMass Particle mass. 0073 * @param[in] charge Particle charge. 0074 * @param[in] yIn Initial position. 0075 * @param[out] yOut Updated position. 0076 * @param[in] hstep Proposed step. 0077 */ 0078 void DoStep(G4double restMass, G4double charge, const G4double yIn[], 0079 G4double yOut[], G4double hstep) const; 0080 0081 /** 0082 * Adopts the Boris Scheme Stepping to estimate the integration error. 0083 * Uses two half-steps (comparing to a full step) to obtain output and 0084 * error estimate. 0085 * @param[in] yIn Initial position. 0086 * @param[in] restMass Particle mass. 0087 * @param[in] charge Particle charge. 0088 * @param[in] hstep Proposed step. 0089 * @param[out] yOut Updated position. 0090 * @param[out] yErr The estimated error. 0091 */ 0092 void StepWithErrorEstimate(const G4double yIn[], G4double restMass, 0093 G4double charge, G4double hstep, 0094 G4double yOut[], G4double yErr[]) const; 0095 0096 /** 0097 * Adopts the Boris Scheme Stepping to estimate the integration error. 0098 * Uses two half-steps (comparing to a full step) to obtain output and 0099 * error estimate. Same as above, but also returns the mid-point evaluation. 0100 * @param[in] yIn Initial position. 0101 * @param[in] restMass Particle mass. 0102 * @param[in] charge Particle charge. 0103 * @param[in] hstep Proposed step. 0104 * @param[out] yMid tThe mid-point evaluation. 0105 * @param[out] yOut Updated position. 0106 * @param[out] yErr The estimated error. 0107 */ 0108 void StepWithMidAndErrorEstimate(const G4double yIn[], G4double restMass, 0109 G4double charge, G4double hstep, 0110 G4double yMid[], G4double yOut[], G4double yErr[]) const; 0111 0112 /** 0113 * Auxiliary methods returning a pointer to the equation of motion 0114 * and the number of integration variables. 0115 */ 0116 inline G4EquationOfMotion* GetEquationOfMotion() const; 0117 inline G4int GetNumberOfVariables() const; 0118 0119 private: 0120 0121 /** 0122 * Internal methods for updating position and velocity, used in DoStep(). 0123 */ 0124 void UpdatePosition(const G4double restMass, const G4double charge, 0125 const G4double yIn[], G4double yOut[], G4double hstep) const; 0126 void UpdateVelocity(const G4double restMass, const G4double charge, 0127 const G4double yIn[], G4double yOut[], G4double hstep) const; 0128 0129 /** 0130 * Utility to mem-copy 'src' array data to 'dst'. 0131 */ 0132 void copy(G4double dst[], const G4double src[]) const; 0133 0134 private: 0135 0136 G4EquationOfMotion* fEquation = nullptr; 0137 G4int fnvar = 8; 0138 static constexpr G4double c_l = CLHEP::c_light/CLHEP::m*CLHEP::second; 0139 }; 0140 0141 #include "G4BorisScheme.icc" 0142 0143 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|