1#ifndef G_AVALANCHE_MC_H
2#define G_AVALANCHE_MC_H
32 const double t,
const size_t w = 1);
34 bool DriftHole(
const double x,
const double y,
const double z,
35 const double t,
const size_t w = 1);
37 bool DriftIon(
const double x,
const double y,
const double z,
38 const double t,
const size_t w = 1);
41 const double t,
const size_t w = 1);
48 const double t,
const bool hole =
false,
52 const double t,
const bool electron =
false,
56 const double t,
const size_t w = 1);
59 void AddElectron(
const double x,
const double y,
const double z,
60 const double t,
const size_t w = 1);
62 void AddHole(
const double x,
const double y,
const double z,
63 const double t,
const size_t w = 1);
65 void AddIon(
const double x,
const double y,
const double z,
66 const double t,
const size_t w = 1);
69 const double t,
const size_t w = 1);
111 double& t0,
double& x1,
double& y1,
double& z1,
112 double& t1,
int& status)
const;
114 double& t0,
double& x1,
double& y1,
double& z1,
115 double& t1,
int& status)
const;
117 double& z0,
double& t0,
double& x1,
double& y1,
118 double& z1,
double& t1,
int& status)
const;
240 double (*
m_fStep)(
double x,
double y,
double z) =
nullptr;
304 std::vector<Seed>& secondaries,
305 const bool aval,
const bool signal)
const;
308 const bool withElectrons,
const bool withHoles,
312 int GetField(
const std::array<double, 3>& x, std::array<double, 3>& e,
313 std::array<double, 3>& b, Medium*& medium)
const;
316 const std::array<double, 3>& x)
const;
319 const std::array<double, 3>& x,
320 const std::array<double, 3>& e,
321 const std::array<double, 3>& b,
322 std::array<double, 3>& v)
const;
325 const std::array<double, 3>& e,
326 const std::array<double, 3>& b,
double& dl,
330 const std::array<double, 3>& x,
331 const std::array<double, 3>& e,
332 const std::array<double, 3>& b)
const;
335 const std::array<double, 3>& x,
336 const std::array<double, 3>& e,
337 const std::array<double, 3>& b)
const;
340 const std::array<double, 3>& v0,
const double dt,
341 std::array<double, 3>& xf, std::array<double, 3>& vf,
345 std::array<double, 3>& x,
346 const std::array<double, 3>& v)
const;
348 void Terminate(
const std::array<double, 3>& x0,
const double t0,
349 std::array<double, 3>& x,
double& t)
const;
352 std::vector<Point>& path,
int& status,
353 std::vector<Seed>& secondaries,
354 const bool semiconductor =
false)
const;
357 std::vector<double>& alphas,
358 std::vector<double>& etas)
const;
364 const std::vector<Point>& path)
const;
365 void PrintError(
const std::string& fcn,
const std::string& par,
367 const std::array<double, 3>& x)
const;
void AddIon(const double x, const double y, const double z, const double t, const size_t w=1)
Add an ion to the list of particles to be transported.
std::vector< EndPoint > m_holes
Start/end points of all holes in the avalanche (including captured ones).
bool m_hasTimeWindow
Flag whether a time window should be used.
size_t GetNumberOfIonEndpoints() const
Return the number of ion trajectories.
double m_tMax
Upper limit of the time window.
int DriftLine(const Seed &seed, std::vector< Point > &path, std::vector< Seed > &secondaries, const bool aval, const bool signal) const
Compute a single drift line.
void EnablePlotting(ViewDrift *view)
Switch on drift line plotting.
bool TransportParticles(std::vector< Seed > &stack, const bool withElectrons, const bool withHoles, const bool aval)
Compute an avalanche.
void DisableAvalancheSizeLimit()
Do not limit the maximum avalanche size.
double GetMobility(const Particle particle, Medium *medium, const std::array< double, 3 > &x) const
Retrieve the low-field mobility.
unsigned int m_sizeCut
Max. avalanche size.
void PrintError(const std::string &fcn, const std::string &par, const Particle particle, const std::array< double, 3 > &x) const
void SetTimeSteps(const double d=0.02)
Use fixed-time steps (default 20 ps).
void EnableDebugging(const bool on=true)
Switch debugging messages on/off (default: off).
bool ComputeGainLoss(const Particle ptype, const size_t w, std::vector< Point > &path, int &status, std::vector< Seed > &secondaries, const bool semiconductor=false) const
Compute multiplication and losses along the current drift line.
void EnableSignalCalculation(const bool on=true)
Switch calculation of induced currents on or off (default: enabled).
void EnableMobilityMap(const bool on=true)
Retrieve the (low-field) mobility from the component.
const std::vector< EndPoint > & GetHoles() const
void AddHole(const double x, const double y, const double z, const double t, const size_t w=1)
Add a hole to the list of particles to be transported.
void DisablePlotting()
Switch off drift line plotting.
std::pair< unsigned int, unsigned int > GetAvalancheSize() const
Return the number of electrons and ions/holes in the avalanche.
const std::vector< EndPoint > & GetElectrons() const
void SetIonSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by ions.
bool DriftIon(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an ion from a given starting point.
bool m_useMobilityMap
Take mobility coefficients from the component.
void SetTimeWindow(const double t0, const double t1)
Define a time interval (only carriers inside the interval are drifted).
int m_nMc
Sample step size according to collision time.
void UseWeightingPotential(const bool on=true)
Use the weighting potential (as opposed to the weighting field) for calculating the induced signal.
bool GetDiffusion(const Particle particle, Medium *medium, const std::array< double, 3 > &e, const std::array< double, 3 > &b, double &dl, double &dt) const
Compute the diffusion coefficients.
bool m_useAttachmentMap
Take attachment coefficients from the component.
void EnableMultiplication(const bool on)
Switch multiplication on/off.
bool ResumeAvalanche(const bool electron=true, const bool hole=true)
Resume the simulation from the current set of charge carriers.
void GetIonEndpoint(const size_t i, double &x0, double &y0, double &z0, double &t0, double &x1, double &y1, double &z1, double &t1, int &status) const
void UnsetTimeWindow()
Do not limit the time interval within which carriers are drifted.
AvalancheMC(Sensor *sensor)
Constructor.
const std::vector< EndPoint > & GetNegativeIons() const
bool AvalancheElectron(const double x, const double y, const double z, const double t, const bool hole=false, const size_t w=1)
Simulate an avalanche initiated by an electron at a given starting point.
std::vector< EndPoint > m_ions
Start/end points of all positive ions in the avalanche.
unsigned int m_nElectrons
Number of electrons produced.
bool AvalancheHole(const double x, const double y, const double z, const double t, const bool electron=false, const size_t w=1)
Simulate an avalanche initiated by a hole at a given starting point.
void GetAvalancheSize(unsigned int &ne, unsigned int &ni) const
Return the number of electrons and ions/holes in the avalanche.
void AddNegativeIon(const double x, const double y, const double z, const double t, const size_t w=1)
Add an negative ion to the list of particles to be transported.
bool m_useTownsendMap
Take Townsend coefficients from the component.
void AddDiffusion(const double step, const double dl, const double dt, std::array< double, 3 > &x, const std::array< double, 3 > &v) const
Add a diffusion step.
void EnableRKFSteps(const bool on=true)
Switch on Runge-Kutta-Fehlberg stepping (as opposed to simple straight-line steps.
void Terminate(const std::array< double, 3 > &x0, const double t0, std::array< double, 3 > &x, double &t) const
Terminate a drift line close to the boundary.
~AvalancheMC()
Destructor.
int GetField(const std::array< double, 3 > &x, std::array< double, 3 > &e, std::array< double, 3 > &b, Medium *&medium) const
Compute electric and magnetic field at a given position.
void EnableVelocityMap(const bool on=true)
Retrieve the drift velocity from the component.
AvalancheMC()
Default constructor.
void GetNegativeIonEndpoint(const size_t i, double &x0, double &y0, double &z0, double &t0, double &x1, double &y1, double &z1, double &t1, int &status) const
unsigned int m_nNegativeIons
Number of negative ions produced.
void SetSensor(Sensor *s)
Set the sensor.
void AddElectron(const double x, const double y, const double z, const double t, const size_t w=1)
Add an electron to the list of particles to be transported.
void ComputeSignal(const double q, const std::vector< Point > &path) const
Compute the induced signal for the current drift line.
StepModel m_stepModel
Step size model.
void StepRKF(const Particle particle, const std::array< double, 3 > &x0, const std::array< double, 3 > &v0, const double dt, std::array< double, 3 > &xf, std::array< double, 3 > &vf, int &status) const
Compute end point and effective velocity for a step.
bool m_useVelocityMap
Take the drift velocities from the component.
void DisableAttachment()
Switch off attachment and multiplication.
unsigned int m_nIons
Number of ions produced.
double m_scaleE
Scaling factor for electron signals.
double GetTownsend(const Particle particle, Medium *medium, const std::array< double, 3 > &x, const std::array< double, 3 > &e, const std::array< double, 3 > &b) const
Compute the Townsend coefficient.
size_t GetNumberOfElectronEndpoints() const
Return the number of electron trajectories in the last simulated avalanche (including captured electr...
const std::vector< EndPoint > & GetIons() const
void EnableDiffusion()
Switch on diffusion (default: enabled).
void EnableAttachmentMap(const bool on=true)
Retrieve the attachment coefficient from the component.
void SetStepDistanceFunction(double(*f)(double x, double y, double z))
Retrieve the step distance from a user-supplied function.
void SetElectronSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by electrons.
void GetElectronEndpoint(const size_t i, double &x0, double &y0, double &z0, double &t0, double &x1, double &y1, double &z1, double &t1, int &status) const
Return the coordinates and time of start and end point of a given electron drift line.
void DisableDiffusion()
Switch off diffusion.
void SetHoleSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by holes.
double m_tMc
Fixed time step.
void EnableDriftLines(const bool on=true)
Switch on storage of drift lines (default: off).
bool DriftNegativeIon(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of a negative ion from a given starting point.
bool Equilibrate(std::vector< double > &alphas) const
int GetAvalancheSizeLimit() const
Return the currently set avalanche size limit.
double m_dMc
Fixed distance step.
unsigned int m_nHoles
Number of holes produced.
std::vector< EndPoint > m_electrons
Start/end points of all electrons in the avalanche (including captured ones).
void EnableAvalancheSizeLimit(const unsigned int size)
Set a maximum avalanche size (ignore further multiplication once this size has been reached).
double GetAttachment(const Particle particle, Medium *medium, const std::array< double, 3 > &x, const std::array< double, 3 > &e, const std::array< double, 3 > &b) const
Compute the attachment coefficient.
void SetCollisionSteps(const unsigned int n=100)
Use exponentially distributed time steps with mean equal to the specified multiple of the collision t...
void EnableAttachment()
Switch on attachment (default: enabled).
bool GetVelocity(const Particle particle, Medium *medium, const std::array< double, 3 > &x, const std::array< double, 3 > &e, const std::array< double, 3 > &b, std::array< double, 3 > &v) const
Compute the drift velocity.
bool DriftElectron(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an electron from a given starting point.
double m_scaleI
Scaling factor for ion signals.
void EnableTownsendMap(const bool on=true)
Retrieve the Townsend coefficient from the component.
bool ComputeAlphaEta(const Particle ptype, std::vector< Point > &path, std::vector< double > &alphas, std::vector< double > &etas) const
Compute Townsend and attachment coefficients along the current drift line.
void ComputeInducedCharge(const double q, const std::vector< Point > &path) const
Compute the induced charge for the current drift line.
void EnableInducedChargeCalculation(const bool on=true)
Switch on calculation of induced charge (default: disabled).
void SetSignalAveragingOrder(const unsigned int navg)
Set the number of points to be used when averaging the signal vector over a time bin in the Sensor cl...
std::vector< EndPoint > m_negativeIons
Start/end points of all negative ions in the avalanche.
double m_tMin
Lower limit of the time window.
void SetDistanceSteps(const double d=0.001)
Use fixed distance steps (default 10 um).
double(* m_fStep)(double x, double y, double z)
User function returning the step size.
double m_scaleH
Scaling factor for hole signals.
bool m_useWeightingPotential
void EnableProjectedPathIntegration(const bool on=true)
Switch on equilibration of multiplication and attachment over the drift line (default: enabled).
bool DriftHole(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of a hole from a given starting point.
bool AvalancheElectronHole(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate an avalanche initiated by an electron-hole pair.
Visualize drift lines and tracks.
size_t weight
Multiplicity.
std::vector< Point > path
Drift line.
Particle type
Particle type.