Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TCashKarpRKF45< T_Equation, N > Class Template Reference

#include <G4TCashKarpRKF45.hh>

+ Inheritance diagram for G4TCashKarpRKF45< T_Equation, N >:

Public Member Functions

 G4TCashKarpRKF45 (T_Equation *EqRhs, G4bool primary=true)
 
virtual ~G4TCashKarpRKF45 ()
 
void StepWithError (const G4double yInput[], const G4double dydx[], G4double Step, G4double yOut[], G4double yErr[])
 
virtual void Stepper (const G4double yInput[], const G4double dydx[], G4double hstep, G4double yOutput[], G4double yError[]) override final
 
void RightHandSideInl (const G4double y[], G4double dydx[])
 
G4double DistChord () const override
 
G4int IntegratorOrder () const override
 
- Public Member Functions inherited from G4MagIntegratorStepper
 G4MagIntegratorStepper (G4EquationOfMotion *Equation, G4int numIntegrationVariables, G4int numStateVariables=12, G4bool isFSAL=false)
 
virtual ~G4MagIntegratorStepper ()=default
 
 G4MagIntegratorStepper (const G4MagIntegratorStepper &)=delete
 
G4MagIntegratorStepperoperator= (const G4MagIntegratorStepper &)=delete
 
virtual void Stepper (const G4double y[], const G4double dydx[], G4double h, G4double yout[], G4double yerr[])=0
 
virtual G4double DistChord () const =0
 
void NormaliseTangentVector (G4double vec[6])
 
void NormalisePolarizationVector (G4double vec[12])
 
void RightHandSide (const G4double y[], G4double dydx[]) const
 
void RightHandSide (const G4double y[], G4double dydx[], G4double field[]) const
 
G4int GetNumberOfVariables () const
 
G4int GetNumberOfStateVariables () const
 
virtual G4int IntegratorOrder () const =0
 
G4int IntegrationOrder ()
 
G4EquationOfMotionGetEquationOfMotion ()
 
const G4EquationOfMotionGetEquationOfMotion () const
 
void SetEquationOfMotion (G4EquationOfMotion *newEquation)
 
unsigned long GetfNoRHSCalls ()
 
void ResetfNORHSCalls ()
 
G4bool IsFSAL () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4MagIntegratorStepper
void SetIntegrationOrder (G4int order)
 
void SetFSAL (G4bool flag=true)
 

Detailed Description

template<class T_Equation, unsigned int N = 6>
class G4TCashKarpRKF45< T_Equation, N >

Definition at line 63 of file G4TCashKarpRKF45.hh.

Constructor & Destructor Documentation

◆ G4TCashKarpRKF45()

template<class T_Equation , unsigned int N>
G4TCashKarpRKF45< T_Equation, N >::G4TCashKarpRKF45 ( T_Equation *  EqRhs,
G4bool  primary = true 
)

Definition at line 123 of file G4TCashKarpRKF45.hh.

125 : G4MagIntegratorStepper(dynamic_cast<G4EquationOfMotion*>(EqRhs), N )
126 , fEquation_Rhs(EqRhs)
127{
128 if( dynamic_cast<G4EquationOfMotion*>(EqRhs) == nullptr )
129 {
130 G4Exception("G4TCashKarpRKF45: constructor", "GeomField0001",
131 FatalException, "Equation is not an G4EquationOfMotion.");
132 }
133
134 fLastInitialVector = new G4double[N];
135 fLastFinalVector = new G4double[N];
136 fLastDyDx = new G4double[N];
137
138 fMidVector = new G4double[N];
139 fMidError = new G4double[N];
140
141 if(primary)
142 {
143 fAuxStepper = new G4TCashKarpRKF45<T_Equation, N> (EqRhs, !primary);
144 }
145}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83

◆ ~G4TCashKarpRKF45()

template<class T_Equation , unsigned int N>
G4TCashKarpRKF45< T_Equation, N >::~G4TCashKarpRKF45
virtual

Definition at line 148 of file G4TCashKarpRKF45.hh.

