1#ifndef G_MEDIUM_MAGBOLTZ_9
2#define G_MEDIUM_MAGBOLTZ_9
21 const std::string& gas2 =
"",
const double f2 = 0.,
22 const std::string& gas3 =
"",
const double f3 = 0.,
23 const std::string& gas4 =
"",
const double f4 = 0.,
24 const std::string& gas5 =
"",
const double f5 = 0.,
25 const std::string& gas6 =
"",
const double f6 = 0.);
43 m_useAnisotropic = on;
66 std::string gasname)
override;
92 double& dx,
double& dy,
double& dz,
93 std::vector<std::pair<Particle, double> >& secondaries,
94 int& ndxc,
int& band)
override;
97 return m_dxcProducts.size();
100 int& type,
double& energy)
const override;
104 double& ctheta,
int& nsec,
double& esec)
override;
112 unsigned int& nIonising,
113 unsigned int& nAttachment,
114 unsigned int& nInelastic,
115 unsigned int& nExcitation,
116 unsigned int& nSuperelastic)
const;
120 bool GetLevel(
const unsigned int i,
int& ngas,
int& type, std::string& descr,
135 unsigned int& nIonising,
136 unsigned int& nInelastic)
const;
166 void RunMagboltz(
const double e,
const double b,
const double btheta,
167 const int ncoll,
bool verbose,
double& vx,
double& vy,
168 double& vz,
double& dl,
double& dt,
double& alpha,
169 double& eta,
double& lor,
double& vxerr,
double& vyerr,
170 double& vzerr,
double& dlerr,
double& dterr,
171 double& alphaerr,
double& etaerr,
double& lorerr,
172 double& alphatof, std::array<double, 6>& difftens);
178 const bool verbose =
true);
184 static constexpr int nEnergyStepsLog = 1000;
185 static constexpr int nEnergyStepsGamma = 5000;
186 static constexpr int nCsTypes = 7;
187 static constexpr int nCsTypesGamma = 4;
189 static const int DxcTypeRad;
190 static const int DxcTypeCollIon;
191 static const int DxcTypeCollNonIon;
197 bool m_useGasMotion =
false;
199 bool m_autoEnergyLimit =
true;
207 double m_eHigh, m_eHighLog;
211 bool m_useCsOutput =
false;
213 unsigned int m_nTerms = 0;
215 std::array<double, m_nMaxGases> m_rgas;
216 std::array<double, m_nMaxGases> m_s2;
218 std::array<double, Magboltz::nMaxLevels> m_wOpalBeaty;
221 std::array<std::array<double, 5>,
m_nMaxGases> m_parGreenSawada;
222 std::array<bool, m_nMaxGases> m_hasGreenSawada;
224 bool m_useOpalBeaty =
true;
226 bool m_useGreenSawada =
false;
229 std::array<double, Magboltz::nMaxLevels> m_energyLoss;
231 std::array<int, Magboltz::nMaxLevels> m_csType;
234 std::array<double, Magboltz::nMaxLevels> m_yFluorescence;
236 std::array<unsigned int, Magboltz::nMaxLevels> m_nAuger1;
237 std::array<unsigned int, Magboltz::nMaxLevels> m_nAuger2;
239 std::array<double, Magboltz::nMaxLevels> m_eAuger1;
240 std::array<double, Magboltz::nMaxLevels> m_eAuger2;
241 std::array<unsigned int, Magboltz::nMaxLevels> m_nFluorescence;
242 std::array<double, Magboltz::nMaxLevels> m_eFluorescence;
245 bool m_useAnisotropic =
true;
246 std::vector<std::vector<double> > m_scatPar;
247 std::vector<std::vector<double> > m_scatCut;
248 std::vector<std::vector<double> > m_scatParLog;
249 std::vector<std::vector<double> > m_scatCutLog;
250 std::array<int, Magboltz::nMaxLevels> m_scatModel;
253 std::vector<std::string> m_description;
256 std::vector<double> m_cfTot;
257 std::vector<double> m_cfTotLog;
259 double m_cfNull = 0.;
261 std::vector<std::vector<double> > m_cf;
262 std::vector<std::vector<double> > m_cfLog;
271 std::array<unsigned int, nCsTypes> m_nCollisions;
273 std::vector<unsigned int> m_nCollisionsDetailed;
277 std::array<double, Magboltz::nMaxLevels> m_rPenning;
279 std::array<double, Magboltz::nMaxLevels> m_lambdaPenning;
281 unsigned int m_nPenning = 0;
285 bool m_useDeexcitation =
false;
288 bool m_useRadTrap =
true;
290 struct Deexcitation {
300 std::vector<double> p;
302 std::vector<int>
final;
304 std::vector<int> type;
318 std::vector<Deexcitation> m_deexcitations;
320 std::array<int, Magboltz::nMaxLevels> m_iDeexcitation;
333 std::vector<dxcProd> m_dxcProducts;
336 std::array<double, m_nMaxGases> m_ionPot;
338 double m_minIonPot = -1.;
341 std::array<double, m_nMaxGases> m_scaleExc;
344 double m_eFinalGamma, m_eStepGamma;
346 unsigned int m_nPhotonTerms = 0;
348 std::vector<double> m_cfTotGamma;
350 std::vector<std::vector<double> > m_cfGamma;
351 std::vector<int> csTypeGamma;
357 std::array<unsigned int, nCsTypesGamma> m_nPhotonCollisions;
359 bool Update(
const bool verbose =
false);
360 bool Mixer(
const bool verbose =
false);
361 void SetupGreenSawada();
363 void GetExcitationIonisationLevels();
365 void ComputeDeexcitationTable(
const bool verbose);
366 void AddPenningDeexcitation(Deexcitation& dxc,
const double rate,
367 const double pPenning) {
368 dxc.p.push_back(rate * (1. - pPenning));
369 dxc.type.push_back(DxcTypeCollNonIon);
370 dxc.final.push_back(-1);
372 dxc.p.push_back(rate * pPenning);
373 dxc.type.push_back(DxcTypeCollIon);
374 dxc.final.push_back(-1);
377 double RateConstantWK(
const double energy,
const double osc,
378 const double pacs,
const int igas1,
379 const int igas2)
const;
380 double RateConstantHardSphere(
const double r1,
const double r2,
381 const int igas1,
const int igas2)
const;
382 void ComputeDeexcitationInternal(
int iLevel,
int& fLevel);
383 bool ComputePhotonCollisionTable(
const bool verbose);
static constexpr unsigned int m_nMaxGases
void SetSplittingFunctionGreenSawada()
Sample the secondary electron energy according to the Green-Sawada model.
bool EnablePenningTransfer() override
void EnableAnisotropicScattering(const bool on=true)
Switch on/off anisotropic scattering (enabled by default)
unsigned int GetNumberOfLevels()
Get the number of cross-section terms.
void SetExcitationScaling(const double r, std::string gasname)
Multiply all excitation cross-sections by a uniform scaling factor.
bool GetLevel(const unsigned int i, int &ngas, int &type, std::string &descr, double &e)
Get detailed information about a given cross-section term i.
double GetElectronNullCollisionRate(const int band) override
Get the overall null-collision rate [ns-1].
virtual ~MediumMagboltz()
Destructor.
void ResetCollisionCounters()
Reset the collision counters.
void EnableRadiationTrapping()
Switch on discrete photoabsorption levels.
unsigned int GetNumberOfElectronCollisions() const
Get the total number of electron collisions.
double GetPhotonCollisionRate(const double e) override
bool ElectronCollision(const double e, int &type, int &level, double &e1, double &dx, double &dy, double &dz, std::vector< std::pair< Particle, double > > &secondaries, int &ndxc, int &band) override
Sample the collision type.
void EnableAutoEnergyLimit(const bool on=true)
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, std::array< double, 6 > &difftens)
void ComputeDeexcitation(int iLevel, int &fLevel)
void SetSplittingFunctionOpalBeaty()
Sample the secondary electron energy according to the Opal-Beaty model.
static int GetGasNumberMagboltz(const std::string &input)
void GenerateGasTable(const int numCollisions=10, const bool verbose=true)
double GetMaxElectronEnergy() const
Get the highest electron energy in the table of scattering rates.
bool GetDeexcitationProduct(const unsigned int i, double &t, double &s, int &type, double &energy) const override
void SetSplittingFunctionFlat()
Sample the secondary electron energy from a flat distribution.
MediumMagboltz()
Default constructor.
unsigned int GetNumberOfPenningTransfers() const
Get the number of Penning transfers that occured since the last reset.
double GetMaxPhotonEnergy() const
Get the highest photon energy in the table of scattering rates.
unsigned int GetNumberOfPhotonCollisions() const
Get the total number of photon collisions.
bool SetMaxPhotonEnergy(const double e)
void DisablePenningTransfer() override
Switch the simulation of Penning transfers off globally.
bool GetPhotonCollision(const double e, int &type, int &level, double &e1, double &ctheta, int &nsec, double &esec) override
bool GetPenningTransfer(const unsigned int i, double &r, double &lambda)
Get the Penning transfer probability and distance of a specific level.
unsigned int GetNumberOfDeexcitationProducts() const override
void PlotElectronCrossSections()
void DisableDeexcitation()
Switch off (microscopic) de-excitation handling.
void EnableCrossSectionOutput(const bool on=true)
Write the gas cross-section table to a file during the initialisation.
void DisableRadiationTrapping()
Switch off discrete photoabsorption levels.
bool Initialise(const bool verbose=false)
double GetElectronCollisionRate(const double e, const int band) override
Get the (real) collision rate [ns-1] at a given electron energy e [eV].
bool SetMaxElectronEnergy(const double e)
void EnableThermalMotion(const bool on=true)
void PrintGas() override
Print information about the present gas mixture and available data.
void EnableDeexcitation()
Switch on (microscopic) de-excitation handling.