Geant4-11
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
G4NystromRK4 Class Reference

#include <G4NystromRK4.hh>

Inheritance diagram for G4NystromRK4:
G4MagIntegratorStepper

Public Member Functions

virtual G4double DistChord () const override
 
 G4NystromRK4 (G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0)
 
G4double GetDistanceForConstantField () const
 
G4EquationOfMotionGetEquationOfMotion ()
 
const G4EquationOfMotionGetEquationOfMotion () const
 
unsigned long GetfNoRHSCalls ()
 
G4int GetNumberOfStateVariables () const
 
G4int GetNumberOfVariables () const
 
G4int IntegrationOrder ()
 
virtual G4int IntegratorOrder () const override
 
G4bool IsFSAL () const
 
void NormalisePolarizationVector (G4double vec[12])
 
void NormaliseTangentVector (G4double vec[6])
 
void ResetfNORHSCalls ()
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
void SetDistanceForConstantField (G4double length)
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
virtual void Stepper (const G4double y[], const G4double dydx[], G4double hstep, G4double yOut[], G4double yError[]) override
 
 ~G4NystromRK4 ()
 

Protected Member Functions

void SetFSAL (G4bool flag=true)
 
void SetIntegrationOrder (G4int order)
 

Private Member Functions

G4double GetFCof ()
 
G4CachedMagneticFieldGetField ()
 
const G4CachedMagneticFieldGetField () const
 
void GetFieldValue (const G4double point[4], G4double field[3])
 

Private Attributes

std::unique_ptr< G4CachedMagneticFieldfCachedField
 
G4double fCoefficient = 0.0
 
G4ThreeVector fEndPoint
 
G4EquationOfMotionfEquation_Rhs = nullptr
 
G4ThreeVector fInitialPoint
 
G4int fIntegrationOrder = -1
 
G4double fInverseMomentum = 0.0
 
G4bool fIsFSAL = false
 
G4ThreeVector fMidPoint
 
G4double fMomentum = 0.0
 
G4double fMomentum2 = 0.0
 
const G4int fNoIntegrationVariables = 0
 
unsigned long fNoRHSCalls = 0UL
 
const G4int fNoStateVariables = 0
 

Detailed Description

Definition at line 51 of file G4NystromRK4.hh.

Constructor & Destructor Documentation

◆ G4NystromRK4()

G4NystromRK4::G4NystromRK4 ( G4Mag_EqRhs EquationMotion,
G4double  distanceConstField = 0.0 
)

Definition at line 51 of file G4NystromRK4.cc.

53{
54 if (distanceConstField > 0)
55 {
56 SetDistanceForConstantField(distanceConstField);
57 }
58}
G4MagIntegratorStepper(G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12, G4bool isFSAL=false)
void SetDistanceForConstantField(G4double length)

References SetDistanceForConstantField().

◆ ~G4NystromRK4()

G4NystromRK4::~G4NystromRK4 ( )
inline

Definition at line 58 of file G4NystromRK4.hh.

58{}

Member Function Documentation

◆ DistChord()

G4double G4NystromRK4::DistChord ( ) const
overridevirtual

Implements G4MagIntegratorStepper.

Definition at line 183 of file G4NystromRK4.cc.

184{
186}
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)
G4ThreeVector fInitialPoint
Definition: G4NystromRK4.hh:86
G4ThreeVector fMidPoint
Definition: G4NystromRK4.hh:87
G4ThreeVector fEndPoint
Definition: G4NystromRK4.hh:88

References G4LineSection::Distline(), fEndPoint, fInitialPoint, and fMidPoint.

◆ GetDistanceForConstantField()

G4double G4NystromRK4::GetDistanceForConstantField ( ) const

Definition at line 206 of file G4NystromRK4.cc.

207{
208 if (GetField() == nullptr)
209 {
210 return 0.0;
211 }
212 return GetField()->GetConstDistance();
213}
G4double GetConstDistance() const
G4CachedMagneticField * GetField()

References G4CachedMagneticField::GetConstDistance(), and GetField().

◆ GetEquationOfMotion() [1/2]

G4EquationOfMotion * G4MagIntegratorStepper::GetEquationOfMotion ( )
inlineinherited

◆ GetEquationOfMotion() [2/2]

const G4EquationOfMotion * G4MagIntegratorStepper::GetEquationOfMotion ( ) const
inlineinherited