149{
150 delete[] fLastInitialVector;
151 delete[] fLastFinalVector;
152 delete[] fLastDyDx;
153 delete[] fMidVector;
154 delete[] fMidError;
155
156 delete fAuxStepper;
157}

Member Function Documentation

◆ DistChord()

template<class T_Equation , unsigned int N>
G4double G4TCashKarpRKF45< T_Equation, N >::DistChord
inlineoverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 270 of file G4TCashKarpRKF45.hh.

271{
272 G4double distLine, distChord;
273 G4ThreeVector initialPoint, finalPoint, midPoint;
274
275 // Store last initial and final points (they will be overwritten in
276 // self-Stepper call!)
277 initialPoint = G4ThreeVector(fLastInitialVector[0], fLastInitialVector[1],
278 fLastInitialVector[2]);
279 finalPoint = G4ThreeVector(fLastFinalVector[0], fLastFinalVector[1],
280 fLastFinalVector[2]);
281
282 // Do half a step using StepNoErr
283
284 fAuxStepper->G4TCashKarpRKF45::Stepper(fLastInitialVector, fLastDyDx,
285 0.5 * fLastStepLength, fMidVector,
286 fMidError);
287
288 midPoint = G4ThreeVector(fMidVector[0], fMidVector[1], fMidVector[2]);
289
290 // Use stored values of Initial and Endpoint + new Midpoint to evaluate
291 // distance of Chord
292
293 if(initialPoint != finalPoint)
294 {
295 distLine = G4LineSection::Distline(midPoint, initialPoint, finalPoint);
296 distChord = distLine;
297 }
298 else
299 {
300 distChord = (midPoint - initialPoint).mag();
301 }
302 return distChord;
303}
CLHEP::Hep3Vector G4ThreeVector
static G4double Distline(const G4ThreeVector &OtherPnt, const G4ThreeVector &LinePntA, const G4ThreeVector &LinePntB)

◆ IntegratorOrder()

template<class T_Equation , unsigned int N = 6>
G4int G4TCashKarpRKF45< T_Equation, N >::IntegratorOrder ( ) const
inlineoverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 94 of file G4TCashKarpRKF45.hh.

94{ return 4; }

◆ RightHandSideInl()

template<class T_Equation , unsigned int N = 6>
void G4TCashKarpRKF45< T_Equation, N >::RightHandSideInl ( const G4double  y[],
G4double  dydx[] 
)
inline

Definition at line 86 of file G4TCashKarpRKF45.hh.

88 {
89 fEquation_Rhs->T_Equation::RightHandSide(y, dydx);
90 }

◆ Stepper()

template<class T_Equation , unsigned int N>
void G4TCashKarpRKF45< T_Equation, N >::Stepper ( const G4double  yInput[],
const G4double  dydx[],
G4double  hstep,
G4double  yOutput[],
G4double  yError[] 
)
inlinefinaloverridevirtual

Implements G4MagIntegratorStepper.

Definition at line 307 of file G4TCashKarpRKF45.hh.

312{
313 assert( yOutput != yInput );
314 assert( yError != yInput );
315
316 StepWithError( yInput, dydx, Step, yOutput, yError);
317}
void StepWithError(const G4double yInput[], const G4double dydx[], G4double Step, G4double yOut[], G4double yErr[])

◆ StepWithError()

template<class T_Equation , unsigned int N = 6>
void G4TCashKarpRKF45< T_Equation, N >::StepWithError ( const G4double  yInput[],
const G4double  dydx[],
G4double  Step,
G4double  yOut[],
G4double  yErr[] 
)
inline

Definition at line 171 of file G4TCashKarpRKF45.hh.

