|
|
|||
File indexing completed on 2026-09-04 09:13:09
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4TExplicitEuler 0027 // 0028 // Class description: 0029 // 0030 // Templated version of G4ExplicitEuler. 0031 // Adapted from G4G4TExplicitEuler class. 0032 // 0033 // Information from G4Explicit Euler: 0034 // ---------------------------------- 0035 // Explicit Euler stepper for magnetic field: x_1 = x_0 + h * dx_0. 0036 // The simplistic approach to solving linear differential equations. 0037 // Take the current derivative and add it to the current position. 0038 0039 // Author: Josh Xie (CERN, Google Summer of Code 2014), June 2014 0040 // Supervisors: Sandro Wenzel, John Apostolakis (CERN) 0041 // -------------------------------------------------------------------- 0042 #ifndef G4TExplicitEuler_HH 0043 #define G4TExplicitEuler_HH 0044 0045 #include "G4TMagErrorStepper.hh" 0046 #include "G4ThreeVector.hh" 0047 0048 /** 0049 * @brief G4TExplicitEuler is a templated version of G4ExplicitEuler stepper. 0050 */ 0051 0052 template <class T_Equation, int N> 0053 class G4TExplicitEuler 0054 : public G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N> 0055 { 0056 public: 0057 0058 static constexpr double IntegratorCorrection = 1.; 0059 0060 G4TExplicitEuler(T_Equation* EqRhs, G4int numberOfVariables = N) 0061 : G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N> 0062 (EqRhs, numberOfVariables), fEquation_Rhs(EqRhs) 0063 { 0064 if( numberOfVariables != N ) 0065 { 0066 G4ExceptionDescription msg; 0067 msg << "Equation has an incompatible number of variables." ; 0068 msg << " template N = " << N << " equation-Nvar= " 0069 << numberOfVariables; 0070 G4Exception("G4TExplicitEuler: constructor", "GeomField0003", 0071 FatalErrorInArgument, msg ); 0072 } 0073 } 0074 0075 ~G4TExplicitEuler() = default; 0076 0077 inline void DumbStepper(const G4double yIn[], 0078 const G4double dydx[], 0079 G4double h, G4double yOut[]) // override final 0080 { 0081 // Initialise time to t0, needed when it is not updated by the integration. 0082 // yOut[7] = yIn[7]; // Better to set it to NaN; // TODO 0083 0084 for(G4int i = 0; i < N; ++i) 0085 { 0086 yOut[i] = yIn[i] + h * dydx[i]; // 1st and only Step 0087 } 0088 0089 return; 0090 } 0091 0092 G4int IntegratorOrder() const { return 1; } 0093 0094 private: 0095 0096 T_Equation* fEquation_Rhs; 0097 }; 0098 0099 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|