◆ GetFCof()

G4double G4NystromRK4::GetFCof ( )
inlineprivate

Referenced by Stepper().

◆ GetField() [1/2]

G4CachedMagneticField * G4NystromRK4::GetField ( )
private

◆ GetField() [2/2]

const G4CachedMagneticField * G4NystromRK4::GetField ( ) const
private

Definition at line 220 of file G4NystromRK4.cc.

221{
222 return const_cast<G4NystromRK4*>(this)->GetField();
223}

References GetField().

◆ GetFieldValue()

void G4NystromRK4::GetFieldValue ( const G4double  point[4],
G4double  field[3] 
)
inlineprivate

Referenced by Stepper().

◆ GetfNoRHSCalls()

unsigned long G4MagIntegratorStepper::GetfNoRHSCalls ( )
inlineinherited

◆ GetNumberOfStateVariables()

G4int G4MagIntegratorStepper::GetNumberOfStateVariables ( ) const
inlineinherited

◆ GetNumberOfVariables()

G4int G4MagIntegratorStepper::GetNumberOfVariables ( ) const
inlineinherited

◆ IntegrationOrder()

G4int G4MagIntegratorStepper::IntegrationOrder ( )
inlineinherited

◆ IntegratorOrder()

virtual G4int G4NystromRK4::IntegratorOrder ( ) const
inlineoverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 71 of file G4NystromRK4.hh.

71{ return 4; }

◆ IsFSAL()

G4bool G4MagIntegratorStepper::IsFSAL ( ) const
inlineinherited

◆ NormalisePolarizationVector()

void G4MagIntegratorStepper::NormalisePolarizationVector ( G4double  vec[12])
inlineinherited

◆ NormaliseTangentVector()

void G4MagIntegratorStepper::NormaliseTangentVector ( G4double  vec[6])
inlineinherited

◆ ResetfNORHSCalls()

void G4MagIntegratorStepper::ResetfNORHSCalls ( )
inlineinherited

◆ RightHandSide() [1/2]

void G4MagIntegratorStepper::RightHandSide ( const G4double  y[],
G4double  dydx[] 
) const
inlineinherited

◆ RightHandSide() [2/2]

void G4MagIntegratorStepper::RightHandSide ( const G4double  y[],
G4double  dydx[],
G4double  field[] 
) const
inlineinherited

◆ SetDistanceForConstantField()

void G4NystromRK4::SetDistanceForConstantField ( G4double  length)

Definition at line 188 of file G4NystromRK4.cc.

189{
190 if (GetField() == nullptr)
191 {
192 G4Exception("G4NystromRK4::SetDistanceForConstantField",
193 "Nystrom 001", JustWarning,
194 "Provided field is not G4CachedMagneticField. Changing field type.");
195
196 fCachedField = std::unique_ptr<G4CachedMagneticField>(
198 dynamic_cast<G4MagneticField*>(GetEquationOfMotion()->GetFieldObj()),
199 length));
200
202 }
203 GetField()->SetConstDistance(length);
204}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
void SetConstDistance(G4double dist)
void SetFieldObj(G4Field *pField)
std::unique_ptr< G4CachedMagneticField > fCachedField
Definition: G4NystromRK4.hh:90

References fCachedField, G4Exception(), G4MagIntegratorStepper::GetEquationOfMotion(), GetField(), JustWarning, G4CachedMagneticField::SetConstDistance(), and G4EquationOfMotion::SetFieldObj().

Referenced by G4NystromRK4().

◆ SetEquationOfMotion()

void G4MagIntegratorStepper::SetEquationOfMotion ( G4EquationOfMotion newEquation)
inlineinherited

◆ SetFSAL()

void G4MagIntegratorStepper::SetFSAL ( G4bool  flag = true)
inlineprotectedinherited

◆ SetIntegrationOrder()

void G4MagIntegratorStepper::SetIntegrationOrder ( G4int  order)
inlineprotectedinherited

◆ Stepper()

void G4NystromRK4::Stepper ( const G4double  y[],
const G4double  dydx[],
G4double  hstep,
G4double  yOut[],
G4double  yError[] 
)
overridevirtual

Implements G4MagIntegratorStepper.

Definition at line 60 of file G4NystromRK4.cc.

