Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
neBEM Namespace Reference

Functions

int neBEMSetDefaults (void)
 Assign default values to some of the important global variables.
 
int ReadInitFile (char filename[])
 
int neBEMGetInputsFromFiles (void)
 Do-nothing function (no file inputs).
 
int neBEMGetNbPrimitives ()
 Return the number of primitives.
 
int neBEMGetPrimitive (int prim, int *nvertex, double xvert[], double yvert[], double zvert[], double *xnorm, double *ynorm, double *znorm, int *volref1, int *volref2)
 Return one primitive at a time.
 
int neBEMGetPeriodicities (int, int *ix, int *jx, double *sx, int *iy, int *jy, double *sy, int *iz, int *jz, double *sz)
 
int neBEMGetMirror (int, int *ix, int *jx, double *sx, int *iy, int *jy, double *sy, int *iz, int *jz, double *sz)
 
int neBEMGetBoundingPlanes (int *ixmin, double *cxmin, double *vxmin, int *ixmax, double *cxmax, double *vxmax, int *iymin, double *cymin, double *vymin, int *iymax, double *cymax, double *vymax, int *izmin, double *czmin, double *vzmin, int *izmax, double *czmax, double *vzmax)
 
int neBEMVolumeDescription (int vol, int *shape, int *material, double *epsilon, double *potential, double *charge, int *boundarytype)
 Return information about a volume.
 
int neBEMVolumePoint (double x, double y, double z)
 Return the volume in which a point is located.
 
void neBEMVolumePrimitives (int, int *, int[])
 

Function Documentation

◆ neBEMGetBoundingPlanes()

int neBEM::neBEMGetBoundingPlanes ( int * ixmin,
double * cxmin,
double * vxmin,
int * ixmax,
double * cxmax,
double * vxmax,
int * iymin,
double * cymin,
double * vymin,
int * iymax,
double * cymax,
double * vymax,
int * izmin,
double * czmin,
double * vzmin,
int * izmax,
double * czmax,
double * vzmax )

Return infinite (bounding) conductors if any. ixmin=0: lower x-plane does not exist ixmin=1: lower x-plane does exist cxmin: coordinate of lower x-plane vxmin: potential of lower x-plane Similar for ixmax, iymin, iymax, izmin, izmax

Definition at line 308 of file NeBemInterface.cpp.

313 {
314 if (!Garfield::gComponentNeBem3d) return -1;
315 *ixmin = *ixmax = 0;
316 *vxmin = *vxmax = 0.;
317 *cxmin = *cxmax = 0.;
318 const unsigned int nx = Garfield::gComponentNeBem3d->GetNumberOfPlanesX();
319 for (unsigned int i = 0; i < nx; ++i) {
320 double x = 0., v = 0.;
321 Garfield::gComponentNeBem3d->GetPlaneX(i, x, v);
322 if (i == 0) {
323 *ixmin = 1;
324 *vxmin = v;
325 *cxmin = x;
326 } else {
327 *ixmax = 1;
328 *vxmax = v;
329 *cxmax = x;
330 }
331 }
332 *iymin = *iymax = 0;
333 *vymin = *vymax = 0.;
334 *cymin = *cymax = 0.;
335 const unsigned int ny = Garfield::gComponentNeBem3d->GetNumberOfPlanesY();
336 for (unsigned int i = 0; i < ny; ++i) {
337 double y = 0., v = 0.;
339 if (i == 0) {
340 *iymin = 1;
341 *vymin = v;
342 *cymin = y;
343 } else {
344 *iymax = 1;
345 *vymax = v;
346 *cymax = y;
347 }
348 }
349 *izmin = *izmax = 0;
350 *vzmin = *vzmax = 0.;
351 *czmin = *czmax = 0.;
352 const unsigned int nz = Garfield::gComponentNeBem3d->GetNumberOfPlanesZ();
353 for (unsigned int i = 0; i < nz; ++i) {
354 double z = 0., v = 0.;
356 if (i == 0) {
357 *izmin = 1;
358 *vzmin = v;
359 *czmin = z;
360 } else {
361 *izmax = 1;
362 *vzmax = v;
363 *czmax = z;
364 }
365 }
366 // Convert from cm to m.
367 *cxmin *= 0.01;
368 *cxmax *= 0.01;
369 *cymin *= 0.01;
370 *cymax *= 0.01;
371 *czmin *= 0.01;
372 *czmax *= 0.01;
373
374 return 0;
375}
bool GetPlaneZ(const unsigned int i, double &z, double &v) const
Retrieve the parameters of a plane at constant z.
bool GetPlaneY(const unsigned int i, double &y, double &v) const
Retrieve the parameters of a plane at constant y.
unsigned int GetNumberOfPlanesY() const
Get the number of equipotential planes at constant y.
unsigned int GetNumberOfPlanesZ() const
Get the number of equipotential planes at constant z.
ComponentNeBem3d * gComponentNeBem3d

