Garfield++ v1r0
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// Interpolation in a two-dimensional field map created by Sentaurus Device
2
3#ifndef G_COMPONENT_TCAD_2D_H
4#define G_COMPONENT_TCAD_2D_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 void SetRangeZ(const double zmin, const double zmax);
30
31 // Import mesh and field map from files.
32 bool Initialise(const std::string gridfilename,
33 const std::string datafilename);
34
35 // List all currently defined regions.
36 void PrintRegions();
37 // Get the number of regions in the device.
38 int GetNumberOfRegions() const { return nRegions; }
39 void GetRegion(const int i, std::string& name, bool& active);
40 void SetDriftRegion(const int ireg);
41 void UnsetDriftRegion(const int ireg);
42 // Set/get the medium for a given region.
43 void SetMedium(const int ireg, Medium* m);
44 Medium* GetMedium(const unsigned int& ireg) const;
45
46 // Retrieve information about the mesh.
47 int GetNumberOfElements() const { return nElements; }
48 bool GetElement(const int i, double& vol, double& dmin, double& dmax,
49 int& type);
50 bool GetElement(const int i, double& vol, double& dmin, double& dmax,
51 int& type, int& node1, int& node2, int& node3, int& node4,
52 int& reg);
53 int GetNumberOfNodes() const { return nVertices; }
54 bool GetNode(const int i, double& x, double& y, double& v, double& ex,
55 double& ey);
56
57 // Mobilities
58 bool GetMobility(const double x, const double y, const double z, double& emob,
59 double& hmob);
60
61 private:
62 // Max. number of vertices per element
63 static const int nMaxVertices = 4;
64
65 // Regions
66 int nRegions;
67 struct region {
68 // Name of region (from Tcad)
69 std::string name;
70 // Flag indicating if the region is active (i. e. a drift medium)
71 bool drift;
72 Medium* medium;
73 };
74 std::vector<region> regions;
75
76 // Vertices
77 int nVertices;
78 struct vertex {
79 // Coordinates [cm]
80 double x, y;
81 // Potential [V] and electric field [V / cm]
82 double p, ex, ey;
83 // Mobilities [cm2 / (V ns)]
84 double emob, hmob;
85 // Flag indicating if vertex belongs to more than one region
86 bool isShared;
87 };
88 std::vector<vertex> vertices;
89
90 // Elements
91 int nElements;
92 struct element {
93 // Indices of vertices
94 int vertex[nMaxVertices];
95 // Type of element
96 // 0: Point
97 // 1: Segment (line)
98 // 2: Triangle
99 // 3: Rectangle
100 // 4: Polygon
101 // Types 1 - 3 are supported by this class.
102 int type;
103 // Associated region
104 int region;
105 int nNeighbours;
106 std::vector<int> neighbours;
107 };
108 std::vector<element> elements;
109
110 // Available data.
111 bool hasPotential;
112 bool hasField;
113 bool hasElectronMobility;
114 bool hasHoleMobility;
115
116 // Voltage range
117 double pMin, pMax;
118
119 // Bounding box
120 bool hasRangeZ;
121 double xMinBoundingBox, yMinBoundingBox, zMinBoundingBox;
122 double xMaxBoundingBox, yMaxBoundingBox, zMaxBoundingBox;
123
124 // Element from the previous call
125 int lastElement;
126 // Shape functions for interpolation
127 // (local coordinates)
128 double w[nMaxVertices];
129
130 // Reset the component
131 void Reset();
132 // Periodicities
133 void UpdatePeriodicity();
134
135 bool CheckRectangle(const double x, const double y, const int i);
136 bool CheckTriangle(const double x, const double y, const int i);
137 bool CheckLine(const double x, const double y, const int i);
138
139 bool LoadGrid(const std::string gridfilename);
140 bool LoadData(const std::string datafilename);
141 void FindNeighbours();
142 void Cleanup();
143};
144}
145#endif
bool GetNode(const int i, double &x, double &y, double &v, double &ex, double &ey)
void SetDriftRegion(const int ireg)
void UnsetDriftRegion(const int ireg)
void SetMedium(const int ireg, Medium *m)
bool GetElement(const int i, double &vol, double &dmin, double &dmax, int &type)
bool GetVoltageRange(double &vmin, double &vmax)
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 ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
void SetRangeZ(const double zmin, const double zmax)
Medium * GetMedium(const double &x, const double &y, const double &z)
void GetRegion(const int i, std::string &name, bool &active)
bool GetMobility(const double x, const double y, const double z, double &emob, double &hmob)