Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NystromRK4.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4NystromRK4
27//
28// Class description:
29//
30// Integrates the equations of the motion of a particle in a magnetic field
31// using 4th Runge-Kutta-Nystrom method with errors estimation
32// (ATL-SOFT-PUB-2009-01)
33// Current form can be used only for 'pure' magnetic field.
34// Notes: 1) field must be time-independent.
35// 2) time is not integrated
36
37// Author: Igor Gavrilenko (CERN), 15.05.2009 (as G4AtlasRK4)
38// Adaptations: John Apostolakis (CERN), 05.11.2009
39// -------------------------------------------------------------------
40#ifndef G4NYSTROMRK4_HH
41#define G4NYSTROMRK4_HH
42
44#include "G4Mag_EqRhs.hh"
46#include "G4ThreeVector.hh"
47
48#include <memory>
49
50/**
51 * @brief G4NystromRK4 integrates the equations of the motion of a particle
52 * in a magnetic field using 4th Runge-Kutta-Nystrom method with errors
53 * estimation. The current form can be used only for 'pure' magnetic field.
54 */
55
57{
58 public:
59
60 /**
61 * Constructor for G4NystromRK4. Can be used only for Magnetic Fields
62 * and for 6 variables (x,p).
63 * @param[in] EquationMotion Pointer to the provided equation of motion.
64 * @param[in] distanceConstField Distance value for constant field.
65 */
66 G4NystromRK4(G4Mag_EqRhs* EquationMotion,
67 G4double distanceConstField = 0.0);
68
69 /**
70 * Default Destructor.
71 */
72 ~G4NystromRK4() override = default;
73
74 /**
75 * The stepper for the Runge Kutta integration.
76 * The stepsize is fixed, with the step size given by 'hstep'.
77 * Integrates ODE starting values y[0 to 6].
78 * Outputs yOut[] and its estimated error yError[].
79 * Provides error via analytical method.
80 * @param[in] y Starting values array of integration variables.
81 * @param[in] dydx Derivatives array.
82 * @param[in] hstep The given step size.
83 * @param[out] yOut Integration output.
84 * @param[out] yError The estimated error.
85 */
86 void Stepper(const G4double y[],
87 const G4double dydx[],
88 G4double hstep,
89 G4double yOut[],
90 G4double yError[]) override;
91
92 /**
93 * Setter and getter for the distance value for constant field.
94 */
97
98 /**
99 * Returns the order, 4, of integration.
100 */
101 inline G4int IntegratorOrder() const override;
102
103 /**
104 * Returns the distance from chord line.
105 */
106 G4double DistChord() const override;
107
108 /**
109 * Returns the stepper type-ID, "kNystromRK4".
110 */
111 inline G4StepperType StepperType() const override;
112
113 private:
114
115 /**
116 * Private accessors for field data.
117 */
118 inline void GetFieldValue(const G4double point[4], G4double field[3]);
119 inline G4double GetFCof();
120 G4CachedMagneticField* GetField();
121 const G4CachedMagneticField* GetField() const;
122
123 private:
124
125 G4double fMomentum = 0.0;
126 G4double fMomentum2 = 0.0;
127 G4double fInverseMomentum = 0.0;
128 G4double fCoefficient = 0.0;
129 G4ThreeVector fInitialPoint;
130 G4ThreeVector fMidPoint;
131 G4ThreeVector fEndPoint;
132
133 std::unique_ptr<G4CachedMagneticField> fCachedField;
134};
135
136#include "G4NystromRK4.icc"
137
138#endif
G4StepperType
G4StepperType defines the available integrator of particle's equation of motion in Geant4.
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4CachedMagneticField is a specialisation of G4MagneticField and is used to cache the Magnetic Field ...
G4MagIntegratorStepper(G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12, G4bool isFSAL=false)
G4Mag_EqRhs is the "standard" equation of motion of a particle in a pure magnetic field.
G4StepperType StepperType() const override
~G4NystromRK4() override=default
G4double GetDistanceForConstantField() const
G4int IntegratorOrder() const override
void Stepper(const G4double y[], const G4double dydx[], G4double hstep, G4double yOut[], G4double yError[]) override
G4double DistChord() const override
void SetDistanceForConstantField(G4double length)
G4NystromRK4(G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0)