Referenced by neBEMReadGeometry().

◆ neBEMGetInputsFromFiles()

int neBEM::neBEMGetInputsFromFiles ( void )

Do-nothing function (no file inputs).

Definition at line 189 of file NeBemInterface.cpp.

189{ return 0; }

Referenced by neBEMInitialize().

◆ neBEMGetMirror()

int neBEM::neBEMGetMirror ( int ,
int * ix,
int * jx,
double * sx,
int * iy,
int * jy,
double * sy,
int * iz,
int * jz,
double * sz )

Return information about mirror periodicity. ix: 0 = no mirror in x, 1 = producing charge density of opposite sign (infinite cond plane) 2 = producing charge density of same sign jx: not used at present sx: x distance of the mirror from origin

Definition at line 281 of file NeBemInterface.cpp.

282 {
283
284 if (!Garfield::gComponentNeBem3d) return -1;
285 *jx = *jy = *jz = 0;
286 bool perx = false, pery = false, perz = false;
287 Garfield::gComponentNeBem3d->IsMirrorPeriodic(perx, pery, perz);
288 // Only one reflection is allowed at present.
289 *ix = *iy = *iz = 0;
290 if (perx) {
291 *ix = 2;
292 } else if (pery) {
293 *iy = 2;
294 } else if (perz) {
295 *iz = 2;
296 }
297 // Mirror assumed to be passing through the origin.
298 *sx = *sy = *sz = 0.;
299 return 0;
300}

Referenced by neBEMReadGeometry().

◆ neBEMGetNbPrimitives()

int neBEM::neBEMGetNbPrimitives ( void )

Return the number of primitives.

Definition at line 192 of file NeBemInterface.cpp.

192 {
193 if (!Garfield::gComponentNeBem3d) return 0;
194 return Garfield::gComponentNeBem3d->GetNumberOfPrimitives();
195}

Referenced by neBEMReadGeometry().

◆ neBEMGetPeriodicities()

int neBEM::neBEMGetPeriodicities ( int ,
int * ix,
int * jx,
double * sx,
int * iy,
int * jy,
double * sy,
int * iz,
int * jz,
double * sz )

Return information about periodicities. ix: 0 = no periodicity in x, 1 = simple periodicity of length sx, 2 = mirror periodicity of length sx, 3 = axial periodicity around x with sector angle sx, 4 = rotational symmetry around x jx: number of periodic copies internally in neBEM

Definition at line 237 of file NeBemInterface.cpp.

