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

Two-dimensional implementation of the nearly exact Boundary Element Method. More...

#include <ComponentNeBem2d.hh>

+ Inheritance diagram for Garfield::ComponentNeBem2d:

Public Member Functions

 ComponentNeBem2d ()
 
 ~ComponentNeBem2d ()
 
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 SetProjectionX ()
 
void SetProjectionY ()
 
void SetProjectionZ ()
 
void AddPanel (const double x0, const double y0, const double x1, const double y1, const int bctype, const double bcval, const double lambda)
 
void AddWire (const double x0, const double y0, const double d, const double bcval)
 
void SetNumberOfDivisions (const int ndiv)
 
void SetNumberOfCollocationPoints (const int ncoll)
 
void SetMinimumElementSize (const double min)
 
void EnableAutoResizing ()
 
void DisableAutoResizing ()
 
void EnableRandomCollocation ()
 
void DisableRandomCollocation ()
 
void SetMaxNumberOfIterations (const int niter)
 
int GetNumberOfPanels ()
 
int GetNumberOfWires ()
 
int GetNumberOfElements ()
 
- 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

Two-dimensional implementation of the nearly exact Boundary Element Method.

Definition at line 10 of file ComponentNeBem2d.hh.

Constructor & Destructor Documentation

◆ ComponentNeBem2d()

Garfield::ComponentNeBem2d::ComponentNeBem2d ( )

Definition at line 13 of file ComponentNeBem2d.cc.

14 : projAxis(2),
15 nDivisions(5),
16 nCollocationPoints(3),
17 minSize(1.e-3),
18 autoSize(false),
19 randomCollocation(false),
20 nMaxIterations(3),
21 nPanels(0),
22 nWires(0),
23 nElements(0),
24 matrixInversionFlag(false) {
25
26 m_className = "ComponentNeBem2d";
27
28 influenceMatrix.clear();
29 inverseMatrix.clear();
30}
std::string m_className
Class name.

◆ ~ComponentNeBem2d()

Garfield::ComponentNeBem2d::~ComponentNeBem2d ( )
inline

Definition at line 15 of file ComponentNeBem2d.hh.

15{}

Member Function Documentation

◆ AddPanel()

void Garfield::ComponentNeBem2d::AddPanel ( const double  x0,
const double  y0,
const double  x1,
const double  y1,
const int  bctype,
const double  bcval,
const double  lambda 
)

Definition at line 127 of file ComponentNeBem2d.cc.

130 {
131
132 const double dx = x1 - x0;
133 const double dy = y1 - y0;
134 if (dx * dx + dy * dy <= Small) {
135 std::cerr << m_className << "::AddPanel:\n";
136 std::cerr << " Panel length must be greater than zero.\n";
137 return;
138 }
139
140 panel newPanel;
141 newPanel.x0 = x0;
142 newPanel.y0 = y0;
143 newPanel.x1 = x1;
144 newPanel.y1 = y1;
145 if (bctype < 0 || bctype > 3) {
146 std::cerr << m_className << "::AddPanel:\n";
147 std::cerr << " Unknown boundary condition type: " << bctype << "\n";
148 return;
149 }
150 newPanel.bcType = bctype;
151 newPanel.bcValue = bcval;
152 newPanel.lambda = lambda;
153 panels.push_back(newPanel);
154 ++nPanels;
155
156 if (m_debug) {
157 std::cout << m_className << "::AddPanel:\n";
158 std::cout << " From: (" << x0 << ", " << y0 << ")\n";
159 std::cout << " To: (" << x1 << ", " << y1 << ")\n";
160 switch (bctype) {
161 case 0:
162 std::cout << " Type: Conductor\n";
163 std::cout << " Potential: " << bcval << " V\n";
164 break;
165 case 1:
166 std::cout << " Floating conductor\n";
167 break;
168 case 2:
169 std::cout << " Dielectric-dielectric interface\n";
170 std::cout << " Lambda: " << lambda << "\n";
171 break;
172 case 3:
173 std::cout << " Surface charge\n";
174 break;
175 default:
176 std::cout << " Unknown boundary condition (program bug!)\n";
177 }
178 }
179
180 m_ready = false;
181 matrixInversionFlag = false;
182}
bool m_ready
Ready for use?
bool m_debug
Switch on/off debugging messages.