65{
66 fInitialPoint = { y[0], y[1], y[2] };
67
68 G4double field[3];
69
70 constexpr G4double one_sixth= 1./6.;
71 const G4double S5 = 0.5 * hstep;
72 const G4double S4 = .25 * hstep;
73 const G4double S6 = hstep * one_sixth;
74
75 const G4double momentum2 = getValue2(y, Value3D::Momentum);
76 if (notEquals(momentum2, fMomentum2))
77 {
78 fMomentum = std::sqrt(momentum2);
79 fMomentum2 = momentum2;
82 }
83
84 // Point 1
85 const G4double K1[3] = {
86 fInverseMomentum * dydx[3],
87 fInverseMomentum * dydx[4],
88 fInverseMomentum * dydx[5]
89 };
90
91 // Point2
92 G4double p[4] = {
93 y[0] + S5 * (dydx[0] + S4 * K1[0]),
94 y[1] + S5 * (dydx[1] + S4 * K1[1]),
95 y[2] + S5 * (dydx[2] + S4 * K1[2]),
96 y[7]
97 };
98
99 GetFieldValue(p, field);
100
101 const G4double A2[3] = {
102 dydx[0] + S5 * K1[0],
103 dydx[1] + S5 * K1[1],
104 dydx[2] + S5 * K1[2]
105 };
106
107 const G4double K2[3] = {
108 (A2[1] * field[2] - A2[2] * field[1]) * fCoefficient,
109 (A2[2] * field[0] - A2[0] * field[2]) * fCoefficient,
110 (A2[0] * field[1] - A2[1] * field[0]) * fCoefficient
111 };
112
113 fMidPoint = { p[0], p[1], p[2] };
114
115 // Point 3 with the same magnetic field
116 const G4double A3[3] = {
117 dydx[0] + S5 * K2[0],
118 dydx[1] + S5 * K2[1],
119 dydx[2] + S5 * K2[2]
120 };
121
122 const G4double K3[3] = {
123 (A3[1] * field[2] - A3[2] * field[1]) * fCoefficient,
124 (A3[2] * field[0] - A3[0] * field[2]) * fCoefficient,
125 (A3[0] * field[1] - A3[1] * field[0]) * fCoefficient
126 };
127
128 // Point 4
129 p[0] = y[0] + hstep * (dydx[0] + S5 * K3[0]);
130 p[1] = y[1] + hstep * (dydx[1] + S5 * K3[1]);
131 p[2] = y[2] + hstep * (dydx[2] + S5 * K3[2]);
132
133 GetFieldValue(p, field);
134
135 const G4double A4[3] = {
136 dydx[0] + hstep * K3[0],
137 dydx[1] + hstep * K3[1],
138 dydx[2] + hstep * K3[2]
139 };
140
141 const G4double K4[3] = {
142 (A4[1] * field[2] - A4[2] * field[1]) * fCoefficient,
143 (A4[2] * field[0] - A4[0] * field[2]) * fCoefficient,
144 (A4[0] * field[1] - A4[1] * field[0]) * fCoefficient
145 };
146
147 // New position
148 yOut[0] = y[0] + hstep * (dydx[0] + S6 * (K1[0] + K2[0] + K3[0]));
149 yOut[1] = y[1] + hstep * (dydx[1] + S6 * (K1[1] + K2[1] + K3[1]));
150 yOut[2] = y[2] + hstep * (dydx[2] + S6 * (K1[2] + K2[2] + K3[2]));
151 // New direction
152 yOut[3] = dydx[0] + S6 * (K1[0] + K4[0] + 2. * (K2[0] + K3[0]));
153 yOut[4] = dydx[1] + S6 * (K1[1] + K4[1] + 2. * (K2[1] + K3[1]));
154 yOut[5] = dydx[2] + S6 * (K1[2] + K4[2] + 2. * (K2[2] + K3[2]));
155 // Pass Energy, time unchanged -- time is not integrated !!
156 yOut[6] = y[6];
157 yOut[7] = y[7];
158
159 fEndPoint = { yOut[0], yOut[1], yOut[2] };
160
161 // Errors
162 yError[3] = hstep * std::fabs(K1[0] - K2[0] - K3[0] + K4[0]);
163 yError[4] = hstep * std::fabs(K1[1] - K2[1] - K3[1] + K4[1]);
164 yError[5] = hstep * std::fabs(K1[2] - K2[2] - K3[2] + K4[2]);
165 yError[0] = hstep * yError[3];
166 yError[1] = hstep * yError[4];
167 yError[2] = hstep * yError[5];
168 yError[3] *= fMomentum;
169 yError[4] *= fMomentum;
170 yError[5] *= fMomentum;
171
172 // Normalize momentum
173 const G4double normF = fMomentum / getValue(yOut, Value3D::Momentum);
174 yOut[3] *= normF;
175 yOut[4] *= normF;
176 yOut[5] *= normF;
177
178 // My trial code:
179 // G4double endMom2 = yOut[3]*yOut[3]+yOut[4]*yOut[4]+yOut[5]*yOut[5];
180 // G4double normF = std::sqrt( startMom2 / endMom2 );
181}
double G4double
Definition: G4Types.hh:83
void GetFieldValue(const G4double point[4], G4double field[3])
G4double fInverseMomentum
Definition: G4NystromRK4.hh:84
G4double GetFCof()
G4double fMomentum2
Definition: G4NystromRK4.hh:83
G4double fMomentum
Definition: G4NystromRK4.hh:82
G4double fCoefficient
Definition: G4NystromRK4.hh:85
G4bool notEquals(G4double p1, G4double p2)
Definition: G4NystromRK4.cc:43
G4double getValue(const ArrayType &array, Value1D value)
G4double getValue2(const ArrayType &array, Value1D value)