238 {
239 if (!Garfield::gComponentNeBem3d) return -1;
240 *ix = 0;
241 *iy = 0;
242 *iz = 0;
243 bool perx = false, pery = false, perz = false;
244 Garfield::gComponentNeBem3d->IsPeriodic(perx, pery, perz);
245 if (perx) *ix = 1;
246 if (pery) *iy = 1;
247 if (perz) *iz = 1;
248 Garfield::gComponentNeBem3d->IsMirrorPeriodic(perx, pery, perz);
249 if (perx) *ix = 2;
250 if (pery) *iy = 2;
251 if (perz) *iz = 2;
252 *sx = 0.;
253 *sy = 0.;
254 *sz = 0.;
255 if (*ix > 0) Garfield::gComponentNeBem3d->GetPeriodicityX(*sx);
256 if (*iy > 0) Garfield::gComponentNeBem3d->GetPeriodicityY(*sy);
257 if (*iz > 0) Garfield::gComponentNeBem3d->GetPeriodicityZ(*sz);
258 // Convert from cm to m.
259 *sx *= 0.01;
260 *sy *= 0.01;
261 *sz *= 0.01;
262 *jx = 0;
263 *jy = 0;
264 *jz = 0;
265 if (*ix > 0 || *iy > 0 || *iz > 0) {
266 unsigned int nx = 0, ny = 0, nz = 0;
267 Garfield::gComponentNeBem3d->GetPeriodicCopies(nx, ny, nz);
268 *jx = nx;
269 *jy = ny;
270 *jz = nz;
271 }
272 return 0;
273}

Referenced by neBEMReadGeometry().

◆ neBEMGetPrimitive()

int neBEM::neBEMGetPrimitive ( int prim,
int * nvertex,
double xvert[],
double yvert[],
double zvert[],
double * xnorm,
double * ynorm,
double * znorm,
int * volref1,
int * volref2 )

Return one primitive at a time.

Definition at line 198 of file NeBemInterface.cpp.

200 {
201
202 if (!Garfield::gComponentNeBem3d) return -1;
203 if (prim < 1) return -1;
204 double a = 0., b = 0., c = 0.;
205 std::vector<double> xv;
206 std::vector<double> yv;
207 std::vector<double> zv;
208 int vol1 = 0, vol2 = 0;
209 if (!Garfield::gComponentNeBem3d->GetPrimitive(prim - 1, a, b, c,
210 xv, yv, zv, vol1, vol2)) {
211 return -1;
212 }
213 const size_t nv = xv.size();
214 *nvertex = nv;
215 for (size_t i = 0; i < nv; ++i) {
216 // Convert from cm to m.
217 xvert[i] = 0.01 * xv[i];
218 yvert[i] = 0.01 * yv[i];
219 zvert[i] = 0.01 * zv[i];
220 }
221 *xnorm = a;
222 *ynorm = b;
223 *znorm = c;
224 if (nv == 2) *xnorm *= 0.01;
225 *volref1 = vol1;
226 *volref2 = vol2;
227 return 0;
228}

Referenced by neBEMReadGeometry().

◆ neBEMSetDefaults()

int neBEM::neBEMSetDefaults ( void )

Assign default values to some of the important global variables.

Definition at line 13 of file NeBemInterface.cpp.

