Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
examples
extended
field
field02
src
F02ElectricFieldSetup.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
//
28
//
29
// $Id$
30
//
31
// User Field class implementation.
32
//
33
34
#include "
F02ElectricFieldSetup.hh
"
35
#include "
F02FieldMessenger.hh
"
36
37
#include "
G4UniformElectricField.hh
"
38
#include "
G4UniformMagField.hh
"
39
#include "
G4MagneticField.hh
"
40
#include "
G4FieldManager.hh
"
41
#include "
G4TransportationManager.hh
"
42
#include "
G4EquationOfMotion.hh
"
43
#include "
G4EqMagElectricField.hh
"
44
#include "
G4Mag_UsualEqRhs.hh
"
45
#include "
G4MagIntegratorStepper.hh
"
46
#include "
G4MagIntegratorDriver.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
60
#include "
G4PhysicalConstants.hh
"
61
#include "
G4SystemOfUnits.hh
"
62
63
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
64
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65
66
//
67
// Constructors:
68
69
F02ElectricFieldSetup::F02ElectricFieldSetup
()
70
: fFieldManager(0),
71
fChordFinder(0),
72
fEquation(0),
73
fEMfield(0),
74
fElFieldValue(),
75
fStepper(0),
76
fIntgrDriver(0),
77
fStepperType(4),
// ClassicalRK4 -- the default stepper
78
fMinStep(0.010*
mm
)
// minimal step of 10 microns
79
{
80
fEMfield =
new
G4UniformElectricField
(
81
G4ThreeVector
(0.0,100000.0*
kilovolt
/
cm
,0.0));
82
fEquation =
new
G4EqMagElectricField
(fEMfield);
83
84
fFieldManager =
GetGlobalFieldManager
();
85
fFieldMessenger =
new
F02FieldMessenger
(
this
) ;
86
UpdateField
();
87
}
88
89
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
90
91
F02ElectricFieldSetup::F02ElectricFieldSetup
(
G4ThreeVector
fieldVector)
92
: fFieldManager(0),
93
fChordFinder(0),
94
fEquation(0),
95
fEMfield(0),
96
fElFieldValue(),
97
fStepper(0),
98
fIntgrDriver(0),
99
fStepperType(4),
// ClassicalRK4 -- the default stepper
100
fMinStep(0.010*
mm
)
// minimal step of 10 microns
101
{
102
fEMfield =
new
G4UniformElectricField
(fieldVector);
103
// GetGlobalFieldManager()->CreateChordFinder(this);
104
fEquation =
new
G4EqMagElectricField
(fEMfield);
105
106
fFieldManager =
GetGlobalFieldManager
();
107
fFieldMessenger =
new
F02FieldMessenger
(
this
) ;
108
UpdateField
();
109
}
110
111
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
113
114
F02ElectricFieldSetup::~F02ElectricFieldSetup
()
115
{
116
if
(fChordFinder)
delete
fChordFinder;
117
if
(fStepper)
delete
fStepper;
118
if
(fEquation)
delete
fEquation;
119
if
(fEMfield)
delete
fEMfield;
120
}
121
122
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
123
124
void
F02ElectricFieldSetup::UpdateField
()
125
{
126
// Register this field to 'global' Field Manager and
127
// Create Stepper and Chord Finder with predefined type, minstep (resp.)
128
129
SetStepper
();
130
131
G4cout
<<
"The minimal step is equal to "
<<fMinStep/
mm
<<
" mm"
<<
G4endl
;
132
133
fFieldManager->
SetDetectorField
(fEMfield );
134
135
if
(fChordFinder)
delete
fChordFinder;
136
// fChordFinder = new G4ChordFinder( fEMfield, fMinStep, fStepper);
137
138
fIntgrDriver =
new
G4MagInt_Driver
(fMinStep,
139
fStepper,
140
fStepper->
GetNumberOfVariables
());
141
142
fChordFinder =
new
G4ChordFinder
(fIntgrDriver);
143
144
fFieldManager->
SetChordFinder
(fChordFinder);
145
}
146
147
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
148
149
void
F02ElectricFieldSetup::SetStepper
()
150
{
151
// Set stepper according to the stepper type
152
153
G4int
nvar = 8;
154
155
if
(fStepper)
delete
fStepper;
156
157
switch
( fStepperType )
158
{
159
case
0:
160
fStepper =
new
G4ExplicitEuler
( fEquation, nvar );
161
G4cout
<<
"G4ExplicitEuler is calledS"
<<
G4endl
;
162
break
;
163
case
1:
164
fStepper =
new
G4ImplicitEuler
( fEquation, nvar );
165
G4cout
<<
"G4ImplicitEuler is called"
<<
G4endl
;
166
break
;
167
case
2:
168
fStepper =
new
G4SimpleRunge
( fEquation, nvar );
169
G4cout
<<
"G4SimpleRunge is called"
<<
G4endl
;
170
break
;
171
case
3:
172
fStepper =
new
G4SimpleHeum
( fEquation, nvar );
173
G4cout
<<
"G4SimpleHeum is called"
<<
G4endl
;
174
break
;
175
case
4:
176
fStepper =
new
G4ClassicalRK4
( fEquation, nvar );
177
G4cout
<<
"G4ClassicalRK4 (default) is called"
<<
G4endl
;
178
break
;
179
case
5:
180
fStepper =
new
G4CashKarpRKF45
( fEquation, nvar );
181
G4cout
<<
"G4CashKarpRKF45 is called"
<<
G4endl
;
182
break
;
183
case
6:
184
fStepper = 0;
// new G4RKG3_Stepper( fEquation, nvar );
185
G4cout
<<
"G4RKG3_Stepper is not currently working for Electric Field"
<<
G4endl
;
186
break
;
187
case
7:
188
fStepper = 0;
// new G4HelixExplicitEuler( fEquation );
189
G4cout
<<
"G4HelixExplicitEuler is not valid for Electric Field"
<<
G4endl
;
190
break
;
191
case
8:
192
fStepper = 0;
// new G4HelixImplicitEuler( fEquation );
193
G4cout
<<
"G4HelixImplicitEuler is not valid for Electric Field"
<<
G4endl
;
194
break
;
195
case
9:
196
fStepper = 0;
// new G4HelixSimpleRunge( fEquation );
197
G4cout
<<
"G4HelixSimpleRunge is not valid for Electric Field"
<<
G4endl
;
198
break
;
199
default
: fStepper = 0;
200
}
201
}
202
203
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
204
205
void
F02ElectricFieldSetup::SetFieldValue
(
G4double
fieldValue)
206
{
207
// Set the value of the Global Field to fieldValue along Z
208
209
G4ThreeVector
fieldVector( 0.0, 0.0, fieldValue );
210
211
SetFieldValue
( fieldVector );
212
}
213
214
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
215
216
void
F02ElectricFieldSetup::SetFieldValue
(
G4ThreeVector
fieldVector)
217
{
218
// Set the value of the Global Field value to fieldVector
219
220
// Find the Field Manager for the global field
221
G4FieldManager
* fieldMgr=
GetGlobalFieldManager
();
222
223
if
(fieldVector !=
G4ThreeVector
(0.,0.,0.))
224
{
225
if
(fEMfield)
delete
fEMfield;
226
fEMfield =
new
G4UniformElectricField
(fieldVector);
227
228
fEquation->
SetFieldObj
(fEMfield);
// must now point to the new field
229
230
// UpdateField();
231
232
fieldMgr->
SetDetectorField
(fEMfield);
233
}
234
else
235
{
236
// If the new field's value is Zero, then it is best to
237
// insure that it is not used for propagation.
238
if
(fEMfield)
delete
fEMfield;
239
fEMfield = 0;
240
fEquation->
SetFieldObj
(fEMfield);
// As a double check ...
241
fieldMgr->
SetDetectorField
(fEMfield);
242
}
243
}
244
245
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
246
247
G4FieldManager
*
F02ElectricFieldSetup::GetGlobalFieldManager
()
248
{
249
// Utility method
250
251
return
G4TransportationManager::GetTransportationManager
()
252
->
GetFieldManager
();
253
}
254
255
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
Generated on Sat May 25 2013 14:32:25 for Geant4 by
1.8.4