Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-30 08:56:24

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 // G4BogackiShampine23
0027 //
0028 // Class description:
0029 //
0030 // Bogacki-Shampine - 4 - 3(2) non-FSAL implementation 
0031 //
0032 // An implementation of the embedded RK method from the paper 
0033 //  [1] P. Bogacki and L. F. Shampine,
0034 //     "A 3(2) pair of Runge - Kutta formulas"
0035 //     Appl. Math. Lett., vol. 2, no. 4, pp. 321-325, Jan. 1989.
0036 //
0037 // This version does not utilise the FSAL property of the method,
0038 // which would allow the reuse of the last derivative in the next step.
0039 // (Alternative FSAL implementation created with revised interface)
0040 
0041 // Author: Somnath Banerjee (CERN, Google Summer of Code 2015), 20.05.2015
0042 // Supervision: John Apostolakis (CERN)
0043 // --------------------------------------------------------------------
0044 #ifndef G4BOGACKI_SHAMPINE23_HH
0045 #define G4BOGACKI_SHAMPINE23_HH
0046 
0047 #include "G4MagIntegratorStepper.hh"
0048 #include "G4FieldTrack.hh"
0049 
0050 /**
0051  * @brief G4BogackiShampine23 is an integrator of particle's equation of
0052  * motion based on the Bogacki-Shampine non-FSAL implementation.
0053  */
0054 
0055 class G4BogackiShampine23 : public G4MagIntegratorStepper
0056 {
0057   public:
0058 
0059     /**
0060      * Constructor for G4BogackiShampine23.
0061      *  @param[in] EqRhs Pointer to the provided equation of motion.
0062      *  @param[in] numberOfVariables The number of integration variables.
0063      */
0064     G4BogackiShampine23(G4EquationOfMotion* EqRhs,
0065                         G4int numberOfVariables = 6);
0066 
0067     /**
0068      * Default Destructor.
0069      */
0070     ~G4BogackiShampine23() override = default;
0071 
0072     /**
0073      * Copy constructor and assignment operator not allowed.
0074      */
0075     G4BogackiShampine23(const G4BogackiShampine23&) = delete;
0076     G4BogackiShampine23& operator = (const G4BogackiShampine23&) = delete;
0077 
0078     /**
0079      * The stepper for the Runge Kutta integration.
0080      * The stepsize is fixed, with the step size given by 'hstep'.
0081      * Integrates ODE starting values yInput[0 to 6].
0082      * Outputs yOutput[] and its estimated error yError[].
0083      *  @param[in] yInput Starting values array of integration variables.
0084      *  @param[in] dydx Derivatives array.
0085      *  @param[in] hstep The given step size.
0086      *  @param[out] yOutput Integration output.
0087      *  @param[out] yError The estimated error.
0088      */
0089     void Stepper(const G4double yInput[],
0090                  const G4double dydx[],
0091                        G4double hstep,
0092                        G4double yOutput[],
0093                        G4double yError[]) override;
0094 
0095     /**
0096      * Same as the Stepper() function above, with dydx also in ouput.
0097      *  @param[in] yInput Starting values array of integration variables.
0098      *  @param[in] dydx Derivatives array.
0099      *  @param[in] hstep The given step size.
0100      *  @param[out] yOutput Integration output.
0101      *  @param[out] yError The estimated error.
0102      *  @param[out] dydxOutput dydx in output.
0103      */
0104     void Stepper(const G4double yInput[],
0105                  const G4double dydx[],
0106                        G4double hstep,
0107                        G4double yOutput[],
0108                        G4double yError[],
0109                        G4double dydxOutput[]);
0110 
0111     /**
0112      * Returns the distance from chord line.
0113      */
0114     G4double DistChord() const override;
0115 
0116     /**
0117      * Returns the order, 3, of integration.
0118      */
0119     inline G4int IntegratorOrder() const override { return 3; }
0120 
0121     /**
0122      * Returns the stepper type-ID, "kBogackiShampine23".
0123      */
0124     inline G4StepperType StepperType() const override { return kBogackiShampine23; }
0125 
0126   private:
0127 
0128     /**
0129      * Utility method used in Stepper() for computing the actual step.
0130      */
0131     void makeStep(const G4double yInput[],
0132                   const G4double dydx[],
0133                   const G4double hstep,
0134                         G4double yOutput[],
0135                         G4double* dydxOutput = nullptr,
0136                         G4double* yError = nullptr) const;
0137 
0138   private:
0139 
0140     G4double fyIn[G4FieldTrack::ncompSVEC],
0141              fdydx[G4FieldTrack::ncompSVEC],
0142              fyOut[G4FieldTrack::ncompSVEC],
0143              fdydxOut[G4FieldTrack::ncompSVEC];
0144     G4double fhstep = -1.0;
0145 };
0146 
0147 #endif