Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:10:18

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 // G4FSALDormandPrince745
0027 //
0028 // Class description:
0029 //
0030 // DormandPrince7 - 5(4) FSAL stepper
0031 
0032 // Author: Somnath Banerjee (CERN, Google Summer of Code 2015), 25.05.2015
0033 // Supervision: John Apostolakis (CERN)
0034 // --------------------------------------------------------------------
0035 #ifndef G4FSALDORMANDPRINCE745_HH
0036 #define G4FSALDORMANDPRINCE745_HH
0037 
0038 #include "G4VFSALIntegrationStepper.hh"
0039 
0040 /**
0041  * @brief G4FSALDormandPrince745 is an integrator of particle's equation of
0042  * motion based on the DormandPrince7 - 5(4) FSAL implementation.
0043  */
0044 
0045 class G4FSALDormandPrince745 : public G4VFSALIntegrationStepper
0046 {
0047   public:
0048 
0049     /**
0050      * Constructor for G4FSALDormandPrince745.
0051      *  @param[in] EqRhs Pointer to the provided equation of motion.
0052      *  @param[in] numberOfVariables The number of integration variables.
0053      *  @param[in] primary Flag for initialisation of the auxiliary stepper.
0054      */
0055     G4FSALDormandPrince745(G4EquationOfMotion* EqRhs,
0056                            G4int numberOfVariables = 6,
0057                            G4bool primary = true);
0058 
0059     /**
0060      * Destructor.
0061      */
0062     ~G4FSALDormandPrince745() override;
0063 
0064     /**
0065      * Copy constructor and assignment operator not allowed.
0066      */
0067     G4FSALDormandPrince745(const G4FSALDormandPrince745&) = delete;
0068     G4FSALDormandPrince745& operator=(const G4FSALDormandPrince745&) = delete;
0069 
0070     /**
0071      * The stepper for the Runge Kutta integration.
0072      * The stepsize is fixed, with the step size given by 'h'.
0073      * Integrates ODE starting values y[0 to 6].
0074      * Outputs yout[] and its estimated error yerr[].
0075      *  @param[in] y Starting values array of integration variables.
0076      *  @param[in] dydx Derivatives array.
0077      *  @param[in] h The given step size.
0078      *  @param[out] yout Integration output.
0079      *  @param[out] yerr The estimated error.
0080      *  @param[out] nextDydx Last derivatives array for the next step.
0081      */
0082     void Stepper( const G4double y[],
0083                   const G4double dydx[],
0084                         G4double h,
0085                         G4double yout[],
0086                         G4double yerr[],
0087                         G4double nextDydx[]) override ;
0088 
0089     /**
0090      * Calculates the output at the tau fraction of step.
0091      *  @param[in] yInput Starting values array of integration variables.
0092      *  @param[in] dydx Derivatives array.
0093      *  @param[out] yOut Interpolation output.
0094      *  @param[in] Step The given step size.
0095      *  @param[in] tau The tau fraction of the step.
0096      */
0097     void interpolate( const G4double yInput[],
0098                       const G4double dydx[],
0099                             G4double yOut[],
0100                             G4double Step,
0101                             G4double tau ) ;
0102 
0103     /**
0104      * Calculates the output at the tau fraction of step. Same as above
0105      * for higher order interpolant.
0106      */
0107     void Interpolate( const G4double yInput[],
0108                       const G4double dydx[],
0109                       const G4double Step,
0110                             G4double yOut[],
0111                             G4double tau );
0112     
0113     /**
0114      * Setup method for higher order interpolant.
0115      *  @param[in] yInput Starting values array of integration variables.
0116      *  @param[in] dydx Derivatives array.
0117      *  @param[in] Step The given step size.
0118      */
0119     void SetupInterpolate( const G4double yInput[],
0120                            const G4double dydx[],
0121                            const G4double Step );
0122 
0123     /**
0124      * Returns the distance from chord line.
0125      */
0126     G4double DistChord() const override;
0127 
0128     /**
0129      * Returns the order, 4, of integration.
0130      */
0131     inline G4int IntegratorOrder() const override { return 4; }
0132 
0133     /**
0134      * Returns true as this is a FSAL integrator.
0135      */
0136     inline G4bool isFSAL() const { return true; }
0137     
0138   private:
0139     
0140     /** Working arrays -- used during stepping. */
0141     G4double *ak2, *ak3, *ak4, *ak5, *ak6, *ak7,
0142              *ak8, *ak9,         // For additional stages in the interpolant
0143              *yTemp, *yIn;
0144     
0145     /** Only for use with DistChord(). */
0146     G4double* pseudoDydx_for_DistChord;
0147     
0148     G4double fLastStepLength = -1.0;
0149     G4double *fLastInitialVector, *fLastFinalVector,
0150              *fInitialDyDx, *fLastDyDx,
0151              *fMidVector, *fMidError;   // For DistChord() calculations
0152     
0153     G4FSALDormandPrince745* fAuxStepper = nullptr;
0154 };
0155 
0156 #endif