Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 09:10:51

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 // G4ModifiedMidpoint
0026 //
0027 // Class description:
0028 //
0029 // Modified midpoint method implementation, based on Boost odeint.
0030 
0031 // Author: Dmitry Sorokin (CERN, Google Summer of Code 2016), 07.10.2016
0032 // Supervision: John Apostolakis (CERN)
0033 // --------------------------------------------------------------------
0034 #ifndef G4MODIFIED_MIDPOINT_HH
0035 #define G4MODIFIED_MIDPOINT_HH
0036 
0037 #include "G4Types.hh"
0038 #include "G4EquationOfMotion.hh"
0039 #include "G4FieldTrack.hh"
0040 
0041 /**
0042  * @brief G4ModifiedMidpoint implements a midpoint method adapted from
0043  * Boost odeint.
0044  */
0045 
0046 class G4ModifiedMidpoint
0047 {
0048   public:
0049 
0050     /**
0051      * Constructor for G4ModifiedMidpoint.
0052      *  @param[in] equation Pointer to the provided equation of motion.
0053      *  @param[in] nvar The number of integration variables.
0054      *  @param[in] steps The minimum number of steps.
0055      */
0056     G4ModifiedMidpoint( G4EquationOfMotion* equation,
0057                         G4int nvar = 6, G4int steps = 2 );
0058 
0059     /**
0060      * Default Destructor.
0061      */
0062     ~G4ModifiedMidpoint() = default;
0063 
0064     /**
0065      * Computes one step.
0066      *  @param[in] yIn Starting values array of integration variables.
0067      *  @param[in] dydxIn Derivatives array in input.
0068      *  @param[out] yOut Integration output.
0069      *  @param[in] hstep The given step size.
0070      */
0071     void DoStep( const G4double yIn[], const G4double dydxIn[],
0072                  G4double yOut[], G4double hstep) const;
0073 
0074     /**
0075      * Computes one step, as above but using also intermediate values.
0076      *  @param[in] yIn Starting values array of integration variables.
0077      *  @param[in] dydxIn Derivatives array in input.
0078      *  @param[out] yOut Integration output.
0079      *  @param[in] hstep The given step size.
0080      *  @param[in] yMid Mid point integration variables.
0081      *  @param[in] derivs Intermediate derivatives.
0082      */
0083     void DoStep( const G4double yIn[], const G4double dydxIn[],
0084                  G4double yOut[], G4double hstep, G4double yMid[],
0085                  G4double derivs[][G4FieldTrack::ncompSVEC]) const;
0086 
0087     /**
0088      * Setter and getter for steps.
0089      */
0090     inline void SetSteps(G4int steps);
0091     inline G4int GetSteps() const;
0092 
0093     /**
0094      * Setter and getter for the equation of motion.
0095      */
0096     inline void SetEquationOfMotion(G4EquationOfMotion* equation);
0097     inline G4EquationOfMotion* GetEquationOfMotion() const;
0098 
0099     /**
0100      * Returns the number of integration variables.
0101      */
0102     inline G4int GetNumberOfVariables() const;
0103 
0104   private:
0105 
0106     /**
0107      * Utility for copying array content from 'src' to 'dst'.
0108      */
0109     void copy(G4double dst[], const G4double src[]) const;
0110 
0111   private:
0112 
0113     G4EquationOfMotion* fEquation = nullptr;
0114     G4int fnvar = 0;
0115     G4int fsteps = 0;
0116 };
0117 
0118 #include "G4ModifiedMidpoint.icc"
0119 
0120 #endif