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

Interpolation in a three-dimensional field map created by Sentaurus Device. More...

#include <ComponentTcad3d.hh>

+ Inheritance diagram for Garfield::ComponentTcad3d:

Public Member Functions

 ComponentTcad3d ()
 Constructor.
 
 ~ComponentTcad3d ()
 Destructor.
 
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).
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
 
MediumGetMedium (const double x, const double y, const double z) override
 Get the medium at a given location (x, y, z).
 
bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
 Get the bounding box coordinates.
 
bool GetElementaryCell (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
 Get the coordinates of the elementary cell.
 
bool GetElement (const size_t i, double &vol, double &dmin, double &dmax, int &type, std::vector< size_t > &nodes, int &reg) const
 
bool GetNode (const size_t i, double &x, double &y, double &z, double &v, double &ex, double &ey, double &ez) const
 
- Public Member Functions inherited from Garfield::ComponentTcadBase< 3 >
 ComponentTcadBase ()=delete
 Default constructor.
 
 ComponentTcadBase (const std::string &name)
 Constructor.
 
virtual ~ComponentTcadBase ()
 Destructor.
 
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
 
bool GetVoltageRange (double &vmin, double &vmax) override
 Calculate the voltage range [V].
 
bool Initialise (const std::string &gridfilename, const std::string &datafilename)
 
bool SetWeightingField (const std::string &datfile1, const std::string &datfile2, const double dv, const std::string &label)
 
bool SetWeightingFieldShift (const std::string &label, const double x, const double y, const double z)
 
void PrintRegions () const
 List all currently defined regions.
 
size_t GetNumberOfRegions () const
 Get the number of regions in the device.
 
void GetRegion (const size_t ireg, std::string &name, bool &active) const
 Get the name and "active volume" flag of a region.
 
void SetDriftRegion (const size_t ireg)
 Make a region active ("driftable").
 
void UnsetDriftRegion (const size_t ireg)
 Make a region inactive.
 
void SetMedium (const size_t ireg, Medium *m)
 Set the medium to be associated to a given region.
 
size_t GetNumberOfElements () const
 Get the number of elements in the mesh.
 
size_t GetNumberOfNodes () const
 Get the number of vertices in the mesh.
 
void EnableVelocityMap (const bool on)
 Switch use of the imported velocity map on/off.
 
bool HasVelocityMap () const override
 Does the component have velocity maps?
 
bool ElectronVelocity (const double x, const double y, const double z, double &vx, double &vy, double &vz) override
 Get the electron drift velocity.
 
bool HoleVelocity (const double x, const double y, const double z, double &vx, double &vy, double &vz) override
 Get the hole drift velocity.
 
size_t GetNumberOfDonors ()
 Get the number of donor states found in the map.
 
size_t GetNumberOfAcceptors ()
 Get the number of acceptor states found in the map.
 
bool SetDonor (const size_t donorNumber, const double exsec, const double hxsec, const double concentration)
 
bool SetAcceptor (const size_t acceptorNumber, const double exsec, const double hxsec, const double concentration)
 Set the properties of an acceptor-type defect state.
 
void EnableAttachmentMap (const bool on)
 Switch use of the imported trapping map on/off.
 
bool HasAttachmentMap () const override
 Does the component have attachment maps?
 
bool ElectronAttachment (const double x, const double y, const double z, double &eta) override
 Get the electron attachment coefficient.
 
bool HoleAttachment (const double x, const double y, const double z, double &eta) override
 Get the hole attachment coefficient.
 
bool GetElectronLifetime (const double x, const double y, const double z, double &etau) override
 
bool GetHoleLifetime (const double x, const double y, const double z, double &htau) override
 
bool GetElectronMobility (const double x, const double y, const double z, double &mob)
 
bool GetHoleMobility (const double x, const double y, const double z, double &mob)
 
- Public Member Functions inherited from Garfield::Component
 Component ()=delete
 Default constructor.
 
 Component (const std::string &name)
 Constructor.
 
virtual ~Component ()
 Destructor.
 
virtual void SetGeometry (Geometry *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 double DelayedWeightingPotential (const double x, const double y, const double z, const double t, 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 GetElementaryCell (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 Get the coordinates of the elementary cell.
 
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 IntegrateFluxParallelogram (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)
 
double IntegrateWeightingFluxParallelogram (const std::string &label, 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)
 
double IntegrateFluxLine (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const double xp, const double yp, const double zp, const unsigned int nI, const int isign=0)
 
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 EnablePeriodicityY (const bool on=true)
 Enable simple periodicity in the $y$ direction.
 
void EnablePeriodicityZ (const bool on=true)
 Enable simple periodicity in the $z$ direction.
 
void IsPeriodic (bool &perx, bool &pery, bool &perz)
 Return periodicity flags.
 
void EnableMirrorPeriodicityX (const bool on=true)
 Enable mirror periodicity in the $x$ direction.
 
void EnableMirrorPeriodicityY (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void EnableMirrorPeriodicityZ (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void IsMirrorPeriodic (bool &perx, bool &pery, bool &perz)
 Return mirror periodicity flags.
 
void EnableAxialPeriodicityX (const bool on=true)
 Enable axial periodicity in the $x$ direction.
 
void EnableAxialPeriodicityY (const bool on=true)
 Enable axial periodicity in the $y$ direction.
 
void EnableAxialPeriodicityZ (const bool on=true)
 Enable axial periodicity in the $z$ direction.
 
void IsAxiallyPeriodic (bool &perx, bool &pery, bool &perz)
 Return axial periodicity flags.
 
void EnableRotationSymmetryX (const bool on=true)
 Enable rotation symmetry around the $x$ axis.
 
void EnableRotationSymmetryY (const bool on=true)
 Enable rotation symmetry around the $y$ axis.
 
void EnableRotationSymmetryZ (const bool on=true)
 Enable rotation symmetry around the $z$ axis.
 
void IsRotationSymmetric (bool &rotx, bool &roty, bool &rotz)
 Return rotation symmetry flags.
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 
virtual bool HasAttachmentMap () const
 Does the component have attachment maps?
 
virtual bool HasVelocityMap () const
 Does the component have velocity maps?
 
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 bool ElectronVelocity (const double, const double, const double, double &vx, double &vy, double &vz)
 Get the electron drift velocity.
 
virtual bool HoleVelocity (const double, const double, const double, double &vx, double &vy, double &vz)
 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

- Protected Member Functions inherited from Garfield::ComponentTcadBase< 3 >
void UpdatePeriodicity () override
 Verify periodicities.
 
void Cleanup ()
 
virtual bool Interpolate (const double x, const double y, const double z, const std::vector< double > &field, double &f)=0
 
virtual bool Interpolate (const double x, const double y, const double z, const std::vector< std::array< double, N > > &field, double &fx, double &fy, double &fz)=0
 
virtual void FillTree ()=0
 
size_t FindRegion (const std::string &name) const
 
void MapCoordinates (std::array< double, N > &x, std::array< bool, N > &mirr) const
 
bool InBoundingBox (const std::array< double, N > &x) const
 
void UpdateAttachment ()
 
bool LoadGrid (const std::string &gridfilename)
 
bool LoadData (const std::string &datafilename)
 
bool ReadDataset (std::ifstream &datafile, const std::string &dataset)
 
bool LoadWeightingField (const std::string &datafilename, std::vector< std::array< double, N > > &wf, std::vector< double > &wp)
 
virtual void Reset ()=0
 Reset the component.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Static Protected Member Functions inherited from Garfield::ComponentTcadBase< 3 >
static unsigned int ElementVertices (const Element &element)
 
- Protected Attributes inherited from Garfield::ComponentTcadBase< 3 >
std::vector< Region > m_regions
 
std::vector< std::array< double, N > > m_vertices
 
std::vector< Elementm_elements
 
std::vector< double > m_epot
 
std::vector< std::array< double, N > > m_efield
 
std::vector< std::array< double, N > > m_wfield
 
std::vector< double > m_wpot
 
std::vector< std::string > m_wlabel
 
std::vector< std::array< double, 3 > > m_wshift
 
std::vector< std::array< double, N > > m_eVelocity
 
std::vector< std::array< double, N > > m_hVelocity
 
std::vector< double > m_eMobility
 
std::vector< double > m_hMobility
 
std::vector< double > m_eLifetime
 
std::vector< double > m_hLifetime
 
std::vector< std::vector< float > > m_donorOcc
 
std::vector< std::vector< float > > m_acceptorOcc
 
std::vector< double > m_eAttachment
 
std::vector< double > m_hAttachment
 
std::vector< Defect > m_donors
 
std::vector< Defect > m_acceptors
 
bool m_useVelocityMap
 
bool m_useAttachmentMap
 
std::array< double, 3 > m_bbMin
 
std::array< double, 3 > m_bbMax
 
double m_pMin
 
double m_pMax
 
- Protected Attributes inherited from Garfield::Component
std::string m_className = "Component"
 Class name.
 
Geometrym_geometry = nullptr
 Pointer to the geometry.
 
std::array< double, 3 > m_b0 = {{0., 0., 0.}}
 Constant magnetic field.
 
bool m_ready = false
 Ready for use?
 
bool m_debug = false
 Switch on/off debugging messages.
 
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.
 
- Static Protected Attributes inherited from Garfield::ComponentTcadBase< 3 >
static constexpr size_t nMaxVertices
 

Detailed Description

Interpolation in a three-dimensional field map created by Sentaurus Device.

Definition at line 13 of file ComponentTcad3d.hh.

Constructor & Destructor Documentation

◆ ComponentTcad3d()

Garfield::ComponentTcad3d::ComponentTcad3d ( )

Constructor.

Definition at line 11 of file ComponentTcad3d.cc.

11: ComponentTcadBase("Tcad3d") {}
ComponentTcadBase()=delete
Default constructor.

◆ ~ComponentTcad3d()

Garfield::ComponentTcad3d::~ComponentTcad3d ( )
inline

Destructor.

Definition at line 18 of file ComponentTcad3d.hh.

18{}

Member Function Documentation

◆ ElectricField() [1/2]

void Garfield::ComponentTcad3d::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::Component.

Definition at line 13 of file ComponentTcad3d.cc.

16 {
17 // Assume this will work.
18 status = 0;
19 ex = ey = ez = p = 0.;
20 m = nullptr;
21 // Make sure the field map has been loaded.
22 if (!m_ready) {
23 std::cerr << m_className << "::ElectricField:\n"
24 << " Field map is not available for interpolation.\n";
25 status = -10;
26 return;
27 }
28 std::array<double, 3> x = {xin, yin, zin};
29 std::array<bool, 3> mirr = {false, false, false};
30 // In case of periodicity, reduce to the cell volume.
31 MapCoordinates(x, mirr);
32 // Check if the point is inside the bounding box.
33 if (!InBoundingBox(x)) {
34 status = -6;
35 return;
36 }
37
38 std::array<double, nMaxVertices> w;
39 const size_t i = FindElement(x[0], x[1], x[2], w);
40 if (i >= m_elements.size()) {
41 // Point is outside the mesh.
42 status = -6;
43 return;
44 }
45 const Element& element = m_elements[i];
46 const unsigned int nVertices = ElementVertices(element);
47 for (unsigned int j = 0; j < nVertices; ++j) {
48 const auto index = element.vertex[j];
49 ex += w[j] * m_efield[index][0];
50 ey += w[j] * m_efield[index][1];
51 ez += w[j] * m_efield[index][2];
52 p += w[j] * m_epot[index];
53 }
54 if (mirr[0]) ex = -ex;
55 if (mirr[1]) ey = -ey;
56 if (mirr[2]) ez = -ez;
57 m = m_regions[element.region].medium;
58 if (!m_regions[element.region].drift || !m) status = -5;
59}
bool InBoundingBox(const std::array< double, N > &x) const
static unsigned int ElementVertices(const Element &element)
std::vector< std::array< double, N > > m_efield
void MapCoordinates(std::array< double, N > &x, std::array< bool, N > &mirr) const
std::string m_className
Class name.
Definition: Component.hh:329
bool m_ready
Ready for use?
Definition: Component.hh:338
Definition: neBEM.h:155

Referenced by ElectricField().

◆ ElectricField() [2/2]

void Garfield::ComponentTcad3d::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::Component.

Definition at line 61 of file ComponentTcad3d.cc.

63 {
64 double v = 0.;
65 ElectricField(x, y, z, ex, ey, ez, v, m, status);
66}
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).

◆ GetBoundingBox()

bool Garfield::ComponentTcad3d::GetBoundingBox ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
)
overridevirtual

Get the bounding box coordinates.

Reimplemented from Garfield::Component.

Definition at line 177 of file ComponentTcad3d.cc.

178 {
179 if (!m_ready) return false;
180 xmin = m_bbMin[0];
181 ymin = m_bbMin[1];
182 zmin = m_bbMin[2];
183 xmax = m_bbMax[0];
184 ymax = m_bbMax[1];
185 zmax = m_bbMax[2];
186 if (m_periodic[0] || m_mirrorPeriodic[0]) {
187 xmin = -std::numeric_limits<double>::infinity();
188 xmax = +std::numeric_limits<double>::infinity();
189 }
190 if (m_periodic[1] || m_mirrorPeriodic[1]) {
191 ymin = -std::numeric_limits<double>::infinity();
192 ymax = +std::numeric_limits<double>::infinity();
193 }
194 if (m_periodic[2] || m_mirrorPeriodic[2]) {
195 zmin = -std::numeric_limits<double>::infinity();
196 zmax = +std::numeric_limits<double>::infinity();
197 }
198 return true;
199}
std::array< bool, 3 > m_mirrorPeriodic
Mirror periodicity in x, y, z.
Definition: Component.hh:346
std::array< bool, 3 > m_periodic
Simple periodicity in x, y, z.
Definition: Component.hh:344

◆ GetElement()

bool Garfield::ComponentTcad3d::GetElement ( const size_t  i,
double &  vol,
double &  dmin,
double &  dmax,
int &  type,
std::vector< size_t > &  nodes,
int &  reg 
) const

Retrieve the properties of an element.

Parameters
iindex of the element
volvolume
dminsmallest length in the element
dmaxlargest length in the element
typeelement type
nodesindices of the constituent vertices
regregion

Definition at line 239 of file ComponentTcad3d.cc.

241 {
242 nodes.clear();
243 if (i >= m_elements.size()) {
244 std::cerr << m_className << "::GetElement: Index out of range.\n";
245 return false;
246 }
247
248 const Element& element = m_elements[i];
249 if (element.type == 2) {
250 // Triangle
251 const auto& v0 = m_vertices[element.vertex[0]];
252 const auto& v1 = m_vertices[element.vertex[1]];
253 const auto& v2 = m_vertices[element.vertex[2]];
254 const double vx = (v1[1] - v0[1]) * (v2[2] - v0[2]) -
255 (v1[2] - v0[2]) * (v2[1] - v0[1]);
256 const double vy = (v1[2] - v0[2]) * (v2[0] - v0[0]) -
257 (v1[0] - v0[0]) * (v2[2] - v0[2]);
258 const double vz = (v1[0] - v0[0]) * (v2[1] - v0[1]) -
259 (v1[1] - v0[1]) * (v2[0] - v0[0]);
260 vol = sqrt(vx * vx + vy * vy + vz * vz);
261 const double a = sqrt(pow(v1[0] - v0[0], 2) + pow(v1[1] - v0[1], 2) +
262 pow(v1[2] - v0[2], 2));
263 const double b = sqrt(pow(v2[0] - v0[0], 2) + pow(v2[1] - v0[1], 2) +
264 pow(v2[2] - v0[2], 2));
265 const double c = sqrt(pow(v1[0] - v2[0], 2) + pow(v1[1] - v2[1], 2) +
266 pow(v1[2] - v2[2], 2));
267 dmin = std::min({a, b, c});
268 dmax = std::max({a, b, c});
269 } else if (element.type == 5) {
270 // Tetrahedron
271 const auto& v0 = m_vertices[element.vertex[0]];
272 const auto& v1 = m_vertices[element.vertex[1]];
273 const auto& v2 = m_vertices[element.vertex[2]];
274 const auto& v3 = m_vertices[element.vertex[3]];
275 vol = fabs((v3[0] - v0[0]) * ((v1[1] - v0[1]) * (v2[2] - v0[2]) -
276 (v2[1] - v0[1]) * (v1[2] - v0[2])) +
277 (v3[1] - v0[1]) * ((v1[2] - v0[2]) * (v2[0] - v0[0]) -
278 (v2[2] - v0[2]) * (v1[0] - v0[0])) +
279 (v3[2] - v0[2]) * ((v1[0] - v0[0]) * (v2[1] - v0[1]) -
280 (v3[0] - v0[0]) * (v1[1] - v0[1]))) /
281 6.;
282 // Loop over all pairs of m_vertices.
283 for (size_t j = 0; j < nMaxVertices - 1; ++j) {
284 const auto& vj = m_vertices[element.vertex[j]];
285 for (size_t k = j + 1; k < nMaxVertices; ++k) {
286 const auto& vk = m_vertices[element.vertex[k]];
287 // Compute distance.
288 const double dist = sqrt(pow(vj[0] - vk[0], 2) + pow(vj[1] - vk[1], 2) +
289 pow(vj[2] - vk[2], 2));
290 if (k == 1) {
291 dmin = dmax = dist;
292 } else {
293 if (dist < dmin) dmin = dist;
294 if (dist > dmax) dmax = dist;
295 }
296 }
297 }
298 } else {
299 std::cerr << m_className << "::GetElement:\n"
300 << " Unexpected element type (" << type << ").\n";
301 return false;
302 }
303 const size_t nVertices = ElementVertices(element);
304 for (size_t j = 0; j < nVertices; ++j) {
305 nodes.push_back(element.vertex[j]);
306 }
307 reg = element.region;
308 return true;
309}
std::vector< std::array< double, N > > m_vertices
static constexpr size_t nMaxVertices
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:337
DoubleAc fabs(const DoubleAc &f)
Definition: DoubleAc.h:615
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314

◆ GetElementaryCell()

bool Garfield::ComponentTcad3d::GetElementaryCell ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
)
overridevirtual

Get the coordinates of the elementary cell.

Reimplemented from Garfield::Component.

Definition at line 201 of file ComponentTcad3d.cc.

203 {
204 if (!m_ready) return false;
205 xmin = m_bbMin[0];
206 ymin = m_bbMin[1];
207 zmin = m_bbMin[2];
208 xmax = m_bbMax[0];
209 ymax = m_bbMax[1];
210 zmax = m_bbMax[2];
211 return true;
212}

◆ GetMedium()

Medium * Garfield::ComponentTcad3d::GetMedium ( const double  x,
const double  y,
const double  z 
)
overridevirtual

Get the medium at a given location (x, y, z).

Reimplemented from Garfield::Component.

Definition at line 126 of file ComponentTcad3d.cc.

127 {
128 // Make sure the field map has been loaded.
129 if (!m_ready) {
130 std::cerr << m_className << "::GetMedium:\n"
131 << " Field map not available for interpolation.\n";
132 return nullptr;
133 }
134
135 std::array<double, 3> x = {xin, yin, zin};
136 std::array<bool, 3> mirr = {false, false, false};
137 MapCoordinates(x, mirr);
138 // Check if the point is inside the bounding box.
139 if (!InBoundingBox(x)) return nullptr;
140
141 // Determine the shape functions.
142 std::array<double, nMaxVertices> w;
143 const size_t i = FindElement(x[0], x[1], x[2], w);
144 if (i >= m_elements.size()) {
145 // Point is outside the mesh.
146 return nullptr;
147 }
148 return m_regions[m_elements[i].region].medium;
149}

◆ GetNode()

bool Garfield::ComponentTcad3d::GetNode ( const size_t  i,
double &  x,
double &  y,
double &  z,
double &  v,
double &  ex,
double &  ey,
double &  ez 
) const

Get the coordinates of a mesh node and the potential and electric field at this node.

Definition at line 311 of file ComponentTcad3d.cc.

313 {
314 if (i >= m_vertices.size()) {
315 std::cerr << m_className << "::GetNode: Index out of range.\n";
316 return false;
317 }
318
319 x = m_vertices[i][0];
320 y = m_vertices[i][1];
321 z = m_vertices[i][2];
322 if (!m_epot.empty()) v = m_epot[i];
323 if (!m_efield.empty()) {
324 ex = m_efield[i][0];
325 ey = m_efield[i][1];
326 ez = m_efield[i][2];
327 }
328 return true;
329}

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