1#if defined(__GPUCOMPILE__) || !defined(G_MEDIUM_MAGBOLTZ_11)
3#if !defined(__GPUCOMPILE__) && !defined(G_MEDIUM_MAGBOLTZ_11)
4#define G_MEDIUM_MAGBOLTZ_11
28 const std::string& gas2 =
"",
const double f2 = 0.,
29 const std::string& gas3 =
"",
const double f3 = 0.,
30 const std::string& gas4 =
"",
const double f4 = 0.,
31 const std::string& gas5 =
"",
const double f5 = 0.,
32 const std::string& gas6 =
"",
const double f6 = 0.);
76 std::string gasname)
override;
103 __device__ double GetElectronCollisionRate__MediumMagboltz(
const double e,
107#ifndef __GPUCOMPILE__
115 double& dx,
double& dy,
double& dz,
116 std::vector<Secondary>& secondaries,
119 std::vector<Secondary>& secondaries);
124 std::vector<Secondary>& secondaries)
override;
132 unsigned int& nIonising,
133 unsigned int& nAttachment,
134 unsigned int& nInelastic,
135 unsigned int& nExcitation,
136 unsigned int& nSuperelastic)
const;
140 bool GetLevel(
const unsigned int i,
int& ngas,
int& type, std::string& descr,
155 unsigned int& nIonising,
156 unsigned int& nInelastic)
const;
192 void RunMagboltz(
const double e,
const double b,
const double btheta,
193 const int ncoll,
bool verbose,
double& vx,
double& vy,
194 double& vz,
double& wv,
double& wr,
double& dl,
double& dt,
195 double& alpha,
double& eta,
double& riontof,
double& ratttof,
196 double& lor,
double& vxerr,
double& vyerr,
double& vzerr,
197 double& wverr,
double& wrerr,
double& dlerr,
double& dterr,
198 double& alphaerr,
double& etaerr,
double& riontoferr,
199 double& ratttoferr,
double& lorerr,
double& alphatof,
200 std::array<double, 6>& difftens);
206 const bool verbose =
true);
221#ifndef __GPUCOMPILE__
250#ifndef __GPUCOMPILE__
255 std::array<double, m_nMaxGases>
m_s2;
273 int* m_numscatParIdx{
nullptr};
277 int* m_numscatCutIdx{
nullptr};
281 int* m_numscatParLogIdx{
nullptr};
282 int m_numscatParLog{0};
285 int* m_numscatCutLogIdx{
nullptr};
286 int m_numscatCutLog{0};
292 int m_numcfTotLog{0};
294 double**
m_cf{
nullptr};
295 int* m_numcfIdx{
nullptr};
299 int* m_numcfLogIdx{
nullptr};
310std::array<unsigned int, Magboltz::nMaxLevels>
m_nAuger1;
311std::array<unsigned int, Magboltz::nMaxLevels>
m_nAuger2;
332std::vector<std::vector<double> >
m_cf;
355#ifndef __GPUCOMPILE__
392 std::vector<double>
p;
394 std::vector<int>
final;
443 bool Mixer(
const bool verbose =
false);
450 const double pPenning) {
451 dxc.
p.push_back(rate * (1. - pPenning));
453 dxc.
final.push_back(-1);
455 dxc.
p.push_back(rate * pPenning);
457 dxc.
final.push_back(-1);
461 const double pacs,
const int igas1,
462 const int igas2)
const;
464 const int igas1,
const int igas2)
const;
468 std::vector<Secondary>& secondaries);
static constexpr unsigned int m_nMaxGases
std::array< double, Magboltz::nMaxLevels > m_eAuger2
void RunMagboltz(const double e, const double b, const double btheta, const int ncoll, bool verbose, double &vx, double &vy, double &vz, double &wv, double &wr, double &dl, double &dt, double &alpha, double &eta, double &riontof, double &ratttof, double &lor, double &vxerr, double &vyerr, double &vzerr, double &wverr, double &wrerr, double &dlerr, double &dterr, double &alphaerr, double &etaerr, double &riontoferr, double &ratttoferr, double &lorerr, double &alphatof, std::array< double, 6 > &difftens)
Run Magboltz for a given electric field, magnetic field and angle.
bool EnablePenningTransfer(const double r, const double lambda) override
Switch on simulation of Penning transfers by means of transfer probabilities, for all excitation leve...
std::array< unsigned int, nCsTypes > m_nCollisions
Collision counters 0: elastic 1: ionisation 2: attachment 3: inelastic 4: excitation 5: super-elastic...
void SetSplittingFunctionGreenSawada()
Sample the secondary electron energy according to the Green-Sawada model.
double RateConstantHardSphere(const double r1, const double r2, const int igas1, const int igas2) const
std::vector< std::vector< double > > m_scatParLog
bool EnablePenningTransfer() override
Switch on simulation of Penning transfers, using pre-implemented parameterisations of the transfer pr...
std::array< double, m_nMaxGases > m_mgas
Mass.
void EnableAnisotropicScattering(const bool on=true)
Switch on/off anisotropic scattering (enabled by default)
unsigned int GetNumberOfPhotonCollisions(unsigned int &nElastic, unsigned int &nIonising, unsigned int &nInelastic) const
Get number of photon collisions by collision type.
std::array< double, Magboltz::nMaxLevels > m_eAuger1
Energy imparted to Auger electrons.
std::array< double, Magboltz::nMaxLevels > m_yFluorescence
Fluorescence yield.
unsigned int GetNumberOfLevels()
Get the number of cross-section terms.
static int GetGasNumberMagboltz(const std::string &input)
bool ComputePhotonCollisionTable(const bool verbose)
void SetExcitationScaling(const double r, std::string gasname)
Multiply all excitation cross-sections by a uniform scaling factor.
bool EnablePenningTransfer(const double r, const double lambda, std::string gasname) override
Switch on simulation of Penning transfers by means of transfer probabilities, for all excitations of ...
bool m_useDeexcitation
Flag enabling/disabling detailed simulation of de-excitation process.
void PlotElectronInverseMeanFreePath(TPad *pad)
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.
bool m_useCsOutput
Flag enabling/disabling output of cross-section table to file.
bool ElectronCollision(const double e, int &type, int &level, double &e1, double &dx, double &dy, double &dz, std::vector< Secondary > &secondaries, int &band) override
Sample the collision type.
std::array< int, Magboltz::nMaxLevels > m_csType
Cross-section type.
double GetElectronNullCollisionRate(const int band) override
std::array< unsigned int, Magboltz::nMaxLevels > m_nAuger1
Number of Auger electrons produced in a collision.
std::array< double, Magboltz::nMaxLevels > m_rPenning
Penning transfer probability (by level)
virtual ~MediumMagboltz()
Destructor.
void ResetCollisionCounters()
Reset the collision counters.
std::array< double, m_nMaxGases > m_s2
unsigned int m_nPhotonTerms
void SetLineWidth(const double n)
Set the number of emission line widths within which to apply absorption by discrete lines.
void EnableRadiationTrapping()
Switch on discrete photoabsorption levels.
std::array< double, Magboltz::nMaxLevels > m_energyLoss
Energy loss.
double GetElectronCollisionRate(const double e, const unsigned int level, const int band)
Get the collision rate [ns-1] for a specific level.
unsigned int m_nPenning
Number of Penning ionisations.
std::vector< std::vector< double > > m_scatPar
std::vector< std::vector< double > > m_cf
static const int DxcTypeCollNonIon
MediumMagboltz(const std::string &gas1, const double f1=1., const std::string &gas2="", const double f2=0., const std::string &gas3="", const double f3=0., const std::string &gas4="", const double f4=0., const std::string &gas5="", const double f5=0., const std::string &gas6="", const double f6=0.)
Constructor.
unsigned int GetNumberOfElectronCollisions() const
Get the total number of electron collisions.
double GetPhotonCollisionRate(const double e) override
std::array< std::array< double, 5 >, m_nMaxGases > m_parGreenSawada
Green-Sawada splitting parameters [eV] (Γs, Γb, Ts, Ta, Tb).
bool m_useRadTrap
Flag enabling/disable radiation trapping (absorption of photons discrete excitation lines)
static constexpr int nEnergyStepsGamma
double m_eStep
Energy spacing in the linear part of the collision rate tables.
std::vector< std::vector< double > > m_cfGamma
void EnableAutoEnergyLimit(const bool on=true)
Let Magboltz determine the upper energy limit (this is the default) or use the energy limit specified...
void ComputeDeexcitationTable(const bool verbose)
std::array< double, m_nMaxGases > m_rgas
Recoil energy parameter.
double CreateGPUTransferObject(MediumGPU *&med_gpu) override
Create and initialise GPU Transfer class.
unsigned int GetNumberOfElectronCollisions(const unsigned int level) const
Get the number of collisions for a specific cross-section term.
bool m_useGasMotion
Simulate thermal motion of the gas or not (when running Magboltz).
std::vector< std::vector< double > > m_cfLog
void SetSplittingFunctionOpalBeaty()
Sample the secondary electron energy according to the Opal-Beaty model.
double CalcDiscreteLineCf(const Deexcitation &dxc, double e, double cfOth) const
double m_cfNull
Null-collision frequency.
void ComputeDeexcitation(int iLevel, int &fLevel, std::vector< Secondary > &secondaries)
bool DisablePenningTransfer(std::string gasname) override
Switch the simulation of Penning transfers off for a given component.
std::array< unsigned int, nCsTypesGamma > m_nPhotonCollisions
std::vector< Deexcitation > m_deexcitations
static const int DxcTypeRad
void GenerateGasTable(const int numCollisions=10, const bool verbose=true)
Generate a new gas table (can later be saved to file) by running Magboltz for all electric fields,...
static constexpr int nCsTypesGamma
bool m_useOpalBeaty
Sample secondary electron energies using Opal-Beaty parameterisation.
double GetMaxElectronEnergy() const
Get the highest electron energy in the table of scattering rates.
void SetSplittingFunctionFlat()
Sample the secondary electron energy from a flat distribution.
bool Mixer(const bool verbose=false)
std::array< double, Magboltz::nMaxLevels > m_lambdaPenning
Mean distance of Penning ionisation (by level)
MediumMagboltz()
Default constructor.
std::array< bool, m_nMaxGases > m_hasGreenSawada
unsigned int GetNumberOfPenningTransfers() const
Get the number of Penning transfers that occured since the last reset.
std::array< double, m_nMaxGases > m_scaleExc
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)
Set the highest photon energy to be included in the table of scattering rates.
void AddPenningDeexcitation(Deexcitation &dxc, const double rate, const double pPenning)
void DisablePenningTransfer() override
Switch the simulation of Penning transfers off globally.
bool m_useGreenSawada
Sample secondary electron energies using Green-Sawada parameterisation.
bool GetPenningTransfer(const unsigned int i, double &r, double &lambda)
Get the Penning transfer probability and distance of a specific level.
std::array< int, Magboltz::nMaxLevels > m_scatModel
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.
unsigned int GetNumberOfElectronCollisions(unsigned int &nElastic, unsigned int &nIonising, unsigned int &nAttachment, unsigned int &nInelastic, unsigned int &nExcitation, unsigned int &nSuperelastic) const
Get the number of collisions broken down by cross-section type.
void GetExcitationIonisationLevels()
std::array< int, Magboltz::nMaxLevels > m_iDeexcitation
static const int DxcTypeCollIon
std::array< unsigned int, Magboltz::nMaxLevels > m_nFluorescence
void PlotElectronCollisionRates(TPad *pad)
void ComputeDeexcitationInternal(int iLevel, int &fLevel, std::vector< Secondary > &secondaries)
static constexpr int nCsTypes
double m_eStepInv
Inverse energy spacing.
std::vector< std::string > m_description
Level description.
std::vector< double > m_cfTotGamma
static constexpr int nEnergyStepsLog
bool Initialise(const bool verbose=false)
Initialise the table of scattering rates (called internally when a collision rate is requested and th...
void PlotElectronCrossSections(const unsigned int i, TPad *pad)
bool Update(const bool verbose=false)
std::array< double, Magboltz::nMaxLevels > m_wOpalBeaty
Opal-Beaty-Peterson splitting parameter [eV].
std::array< double, Magboltz::nMaxLevels > m_eFluorescence
unsigned int m_nTerms
Number of different cross-section types in the current gas mixture.
std::vector< double > m_cfTotLog
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)
Set the highest electron energy to be included in the table of scattering rates.
void EnableThermalMotion(const bool on=true)
Take the thermal motion of the gas at the selected temperature into account in the calculations done ...
std::array< unsigned int, Magboltz::nMaxLevels > m_nAuger2
double m_minIonPot
Minimum ionisation potential.
std::vector< std::vector< double > > m_scatCut
double RateConstantWK(const double energy, const double osc, const double pacs, const int igas1, const int igas2) const
void PrintGas() override
Print information about the present gas mixture and available data.
bool PhotonCollision(const double e, int &type, int &level, double &e1, double &ctheta, std::vector< Secondary > &secondaries) override
bool m_autoEnergyLimit
Automatic calculation of the energy limit by Magboltz or not.
std::vector< std::vector< double > > m_scatCutLog
void EnableDeexcitation()
Switch on (microscopic) de-excitation handling.
std::array< double, m_nMaxGases > m_ionPot
Ionisation potentials of each component.
std::vector< double > m_cfTot
std::vector< int > csTypeGamma
std::vector< unsigned int > m_nCollisionsDetailed
Number of collisions for each cross-section term.
double m_eMax
Max. electron energy in the collision rate tables.
constexpr unsigned int nMaxLevels