Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
MediumMagboltz.hh
Go to the documentation of this file.
1#ifndef G_MEDIUM_MAGBOLTZ_9
2#define G_MEDIUM_MAGBOLTZ_9
3
4#include "MediumGas.hh"
5
6namespace Garfield {
7
8/// Interface to %Magboltz (version 9).
9/// - http://magboltz.web.cern.ch/magboltz/
10
11class MediumMagboltz : public MediumGas {
12
13 public:
14 // Constructor
16 // Destructor
17 virtual ~MediumMagboltz() {}
18
19 // Set/get the highest electron energy to be included
20 // in the scattering rates table
21 bool SetMaxElectronEnergy(const double e);
22 double GetMaxElectronEnergy() const { return m_eFinal; }
23
24 // Set/get the highest photon energy to be included
25 // in the scattering rates table
26 bool SetMaxPhotonEnergy(const double e);
27 double GetMaxPhotonEnergy() const { return m_eFinalGamma; }
28
29 // Switch on/off automatic adjustment of max. energy when an
30 // energy exceeding the present range is requested
31 void EnableEnergyRangeAdjustment() { m_useAutoAdjust = true; }
32 void DisableEnergyRangeAdjustment() { m_useAutoAdjust = false; }
33
34 // Switch on/off anisotropic scattering (enabled by default)
36 m_useAnisotropic = true;
37 m_isChanged = true;
38 }
40 m_useAnisotropic = false;
41 m_isChanged = true;
42 }
43
44 // Select secondary electron energy distribution parameterization
48
49 // Switch on/off de-excitation handling
50 void EnableDeexcitation();
51 void DisableDeexcitation() { m_useDeexcitation = false; }
52 // Switch on/off discrete photoabsorption levels
54 void DisableRadiationTrapping() { m_useRadTrap = false; }
55
56 // Switch on/off simplified simulation of Penning transfers by means of
57 // transfer probabilities (not compatible with de-excitation handling)
58 void EnablePenningTransfer(const double r, const double lambda);
59 void EnablePenningTransfer(const double r, const double lambda,
60 std::string gasname);
62 void DisablePenningTransfer(std::string gasname);
63
64 // When enabled, the gas cross-section table is written to file
65 // when loaded into memory.
66 void EnableCrossSectionOutput() { m_useCsOutput = true; }
67 void DisableCrossSectionOutput() { m_useCsOutput = false; }
68
69 // Multiply excitation cross-sections by a uniform scaling factor
70 void SetExcitationScalingFactor(const double r, std::string gasname);
71
72 bool Initialise(const bool verbose = false);
73 void PrintGas();
74
75 // Get the overall null-collision rate [ns-1]
76 double GetElectronNullCollisionRate(const int band);
77 // Get the (real) collision rate [ns-1] at a given electron energy e [eV]
78 double GetElectronCollisionRate(const double e, const int band);
79 // Get the collision rate [ns-1] for a specific level
80 double GetElectronCollisionRate(const double e, const unsigned int level,
81 const int band);
82 // Sample the collision type
83 bool GetElectronCollision(const double e, int& type, int& level, double& e1,
84 double& dx, double& dy, double& dz, int& nion,
85 int& ndxc, int& band);
86 unsigned int GetNumberOfIonisationProducts() const {
87 return m_ionProducts.size();
88 }
89 bool GetIonisationProduct(const unsigned int i, int& type,
90 double& energy) const;
91 void ComputeDeexcitation(int iLevel, int& fLevel);
92 unsigned int GetNumberOfDeexcitationProducts() const {
93 return m_dxcProducts.size();
94 }
95 bool GetDeexcitationProduct(const unsigned int i, double& t, double& s,
96 int& type, double& energy) const;
97
98 double GetPhotonCollisionRate(const double e);
99 bool GetPhotonCollision(const double e, int& type, int& level, double& e1,
100 double& ctheta, int& nsec, double& esec);
101
102 // Reset the collision counters
104 // Get total number of electron collisions
105 unsigned int GetNumberOfElectronCollisions() const;
106 // Get number of collisions broken down by cross-section type
107 unsigned int GetNumberOfElectronCollisions(int& nElastic, int& nIonising,
108 int& nAttachment, int& nInelastic,
109 int& nExcitation,
110 int& nSuperelastic) const;
111 // Get number of cross-section terms
112 int GetNumberOfLevels();
113 // Get detailed information about a given cross-section term i
114 bool GetLevel(const unsigned int i, int& ngas, int& type, std::string& descr,
115 double& e);
116 // Get number of collisions for a specific cross-section term
117 unsigned int GetNumberOfElectronCollisions(const unsigned int level) const;
118
119 int GetNumberOfPenningTransfers() const { return m_nPenning; }
120
121 // Get total number of photon collisions
122 int GetNumberOfPhotonCollisions() const;
123 // Get number of photon collisions by collision type
124 int GetNumberOfPhotonCollisions(int& nElastic, int& nIonising,
125 int& nInelastic) const;
126
127 void RunMagboltz(const double e, const double b, const double btheta,
128 const int ncoll, bool verbose, double& vx, double& vy,
129 double& vz, double& dl, double& dt,
130 double& alpha, double& eta, double& lor,
131 double& vxerr, double& vyerr, double& vzerr,
132 double& dlerr, double& dterr,
133 double& alphaerr, double& etaerr, double& lorerr,
134 double& alphatof);
135
136 // Generate a new gas table (can later be saved to file)
137 void GenerateGasTable(const int numCollisions = 10,
138 const bool verbose = true);
139
148
149 private:
150 static const int nEnergySteps = 20000;
151 static const int nEnergyStepsLog = 200;
152 static const int nEnergyStepsGamma = 5000;
153 static const int nMaxInelasticTerms = 250;
154 static const int nMaxLevels = 512;
155 static const int nCsTypes = 6;
156 static const int nCsTypesGamma = 4;
157
158 static const int DxcTypeRad;
159 static const int DxcTypeCollIon;
160 static const int DxcTypeCollNonIon;
161
162 // Energy spacing of collision rate tables
163 double m_eFinal, m_eStep;
164 double m_eHigh, m_eHighLog;
165 double m_lnStep;
166 bool m_useAutoAdjust;
167
168 // Flag enabling/disabling output of cross-section table to file
169 bool m_useCsOutput;
170 // Number of different cross-section types in the current gas mixture
171 unsigned int m_nTerms;
172 // Recoil energy parameter
173 double m_rgas[m_nMaxGases];
174 // Opal-Beaty-Peterson splitting parameter [eV]
175 double m_wOpalBeaty[nMaxLevels];
176 // Green-Sawada splitting parameters [eV]
177 double m_gsGreenSawada[m_nMaxGases];
178 double m_gbGreenSawada[m_nMaxGases];
179 double m_tsGreenSawada[m_nMaxGases];
180 double m_taGreenSawada[m_nMaxGases];
181 double m_tbGreenSawada[m_nMaxGases];
182 bool m_hasGreenSawada[m_nMaxGases];
183 // Energy loss
184 double m_energyLoss[nMaxLevels];
185 // Cross-section type
186 int m_csType[nMaxLevels];
187 // Parameters for calculation of scattering angles
188 bool m_useAnisotropic;
189 double m_scatParameter[nEnergySteps][nMaxLevels];
190 double m_scatParameterLog[nEnergyStepsLog][nMaxLevels];
191 int m_scatModel[nMaxLevels];
192 double m_scatCut[nEnergySteps][nMaxLevels];
193 double m_scatCutLog[nEnergyStepsLog][nMaxLevels];
194
195 // Level description
196 char m_description[nMaxLevels][50];
197
198 // Total collision frequency
199 double m_cfTot[nEnergySteps];
200 double m_cfTotLog[nEnergyStepsLog];
201 // Null-collision frequency
202 double m_cfNull;
203 // Collision frequencies
204 double m_cf[nEnergySteps][nMaxLevels];
205 double m_cfLog[nEnergyStepsLog][nMaxLevels];
206
207 // Collision counters
208 // 0: elastic
209 // 1: ionisation
210 // 2: attachment
211 // 3: inelastic
212 // 4: excitation
213 // 5: super-elastic
214 unsigned int m_nCollisions[nCsTypes];
215 // Number of collisions for each cross-section term
216 std::vector<unsigned int> m_nCollisionsDetailed;
217
218 // Penning transfer
219 // Penning transfer probability (by level)
220 double m_rPenning[nMaxLevels];
221 // Mean distance of Penning ionisation (by level)
222 double m_lambdaPenning[nMaxLevels];
223 // Number of Penning ionisations
224 unsigned int m_nPenning;
225
226 // Deexcitation
227 // Flag enabling/disabling detailed simulation of de-excitation process
228 bool m_useDeexcitation;
229 // Flag enabling/disable radiation trapping
230 // (absorption of photons discrete excitation lines)
231 bool m_useRadTrap;
232
233 struct deexcitation {
234 // Gas component
235 int gas;
236 // Associated cross-section term
237 int level;
238 // Level description
239 std::string label;
240 // Energy
241 double energy;
242 // Number of de-excitation channels
243 int nChannels;
244 // Branching ratios
245 std::vector<double> p;
246 // Final levels
247 std::vector<int> final;
248 // Type of transition
249 std::vector<int> type;
250 // Oscillator strength
251 double osc;
252 // Total decay rate
253 double rate;
254 // Doppler broadening
255 double sDoppler;
256 // Pressure broadening
257 double gPressure;
258 // Effective width
259 double width;
260 // Integrated absorption collision rate
261 double cf;
262 };
263 std::vector<deexcitation> m_deexcitations;
264 // Mapping between deexcitations and cross-section terms.
265 int m_iDeexcitation[nMaxLevels];
266
267 // List of ionisation products.
268 struct ionProd {
269 int type;
270 double energy;
271 };
272 std::vector<ionProd> m_ionProducts;
273
274 // List of de-excitation products
275 int nDeexcitationProducts;
276 struct dxcProd {
277 // Radial spread
278 double s;
279 // Time delay
280 double t;
281 // Type of deexcitation product
282 int type;
283 // Energy of the electron or photon
284 double energy;
285 };
286 std::vector<dxcProd> m_dxcProducts;
287
288 // Ionisation potentials
289 double m_ionPot[m_nMaxGases];
290 // Minimum ionisation potential
291 double m_minIonPot;
292
293 // Scaling factor for excitation cross-sections
294 double m_scaleExc[m_nMaxGases];
295 // Flag selecting secondary electron energy distribution model
296 bool m_useOpalBeaty;
297 bool m_useGreenSawada;
298
299 // Energy spacing of photon collision rates table
300 double m_eFinalGamma, m_eStepGamma;
301 // Number of photon collision cross-section terms
302 int nPhotonTerms;
303 // Total photon collision frequencies
304 std::vector<double> m_cfTotGamma;
305 // Photon collision frequencies
306 std::vector<std::vector<double> > m_cfGamma;
307 std::vector<int> csTypeGamma;
308 // Photon collision counters
309 // 0: elastic
310 // 1: ionisation
311 // 2: inelastic
312 // 3: excitation
313 int m_nPhotonCollisions[nCsTypesGamma];
314
315 bool GetGasNumberMagboltz(const std::string& input, int& number) const;
316 bool Mixer(const bool verbose = false);
317 void SetupGreenSawada();
318 void ComputeAngularCut(const double parIn, double& cut, double& parOut) const;
319 void ComputeDeexcitationTable(const bool verbose);
320 void ComputeDeexcitationInternal(int iLevel, int& fLevel);
321 bool ComputePhotonCollisionTable(const bool verbose);
322};
323}
324#endif
Base class for gas media.
Definition: MediumGas.hh:13
static const unsigned int m_nMaxGases
Definition: MediumGas.hh:87
int GetNumberOfPhotonCollisions() const
void SetExcitationScalingFactor(const double r, std::string gasname)
bool GetLevel(const unsigned int i, int &ngas, int &type, std::string &descr, double &e)
unsigned int GetNumberOfElectronCollisions() const
bool GetIonisationProduct(const unsigned int i, int &type, double &energy) const
void EnablePenningTransfer(const double r, const double lambda)
void ComputeDeexcitation(int iLevel, int &fLevel)
unsigned int GetNumberOfDeexcitationProducts() const
void GenerateGasTable(const int numCollisions=10, const bool verbose=true)
double GetMaxElectronEnergy() const
void RunMagboltz(const double e, const double b, const double btheta, const int ncoll, bool verbose, double &vx, double &vy, double &vz, double &dl, double &dt, double &alpha, double &eta, double &lor, double &vxerr, double &vyerr, double &vzerr, double &dlerr, double &dterr, double &alphaerr, double &etaerr, double &lorerr, double &alphatof)
double GetMaxPhotonEnergy() const
bool SetMaxPhotonEnergy(const double e)
bool GetElectronCollision(const double e, int &type, int &level, double &e1, double &dx, double &dy, double &dz, int &nion, int &ndxc, int &band)
unsigned int GetNumberOfIonisationProducts() const
double GetElectronNullCollisionRate(const int band)
int GetNumberOfPenningTransfers() const
bool Initialise(const bool verbose=false)
bool GetDeexcitationProduct(const unsigned int i, double &t, double &s, int &type, double &energy) const
double GetPhotonCollisionRate(const double e)
bool SetMaxElectronEnergy(const double e)
double GetElectronCollisionRate(const double e, const int band)
bool GetPhotonCollision(const double e, int &type, int &level, double &e1, double &ctheta, int &nsec, double &esec)
bool m_isChanged
Definition: Medium.hh:326