Garfield++ v2r0
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 ()
 
 ~ComponentConstant ()
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
 
bool GetVoltageRange (double &vmin, double &vmax)
 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)
 
double WeightingPotential (const double x, const double y, const double z, const std::string &label)
 
void SetElectricField (const double ex, const double ey, const double ez)
 
void SetPotential (const double x, const double y, const double z, const double v=0.)
 
void SetWeightingField (const double wx, const double wy, const double wz, const std::string label)
 
void SetWeightingPotential (const double x, const double y, const double z, const double v=0.)
 
- 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
 
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 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.
 
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)
 
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
 Geometry checks.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className
 Class name.
 
GeometryBasem_geometry
 Pointer to the geometry.
 
bool m_ready
 Ready for use?
 
bool m_activeTraps
 Does the component have traps?
 
bool m_hasVelocityMap
 Does the component have velocity maps?
 
bool m_xPeriodic
 Simple periodicity in x.
 
bool m_yPeriodic
 Simple periodicity in y.
 
bool m_zPeriodic
 Simple periodicity in z.
 
bool m_xMirrorPeriodic
 Mirror periodicity in x.
 
bool m_yMirrorPeriodic
 Mirror periodicity in y.
 
bool m_zMirrorPeriodic
 Mirror periodicity in z.
 
bool m_xAxiallyPeriodic
 Axial periodicity in x.
 
bool m_yAxiallyPeriodic
 Axial periodicity in y.
 
bool m_zAxiallyPeriodic
 Axial periodicity in z.
 
bool m_xRotationSymmetry
 Rotation symmetry around x-axis.
 
bool m_yRotationSymmetry
 Rotation symmetry around y-axis.
 
bool m_zRotationSymmetry
 Rotation symmetry around z-axis.
 
double m_bx0
 
double m_by0
 
double m_bz0
 
bool m_debug
 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 ( )

Definition at line 8 of file ComponentConstant.cc.

10 m_fx(0.),
11 m_fy(0.),
12 m_fz(0.),
13 m_hasPotential(false),
14 m_x0(0.),
15 m_y0(0.),
16 m_z0(0.),
17 m_v0(0.),
18 m_hasWeightingField(false),
19 m_wfield(""),
20 m_fwx(0.),
21 m_fwy(0.),
22 m_fwz(0.),
23 m_hasWeightingPotential(false),
24 m_wx0(0.),
25 m_wy0(0.),
26 m_wz0(0.),
27 m_w0(0.) {
28
29 m_className = "ComponentConstant";
30}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:6
std::string m_className
Class name.

◆ ~ComponentConstant()

Garfield::ComponentConstant::~ComponentConstant ( )
inline

Definition at line 16 of file ComponentConstant.hh.

16{}

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 
)
virtual

Implements Garfield::ComponentBase.

Definition at line 57 of file ComponentConstant.cc.

60 {
61
62 ex = m_fx;
63 ey = m_fy;
64 ez = m_fz;
65 if (m_hasPotential) {
66 v = m_v0 - (x - m_x0) * m_fx - (y - m_y0) * m_fy - (z - m_z0) * m_fz;
67 } else {
68 v = 0.;
69 if (m_debug) {
70 std::cerr << m_className << "::ElectricField:\n";
71 std::cerr << " Potential is not defined.\n";
72 }
73 }
74
75 m = GetMedium(x, y, z);
76 if (!m) {
77 if (m_debug) {
78 std::cerr << m_className << "::ElectricField:\n";
79 std::cerr << " (" << x << ", " << y << ", " << z << ")"
80 << " is not inside a medium.\n";
81 }
82 status = -6;
83 return;
84 }
85
86 if (m->IsDriftable()) {
87 status = 0;
88 } else {
89 status = -5;
90 }
91}
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 
)
virtual

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 32 of file ComponentConstant.cc.

34 {
35
36 ex = m_fx;
37 ey = m_fy;
38 ez = m_fz;
39 m = GetMedium(x, y, z);
40 if (!m) {
41 if (m_debug) {
42 std::cerr << m_className << "::ElectricField:\n";
43 std::cerr << " (" << x << ", " << y << ", " << z << ")"
44 << " is not inside a medium.\n";
45 }
46 status = -6;
47 return;
48 }
49
50 if (m->IsDriftable()) {
51 status = 0;
52 } else {
53 status = -5;
54 }
55}