13 {
14
15 neBEMState = 0;
16
17 NbVolumes = 2;
18 VolMax = 2;
19
20 NbPrimitives = 1;
21 MaxNbVertices = 4;
22
23 NbSurfs = 1;
24 NbWires = 0;
25
28 ElementLengthRqstd = 100.0e-6;
29
30 NewModel = 1;
31 NewMesh = 1;
32 NewBC = 1;
33 NewPP = 1;
34 ModelCntr = 1;
35 MeshCntr = 1;
36 BCCntr = 1;
37 PPCntr = 1;
38
39 DebugLevel = 0;
40
41 LengthScale = 1.0;
42
43 TimeStep = 1;
44
45 strcpy(DeviceOutDir, "neBEMOut");
46
47 OptDeviceFile = 0;
48 strcpy(DeviceInputFile, "");
49
53
54 OptGnuplot = 1;
59
60 // Same directory can be used over and over again - BEWARE!
61 OptReuseDir = 1;
62
63 // Matrix inversion procedure => 0: LU, 1: SVD, 2:GSL
64 OptInvMatProc = 0;
65
75
77
78 return 0;
79} // neBEMSetDefaults ends
INTFACEGLOBAL int OptPrimitiveFiles
INTFACEGLOBAL int neBEMState
INTFACEGLOBAL int OptPrintVolumeDetails
INTFACEGLOBAL char DeviceInputFile[256]
INTFACEGLOBAL int OptGnuplotPrimitives
INTFACEGLOBAL int OptDeviceFile
INTFACEGLOBAL int OptPrintPrimaryDetails
INTFACEGLOBAL int OptPrintVertexAndNormal
INTFACEGLOBAL int OptElementFiles
INTFACEGLOBAL int OptGnuplot
INTFACEGLOBAL int OptGnuplotElements
INTFACEGLOBAL int OptReuseDir
neBEMGLOBAL int DebugLevel
Definition neBEM.h:195
neBEMGLOBAL int NbVolumes
Definition neBEM.h:63
neBEMGLOBAL int MeshCntr
Definition neBEM.h:184
neBEMGLOBAL int PPCntr
Definition neBEM.h:184
neBEMGLOBAL int OptInvMatProc
Definition neBEM.h:43
neBEMGLOBAL int OptRepeatLHMatrix
Definition neBEM.h:58
neBEMGLOBAL int OptStorePrimitives
Definition neBEM.h:51
neBEMGLOBAL int MaxNbVertices
Definition neBEM.h:66
neBEMGLOBAL double ElementLengthRqstd
Definition neBEM.h:114
neBEMGLOBAL int NewModel
Definition neBEM.h:180
neBEMGLOBAL int OptFormattedFile
Definition neBEM.h:56
neBEMGLOBAL int NewMesh
Definition neBEM.h:180
neBEMGLOBAL int NbPrimitives
Definition neBEM.h:64
neBEMGLOBAL int NbWires
Definition neBEM.h:104
neBEMGLOBAL int OptSystemChargeZero
Definition neBEM.h:125
neBEMGLOBAL int NewPP
Definition neBEM.h:180
neBEMGLOBAL int NbSurfs
Definition neBEM.h:104
neBEMGLOBAL int BCCntr
Definition neBEM.h:184
neBEMGLOBAL int TimeStep
Definition neBEM.h:201
neBEMGLOBAL int OptStoreInflMatrix
Definition neBEM.h:47
neBEMGLOBAL int OptForceValidation
Definition neBEM.h:45
neBEMGLOBAL int OptUnformattedFile
Definition neBEM.h:57
neBEMGLOBAL double LengthScale
Definition neBEM.h:198
neBEMGLOBAL int MaxNbElementsOnLength
Definition neBEM.h:112
neBEMGLOBAL int ModelCntr
Definition neBEM.h:184
neBEMGLOBAL int OptValidateSolution
Definition neBEM.h:44
neBEMGLOBAL char DeviceOutDir[256]
Definition neBEM.h:222
neBEMGLOBAL int OptStoreElements
Definition neBEM.h:54
neBEMGLOBAL int VolMax
Definition neBEM.h:84
neBEMGLOBAL int OptStoreInvMatrix
Definition neBEM.h:49
neBEMGLOBAL int NewBC
Definition neBEM.h:180
neBEMGLOBAL int MinNbElementsOnLength
Definition neBEM.h:110

Referenced by neBEMInitialize().

◆ neBEMVolumeDescription()

int neBEM::neBEMVolumeDescription ( int vol,
int * shape,
int * material,
double * epsilon,
double * potential,
double * charge,
int * boundarytype )

Return information about a volume.

Definition at line 378 of file NeBemInterface.cpp.

380 {
381
382 if (!Garfield::gComponentNeBem3d) return -1;
383 if (!Garfield::gComponentNeBem3d->GetVolume(vol, *shape, *material,
384 *epsilon, *potential, *charge,
385 *boundarytype)) {
386 return 0;
387 }
388 return 1;
389}

Referenced by neBEMReadGeometry(), and ReadPrimitives().

