Garfield++ v1r0
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// Interface to Magboltz (version 9)
2
3#ifndef G_MEDIUM_MAGBOLTZ_9
4#define G_MEDIUM_MAGBOLTZ_9
5
6#include "MediumGas.hh"
7
8namespace Garfield {
9
10class MediumMagboltz : public MediumGas {
11
12 public:
13 // Constructor
15 // Destructor
17
18 // Set/get the highest electron energy to be included
19 // in the scattering rates table
20 bool SetMaxElectronEnergy(const double e);
21 double GetMaxElectronEnergy() const { return eFinal; }
22
23 // Set/get the highest photon energy to be included
24 // in the scattering rates table
25 bool SetMaxPhotonEnergy(const double e);
26 double GetMaxPhotonEnergy() const { return eFinalGamma; }
27
28 // Switch on/off automatic adjustment of max. energy when an
29 // energy exceeding the present range is requested
30 void EnableEnergyRangeAdjustment() { useAutoAdjust = true; }
31 void DisableEnergyRangeAdjustment() { useAutoAdjust = false; }
32
33 // Switch on/off anisotropic scattering (enabled by default)
35 useAnisotropic = true;
36 m_isChanged = true;
37 }
39 useAnisotropic = false;
40 m_isChanged = true;
41 }
42
43 // Select secondary electron energy distribution parameterization
47
48 // Switch on/off de-excitation handling
49 void EnableDeexcitation();
50 void DisableDeexcitation() { useDeexcitation = false; }
51 // Switch on/off discrete photoabsorption levels
53 void DisableRadiationTrapping() { useRadTrap = false; }
54
55 // Switch on/off simplified simulation of Penning transfers by means of
56 // transfer probabilities (not compatible with de-excitation handling)
57 void EnablePenningTransfer(const double r, const double lambda);
58 void EnablePenningTransfer(const double r, const double lambda,
59 std::string gasname);
61 void DisablePenningTransfer(std::string gasname);
62
63 // When enabled, the gas cross-section table is written to file
64 // when loaded into memory.
65 void EnableCrossSectionOutput() { useCsOutput = true; }
66 void DisableCrossSectionOutput() { useCsOutput = false; }
67
68 // Multiply excitation cross-sections by a uniform scaling factor
69 void SetExcitationScalingFactor(const double r, std::string gasname);
70
71 bool Initialise(const bool verbose = false);
72 void PrintGas();
73
74 // Get the overall null-collision rate [ns-1]
75 double GetElectronNullCollisionRate(const int band);
76 // Get the (real) collision rate [ns-1] at a given electron energy e [eV]
77 double GetElectronCollisionRate(const double e, const int band);
78 // Get the collision rate [ns-1] for a specific level
79 double GetElectronCollisionRate(const double e, const int level,
80 const int band);
81 // Sample the collision type
82 bool GetElectronCollision(const double e, int& type, int& level, double& e1,
83 double& dx, double& dy, double& dz, int& nion,
84 int& ndxc, int& band);
85 int GetNumberOfIonisationProducts() { return nIonisationProducts; }
86 bool GetIonisationProduct(const int i, int& type, double& energy);
87 void ComputeDeexcitation(int iLevel, int& fLevel);
88 int GetNumberOfDeexcitationProducts() { return nDeexcitationProducts; }
89 bool GetDeexcitationProduct(const int i, double& t, double& s, int& type,
90 double& energy);
91
92 double GetPhotonCollisionRate(const double& e);
93 bool GetPhotonCollision(const double e, int& type, int& level, double& e1,
94 double& ctheta, int& nsec, double& esec);
95
96 // Reset the collision counters
98 // Get total number of electron collisions
100 // Get number of collisions broken down by cross-section type
101 int GetNumberOfElectronCollisions(int& nElastic, int& nIonising,
102 int& nAttachment, int& nInelastic,
103 int& nExcitation, int& nSuperelastic) const;
104 // Get number of cross-section terms
105 int GetNumberOfLevels();
106 // Get detailed information about a given cross-section term i
107 bool GetLevel(const int i, int& ngas, int& type, std::string& descr,
108 double& e);
109 // Get number of collisions for a specific cross-section term
110 int GetNumberOfElectronCollisions(const int level) const;
111
112 int GetNumberOfPenningTransfers() const { return nPenning; }
113
114 // Get total number of photon collisions
115 int GetNumberOfPhotonCollisions() const;
116 // Get number of photon collisions by collision type
117 int GetNumberOfPhotonCollisions(int& nElastic, int& nIonising,
118 int& nInelastic) const;
119
120 void RunMagboltz(const double e, const double b, const double btheta,
121 const int ncoll, bool verbose, double& vx, double& vy,
122 double& vz, double& dl, double& dt, double& alpha,
123 double& eta, double& vxerr, double& vyerr, double& vzerr,
124 double& dlerr, double& dterr, double& alphaerr,
125 double& etaerr, double& alphatof);
126
127 // Generate a new gas table (can later be saved to file)
128 void GenerateGasTable(const int numCollisions = 10,
129 const bool verbose = true);
130
139
140 private:
141 static const int nEnergySteps = 20000;
142 static const int nEnergyStepsLog = 200;
143 static const int nEnergyStepsGamma = 5000;
144 static const int nMaxInelasticTerms = 250;
145 static const int nMaxLevels = 512;
146 static const int nCsTypes = 6;
147 static const int nCsTypesGamma = 4;
148
149 static const int DxcTypeRad;
150 static const int DxcTypeCollIon;
151 static const int DxcTypeCollNonIon;
152
153 // Energy spacing of collision rate tables
154 double eFinal, eStep;
155 double eHigh, eHighLog;
156 double lnStep;
157 bool useAutoAdjust;
158
159 // Flag enabling/disabling output of cross-section table to file
160 bool useCsOutput;
161 // Number of different cross-section types in the current gas mixture
162 int nTerms;
163 // Recoil energy parameter
164 double rgas[m_nMaxGases];
165 // Opal-Beaty-Peterson splitting parameter [eV]
166 double wOpalBeaty[nMaxLevels];
167 // Green-Sawada splitting parameters [eV]
168 double gsGreenSawada[m_nMaxGases];
169 double gbGreenSawada[m_nMaxGases];
170 double tsGreenSawada[m_nMaxGases];
171 double taGreenSawada[m_nMaxGases];
172 double tbGreenSawada[m_nMaxGases];
173 bool m_hasGreenSawada[m_nMaxGases];
174 // Energy loss
175 double energyLoss[nMaxLevels];
176 // Cross-section type
177 int csType[nMaxLevels];
178 // Parameters for calculation of scattering angles
179 bool useAnisotropic;
180 double scatParameter[nEnergySteps][nMaxLevels];
181 double scatParameterLog[nEnergyStepsLog][nMaxLevels];
182 int scatModel[nMaxLevels];
183 double scatCut[nEnergySteps][nMaxLevels];
184 double scatCutLog[nEnergyStepsLog][nMaxLevels];
185
186 // Level description
187 char description[nMaxLevels][50];
188
189 // Total collision frequency
190 double cfTot[nEnergySteps];
191 double cfTotLog[nEnergyStepsLog];
192 // Null-collision frequency
193 double cfNull;
194 // Collision frequencies
195 double cf[nEnergySteps][nMaxLevels];
196 double cfLog[nEnergyStepsLog][nMaxLevels];
197
198 // Collision counters
199 // 0: elastic
200 // 1: ionisation
201 // 2: attachment
202 // 3: inelastic
203 // 4: excitation
204 // 5: super-elastic
205 int nCollisions[nCsTypes];
206 // Number of collisions for each cross-section term
207 std::vector<int> nCollisionsDetailed;
208
209 // Penning transfer
210 // Penning transfer probability (by level)
211 double rPenning[nMaxLevels];
212 // Mean distance of Penning ionisation (by level)
213 double lambdaPenning[nMaxLevels];
214 // Number of Penning ionisations
215 int nPenning;
216
217 // Deexcitation
218 // Flag enabling/disabling detailed simulation of de-excitation process
219 bool useDeexcitation;
220 // Flag enabling/disable radiation trapping
221 // (absorption of photons discrete excitation lines)
222 bool useRadTrap;
223
224 int nDeexcitations;
225 struct deexcitation {
226 // Gas component
227 int gas;
228 // Associated cross-section term
229 int level;
230 // Level description
231 std::string label;
232 // Energy
233 double energy;
234 // Number of de-excitation channels
235 int nChannels;
236 // Branching ratios
237 std::vector<double> p;
238 // Final levels
239 std::vector<int> final;
240 // Type of transition
241 std::vector<int> type;
242 // Oscillator strength
243 double osc;
244 // Total decay rate
245 double rate;
246 // Doppler broadening
247 double sDoppler;
248 // Pressure broadening
249 double gPressure;
250 // Effective width
251 double width;
252 // Integrated absorption collision rate
253 double cf;
254 };
255 std::vector<deexcitation> deexcitations;
256 // Mapping between deexcitations and cross-section terms.
257 int iDeexcitation[nMaxLevels];
258
259 // List of ionisation products.
260 int nIonisationProducts;
261 struct ionProd {
262 int type;
263 double energy;
264 };
265 std::vector<ionProd> ionProducts;
266
267 // List of de-excitation products
268 int nDeexcitationProducts;
269 struct dxcProd {
270 // Radial spread
271 double s;
272 // Time delay
273 double t;
274 // Type of deexcitation product
275 int type;
276 // Energy of the electron or photon
277 double energy;
278 };
279 std::vector<dxcProd> dxcProducts;
280
281 // Ionisation potentials
282 double ionPot[m_nMaxGases];
283 // Minimum ionisation potential
284 double minIonPot;
285
286 // Scaling factor for excitation cross-sections
287 double scaleExc[m_nMaxGases];
288 // Flag selecting secondary electron energy distribution model
289 bool useOpalBeaty;
290 bool useGreenSawada;
291
292 // Energy spacing of photon collision rates table
293 double eFinalGamma, eStepGamma;
294 // Number of photon collision cross-section terms
295 int nPhotonTerms;
296 // Total photon collision frequencies
297 std::vector<double> cfTotGamma;
298 // Photon collision frequencies
299 std::vector<std::vector<double> > cfGamma;
300 std::vector<int> csTypeGamma;
301 // Photon collision counters
302 // 0: elastic
303 // 1: ionisation
304 // 2: inelastic
305 // 3: excitation
306 int nPhotonCollisions[nCsTypesGamma];
307
308 bool GetGasNumberMagboltz(const std::string input, int& number) const;
309 bool Mixer(const bool verbose = false);
310 void SetupGreenSawada();
311 void ComputeAngularCut(double parIn, double& cut, double& parOut);
312 void ComputeDeexcitationTable(const bool verbose);
313 void ComputeDeexcitationInternal(int iLevel, int& fLevel);
314 bool ComputePhotonCollisionTable(const bool verbose);
315};
316}
317#endif
static const unsigned int m_nMaxGases
Definition: MediumGas.hh:82
int GetNumberOfPhotonCollisions() const
void SetExcitationScalingFactor(const double r, std::string gasname)
bool GetDeexcitationProduct(const int i, double &t, double &s, int &type, double &energy)
bool GetIonisationProduct(const int i, int &type, double &energy)
void EnablePenningTransfer(const double r, const double lambda)
void ComputeDeexcitation(int iLevel, int &fLevel)
double GetPhotonCollisionRate(const double &e)
void GenerateGasTable(const int numCollisions=10, const bool verbose=true)
double GetMaxElectronEnergy() const
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)
double GetElectronNullCollisionRate(const int band)
int GetNumberOfPenningTransfers() const
bool Initialise(const bool verbose=false)
bool GetLevel(const int i, int &ngas, int &type, std::string &descr, double &e)
bool SetMaxElectronEnergy(const double e)
int GetNumberOfElectronCollisions() 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 &vxerr, double &vyerr, double &vzerr, double &dlerr, double &dterr, double &alphaerr, double &etaerr, double &alphatof)
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:316