Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-08 08:17:58

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 // G4RK547FEq2
0026 //
0027 // Class description:
0028 //
0029 // An implementation of the 7 stage embedded Runge-Kutta 4,5 pair (RK547FEq2)
0030 // from the paper:
0031 //   D. J. Higham and G. Hall,
0032 //   "Embedded Runge-Kutta formulae with stable equilibrium states",
0033 //   J. Comput. Appl. Math., vol. 29, no. 1, pp. 25-33, 1990.
0034 
0035 // Author: Dmitry Sorokin (CERN, Google Summer of Code 2017), 02.11.2017
0036 // Supervision: John Apostolakis (CERN)
0037 // --------------------------------------------------------------------
0038 #ifndef G4RK547FEQ2_HH
0039 #define G4RK547FEQ2_HH
0040 
0041 #include "G4MagIntegratorStepper.hh"
0042 #include "G4FieldTrack.hh"
0043 
0044 /**
0045  * @brief G4RK547FEq2 is an implementation of the 7 stage embedded
0046  * Runge-Kutta 4,5 pair.
0047  */
0048 
0049 class G4RK547FEq2 : public G4MagIntegratorStepper
0050 {
0051   public:
0052 
0053     /**
0054      * Constructor for G4RK547FEq2.
0055      *  @param[in] EqRhs Pointer to the provided equation of motion.
0056      *  @param[in] integrationVariables The number of integration variables.
0057      */
0058     G4RK547FEq2(G4EquationOfMotion* EqRhs,
0059                 G4int integrationVariables = 6);
0060 
0061     /**
0062      * Default Destructor.
0063      */
0064     ~G4RK547FEq2() override = default;
0065 
0066     /**
0067      * Copy constructor and assignment operator not allowed.
0068      */
0069     G4RK547FEq2 (const G4RK547FEq2&) = delete;
0070     G4RK547FEq2& operator = (const G4RK547FEq2&) = delete;
0071 
0072     /**
0073      * The stepper for the Runge Kutta integration.
0074      * The stepsize is fixed, with the step size given by 'hstep'.
0075      * Integrates ODE starting values yInput[0 to 6].
0076      * Outputs yOutput[] and its estimated error yError[].
0077      *  @param[in] yInput Starting values array of integration variables.
0078      *  @param[in] dydx Derivatives array.
0079      *  @param[in] hstep The given step size.
0080      *  @param[out] yOutput Integration output.
0081      *  @param[out] yError The estimated error.
0082      */
0083     void Stepper( const G4double yInput[],
0084                   const G4double dydx[],
0085                         G4double hstep,
0086                         G4double yOutput[],
0087                         G4double yError[] ) override;
0088 
0089     /**
0090      * Same as the Stepper() function above, with dydx also in ouput.
0091      *  @param[in] yInput Starting values array of integration variables.
0092      *  @param[in] dydx Derivatives array.
0093      *  @param[in] hstep The given step size.
0094      *  @param[out] yOutput Integration output.
0095      *  @param[out] yError The estimated error.
0096      *  @param[out] dydxOutput dydx in output.
0097      */
0098     void Stepper( const G4double yInput[],
0099                   const G4double dydx[],
0100                         G4double hstep,
0101                         G4double yOutput[],
0102                         G4double yError[],
0103                         G4double dydxOutput[] );
0104 
0105     /**
0106      * Returns the distance from chord line.
0107      */
0108     G4double DistChord() const override;
0109 
0110     /**
0111      * Returns the order, 4, of integration.
0112      */
0113     G4int IntegratorOrder() const override { return 4; }
0114 
0115     /**
0116      * Returns the stepper type-ID, "kRK547FEq2".
0117      */
0118     G4StepperType StepperType() const override { return kRK547FEq2; }
0119 
0120   private:
0121 
0122     /**
0123      * Utility method used in Stepper() for computing the actual step.
0124      */
0125     void makeStep( const G4double yInput[],
0126                    const G4double dydx[],
0127                    const G4double hstep,
0128                          G4double yOutput[],
0129                          G4double* dydxOutput = nullptr,
0130                          G4double* yError = nullptr ) const;
0131 
0132   private:
0133 
0134     G4double fyIn[G4FieldTrack::ncompSVEC],
0135              fdydx[G4FieldTrack::ncompSVEC],
0136              fyOut[G4FieldTrack::ncompSVEC],
0137              fdydxOut[G4FieldTrack::ncompSVEC];
0138 
0139     G4double fhstep= -1.0;
0140 };
0141 
0142 #endif