Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-03 09:13:15

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 // G4ClassicalRK4
0027 //
0028 // Class description:
0029 //
0030 // Integrate the equations of the motion of a particle in a magnetic field
0031 // using the classical 4th Runge-Kutta method.
0032 
0033 // Authors: J.Apostolakis, V.Grichine (CERN), 30.01.1997
0034 // -------------------------------------------------------------------
0035 #ifndef G4CLASSICALRK4_HH
0036 #define G4CLASSICALRK4_HH
0037 
0038 #include "G4MagErrorStepper.hh"
0039 
0040 /**
0041  * @brief G4ClassicalRK4 integrates the equations of the motion of a particle
0042  * in a magnetic field using the classical 4th Runge-Kutta method.
0043  */
0044 
0045 class G4ClassicalRK4 : public G4MagErrorStepper 
0046 {
0047   public:
0048 
0049     /**
0050      * Constructor for G4ClassicalRK4.
0051      *  @param[in] EquationMotion Pointer to the provided equation of motion.
0052      *  @param[in] numberOfVariables The number of integration variables.
0053      */
0054     G4ClassicalRK4(G4EquationOfMotion* EquationMotion,
0055                    G4int numberOfVariables = 6) ;
0056 
0057     /**
0058      * Destructor.
0059      */
0060     ~G4ClassicalRK4() override ;
0061 
0062     /**
0063      * Copy constructor and assignment operator not allowed.
0064      */
0065     G4ClassicalRK4(const G4ClassicalRK4&) = delete;
0066     G4ClassicalRK4& operator=(const G4ClassicalRK4&) = delete;
0067 
0068     // A stepper that does not know about errors.
0069     // It is used by the MagErrorStepper stepper.
0070    
0071     /**
0072      * Given values for the variables y[0,..,n-1] and their derivatives
0073      * dydx[0,...,n-1] known at x, uses the classical 4th Runge-Kutta
0074      * method to advance the solution over an interval h and returns the
0075      * incremented variables as yout[0,...,n-1]. The user supplies the
0076      * function RightHandSide(x,y,dydx), which returns derivatives dydx at x.
0077      * The source is routine rk4 from NRC p.712-713.
0078      *  @param[in] yIn Starting values array of integration variables.
0079      *  @param[in] dydx Derivatives array.
0080      *  @param[in] h The given step size.
0081      *  @param[out] yOut Integration output.
0082      */
0083     void DumbStepper( const G4double yIn[],
0084                       const G4double dydx[],
0085                             G4double h,
0086                             G4double yOut[] ) override ;
0087 
0088     /**
0089      * Returns the order, 4, of integration.
0090      */
0091     G4int IntegratorOrder() const override { return 4; }
0092 
0093     /**
0094      * Returns the stepper type-ID, "kClassicalRK4".
0095      */
0096     G4StepperType StepperType() const override { return kClassicalRK4; }
0097 
0098   private:
0099 
0100     G4double *dydxm, *dydxt, *yt; // scratch space - not state 
0101 };
0102 
0103 #endif