◆ neBEMVolumePoint()

int neBEM::neBEMVolumePoint ( double x,
double y,
double z )

Return the volume in which a point is located.

Definition at line 392 of file NeBemInterface.cpp.

392 {
393
394 if (!Garfield::gComponentNeBem3d) return -1;
395 return Garfield::gComponentNeBem3d->GetVolume(100. * x, 100. * y, 100. * z);
396}

Referenced by MapFPR(), and VoxelFPR().

◆ neBEMVolumePrimitives()

void neBEM::neBEMVolumePrimitives ( int ,
int * ,
int [] )

Return the primitives for a volume. TODO! Do we need this?

Definition at line 400 of file NeBemInterface.cpp.

400 {
401
402}

◆ ReadInitFile()

int neBEM::ReadInitFile ( char filename[])

Definition at line 81 of file NeBemInterface.cpp.

81 {
82 FILE* finit = fopen(filename, "r");
83 if (finit == NULL) {
84 neBEMMessage("ReadInitFile - fail to open init file");
85 return -1;
86 }
87
88 fscanf(finit, "MinNbElementsOnLength: %d\n", &MinNbElementsOnLength);
89 fscanf(finit, "MaxNbElementsOnLength: %d\n", &MaxNbElementsOnLength);
90 fscanf(finit, "ElementLengthRqstd: %le\n", &ElementLengthRqstd);
91 fscanf(finit, "LengthScale: %le\n", &LengthScale);
92
93 fscanf(finit, "DebugLevel: %d\n", &DebugLevel);
94
95 fscanf(finit, "NewModel: %d\n", &NewModel);
96 fscanf(finit, "NewMesh: %d\n", &NewMesh);
97 fscanf(finit, "NewBC: %d\n", &NewBC);
98 fscanf(finit, "NewPP: %d\n", &NewPP);
99 fscanf(finit, "ModelCntr: %d\n", &ModelCntr);
100 fscanf(finit, "MeshCntr: %d\n", &MeshCntr);
101 fscanf(finit, "BCCntr: %d\n", &BCCntr);
102 fscanf(finit, "PPCntr: %d\n", &PPCntr);
103
104 fscanf(finit, "DeviceOutDir: %255s\n", DeviceOutDir);
105
106 fscanf(finit, "OptDeviceFile: %d\n", &OptDeviceFile);
107 fscanf(finit, "DeviceInputFile: %255s\n", DeviceInputFile);
108
109 fscanf(finit, "OptPrintPrimaryDetails: %d\n", &OptPrintPrimaryDetails);
110 fscanf(finit, "OptPrintVolumeDetails: %d\n", &OptPrintVolumeDetails);
111 fscanf(finit, "OptPrintVertexAndNormal: %d\n", &OptPrintVertexAndNormal);
112
113 fscanf(finit, "OptGnuplot: %d\n", &OptGnuplot);
114 fscanf(finit, "OptGnuplotPrimitives: %d\n", &OptGnuplotPrimitives);
115 fscanf(finit, "OptGnuplotElements: %d\n", &OptGnuplotElements);
116
117 fscanf(finit, "OptPrimitiveFiles: %d\n", &OptPrimitiveFiles);
118 fscanf(finit, "OptElementFiles: %d\n", &OptElementFiles);
119
120 fscanf(finit, "OptReuseDir: %d\n", &OptReuseDir);
121
122 fscanf(finit, "OptInvMatProc: %d\n", &OptInvMatProc);
123
124 fscanf(finit, "OptValidateSolution: %d\n", &OptValidateSolution);
125 fscanf(finit, "OptForceValidation: %d\n", &OptForceValidation);
126 fscanf(finit, "OptStorePrimitives: %d\n", &OptStorePrimitives);
127 fscanf(finit, "OptStoreElements: %d\n", &OptStoreElements);
128 fscanf(finit, "OptStoreInflMatrix: %d\n", &OptStoreInflMatrix);
129 fscanf(finit, "OptStoreInvMatrix: %d\n", &OptStoreInvMatrix);
130 fscanf(finit, "OptFormattedFile: %d\n", &OptFormattedFile);
131 fscanf(finit, "OptUnformattedFile: %d\n", &OptUnformattedFile);
132 fscanf(finit, "OptRepeatLHMatrix: %d\n", &OptRepeatLHMatrix);
133
134 fscanf(finit, "OptSystemChargeZero: %d\n", &OptSystemChargeZero);
135
136 fscanf(finit, "PrimAfter: %d\n", &PrimAfter);
137
138 fclose(finit);
139
140 fprintf(stdout, "MinNbElementsOnLength: %d\n", MinNbElementsOnLength);
141 fprintf(stdout, "MaxNbElementsOnLength: %d\n", MaxNbElementsOnLength);
142 fprintf(stdout, "ElementLengthRqstd: %e\n", ElementLengthRqstd);
143 fprintf(stdout, "LengthScale: %e\n", LengthScale);
144
145 fprintf(stdout, "NewModel: %d\n", NewModel);
146 fprintf(stdout, "NewMesh: %d\n", NewMesh);
147 fprintf(stdout, "NewBC: %d\n", NewBC);
148 fprintf(stdout, "NewPP: %d\n", NewPP);
149 fprintf(stdout, "ModelCntr: %d\n", ModelCntr);
150 fprintf(stdout, "MeshCntr: %d\n", MeshCntr);
151 fprintf(stdout, "BCCntr: %d\n", BCCntr);
152 fprintf(stdout, "PPCntr: %d\n", PPCntr);
153
154 fprintf(stdout, "DeviceOutDir: %s\n", DeviceOutDir);
155
156 fprintf(stdout, "OptDeviceFile: %d\n", OptDeviceFile);
157 fprintf(stdout, "DeviceInputFile: %s\n", DeviceInputFile);
158
159 fprintf(stdout, "OptPrintPrimaryDetails: %d\n", OptPrintPrimaryDetails);
160 fprintf(stdout, "OptPrintVolumeDetails: %d\n", OptPrintVolumeDetails);
161 fprintf(stdout, "OptPrintVertexAndNormal: %d\n", OptPrintVertexAndNormal);
162
163 fprintf(stdout, "OptGnuplot: %d\n", OptGnuplot);
164 fprintf(stdout, "OptGnuplotPrimitives: %d\n", OptGnuplotPrimitives);
165 fprintf(stdout, "OptGnuplotElements: %d\n", OptGnuplotElements);
166
167 fprintf(stdout, "OptPrimitiveFiles: %d\n", OptPrimitiveFiles);
168 fprintf(stdout, "OptElementFiles: %d\n", OptElementFiles);
169
170 fprintf(stdout, "OptReuseDir: %d\n", OptReuseDir);
171
172 fprintf(stdout, "OptValidateSolution: %d\n", OptValidateSolution);
173 fprintf(stdout, "OptStorePrimitives: %d\n", OptStorePrimitives);
174 fprintf(stdout, "OptStoreElements: %d\n", OptStoreElements);
175 fprintf(stdout, "OptStoreInflMatrix: %d\n", OptStoreInflMatrix);
176 fprintf(stdout, "OptStoreInvMatrix: %d\n", OptStoreInvMatrix);
177 fprintf(stdout, "OptFormattedFile: %d\n", OptFormattedFile);
178 fprintf(stdout, "OptUnformattedFile: %d\n", OptUnformattedFile);
179 fprintf(stdout, "OptRepeatLHMatrix: %d\n", OptRepeatLHMatrix);
180
181 fprintf(stdout, "OptSystemChargeZero: %d\n", OptSystemChargeZero);
182
183 fprintf(stdout, "PrimAfter: %d\n", PrimAfter);
184
185 return 0;
186}
int neBEMMessage(const char *message)
neBEMGLOBAL int PrimAfter
Definition neBEM.h:364