176{
177 // const G4double a2 = 0.2 , a3 = 0.3 , a4 = 0.6 , a5 = 1.0 , a6 = 0.875;
178
179 const G4double b21 = 0.2, b31 = 3.0 / 40.0, b32 = 9.0 / 40.0, b41 = 0.3,
180 b42 = -0.9, b43 = 1.2,
181
182 b51 = -11.0 / 54.0, b52 = 2.5, b53 = -70.0 / 27.0,
183 b54 = 35.0 / 27.0,
184
185 b61 = 1631.0 / 55296.0, b62 = 175.0 / 512.0,
186 b63 = 575.0 / 13824.0, b64 = 44275.0 / 110592.0,
187 b65 = 253.0 / 4096.0,
188
189 c1 = 37.0 / 378.0, c3 = 250.0 / 621.0, c4 = 125.0 / 594.0,
190 c6 = 512.0 / 1771.0, dc5 = -277.0 / 14336.0;
191
192 const G4double dc1 = c1 - 2825.0 / 27648.0, dc3 = c3 - 18575.0 / 48384.0,
193 dc4 = c4 - 13525.0 / 55296.0, dc6 = c6 - 0.25;
194
195 // Initialise time to t0, needed when it is not updated by the integration.
196 // [ Note: Only for time dependent fields (usually electric)
197 // is it neccessary to integrate the time.]
198 // yOut[7] = yTemp[7] = yIn[7];
199
200 // Saving yInput because yInput and yOut can be aliases for same array
201 for(unsigned int i = 0; i < N; ++i)
202 {
203 yIn[i] = yInput[i];
204 }
205 // RightHandSideInl(yIn, dydx) ; // 1st Step
206
207 for(unsigned int i = 0; i < N; ++i)
208 {
209 yTemp[i] = yIn[i] + b21 * Step * dydx[i];
210 }
211 this->RightHandSideInl(yTemp, ak2); // 2nd Step
212
213 for(unsigned int i = 0; i < N; ++i)
214 {
215 yTemp[i] = yIn[i] + Step * (b31 * dydx[i] + b32 * ak2[i]);
216 }
217 this->RightHandSideInl(yTemp, ak3); // 3rd Step
218
219 for(unsigned int i = 0; i < N; ++i)
220 {
221 yTemp[i] = yIn[i] + Step * (b41 * dydx[i] + b42 * ak2[i] + b43 * ak3[i]);
222 }
223 this->RightHandSideInl(yTemp, ak4); // 4th Step
224
225 for(unsigned int i = 0; i < N; ++i)
226 {
227 yTemp[i] = yIn[i] + Step * (b51 * dydx[i] + b52 * ak2[i] + b53 * ak3[i] +
228 b54 * ak4[i]);
229 }
230 this->RightHandSideInl(yTemp, ak5); // 5th Step
231
232 for(unsigned int i = 0; i < N; ++i)
233 {
234 yTemp[i] = yIn[i] + Step * (b61 * dydx[i] + b62 * ak2[i] + b63 * ak3[i] +
235 b64 * ak4[i] + b65 * ak5[i]);
236 }
237 this->RightHandSideInl(yTemp, ak6); // 6th Step
238
239 for(unsigned int i = 0; i < N; ++i)
240 {
241 // Accumulate increments with proper weights
242
243 yOut[i] = yIn[i] +
244 Step * (c1 * dydx[i] + c3 * ak3[i] + c4 * ak4[i] + c6 * ak6[i]);
245 }
246 for(unsigned int i = 0; i < N; ++i)
247 {
248 // Estimate error as difference between 4th and
249 // 5th order methods
250
251 yErr[i] = Step * (dc1 * dydx[i] + dc3 * ak3[i] + dc4 * ak4[i] +
252 dc5 * ak5[i] + dc6 * ak6[i]);
253 }
254 for(unsigned int i = 0; i < N; ++i)
255 {
256 // Store Input and Final values, for possible use in calculating chord
257 fLastInitialVector[i] = yIn[i];
258 fLastFinalVector[i] = yOut[i];
259 fLastDyDx[i] = dydx[i];
260 }
261 // NormaliseTangentVector( yOut ); // Not wanted
262
263 fLastStepLength = Step;
264
265 return;
266}
void RightHandSideInl(const G4double y[], G4double dydx[])

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