References fCoefficient, fEndPoint, fInitialPoint, fInverseMomentum, fMidPoint, fMomentum, fMomentum2, GetFCof(), GetFieldValue(), field_utils::getValue(), field_utils::getValue2(), and anonymous_namespace{G4NystromRK4.cc}::notEquals().

Field Documentation

◆ fCachedField

std::unique_ptr<G4CachedMagneticField> G4NystromRK4::fCachedField
private

Definition at line 90 of file G4NystromRK4.hh.

Referenced by SetDistanceForConstantField().

◆ fCoefficient

G4double G4NystromRK4::fCoefficient = 0.0
private

Definition at line 85 of file G4NystromRK4.hh.

Referenced by Stepper().

◆ fEndPoint

G4ThreeVector G4NystromRK4::fEndPoint
private

Definition at line 88 of file G4NystromRK4.hh.

Referenced by DistChord(), and Stepper().

◆ fEquation_Rhs

G4EquationOfMotion* G4MagIntegratorStepper::fEquation_Rhs = nullptr
privateinherited

Definition at line 124 of file G4MagIntegratorStepper.hh.

◆ fInitialPoint

G4ThreeVector G4NystromRK4::fInitialPoint
private

Definition at line 86 of file G4NystromRK4.hh.

Referenced by DistChord(), and Stepper().

◆ fIntegrationOrder

G4int G4MagIntegratorStepper::fIntegrationOrder = -1
privateinherited

Definition at line 134 of file G4MagIntegratorStepper.hh.

◆ fInverseMomentum

G4double G4NystromRK4::fInverseMomentum = 0.0
private

Definition at line 84 of file G4NystromRK4.hh.

Referenced by Stepper().

◆ fIsFSAL

G4bool G4MagIntegratorStepper::fIsFSAL = false
privateinherited

Definition at line 136 of file G4MagIntegratorStepper.hh.

◆ fMidPoint

G4ThreeVector G4NystromRK4::fMidPoint
private

Definition at line 87 of file G4NystromRK4.hh.

Referenced by DistChord(), and Stepper().

◆ fMomentum

G4double G4NystromRK4::fMomentum = 0.0
private

Definition at line 82 of file G4NystromRK4.hh.

Referenced by Stepper().

◆ fMomentum2

G4double G4NystromRK4::fMomentum2 = 0.0
private

Definition at line 83 of file G4NystromRK4.hh.

Referenced by Stepper().

◆ fNoIntegrationVariables

const G4int G4MagIntegratorStepper::fNoIntegrationVariables = 0
privateinherited

Definition at line 125 of file G4MagIntegratorStepper.hh.

◆ fNoRHSCalls

unsigned long G4MagIntegratorStepper::fNoRHSCalls = 0UL
mutableprivateinherited

Definition at line 128 of file G4MagIntegratorStepper.hh.

◆ fNoStateVariables

const G4int G4MagIntegratorStepper::fNoStateVariables = 0
privateinherited

Definition at line 126 of file G4MagIntegratorStepper.hh.


The documentation for this class was generated from the following files: