Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentTcad3d.hh
Go to the documentation of this file.
1// Interpolation in a three-dimensional field map created by Sentaurus Device
2
3#ifndef G_COMPONENT_TCAD_3D_H
4#define G_COMPONENT_TCAD_3D_H
5
6#include "ComponentBase.hh"
7
8namespace Garfield {
9
11
12 public:
13 // Constructor
15 // Destructor
17
18 void ElectricField(const double x, const double y, const double z, double& ex,
19 double& ey, double& ez, double& v, Medium*& m,
20 int& status);
21 void ElectricField(const double x, const double y, const double z, double& ex,
22 double& ey, double& ez, Medium*& m, int& status);
23
24 Medium* GetMedium(const double& x, const double& y, const double& z);
25
26 bool GetVoltageRange(double& vmin, double& vmax);
27 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
28 double& ymax, double& zmax);
29
30 // Import mesh and field map from files.
31 bool Initialise(const std::string gridfilename,
32 const std::string datafilename);
33
34 // List all currently defined regions.
35 void PrintRegions();
36 // Get the number of regions in the device.
37 int GetNumberOfRegions() const { return m_nRegions; }
38 void GetRegion(const int ireg, std::string& name, bool& active);
39 void SetDriftRegion(const int ireg);
40 void UnsetDriftRegion(const int ireg);
41 // Set/get the medium for a given region
42 void SetMedium(const int ireg, Medium* m);
43 bool GetMedium(const int ireg, Medium*& m) const;
44
45 int GetNumberOfElements() const { return m_nElements; }
46 bool GetElement(const int i, double& vol, double& dmin, double& dmax,
47 int& type);
48 bool GetElement(const int i, double& vol, double& dmin, double& dmax,
49 int& type, int& node1, int& node2, int& node3, int& node4,
50 int& node5, int& node6, int& node7, int& reg);
51 int GetNumberOfNodes() const { return m_nVertices; }
52 bool GetNode(const int i, double& x, double& y, double& z, double& v,
53 double& ex, double& ey, double& ez);
54
55 private:
56 // Max. number of vertices per element
57 static const int nMaxVertices = 7;
58
59 // Regions
60 int m_nRegions;
61 struct region {
62 // Name of region (from Tcad)
63 std::string name;
64 // Flag indicating if the region is active (i. e. a drift medium)
65 bool drift;
66 Medium* medium;
67 };
68 std::vector<region> m_regions;
69
70 // Vertices
71 int m_nVertices;
72 struct vertex {
73 // Coordinates [cm]
74 double x, y, z;
75 // Potential [V] and electric field [V / cm]
76 double p, ex, ey, ez;
77 // Flag indicating if vertex belongs to more than one region
78 bool isShared;
79 };
80 std::vector<vertex> m_vertices;
81
82 // Elements
83 int m_nElements;
84 struct element {
85 // Indices of vertices
86 int vertex[nMaxVertices];
87 // Type of element
88 // 1: Segment (line)
89 // 2: Triangle
90 // 3: Rectangle
91 // 4: Polygon
92 // 5: Tetrahedron
93 // 6: Pyramid
94 // 7: Prism
95 // 8: Brick
96 // 9: Tetrabrick
97 // 10: Polyhedron
98 // Only types 2 and 5 are supported by this class.
99 int type;
100 // Associated region
101 int region;
102 };
103 std::vector<element> m_elements;
104
105 // Face
106 struct face {
107 // Indices of edges
108 int edge[4];
109 int type;
110 };
111
112 // Voltage range
113 double m_pMin, m_pMax;
114
115 // Bounding box
116 double m_xMinBoundingBox, m_yMinBoundingBox, m_zMinBoundingBox;
117 double m_xMaxBoundingBox, m_yMaxBoundingBox, m_zMaxBoundingBox;
118
119 // Element from the previous call
120 int m_lastElement;
121 // Node point weighting factors for interpolation
122 // (local coordinates)
123 double m_w[nMaxVertices];
124
125 // Reset the component
126 void Reset();
127 // Periodicities
128 void UpdatePeriodicity();
129
130 bool CheckTetrahedron(const double x, const double y, const double z,
131 const int i);
132 bool CheckTriangle(const double x, const double y, const double z,
133 const int i);
134
135 bool LoadGrid(const std::string gridfilename);
136 bool LoadData(const std::string datafilename);
137 void Cleanup();
138};
139}
140#endif
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
bool Initialise(const std::string gridfilename, const std::string datafilename)
void UnsetDriftRegion(const int ireg)
void SetMedium(const int ireg, Medium *m)
void GetRegion(const int ireg, std::string &name, bool &active)
Medium * GetMedium(const double &x, const double &y, const double &z)
bool GetElement(const int i, double &vol, double &dmin, double &dmax, int &type)
bool GetVoltageRange(double &vmin, double &vmax)
bool GetNode(const int i, double &x, double &y, double &z, double &v, double &ex, double &ey, double &ez)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
void SetDriftRegion(const int ireg)