Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
F03FieldSetup.cc
이 파일의 문서화 페이지로 가기
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 //
28 //
29 //
30 // $Id: F03FieldSetup.cc 109870 2018-05-09 12:39:45Z gcosmo $
31 //
32 //
33 // Field Setup class implementation.
34 //
35 //
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
39 #include "F03FieldSetup.hh"
40 #include "F03FieldMessenger.hh"
41 
42 #include "G4MagneticField.hh"
43 #include "G4UniformMagField.hh"
44 #include "G4FieldManager.hh"
46 #include "G4Mag_UsualEqRhs.hh"
48 #include "G4ChordFinder.hh"
49 
50 #include "G4ExplicitEuler.hh"
51 #include "G4ImplicitEuler.hh"
52 #include "G4SimpleRunge.hh"
53 #include "G4SimpleHeum.hh"
54 #include "G4ClassicalRK4.hh"
55 #include "G4HelixExplicitEuler.hh"
56 #include "G4HelixImplicitEuler.hh"
57 #include "G4HelixSimpleRunge.hh"
58 #include "G4CashKarpRKF45.hh"
59 #include "G4RKG3_Stepper.hh"
60 
61 #include "G4PhysicalConstants.hh"
62 #include "G4SystemOfUnits.hh"
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67  : fFieldManager(0),
68  fLocalFieldManager(0),
69  fChordFinder(0),
70  fLocalChordFinder(0),
71  fEquation(0),
72  fLocalEquation(0),
73  fMagneticField(0),
74  fLocalMagneticField(0),
75  fStepper(0),
76  fLocalStepper(0),
77  fFieldMessenger(0)
78 {
80  0.0, // 0.5*tesla,
81  0.0));
83  0.0, // 0.5*tesla,
84  0.0));
85 
87 
90 
91  fMinStep = 0.25*mm ; // minimal step of 1 mm is default
92  fStepperType = 4 ; // ClassicalRK4 is default stepper
93 
96 
97  UpdateField();
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  delete fMagneticField;
105  delete fChordFinder;
106  delete fStepper;
107  delete fFieldMessenger;
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
113 {
114  // It must be possible to call 'again' - e.g. to choose an alternative stepper
115  // has been chosen, or in case other changes have been made.
116 
117  // 1. First clean up previous state.
118  delete fChordFinder;
119  fChordFinder= nullptr;
120  delete fLocalChordFinder;
121  fLocalChordFinder= nullptr;
122 
123  G4cout<<"F03FieldSetup::UpdateField> The minimal step is equal to "
124  << fMinStep/mm <<" mm"<<G4endl;
125  G4cout<<" Stepper Type chosen = " << fStepperType
126  << G4endl;
127 
128  // 2. Create the steppers ( Note: this also deletes the previous ones. )
129  CreateSteppers();
130 
131 
132  // 3. Create the chord finder(s)
136 
139 
140  // 4. Ensure that the field is updated (in Field manager & equation)
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 {
149  delete fStepper;
150  fStepper= nullptr;
151 
152  delete fLocalStepper;
153  fLocalStepper= nullptr;
154 
155  switch ( fStepperType )
156  {
157  case 0:
160  G4cout<<"G4ExplicitEuler is called"<<G4endl;
161  break;
162  case 1:
165  G4cout<<"G4ImplicitEuler is called"<<G4endl;
166  break;
167  case 2:
170  G4cout<<"G4SimpleRunge is called"<<G4endl;
171  break;
172  case 3:
175  G4cout<<"G4SimpleHeum is called"<<G4endl;
176  break;
177  case 4:
180  G4cout<<"G4ClassicalRK4 (default) is called"<<G4endl;
181  break;
182  case 5:
185  G4cout<<"G4HelixExplicitEuler is called"<<G4endl;
186  break;
187  case 6:
190  G4cout<<"G4HelixImplicitEuler is called"<<G4endl;
191  break;
192  case 7:
195  G4cout<<"G4HelixSimpleRunge is called"<<G4endl;
196  break;
197  case 8:
200  G4cout<<"G4CashKarpRKF45 is called"<<G4endl;
201  break;
202  case 9:
205  G4cout<<"G4RKG3_Stepper is called"<<G4endl;
206  break;
207  default: fStepper = 0;
208  }
209 }
210 
211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
212 
214 {
215  G4ThreeVector fieldSetVec(0.0, 0.0, fieldStrength);
216  SetFieldValue( fieldSetVec );
217 }
218 
219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
220 
222 {
223  if(fMagneticField) delete fMagneticField;
224 
225  if(fieldVector != G4ThreeVector(0.,0.,0.))
226  {
227  fMagneticField = new G4UniformMagField(fieldVector);
228  }
229  else
230  {
231  // If the new field's value is Zero, then
232  // setting the pointer to zero ensures
233  // that it is not used for propagation.
234  fMagneticField = 0;
235  }
236 
237  // Either
238  // - UpdateField() to reset all (ChordFinder, Equation);
239  // UpdateField();
240  // or simply update the field manager & equation of motion
241  // with pointer to new field
244 
245 }
246 
247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
248 
250 {
252  ->GetFieldManager();
253 }
254 
255 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
256 
258 {
259  static G4double fieldValue[6], position[4];
260  position[0] = position[1] = position[2] = position[3] = 0.0;
261 
262  fMagneticField->GetFieldValue( position, fieldValue);
263  G4ThreeVector fieldVec(fieldValue[0], fieldValue[1], fieldValue[2]);
264 
265  return fieldVec;
266 }
267 
268 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CLHEP::Hep3Vector G4ThreeVector
Definition of the F03FieldMessenger class.
void CreateSteppers()
static constexpr double mm
Definition: G4SIunits.hh:115
G4double fMinStep
#define G4endl
Definition: G4ios.hh:61
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0
G4FieldManager * fFieldManager
void SetFieldObj(G4Field *pField)
G4Mag_UsualEqRhs * fEquation
G4bool SetDetectorField(G4Field *detectorField, int failMode=0)
G4MagneticField * fMagneticField
G4ChordFinder * fLocalChordFinder
double G4double
Definition: G4Types.hh:76
G4FieldManager * GetFieldManager() const
G4MagIntegratorStepper * fStepper
void SetFieldValue(G4ThreeVector fieldVector)
G4MagneticField * fLocalMagneticField
G4ThreeVector GetConstantFieldValue()
static G4TransportationManager * GetTransportationManager()
F03FieldMessenger * fFieldMessenger
void SetChordFinder(G4ChordFinder *aChordFinder)
G4FieldManager * GetGlobalFieldManager()
G4Mag_UsualEqRhs * fLocalEquation
Definition of the F03FieldSetup class.
G4ChordFinder * fChordFinder
G4FieldManager * fLocalFieldManager
virtual ~F03FieldSetup()
G4MagIntegratorStepper * fLocalStepper
G4GLOB_DLL std::ostream G4cout
static constexpr double tesla
Definition: G4SIunits.hh:268