Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HelixExplicitEuler.cc
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// G4HelixExplicitEuler implementation
27//
28// Helix Explicit Euler: x_1 = x_0 + helix(h)
29// with helix(h) being a helix piece of length h.
30// Most simple approach for solving linear differential equations.
31// Take the current derivative and add it to the current position.
32//
33// Author: W.Wander (MIT), 03.11.1998
34// -------------------------------------------------------------------
35
38#include "G4ThreeVector.hh"
39
44
45void G4HelixExplicitEuler::Stepper( const G4double yInput[], // [7]
46 const G4double*,
47 G4double Step,
48 G4double yOut[], // [7]
49 G4double yErr[] )
50{
51 // Estimation of the Stepping Angle
52 //
53 G4ThreeVector Bfld;
54 MagFieldEvaluate(yInput, Bfld);
55
56 const G4int nvar = 6 ;
57 G4double yTemp[8], yIn[8] ;
58 G4ThreeVector Bfld_midpoint;
59
60 // Saving yInput because yInput and yOut can be aliases for same array
61 //
62 for(G4int i=0; i<nvar; ++i)
63 {
64 yIn[i] = yInput[i];
65 }
66
67 G4double h = Step * 0.5;
68
69 // Do full step and two half steps
70 //
71 G4double yTemp2[7];
72 AdvanceHelix(yIn, Bfld, h, yTemp2,yTemp);
73 MagFieldEvaluate(yTemp2, Bfld_midpoint) ;
74 AdvanceHelix(yTemp2, Bfld_midpoint, h, yOut);
76
77 // Error estimation
78 //
79 for(G4int i=0; i<nvar; ++i)
80 {
81 yErr[i] = yOut[i] - yTemp[i];
82 }
83}
84
86{
87 // Implementation : must check whether h/R > 2 pi !!
88 // If( h/R < pi) use G4LineSection::DistLine
89 // Else DistChord=R_helix
90 //
91 G4double distChord;
92 G4double Ang_curve=GetAngCurve();
93
94 if(Ang_curve<=pi)
95 {
96 distChord=GetRadHelix()*(1-std::cos(0.5*Ang_curve));
97 }
98 else if(Ang_curve<twopi)
99 {
100 distChord=GetRadHelix()*(1+std::cos(0.5*(twopi-Ang_curve)));
101 }
102 else
103 {
104 distChord=2.*GetRadHelix();
105 }
106
107 return distChord;
108}
109
111 G4ThreeVector Bfld,
112 G4double h,
113 G4double yOut[] )
114{
115 AdvanceHelix(yIn, Bfld, h, yOut);
116}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
void Stepper(const G4double y[], const G4double *na, G4double h, G4double yout[], G4double yerr[]) override
G4HelixExplicitEuler(G4Mag_EqRhs *EqRhs)
void DumbStepper(const G4double y[], G4ThreeVector Bfld, G4double h, G4double yout[]) override
G4double DistChord() const override
G4double GetRadHelix() const
void MagFieldEvaluate(const G4double y[], G4ThreeVector &Bfield)
G4MagHelicalStepper(G4Mag_EqRhs *EqRhs)
void AdvanceHelix(const G4double yIn[], const G4ThreeVector &Bfld, G4double h, G4double yHelix[], G4double yHelix2[]=nullptr)
void SetAngCurve(const G4double Ang)
G4double GetAngCurve() const
G4Mag_EqRhs is the "standard" equation of motion of a particle in a pure magnetic field.