◆ AddWire()

void Garfield::ComponentNeBem2d::AddWire ( const double  x0,
const double  y0,
const double  d,
const double  bcval 
)

Definition at line 184 of file ComponentNeBem2d.cc.

185 {
186
187 if (d < Small) {
188 std::cerr << m_className << "::AddWire:\n";
189 std::cerr << " Wire diameter must be greater than zero.\n";
190 return;
191 }
192
193 wire newWire;
194 newWire.cX = x0;
195 newWire.cY = y0;
196 newWire.d = d;
197 newWire.bcValue = bcval;
198 wires.push_back(newWire);
199 ++nWires;
200
201 if (m_debug) {
202 std::cout << m_className << "::AddWire:\n";
203 std::cout << " Center: (" << x0 << ", " << y0 << ")\n";
204 std::cout << " Diameter: " << d << " cm\n";
205 std::cout << " Potential: " << bcval << " V\n";
206 }
207
208 m_ready = false;
209 matrixInversionFlag = false;
210}

◆ DisableAutoResizing()

void Garfield::ComponentNeBem2d::DisableAutoResizing ( )
inline

Definition at line 41 of file ComponentNeBem2d.hh.

41{ autoSize = false; }

◆ DisableRandomCollocation()

void Garfield::ComponentNeBem2d::DisableRandomCollocation ( )
inline

Definition at line 43 of file ComponentNeBem2d.hh.

43{ randomCollocation = false; }

◆ ElectricField() [1/2]

void Garfield::ComponentNeBem2d::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 32 of file ComponentNeBem2d.cc.

35 {
36
37 ex = ey = ez = v = 0.;
38 status = 0;
39 // Check if the requested point is inside a medium
40 m = GetMedium(x, y, z);
41 if (m == NULL) {
42 status = -6;
43 return;
44 }
45
46 if (!m_ready) {
47 if (!Initialise()) {
48 std::cerr << m_className << "::ElectricField:\n";
49 std::cerr << " Initialisation failed.\n";
50 status = -11;
51 return;
52 }
53 m_ready = true;
54 }
55
56 double dx = 0., dy = 0.;
57 double xLoc, yLoc;
58 double fx, fy, u;
59
60 // Sum up the contributions from all boundary elements
61 for (int i = nElements; i--;) {
62 dx = x - elements[i].cX;
63 dy = y - elements[i].cY;
64 // Transform to local coordinate system
65 Rotate(dx, dy, elements[i].phi, Global2Local, xLoc, yLoc);
66 // Compute the potential
67 if (!ComputePotential(elements[i].geoType, elements[i].len, xLoc, yLoc,
68 u)) {
69 std::cerr << m_className << "::ElectricField:\n";
70 std::cerr << " Potential contribution from element " << i
71 << " could not be calculated.\n";
72 status = -11;
73 return;
74 }
75 // Compute the field
76 if (!ComputeFlux(elements[i].geoType, elements[i].len, elements[i].phi,
77 xLoc, yLoc, fx, fy)) {
78 std::cerr << m_className << "::ElectricField:\n";
79 std::cerr << " Field contribution from element " << i
80 << " could not be calculated.\n";
81 status = -11;
82 return;
83 }
84 v += u * elements[i].solution;
85 ex += fx * elements[i].solution;
86 ey += fy * elements[i].solution;
87 }
88}
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::ComponentNeBem2d::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 90 of file ComponentNeBem2d.cc.

92 {
93
94 double v = 0.;
95 ElectricField(x, y, z, ex, ey, ez, v, m, status);
96}
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)

Referenced by ElectricField().

◆ EnableAutoResizing()

void Garfield::ComponentNeBem2d::EnableAutoResizing ( )
inline

Definition at line 40 of file ComponentNeBem2d.hh.

40{ autoSize = true; }

◆ EnableRandomCollocation()

void Garfield::ComponentNeBem2d::EnableRandomCollocation ( )
inline

Definition at line 42 of file ComponentNeBem2d.hh.

42{ randomCollocation = true; }

◆ GetNumberOfElements()

int Garfield::ComponentNeBem2d::GetNumberOfElements ( )
inline

