Garfield++ v1r0
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

#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)
 
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 ()
 
virtual ~ComponentBase ()
 
virtual void SetGeometry (GeometryBase *geo)
 
virtual void Clear ()
 
virtual MediumGetMedium (const double &x, const double &y, const double &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
 
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)
 
virtual bool IsReady ()
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 
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 (double x0, double y0, double z0, double &xw, double &yw, double &rw)
 
void EnablePeriodicityX ()
 
void DisablePeriodicityX ()
 
void EnablePeriodicityY ()
 
void DisablePeriodicityY ()
 
void EnablePeriodicityZ ()
 
void DisablePeriodicityZ ()
 
void EnableMirrorPeriodicityX ()
 
void DisableMirrorPeriodicityX ()
 
void EnableMirrorPeriodicityY ()
 
void DisableMirrorPeriodicityY ()
 
void EnableMirrorPeriodicityZ ()
 
void DisableMirrorPeriodicityZ ()
 
void EnableAxialPeriodicityX ()
 
void DisableAxialPeriodicityX ()
 
void EnableAxialPeriodicityY ()
 
void DisableAxialPeriodicityY ()
 
void EnableAxialPeriodicityZ ()
 
void DisableAxialPeriodicityZ ()
 
void EnableRotationSymmetryX ()
 
void DisableRotationSymmetryX ()
 
void EnableRotationSymmetryY ()
 
void DisableRotationSymmetryY ()
 
void EnableRotationSymmetryZ ()
 
void DisableRotationSymmetryZ ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

Additional Inherited Members

virtual void Reset ()=0
 
virtual void UpdatePeriodicity ()=0
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className
 
GeometryBasetheGeometry
 
bool ready
 
bool xPeriodic
 
bool yPeriodic
 
bool zPeriodic
 
bool xMirrorPeriodic
 
bool yMirrorPeriodic
 
bool zMirrorPeriodic
 
bool xAxiallyPeriodic
 
bool yAxiallyPeriodic
 
bool zAxiallyPeriodic
 
bool xRotationSymmetry
 
bool yRotationSymmetry
 
bool zRotationSymmetry
 
double bx0
 
double by0
 
double bz0
 
bool debug
 

Detailed Description

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}

◆ ~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 (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 ready = false;
181 matrixInversionFlag = false;
182}

◆ 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 (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 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 (!ready) {
47 if (!Initialise()) {
48 std::cerr << m_className << "::ElectricField:\n";
49 std::cerr << " Initialisation failed.\n";
50 status = -11;
51 return;
52 }
53 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)

◆ 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

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

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 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 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 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: