Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
F01FieldSetup.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: F01FieldSetup.cc 104350 2017-05-26 07:20:25Z gcosmo $
31 //
32 // User Field setup class implementation.
33 //
34 //
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 
38 #include "F01FieldSetup.hh"
39 #include "F01FieldMessenger.hh"
40 
41 #include "G4MagneticField.hh"
42 #include "G4UniformMagField.hh"
43 #include "G4FieldManager.hh"
45 #include "G4Mag_UsualEqRhs.hh"
47 #include "G4ChordFinder.hh"
48 
49 #include "G4ExplicitEuler.hh"
50 #include "G4ImplicitEuler.hh"
51 #include "G4SimpleRunge.hh"
52 #include "G4SimpleHeum.hh"
53 #include "G4ClassicalRK4.hh"
54 #include "G4HelixExplicitEuler.hh"
55 #include "G4HelixImplicitEuler.hh"
56 #include "G4HelixSimpleRunge.hh"
57 #include "G4CashKarpRKF45.hh"
58 #include "G4RKG3_Stepper.hh"
59 #include "G4ConstRK4.hh"
60 #include "G4NystromRK4.hh"
61 #include "G4HelixMixedStepper.hh"
62 #include "G4ExactHelixStepper.hh"
63 
64 // Newest steppers - from Release 10.3-beta (June 2013)
65 #include "G4BogackiShampine23.hh"
66 #include "G4BogackiShampine45.hh"
67 #include "G4DormandPrince745.hh"
68 
69 #include "G4PhysicalConstants.hh"
70 #include "G4SystemOfUnits.hh"
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
74 // Constructors:
75 
77  : fFieldManager(0),
78  fChordFinder(0),
79  fEquation(0),
80  fMagneticField(new G4UniformMagField(fieldVector)),
81  fStepper(0),
82  fStepperType(0),
83  fMinStep(0.),
84  fFieldMessenger(0)
85 {
86  G4cout << " F01FieldSetup: magnetic field set to Uniform( "
87  << fieldVector << " ) " << G4endl;
88  InitialiseAll();
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94  : fFieldManager(0),
95  fChordFinder(0),
96  fEquation(0),
97  fMagneticField(new G4UniformMagField(G4ThreeVector())),
98  fStepper(0),
99  fStepperType(0),
100  fMinStep(0.),
101  fFieldMessenger(0)
102 {
103  G4cout << " F01FieldSetup: magnetic field set to Uniform( 0.0, 0, 0 ) "
104  << G4endl;
105  InitialiseAll();
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
111 {
113 
115 
116  fMinStep = 1.0*mm; // minimal step of 1 mm is default
117 
118  fStepperType = 4; // ClassicalRK4 is default stepper
119 
121  ->GetFieldManager();
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 
128 {
129  delete fMagneticField;
130  delete fChordFinder;
131  delete fStepper;
132  delete fFieldMessenger;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
138 {
139  delete fChordFinder;
140  fChordFinder= nullptr;
141 
142  // Update field
143  G4cout << " F01FieldSetup::CreateStepperAndChordFinder() called. " << G4endl
144  << " 1. Creating Stepper." << G4endl;
145 
146  SetStepper();
147  G4cout<<"The minimal step is equal to "<<fMinStep/mm<<" mm"<<G4endl;
148 
149  G4cout << " 2. Creating ChordFinder." << G4endl;
151 
152  G4cout << " 3. Updating Field Manager." << G4endl;
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158 
160 {
161 // Set stepper according to the stepper type
162 
163  if (fStepper) delete fStepper;
164 
165  switch ( fStepperType )
166  {
167  case 0:
169  G4cout<<"G4ExplicitEuler is chosen."<<G4endl;
170  break;
171  case 1:
173  G4cout<<"G4ImplicitEuler is chosen"<<G4endl;
174  break;
175  case 2:
177  G4cout<<"G4SimpleRunge is chosen"<<G4endl;
178  break;
179  case 3:
181  G4cout<<"G4SimpleHeum is chosen"<<G4endl;
182  break;
183  case 4:
185  G4cout<<"G4ClassicalRK4 (default) is chosen"<<G4endl;
186  break;
187  case 5:
189  G4cout<<"G4HelixExplicitEuler is chosen"<<G4endl;
190  break;
191  case 6:
193  G4cout<<"G4HelixImplicitEuler is chosen"<<G4endl;
194  break;
195  case 7:
197  G4cout<<"G4HelixSimpleRunge is chosen"<<G4endl;
198  break;
199  case 8:
201  G4cout<<"G4CashKarpRKF45 is chosen"<<G4endl;
202  break;
203  case 9:
205  G4cout<<"G4RKG3_Stepper is chosen"<<G4endl;
206  break;
207  case 10:
209  G4cout<<"G4ExactHelixStepper is chosen"<<G4endl;
210  break;
211  case 11:
213  G4cout<<"G4HelixMixedStepper is chosen"<<G4endl;
214  break;
215  case 12:
216  fStepper = new G4ConstRK4( fEquation );
217  G4cout<<"G4ConstRK4 Stepper is chosen"<<G4endl;
218  break;
219  case 13:
221  G4cout<<" G4NystromRK4 Stepper is chosen"<<G4endl;
222  break;
223  case 14:
224  case 23:
226  G4cout<<"G4BogackiShampine23 Stepper is chosen"<<G4endl;
227  break;
228  case 15:
229  case 45:
231  G4cout<<"G4BogackiShampine45 Stepper is chosen"<<G4endl;
232  break;
233  case 457:
234  case 745:
236  G4cout<<"G4DormandPrince745 Stepper is chosen"<<G4endl;
237  break;
238  default:
240  G4cout<<"G4ClassicalRK4 Stepper (default) is chosen"<<G4endl;
241  // fStepper = new G4DormandPrince745( fEquation );
242  // G4cout<<"G4DormandPrince745 (default) Stepper is chosen"<<G4endl;
243  break;
244  }
245 }
246 
247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
248 
250 {
251  // Set the value of the Global Field to fieldValue along Z
252 
253 #ifdef G4VERBOSE
254  G4cout << "Setting Field strength to "
255  << fieldStrength / gauss << " Gauss."; // << G4endl;
256 #endif
257 
258  G4ThreeVector fieldSetVec(0.0, 0.0, fieldStrength);
259  this->SetFieldValue( fieldSetVec );
260 
261 #ifdef G4VERBOSE
262  G4double fieldValue[6], position[4];
263  position[0] = position[1] = position[2] = position[3] = 0.0;
264  if ( fieldStrength != 0.0 ) {
265  fMagneticField->GetFieldValue( position, fieldValue);
266  G4ThreeVector fieldVec(fieldValue[0], fieldValue[1], fieldValue[2]);
267  // G4cout << " fMagneticField is now " << fMagneticField
268  G4cout << " Magnetic field vector is "
269  << fieldVec / gauss << " G " << G4endl;
270  } else {
271  if ( fMagneticField == 0 )
272  G4cout << " Magnetic field pointer is null." << G4endl;
273  else
274  G4Exception("F01FieldSetup::SetFieldValue(double)",
275  "IncorrectForZeroField",
277  "fMagneticField ptr should be set to 0 for no field.");
278  }
279 #endif
280 }
281 
282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
283 
285 {
286  // Set the value of the Global Field
287 
288  if (fMagneticField) delete fMagneticField;
289 
290  if (fieldVector != G4ThreeVector(0.,0.,0.))
291  {
292  fMagneticField = new G4UniformMagField(fieldVector);
293  }
294  else
295  {
296  // If the new field's value is Zero, signal it as below
297  // so that it is not used for propagation.
298  fMagneticField = 0;
299  }
300 
301  // Set this as the field of the global Field Manager
303 
304  // Now notify equation of new field
306 
307 }
308 
309 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
310 
312 {
313  // Utility method
314 
316  ->GetFieldManager();
317 }
318 
319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
CLHEP::Hep3Vector G4ThreeVector
F01FieldMessenger * fFieldMessenger
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
virtual void GetFieldValue(const G4double Point[4], G4double *Bfield) const =0
#define fMinStep
G4ChordFinder * fChordFinder
G4double fMinStep
G4MagIntegratorStepper * fStepper
void SetFieldObj(G4Field *pField)
G4bool SetDetectorField(G4Field *detectorField, int failMode=0)
void InitialiseAll()
void SetFieldValue(G4ThreeVector fieldVector)
double G4double
Definition: G4Types.hh:76
static constexpr double gauss
Definition: G4SIunits.hh:270
G4FieldManager * GetFieldManager() const
G4FieldManager * fFieldManager
void CreateStepperAndChordFinder()
virtual ~F01FieldSetup()
static G4TransportationManager * GetTransportationManager()
Definition of the F01FieldMessenger class.
G4FieldManager * GetGlobalFieldManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4Mag_UsualEqRhs * fEquation
void SetChordFinder(G4ChordFinder *aChordFinder)
Definition of the F01FieldSetup class.
G4MagneticField * fMagneticField
G4GLOB_DLL std::ostream G4cout