◆ GetVoltageRange()

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

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 93 of file ComponentConstant.cc.

93 {
94
95 if (!m_hasPotential) return false;
96
97 if (!m_geometry) {
98 std::cerr << m_className << "::GetVoltageRange:\n";
99 std::cerr << " Geometry pointer is null.\n";
100 return false;
101 }
102 double xmin, ymin, zmin;
103 double xmax, ymax, zmax;
104 if (!GetBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax)) {
105 std::cerr << m_className << "::GetVoltageRange:\n";
106 std::cerr << " Could not determine bounding box.\n";
107 return false;
108 }
109 // Calculate potentials at each corner
110 const double pxmin = m_v0 - (xmin - m_x0) * m_fx;
111 const double pxmax = m_v0 - (xmax - m_x0) * m_fx;
112 const double pymin = m_v0 - (ymin - m_y0) * m_fy;
113 const double pymax = m_v0 - (ymax - m_y0) * m_fy;
114 const double pzmin = m_v0 - (zmin - m_z0) * m_fz;
115 const double pzmax = m_v0 - (zmax - m_z0) * m_fz;
116 double p[8];
117 p[0] = pxmin + pymin + pzmin;
118 p[1] = pxmin + pymin + pzmax;
119 p[2] = pxmin + pymax + pzmin;
120 p[3] = pxmin + pymax + pzmax;
121 p[4] = pxmax + pymin + pzmin;
122 p[5] = pxmax + pymin + pzmax;
123 p[6] = pxmax + pymax + pzmin;
124 p[7] = pxmax + pymax + pzmax;
125 vmin = vmax = p[7];
126 for (int i = 7; i--;) {
127 if (p[i] > vmax) vmax = p[i];
128 if (p[i] < vmin) vmin = p[i];
129 }
130
131 return true;
132}
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 
)

Definition at line 166 of file ComponentConstant.cc.

167 {
168
169 m_fx = ex;
170 m_fy = ey;
171 m_fz = ez;
172 if (m_fx * m_fx + m_fy * m_fy + m_fz * m_fz > Small) return;
173
174 std::cerr << m_className << "::SetField:\n";
175 std::cerr << " Electric field is set to zero.\n";
176 m_ready = true;
177}
bool m_ready
Ready for use?

◆ SetPotential()

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

Definition at line 179 of file ComponentConstant.cc.

180 {
181
182 m_x0 = x;
183 m_y0 = y;
184 m_z0 = z;
185 m_v0 = v;
186 m_hasPotential = true;
187}

◆ SetWeightingField()

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

Definition at line 189 of file ComponentConstant.cc.

191 {
192
193 m_wfield = label;
194 m_fwx = wx;
195 m_fwy = wy;
196 m_fwz = wz;
197 m_hasWeightingField = true;
198}

◆ SetWeightingPotential()

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

Definition at line 200 of file ComponentConstant.cc.

201 {
202
203 if (!m_hasWeightingField) {
204 std::cerr << m_className << "::SetWeightingPotential:\n";
205 std::cerr << " Set the weighting field first!\n";
206 return;
207 }
208 m_wx0 = x;
209 m_wy0 = y;
210 m_wz0 = z;
211 m_w0 = v;
212 m_hasWeightingPotential = true;
213}

◆ WeightingField()

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

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 134 of file ComponentConstant.cc.

136 {
137
138 if (!m_hasWeightingField || label != m_wfield) return;
139
140 Medium* m = GetMedium(x, y, z);
141 if (!m) {
142 wx = wy = wz = 0.;
143 if (m_debug) {
144 std::cout << m_className << "::WeightingField:\n";
145 std::cout << " No medium at (" << x << ", " << y << ", " << z << ")\n";
146 }
147 return;
148 }
149 wx = m_fwx;
150 wy = m_fwy;
151 wz = m_fwz;
152}

◆ WeightingPotential()

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

Reimplemented from Garfield::ComponentBase.

Definition at line 154 of file ComponentConstant.cc.

156 {
157
158 if (!m_hasWeightingPotential || label != m_wfield) return 0.;
159
160 Medium* m = GetMedium(x, y, z);
161 if (!m) return 0.;
162
163 return m_w0 - (x - m_wx0) * m_fwx - (y - m_wy0) * m_fwy - (z - m_wz0) * m_fwz;
164}

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