Definition at line 48 of file ComponentNeBem2d.hh.

48{ return nElements; }

◆ GetNumberOfPanels()

int Garfield::ComponentNeBem2d::GetNumberOfPanels ( )
inline

Definition at line 46 of file ComponentNeBem2d.hh.

46{ return nPanels; }

◆ GetNumberOfWires()

int Garfield::ComponentNeBem2d::GetNumberOfWires ( )
inline

Definition at line 47 of file ComponentNeBem2d.hh.

47{ return nWires; }

◆ GetVoltageRange()

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

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 98 of file ComponentNeBem2d.cc.

98 {
99
100 if (nPanels <= 0 && nWires <= 0) return false;
101 bool gotValue = false;
102
103 for (int i = nPanels; i--;) {
104 if (panels[i].bcType != 0) continue;
105 if (!gotValue) {
106 vmin = vmax = panels[i].bcValue;
107 gotValue = true;
108 } else {
109 if (panels[i].bcValue < vmin) vmin = panels[i].bcValue;
110 if (panels[i].bcValue > vmax) vmax = panels[i].bcValue;
111 }
112 }
113
114 for (int i = nWires; i--;) {
115 if (!gotValue) {
116 vmin = vmax = wires[i].bcValue;
117 gotValue = true;
118 } else {
119 if (wires[i].bcValue < vmin) vmin = wires[i].bcValue;
120 if (wires[i].bcValue > vmax) vmax = wires[i].bcValue;
121 }
122 }
123
124 return gotValue;
125}

◆ SetMaxNumberOfIterations()

void Garfield::ComponentNeBem2d::SetMaxNumberOfIterations ( const int  niter)

Definition at line 251 of file ComponentNeBem2d.cc.

251 {
252
253 if (niter <= 0) {
254 std::cerr << m_className << "::SetMaxNumberOfIterations:\n";
255 std::cerr << " Number of iterations must be greater than zero.\n";
256 return;
257 }
258
259 nMaxIterations = niter;
260}

◆ SetMinimumElementSize()

void Garfield::ComponentNeBem2d::SetMinimumElementSize ( const double  min)

Definition at line 238 of file ComponentNeBem2d.cc.

238 {
239
240 if (min < Small) {
241 std::cerr << m_className << "::SetMinimumElementSize:\n";
242 std::cerr << " Provided element size is too small.\n";
243 return;
244 }
245
246 minSize = min;
247 m_ready = false;
248 matrixInversionFlag = false;
249}

◆ SetNumberOfCollocationPoints()

void Garfield::ComponentNeBem2d::SetNumberOfCollocationPoints ( const int  ncoll)

Definition at line 225 of file ComponentNeBem2d.cc.

225 {
226
227 if (ncoll <= 0) {
228 std::cerr << m_className << "::SetNumberOfCollocationPoints:\n";
229 std::cerr << " Number of coll. points must be greater than zero.\n";
230 return;
231 }
232
233 nCollocationPoints = ncoll;
234 m_ready = false;
235 matrixInversionFlag = false;
236}

◆ SetNumberOfDivisions()

void Garfield::ComponentNeBem2d::SetNumberOfDivisions ( const int  ndiv)

Definition at line 212 of file ComponentNeBem2d.cc.

212 {
213
214 if (ndiv <= 0) {
215 std::cerr << m_className << "::SetNumberOfDivisions:\n";
216 std::cerr << " Number of divisions must be greater than zero.\n";
217 return;
218 }
219
220 nDivisions = ndiv;
221 m_ready = false;
222 matrixInversionFlag = false;
223}

◆ SetProjectionX()

void Garfield::ComponentNeBem2d::SetProjectionX ( )
inline

Definition at line 27 of file ComponentNeBem2d.hh.

27{ projAxis = 0; }

◆ SetProjectionY()

void Garfield::ComponentNeBem2d::SetProjectionY ( )
inline

Definition at line 28 of file ComponentNeBem2d.hh.

28{ projAxis = 1; }

◆ SetProjectionZ()

void Garfield::ComponentNeBem2d::SetProjectionZ ( )
inline

Definition at line 29 of file ComponentNeBem2d.hh.

29{ projAxis = 2; }

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