Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentTcad2d.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_TCAD_2D_H
2#define G_COMPONENT_TCAD_2D_H
3
4#include "ComponentBase.hh"
5
6namespace Garfield {
7
8/// Interpolation in a two-dimensional field map created by Sentaurus Device.
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
22 void ElectricField(const double x, const double y, const double z, double& ex,
23 double& ey, double& ez, Medium*& m, int& status) {
24
25 double v = 0.;
26 ElectricField(x, y, z, ex, ey, ez, v, m, status);
27 }
28
29 void WeightingField(const double x, const double y, const double z,
30 double& wx, double& wy, double& wz,
31 const std::string& label);
32
33 Medium* GetMedium(const double x, const double y, const double z);
34
35 bool GetVoltageRange(double& vmin, double& vmax);
36 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
37 double& ymax, double& zmax);
38 void SetRangeZ(const double zmin, const double zmax);
39
40 // Import mesh and field map from files.
41 bool Initialise(const std::string& gridfilename,
42 const std::string& datafilename);
43
44 // List all currently defined regions.
45 void PrintRegions() const;
46 // Get the number of regions in the device.
47 unsigned int GetNumberOfRegions() const { return m_regions.size(); }
48 void GetRegion(const unsigned int i, std::string& name, bool& active) const;
49 void SetDriftRegion(const unsigned int ireg);
50 void UnsetDriftRegion(const unsigned int ireg);
51 // Set/get the medium for a given region.
52 void SetMedium(const unsigned int ireg, Medium* m);
53 Medium* GetMedium(const unsigned int ireg) const;
54
55 // Retrieve information about the mesh.
56 unsigned int GetNumberOfElements() const { return m_elements.size(); }
57 bool GetElement(const unsigned int i,
58 double& vol, double& dmin, double& dmax,
59 int& type) const;
60 bool GetElement(const unsigned int i, double& vol, double& dmin, double& dmax,
61 int& type, int& node1, int& node2, int& node3, int& node4,
62 int& reg) const;
63 unsigned int GetNumberOfNodes() const { return m_vertices.size(); }
64 bool GetNode(const unsigned int i, double& x, double& y, double& v,
65 double& ex, double& ey) const;
66
67 // Mobilities
68 bool GetMobility(const double x, const double y, const double z, double& emob,
69 double& hmob);
70
71 // Velocity field maps
72 void ElectronVelocity(const double x, const double y, const double z,
73 double& vx, double& vy, double& vz,
74 Medium*& m, int& status);
75 void HoleVelocity(const double x, const double y, const double z,
76 double& vx, double& vy, double& vz,
77 Medium*& m, int& status);
78 // Lifetime field maps
79 bool GetElectronLifetime(const double x, const double y, const double z,
80 double& etau);
81 bool GetHoleLifetime(const double x, const double y, const double z,
82 double& htau);
83
84 // Trapping
85 int GetNumberOfDonors() { return m_donors.size(); }
86 int GetNumberOfAcceptors() { return m_acceptors.size(); }
87
88 bool GetDonorOccupation(const double x, const double y, const double z,
89 const unsigned int donorNumber,
90 double& occupationFraction);
91 bool GetAcceptorOccupation(const double x, const double y, const double z,
92 const unsigned int acceptorNumber,
93 double& occupationFraction);
94 bool SetDonor(const unsigned int donorNumber,
95 const double eXsec, const double hxSec,
96 const double concentration);
97 bool SetAcceptor(const unsigned int acceptorNumber,
98 const double eXsec, const double hxSec,
99 const double concentration);
100
101 bool ElectronAttachment(const double x, const double y, const double z,
102 double& eta);
103 bool HoleAttachment(const double x, const double y, const double z,
104 double& eta);
105
106 private:
107 // Max. number of vertices per element
108 static const int nMaxVertices = 4;
109
110 // Regions
111 struct Region {
112 // Name of region (from Tcad)
113 std::string name;
114 // Flag indicating if the region is active (i. e. a drift medium)
115 bool drift;
116 Medium* medium;
117 };
118 std::vector<Region> m_regions;
119
120 // Vertices
121 struct Vertex {
122 // Coordinates [cm]
123 double x, y;
124 // Potential [V] and electric field [V / cm]
125 double p, ex, ey;
126 // Mobilities [cm2 / (V ns)]
127 double emob, hmob;
128 // Velocities [cm/ns]
129 double eVx, eVy;
130 double hVx, hVy;
131 // Lifetimes [1/ns]
132 double eTau, hTau;
133 // Trap occupations [dimensionless]
134 std::vector<float> donorOcc;
135 std::vector<float> acceptorOcc;
136 };
137 std::vector<Vertex> m_vertices;
138
139 // Elements
140 struct Element {
141 // Indices of vertices
142 int vertex[nMaxVertices];
143 // Type of element
144 // 0: Point
145 // 1: Segment (line)
146 // 2: Triangle
147 // 3: Rectangle
148 // 4: Polygon
149 // Types 1 - 3 are supported by this class.
150 int type;
151 // Associated region
152 int region;
153 std::vector<int> neighbours;
154 // Bounding box
155 double xmin, xmax;
156 double ymin, ymax;
157 };
158 std::vector<Element> m_elements;
159
160 struct Defect {
161 // Electron cross-section
162 double xsece;
163 // Hole cross-section
164 double xsech;
165 // Concentration
166 double conc;
167 };
168 std::vector<Defect> m_donors;
169 std::vector<Defect> m_acceptors;
170
171 // Available data.
172 bool m_hasPotential;
173 bool m_hasField;
174 bool m_hasElectronMobility;
175 bool m_hasHoleMobility;
176 bool m_hasElectronVelocity;
177 bool m_hasHoleVelocity;
178 bool m_hasElectronLifetime;
179 bool m_hasHoleLifetime;
180
181 // Are all the cross-sections and concentrations valid and set.
182 bool m_validTraps;
183
184 // Voltage range
185 double m_pMin, m_pMax;
186
187 // Bounding box
188 bool m_hasRangeZ;
189 double m_xMinBB, m_yMinBB, m_zMinBB;
190 double m_xMaxBB, m_yMaxBB, m_zMaxBB;
191
192 // Element from the previous call
193 int m_lastElement;
194
195 // Reset the component
196 void Reset();
197 // Periodicities
198 void UpdatePeriodicity();
199
200 // Check whether a point is inside a given element and calculate the
201 // shape functions if it is.
202 bool CheckElement(const double x, const double y,
203 const Element& element, double w[nMaxVertices]) const;
204 bool CheckRectangle(const double x, const double y, const Element& element,
205 double w[nMaxVertices]) const;
206 bool CheckTriangle(const double x, const double y, const Element& element,
207 double w[nMaxVertices]) const;
208 bool CheckLine(const double x, const double y, const Element& element,
209 double w[nMaxVertices]) const;
210
211 bool LoadGrid(const std::string& gridfilename);
212 bool LoadData(const std::string& datafilename);
213 bool ReadDataset(std::ifstream& datafile, const std::string& dataset);
214 void FindNeighbours();
215 void Cleanup();
216
217 int FindRegion(const std::string& name) const;
218
219 void MapCoordinates(double& x, double& y, bool& xmirr, bool& ymirr) const;
220 bool CheckTraps() const;
221};
222}
223#endif
Abstract base class for components.
Interpolation in a two-dimensional field map created by Sentaurus Device.
unsigned int GetNumberOfElements() const
bool GetVoltageRange(double &vmin, double &vmax)
Calculate the voltage range [V].
bool GetDonorOccupation(const double x, const double y, const double z, const unsigned int donorNumber, double &occupationFraction)
void GetRegion(const unsigned int i, std::string &name, bool &active) const
bool GetNode(const unsigned int i, double &x, double &y, double &v, double &ex, double &ey) const
bool SetDonor(const unsigned int donorNumber, const double eXsec, const double hxSec, const double concentration)
bool Initialise(const std::string &gridfilename, const std::string &datafilename)
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
unsigned int GetNumberOfNodes() const
void SetRangeZ(const double zmin, const double zmax)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
bool GetHoleLifetime(const double x, const double y, const double z, double &htau)
void ElectronVelocity(const double x, const double y, const double z, double &vx, double &vy, double &vz, Medium *&m, int &status)
Get the electron drift velocity.
bool ElectronAttachment(const double x, const double y, const double z, double &eta)
Get the electron attachment coefficient.
bool GetElectronLifetime(const double x, const double y, const double z, double &etau)
bool GetAcceptorOccupation(const double x, const double y, const double z, const unsigned int acceptorNumber, double &occupationFraction)
unsigned int GetNumberOfRegions() const
bool GetElement(const unsigned int i, double &vol, double &dmin, double &dmax, int &type) const
void UnsetDriftRegion(const unsigned int ireg)
void SetMedium(const unsigned int ireg, Medium *m)
void HoleVelocity(const double x, const double y, const double z, double &vx, double &vy, double &vz, Medium *&m, int &status)
Get the hole drift velocity.
bool HoleAttachment(const double x, const double y, const double z, double &eta)
Get the hole attachment coefficient.
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
void SetDriftRegion(const unsigned int ireg)
Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).
bool GetMobility(const double x, const double y, const double z, double &emob, double &hmob)
bool SetAcceptor(const unsigned int acceptorNumber, const double eXsec, const double hxSec, const double concentration)
Abstract base class for media.
Definition: Medium.hh:11