Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ComponentConstant Class Reference

Component with constant electric field. More...

#include <ComponentConstant.hh>

+ Inheritance diagram for Garfield::ComponentConstant:

Public Member Functions

 ComponentConstant ()
 Constructor.
 
 ~ComponentConstant ()
 Destructor.
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
 Calculate the drift field [V/cm] and potential [V] at (x, y, z).
 
bool GetVoltageRange (double &vmin, double &vmax) override
 Calculate the voltage range [V].
 
void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
 
double WeightingPotential (const double x, const double y, const double z, const std::string &label) override
 
void SetElectricField (const double ex, const double ey, const double ez)
 Set the components of the electric field [V / cm].
 
void SetPotential (const double x, const double y, const double z, const double v=0.)
 Specify the potential at a given point.
 
void SetWeightingField (const double wx, const double wy, const double wz, const std::string label)
 Set the components of the weighting field [1 / cm].
 
void SetWeightingPotential (const double x, const double y, const double z, const double v=0.)
 Specify the weighting potential at a given point.
 
- Public Member Functions inherited from Garfield::ComponentBase
 ComponentBase ()
 Constructor.
 
virtual ~ComponentBase ()
 Destructor.
 
virtual void SetGeometry (GeometryBase *geo)
 Define the geometry.
 
virtual void Clear ()
 Reset.
 
virtual MediumGetMedium (const double x, const double y, const double z)
 Get the medium at a given location (x, y, z).
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)=0
 Calculate the drift field [V/cm] and potential [V] at (x, y, z).
 
virtual bool GetVoltageRange (double &vmin, double &vmax)=0
 Calculate the voltage range [V].
 
virtual void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
 
virtual double WeightingPotential (const double x, const double y, const double z, const std::string &label)
 
virtual void DelayedWeightingField (const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label)
 
virtual void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
 
void SetMagneticField (const double bx, const double by, const double bz)
 Set a constant magnetic field.
 
virtual bool IsReady ()
 Ready for use?
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 Get the bounding box coordinates.
 
double IntegrateFluxCircle (const double xc, const double yc, const double r, const unsigned int nI=50)
 
double IntegrateFluxSphere (const double xc, const double yc, const double zc, const double r, const unsigned int nI=20)
 
double IntegrateFlux (const double x0, const double y0, const double z0, const double dx1, const double dy1, const double dz1, const double dx2, const double dy2, const double dz2, const unsigned int nU=20, const unsigned int nV=20)
 
virtual bool IsWireCrossed (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc, const bool centre, double &rc)
 
