Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59: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 //
0032 //
0033 // Created: Josh Xie, June 2014  (supported by Google Summer of Code 2014 )
0034 // 
0035 // Supervisors:  Sandro Wenzel, John Apostolakis (CERN)
0036 // Adapted from G4G4TExplicitEuler class
0037 // -------------------------------------------------------------------
0038 //
0039 // Information from G4Explicit Euler:
0040 // ----------------------------------
0041 // Explicit Euler stepper for magnetic field: x_1 = x_0 + h * dx_0.
0042 // The simplistic approach to solving linear differential equations.
0043 // Take the current derivative and add it to the current position.
0044 // 
0045 // Created: W.Wander <wwc@mit.edu>, 12.09.1997
0046 // -------------------------------------------------------------------
0047 
0048 // --------------------------------------------------------------------
0049 #ifndef G4TExplicitEuler_HH
0050 #define G4TExplicitEuler_HH
0051 
0052 #include "G4TMagErrorStepper.hh"
0053 #include "G4ThreeVector.hh"
0054 
0055 template <class T_Equation, int N>
0056 class G4TExplicitEuler
0057   : public G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N>
0058 {
0059  public:  // with description
0060   static constexpr double IntegratorCorrection = 1.;
0061 
0062   G4TExplicitEuler(T_Equation* EqRhs, G4int numberOfVariables = N)
0063     : G4TMagErrorStepper<G4TExplicitEuler<T_Equation, N>, T_Equation, N>(
0064         EqRhs, numberOfVariables)
0065     , fEquation_Rhs(EqRhs)
0066   {
0067     if( numberOfVariables != N ){
0068        G4ExceptionDescription msg;
0069        msg << "Equation has an incompatible number of variables." ;
0070        msg << "   template N = " << N << " equation-Nvar= "
0071            << numberOfVariables;
0072        G4Exception("G4TExplicitEuler: constructor", "GeomField0003",
0073                    FatalErrorInArgument, msg );
0074     }
0075   }
0076    
0077   ~G4TExplicitEuler() { ; }
0078 
0079   inline void DumbStepper(const G4double yIn[],
0080                           const G4double dydx[],
0081                           G4double h, G4double yOut[]) // override final
0082   {
0083     // Initialise time to t0, needed when it is not updated by the integration.
0084     // yOut[7] = yIn[7];   //  Better to set it to NaN;  // TODO
0085 
0086     for(G4int i = 0; i < N; ++i)
0087     {
0088       yOut[i] = yIn[i] + h * dydx[i];  // 1st and only Step
0089     }
0090 
0091     return;
0092   }
0093 
0094  public:  // without description
0095   G4int IntegratorOrder() const { return 1; }
0096 
0097  private:
0098   T_Equation* fEquation_Rhs;
0099 };
0100 
0101 #endif /* G4TExplicitEuler_HH */