1#ifndef G_MEDIUM_MAGBOLTZ_9
2#define G_MEDIUM_MAGBOLTZ_9
39 m_useAnisotropic = on;
61 std::string gasname)
override;
87 double& dx,
double& dy,
double& dz,
88 std::vector<std::pair<int, double> >& secondaries,
89 int& ndxc,
int& band)
override;
92 return m_dxcProducts.size();
95 int& type,
double& energy)
const override;
99 double& ctheta,
int& nsec,
double& esec)
override;
107 unsigned int& nIonising,
108 unsigned int& nAttachment,
109 unsigned int& nInelastic,
110 unsigned int& nExcitation,
111 unsigned int& nSuperelastic)
const;
115 bool GetLevel(
const unsigned int i,
int& ngas,
int& type, std::string& descr,
127 unsigned int& nIonising,
128 unsigned int& nInelastic)
const;
158 void RunMagboltz(
const double e,
const double b,
const double btheta,
159 const int ncoll,
bool verbose,
double& vx,
double& vy,
160 double& vz,
double& dl,
double& dt,
double& alpha,
161 double& eta,
double& lor,
double& vxerr,
double& vyerr,
162 double& vzerr,
double& dlerr,
double& dterr,
163 double& alphaerr,
double& etaerr,
double& lorerr,
164 double& alphatof, std::array<double, 6>& difftens);
170 const bool verbose =
true);
173 static constexpr int nEnergyStepsLog = 1000;
174 static constexpr int nEnergyStepsGamma = 5000;
175 static constexpr int nCsTypes = 7;
176 static constexpr int nCsTypesGamma = 4;
178 static const int DxcTypeRad;
179 static const int DxcTypeCollIon;
180 static const int DxcTypeCollNonIon;
183 bool m_useGasMotion =
false;
185 bool m_autoEnergyLimit =
true;
191 double m_eHigh, m_eHighLog;
193 bool m_useAutoAdjust =
true;
196 bool m_useCsOutput =
false;
198 unsigned int m_nTerms = 0;
200 std::array<double, m_nMaxGases> m_rgas;
202 std::array<double, Magboltz::nMaxLevels> m_wOpalBeaty;
205 std::array<std::array<double, 5>,
m_nMaxGases> m_parGreenSawada;
206 std::array<bool, m_nMaxGases> m_hasGreenSawada;
208 bool m_useOpalBeaty =
true;
210 bool m_useGreenSawada =
false;
213 std::array<double, Magboltz::nMaxLevels> m_energyLoss;
215 std::array<int, Magboltz::nMaxLevels> m_csType;
218 std::array<double, Magboltz::nMaxLevels> m_yFluorescence;
220 std::array<unsigned int, Magboltz::nMaxLevels> m_nAuger1;
221 std::array<unsigned int, Magboltz::nMaxLevels> m_nAuger2;
223 std::array<double, Magboltz::nMaxLevels> m_eAuger1;
224 std::array<double, Magboltz::nMaxLevels> m_eAuger2;
225 std::array<unsigned int, Magboltz::nMaxLevels> m_nFluorescence;
226 std::array<double, Magboltz::nMaxLevels> m_eFluorescence;
229 bool m_useAnisotropic =
true;
230 std::vector<std::vector<double> > m_scatPar;
231 std::vector<std::vector<double> > m_scatCut;
232 std::vector<std::vector<double> > m_scatParLog;
233 std::vector<std::vector<double> > m_scatCutLog;
234 std::array<int, Magboltz::nMaxLevels> m_scatModel;
237 std::vector<std::string> m_description;
240 std::vector<double> m_cfTot;
241 std::vector<double> m_cfTotLog;
243 double m_cfNull = 0.;
245 std::vector<std::vector<double> > m_cf;
246 std::vector<std::vector<double> > m_cfLog;
255 std::array<unsigned int, nCsTypes> m_nCollisions;
257 std::vector<unsigned int> m_nCollisionsDetailed;
261 std::array<double, Magboltz::nMaxLevels> m_rPenning;
263 std::array<double, Magboltz::nMaxLevels> m_lambdaPenning;
265 unsigned int m_nPenning = 0;
269 bool m_useDeexcitation =
false;
272 bool m_useRadTrap =
true;
274 struct Deexcitation {
284 std::vector<double> p;
286 std::vector<int>
final;
288 std::vector<int> type;
302 std::vector<Deexcitation> m_deexcitations;
304 std::array<int, Magboltz::nMaxLevels> m_iDeexcitation;
317 std::vector<dxcProd> m_dxcProducts;
320 std::array<double, m_nMaxGases> m_ionPot;
322 double m_minIonPot = -1.;
325 std::array<double, m_nMaxGases> m_scaleExc;
328 double m_eFinalGamma, m_eStepGamma;
330 unsigned int m_nPhotonTerms = 0;
332 std::vector<double> m_cfTotGamma;
334 std::vector<std::vector<double> > m_cfGamma;
335 std::vector<int> csTypeGamma;
341 std::array<unsigned int, nCsTypesGamma> m_nPhotonCollisions;
343 int GetGasNumberMagboltz(
const std::string& input)
const;
344 bool Mixer(
const bool verbose =
false);
345 void SetupGreenSawada();
346 void SetScatteringParameters(
const int model,
const double parIn,
double& cut,
347 double& parOut)
const;
348 void ComputeAngularCut(
const double parIn,
double& cut,
double& parOut)
const;
349 void ComputeDeexcitationTable(
const bool verbose);
350 void AddPenningDeexcitation(Deexcitation& dxc,
const double rate,
351 const double pPenning) {
352 dxc.p.push_back(rate * pPenning);
353 dxc.p.push_back(rate * (1. - pPenning));
354 dxc.type.push_back(DxcTypeCollIon);
355 dxc.type.push_back(DxcTypeCollNonIon);
357 double RateConstantWK(
const double energy,
const double osc,
358 const double pacs,
const int igas1,
359 const int igas2)
const;
360 double RateConstantHardSphere(
const double r1,
const double r2,
361 const int igas1,
const int igas2)
const;
362 void ComputeDeexcitationInternal(
int iLevel,
int& fLevel);
363 bool ComputePhotonCollisionTable(
const bool verbose);
Base class for gas media.
static constexpr unsigned int m_nMaxGases
bool EnablePenningTransfer(const double r, const double lambda) override
void SetSplittingFunctionGreenSawada()
Sample the secondary electron energy according to the Green-Sawada model.
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
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.
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()
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
unsigned int GetNumberOfDeexcitationProducts() const override
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 GetElectronCollision(const double e, int &type, int &level, double &e1, double &dx, double &dy, double &dz, std::vector< std::pair< int, double > > &secondaries, int &ndxc, int &band) override
Sample the collision type.
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.
void EnableEnergyRangeAdjustment(const bool on)