virtual bool IsInTrapRadius (const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
 
void EnablePeriodicityX (const bool on=true)
 Enable simple periodicity in the $x$ direction.
 
void DisablePeriodicityX ()
 
void EnablePeriodicityY (const bool on=true)
 Enable simple periodicity in the $y$ direction.
 
void DisablePeriodicityY ()
 
void EnablePeriodicityZ (const bool on=true)
 Enable simple periodicity in the $z$ direction.
 
void DisablePeriodicityZ ()
 
void EnableMirrorPeriodicityX (const bool on=true)
 Enable mirror periodicity in the $x$ direction.
 
void DisableMirrorPeriodicityX ()
 
void EnableMirrorPeriodicityY (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityY ()
 
void EnableMirrorPeriodicityZ (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityZ ()
 
void EnableAxialPeriodicityX (const bool on=true)
 Enable axial periodicity in the $x$ direction.
 
void DisableAxialPeriodicityX ()
 
void EnableAxialPeriodicityY (const bool on=true)
 Enable axial periodicity in the $y$ direction.
 
void DisableAxialPeriodicityY ()
 
void EnableAxialPeriodicityZ (const bool on=true)
 Enable axial periodicity in the $z$ direction.
 
void DisableAxialPeriodicityZ ()
 
void EnableRotationSymmetryX (const bool on=true)
 Enable rotation symmetry around the $x$ axis.
 
void DisableRotationSymmetryX ()
 
void EnableRotationSymmetryY (const bool on=true)
 Enable rotation symmetry around the $y$ axis.
 
void DisableRotationSymmetryY ()
 
void EnableRotationSymmetryZ (const bool on=true)
 Enable rotation symmetry around the $z$ axis.
 
void DisableRotationSymmetryZ ()
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 
void ActivateTraps ()
 Request trapping to be taken care of by the component (for TCAD).
 
void DeactivateTraps ()
 
bool IsTrapActive ()
 
void ActivateVelocityMap ()
 Request velocity to be taken care of by the component (for TCAD).
 
void DectivateVelocityMap ()
 
bool IsVelocityActive ()
 
virtual bool ElectronAttachment (const double, const double, const double, double &eta)
 Get the electron attachment coefficient.
 
virtual bool HoleAttachment (const double, const double, const double, double &eta)
 Get the hole attachment coefficient.
 
virtual void ElectronVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 Get the electron drift velocity.
 
virtual void HoleVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 Get the hole drift velocity.
 
virtual bool GetElectronLifetime (const double, const double, const double, double &etau)
 
virtual bool GetHoleLifetime (const double, const double, const double, double &htau)
 

Additional Inherited Members

virtual void Reset ()=0
 Reset the component.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className = "ComponentBase"
 Class name.
 
GeometryBasem_geometry = nullptr
 Pointer to the geometry.
 
bool m_ready = false
 Ready for use?
 
bool m_activeTraps = false
 Does the component have traps?
 
bool m_hasVelocityMap = false
 Does the component have velocity maps?
 
std::array< bool, 3 > m_periodic = {{false, false, false}}
 Simple periodicity in x, y, z.
 
std::array< bool, 3 > m_mirrorPeriodic = {{false, false, false}}
 Mirror periodicity in x, y, z.
 
std::array< bool, 3 > m_axiallyPeriodic = {{false, false, false}}
 Axial periodicity in x, y, z.
 
std::array< bool, 3 > m_rotationSymmetric = {{false, false, false}}
 Rotation symmetry around x-axis, y-axis, z-axis.
 
double m_bx0 = 0.
 
double m_by0 = 0.
 
double m_bz0 = 0.
 
bool m_debug = false
 Switch on/off debugging messages.
 

Detailed Description

Component with constant electric field.

Definition at line 10 of file ComponentConstant.hh.

Constructor & Destructor Documentation

◆ ComponentConstant()

Garfield::ComponentConstant::ComponentConstant ( )

Constructor.

Definition at line 8 of file ComponentConstant.cc.

8 : ComponentBase() {
9 m_className = "ComponentConstant";
10}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:9
std::string m_className
Class name.

◆ ~ComponentConstant()

Garfield::ComponentConstant::~ComponentConstant ( )
inline

Destructor.

Definition at line 15 of file ComponentConstant.hh.

15{}

Member Function Documentation

◆ ElectricField() [1/2]

void Garfield::ComponentConstant::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
double &  v,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field [V/cm] and potential [V] at (x, y, z).

Implements Garfield::ComponentBase.

Definition at line 35 of file ComponentConstant.cc.

38 {
39 ex = m_fx;
40 ey = m_fy;
41 ez = m_fz;
42 if (m_hasPotential) {
43 v = m_v0 - (x - m_x0) * m_fx - (y - m_y0) * m_fy - (z - m_z0) * m_fz;
44 } else {
45 v = 0.;
46 if (m_debug) {
47 std::cerr << m_className << "::ElectricField: Potential not defined.\n";
48 }
49 }
50
51 m = GetMedium(x, y, z);
52 if (!m) {
53 if (m_debug) {
54 std::cout << m_className << "::ElectricField: No medium at ("
55 << x << ", " << y << ", " << z << ").\n";
56 }
57 status = -6;
58 return;
59 }
60
61 if (m->IsDriftable()) {
62 status = 0;
63 } else {
64 status = -5;
65 }
66}
bool m_debug
Switch on/off debugging messages.
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).

◆ ElectricField() [2/2]

void Garfield::ComponentConstant::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field at given point.

Parameters
x,y,zcoordinates [cm].
ex,ey,ezcomponents of the electric field [V/cm].
mpointer to the medium at this location.
statusstatus flag

Status flags:

        0: Inside an active medium
      > 0: Inside a wire of type X
-4 ... -1: On the side of a plane where no wires are
       -5: Inside the mesh but not in an active medium
       -6: Outside the mesh
      -10: Unknown potential type (should not occur)
    other: Other cases (should not occur)

Implements Garfield::ComponentBase.

Definition at line 12 of file ComponentConstant.cc.

14 {
15 ex = m_fx;
16 ey = m_fy;
17 ez = m_fz;
18 m = GetMedium(x, y, z);
19 if (!m) {
20 if (m_debug) {
21 std::cout << m_className << "::ElectricField: No medium at ("
22 << x << ", " << y << ", " << z << ").\n";
23 }
24 status = -6;
25 return;
26 }
27
28 if (m->IsDriftable()) {
29 status = 0;
30 } else {
31 status = -5;
32 }
33}

◆ GetVoltageRange()

bool Garfield::ComponentConstant::GetVoltageRange ( double &  vmin,
double &  vmax 
)
overridevirtual

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 68 of file ComponentConstant.cc.

68 {
69 if (!m_hasPotential) return false;
70
71 if (!m_geometry) {
72 std::cerr << m_className << "::GetVoltageRange: Geometry not set.\n";
73 return false;
74 }
75 double xmin, ymin, zmin;
76 double xmax, ymax, zmax;
77 if (!GetBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)) {
78 std::cerr << m_className << "::GetVoltageRange:\n"
79 << " Could not determine the bounding box.\n";
80 return false;
81 }
82 // Calculate potentials at each corner
83 const double pxmin = m_v0 - (xmin - m_x0) * m_fx;
84 const double pxmax = m_v0 - (xmax - m_x0) * m_fx;
85 const double pymin = m_v0 - (ymin - m_y0) * m_fy;
86 const double pymax = m_v0 - (ymax - m_y0) * m_fy;
87 const double pzmin = m_v0 - (zmin - m_z0) * m_fz;
88 const double pzmax = m_v0 - (zmax - m_z0) * m_fz;
89 double p[8];
90 p[0] = pxmin + pymin + pzmin;
91 p[1] = pxmin + pymin + pzmax;
92 p[2] = pxmin + pymax + pzmin;
93 p[3] = pxmin + pymax + pzmax;
94 p[4] = pxmax + pymin + pzmin;
95 p[5] = pxmax + pymin + pzmax;
96 p[6] = pxmax + pymax + pzmin;
97 p[7] = pxmax + pymax + pzmax;
98 vmin = vmax = p[7];
99 for (int i = 7; i--;) {
100 if (p[i] > vmax) vmax = p[i];
101 if (p[i] < vmin) vmin = p[i];
102 }
103
104 return true;
105}
GeometryBase * m_geometry
Pointer to the geometry.
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.

◆ SetElectricField()

void Garfield::ComponentConstant::SetElectricField ( const double  ex,
const double  ey,
const double  ez 
)

Set the components of the electric field [V / cm].

Definition at line 137 of file ComponentConstant.cc.

138 {
139 m_fx = ex;
140 m_fy = ey;
141 m_fz = ez;
142 if (m_fx * m_fx + m_fy * m_fy + m_fz * m_fz > Small) return;
143
144 std::cerr << m_className << "::SetElectricField: Field set to zero.\n";
145 m_ready = true;
146}
bool m_ready
Ready for use?

◆ SetPotential()

void Garfield::ComponentConstant::SetPotential ( const double  x,
const double  y,
const double  z,
const double  v = 0. 
)

Specify the potential at a given point.

Definition at line 148 of file ComponentConstant.cc.

149 {
150 m_x0 = x;
151 m_y0 = y;
152 m_z0 = z;
153 m_v0 = v;
154 m_hasPotential = true;
155}

◆ SetWeightingField()

void Garfield::ComponentConstant::SetWeightingField ( const double  wx,
const double  wy,
const double  wz,
const std::string  label 
)

Set the components of the weighting field [1 / cm].

Definition at line 157 of file ComponentConstant.cc.

159 {
160 m_wfield = label;
161 m_fwx = wx;
162 m_fwy = wy;
163 m_fwz = wz;
164 m_hasWeightingField = true;
165}

◆ SetWeightingPotential()

void Garfield::ComponentConstant::SetWeightingPotential ( const double  x,
const double  y,
const double  z,
const double  v = 0. 
)

Specify the weighting potential at a given point.

Definition at line 167 of file ComponentConstant.cc.

168 {
169 if (!m_hasWeightingField) {
170 std::cerr << m_className << "::SetWeightingPotential:\n"
171 << " Set the weighting field first!\n";
172 return;
173 }
174 m_wx0 = x;
175 m_wy0 = y;
176 m_wz0 = z;
177 m_w0 = v;
178 m_hasWeightingPotential = true;
179}

◆ WeightingField()

void Garfield::ComponentConstant::WeightingField ( const double  x,
const double  y,
const double  z,
double &  wx,
double &  wy,
double &  wz,
const std::string &  label 
)
overridevirtual

Calculate the weighting field at a given point and for a given electrode.

Parameters
x,y,zcoordinates [cm].
wx,wy,wzcomponents of the weighting field [1/cm].
labelname of the electrode

Reimplemented from Garfield::ComponentBase.

Definition at line 107 of file ComponentConstant.cc.

109 {
110 if (!m_hasWeightingField || label != m_wfield) return;
111
112 Medium* m = GetMedium(x, y, z);
113 if (!m) {
114 wx = wy = wz = 0.;
115 if (m_debug) {
116 std::cout << m_className << "::WeightingField: No medium at ("
117 << x << ", " << y << ", " << z << ")\n";
118 }
119 return;
120 }
121 wx = m_fwx;
122 wy = m_fwy;
123 wz = m_fwz;
124}

◆ WeightingPotential()

double Garfield::ComponentConstant::WeightingPotential ( const double  x,
const double  y,
const double  z,
const std::string &  label 
)
overridevirtual

Calculate the weighting potential at a given point.

Parameters
x,y,zcoordinates [cm].
labelname of the electrode.
Returns
weighting potential [dimensionless].

Reimplemented from Garfield::ComponentBase.

Definition at line 126 of file ComponentConstant.cc.

128 {
129 if (!m_hasWeightingPotential || label != m_wfield) return 0.;
130
131 Medium* m = GetMedium(x, y, z);
132 if (!m) return 0.;
133
134 return m_w0 - (x - m_wx0) * m_fwx - (y - m_wy0) * m_fwy - (z - m_wz0) * m_fwz;
135}

The documentation for this class was generated from the following files: