Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentCST.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_CST_H
2#define G_COMPONENT_CST_H
3
4#include <map>
5#include <vector>
6
8
9namespace Garfield {
10
15
17 public:
22
23 void ShiftComponent(const double xShift, const double yShift,
24 const double zShift);
25
26 void GetNumberOfMeshLines(unsigned int& nx, unsigned int& ny,
27 unsigned int& nz) const;
28 size_t GetNumberOfElements() const override { return m_nElements; }
29 bool GetElementNodes(const size_t i,
30 std::vector<size_t>& nodes) const override;
31 bool GetElementRegion(const size_t i, size_t& mat,
32 bool& drift) const override;
33 size_t GetNumberOfNodes() const override { return m_nNodes; }
34 bool GetNode(const size_t i, double& x, double& y, double& z) const override;
35
36 void GetElementBoundaries(unsigned int element, double& xmin, double& xmax,
37 double& ymin, double& ymax, double& zmin,
38 double& zmax) const;
39
40 Medium* GetMedium(const double x, const double y, const double z) override;
41 void ElectricField(const double x, const double y, const double z, double& ex,
42 double& ey, double& ez, Medium*& m, int& status) override;
43 void ElectricField(const double x, const double y, const double z, double& ex,
44 double& ey, double& ez, double& v, Medium*& m,
45 int& status) override;
46 void WeightingField(const double x, const double y, const double z,
47 double& wx, double& wy, double& wz,
48 const std::string& label) override;
49
50 double WeightingPotential(const double x, const double y, const double z,
51 const std::string& label) override;
52 /* FIX DOXYGEN ERROR ON PDF GENERATION
53 * Deprecated version of the interface based on text file import of field
54 * data.
55 * \param elist Information about the element material of mesh cells. Each
56 * line contains the element number and the material index:
57 * \code
58 * 0 3
59 * ...
60 * \endcode
61 *
62 * \param nlist Information about the mesh like this:
63 * \code
64 * xmax 136 ymax 79 zmax 425
65 * x−lines
66 * 0
67 * 8 . 9 2 8 5 7 e −07
68 * 1 . 7 8 5 7 1 e −06
69 * ...
70 * y−lines
71 * 0
72 * 8 . 9 2 8 5 7 e −07
73 * 1 . 7 8 5 7 1 e −06
74 * ...
75 * z−lines
76 * 0.0027
77 * 0.00270674
78 * ...
79 * \endcode
80 *
81 * \param mplist Information about material properties used in the simulation:
82 * \code
83 * Materials 4
84 * Material 1 PERX 1 . 0 0 0 0 0 0
85 * Material 2 RSVX 0 . 0 0 0 0 0 0 PERX 0 . 1 0 0 0 0 0 0E+11
86 * Material 3 PERX 3 . 5 0 0 0 0 0
87 * Material 4 PERX 4 . 8 0 0 0 0 0
88 * \endcode
89 *
90 * \param prnsol Information about the node potentials. Each line contains the
91 * node number and the potential:
92 * \code
93 * 0 1000.00
94 * ...
95 * \endcode
96 * \param unit The units used in the nlist input file
97 */
98 bool Initialise(std::string elist, std::string nlist, std::string mplist,
99 std::string prnsol, std::string unit = "cm");
109
110 bool Initialise(std::string dataFile, std::string unit = "cm");
123 bool SetWeightingField(std::string prnsol, std::string label,
124 bool isBinary = true);
125
126 // Range
127
128 void SetRangeZ(const double zmin, const double zmax);
185 void EnableShaping() { doShaping = true; }
186 void DisableShaping() { doShaping = false; }
192 int Index2Element(const unsigned int i, const unsigned int j,
193 const unsigned int k) const;
201 bool Coordinate2Index(const double x, const double y, const double z,
202 unsigned int& i, unsigned int& j,
203 unsigned int& k) const;
204
205 protected:
206 void SetRange() override;
207
208 double GetElementVolume(const size_t i) const override;
209 void GetAspectRatio(const size_t i, double& dmin,
210 double& dmax) const override;
211
229 bool Coordinate2Index(const double x, const double y, const double z,
230 unsigned int& i, unsigned int& j, unsigned int& k,
231 double* position_mapped, bool* mirrored) const;
232
233 private:
234 std::vector<double> m_xlines;
235 std::vector<double> m_ylines;
236 std::vector<double> m_zlines;
238 std::vector<float> m_potential;
240 std::map<std::string, std::vector<float> > m_weightingFields;
242 std::vector<unsigned char> m_elementMaterial;
243
244 unsigned int m_nx = 0;
245 unsigned int m_ny = 0;
246 unsigned int m_nz = 0;
247 size_t m_nElements = 0;
248 size_t m_nNodes = 0;
249 // If true x,y,z fields of this component are disabled (e=0 V/cm).
250 bool disableFieldComponent[3] = {false, false, false};
251 bool doShaping = false;
252
253 void ElectricFieldBinary(const double x, const double y, const double z,
254 double& ex, double& ey, double& ez, double& v,
255 Medium*& m, int& status,
256 const bool calculatePotential = false) const;
257 float GetFieldComponent(const unsigned int i, const unsigned int j,
258 const unsigned int k, const double rx,
259 const double ry, const double rz,
260 const char component,
261 const std::vector<float>& potentials) const;
262
263 float GetPotential(const unsigned int i, const unsigned int j,
264 const unsigned int k, const double rx, const double ry,
265 const double rz,
266 const std::vector<float>& potentials) const;
267
268 void ShapeField(float& ex, float& ey, float& ez, const double rx,
269 const double ry, const double rz, const unsigned int i,
270 const unsigned int j, const unsigned int k,
271 const std::vector<float>& potentials) const;
272
273 /* Calculate the index (i,j,k) along x,y,z direction of the given element.
274 * i,j,k start at 0 and reach at maximum
275 * m_xlines-1,m_ylines-1,m_zlines-1
276 */
277 void Element2Index(const size_t element, unsigned int& i, unsigned int& j,
278 unsigned int& k) const;
279
280 int Index2Node(const unsigned int i, const unsigned int j,
281 const unsigned int k) const;
282
283 void Node2Index(const size_t node, unsigned int& i, unsigned int& j,
284 unsigned int& k) const;
285};
286
287} // namespace Garfield
288
289#endif
float GetPotential(const unsigned int i, const unsigned int j, const unsigned int k, const double rx, const double ry, const double rz, const std::vector< float > &potentials) const
void EnableShaping()
If you calculate the electric field component in direction along a line in x direction this field co...
std::vector< double > m_xlines
x positions used in the CST mesh
bool Coordinate2Index(const double x, const double y, const double z, unsigned int &i, unsigned int &j, unsigned int &k) const
Find the positions in the x/y/z position vectors (m_xlines, m_ylines, m_zlines) for a given point.
size_t m_nElements
Number of elements.
std::vector< double > m_zlines
z positions used in the CST mesh
~ComponentCST()
Destructor.
float GetFieldComponent(const unsigned int i, const unsigned int j, const unsigned int k, const double rx, const double ry, const double rz, const char component, const std::vector< float > &potentials) const
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
unsigned int m_ny
Number of mesh lines in y direction.
void Element2Index(const size_t element, unsigned int &i, unsigned int &j, unsigned int &k) const
size_t GetNumberOfElements() const override
size_t GetNumberOfNodes() const override
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
void ElectricFieldBinary(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status, const bool calculatePotential=false) const
bool Initialise(std::string elist, std::string nlist, std::string mplist, std::string prnsol, std::string unit="cm")
void ShapeField(float &ex, float &ey, float &ez, const double rx, const double ry, const double rz, const unsigned int i, const unsigned int j, const unsigned int k, const std::vector< float > &potentials) const
std::vector< float > m_potential
Potentials resulting from the CST simulation.
bool GetNode(const size_t i, double &x, double &y, double &z) const override
bool GetElementNodes(const size_t i, std::vector< size_t > &nodes) const override
bool GetElementRegion(const size_t i, size_t &mat, bool &drift) const override
Medium * GetMedium(const double x, const double y, const double z) override
unsigned int m_nx
Number of mesh lines in x direction.
void GetElementBoundaries(unsigned int element, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const
std::vector< unsigned char > m_elementMaterial
Material id for each element (unsigned char since it uses only 1 byte)
std::vector< double > m_ylines
y positions used in the CST mesh
void GetNumberOfMeshLines(unsigned int &nx, unsigned int &ny, unsigned int &nz) const
double GetElementVolume(const size_t i) const override
bool Coordinate2Index(const double x, const double y, const double z, unsigned int &i, unsigned int &j, unsigned int &k, double *position_mapped, bool *mirrored) const
Calculate the index in the vectors m_xlines, m_ylines, m_zlines, which is before the given coordinate...
bool SetWeightingField(std::string prnsol, std::string label, bool isBinary=true)
Initialise a weighting field.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
size_t m_nNodes
Number of nodes.
void ShiftComponent(const double xShift, const double yShift, const double zShift)
void SetRange() override
bool Initialise(std::string dataFile, std::string unit="cm")
Import of field data based on binary files.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
void GetAspectRatio(const size_t i, double &dmin, double &dmax) const override
std::map< std::string, std::vector< float > > m_weightingFields
Map of weighting field potentials.
int Index2Node(const unsigned int i, const unsigned int j, const unsigned int k) const
void SetRangeZ(const double zmin, const double zmax)
unsigned int m_nz
Number of mesh lines in z direction.
ComponentCST()
Constructor.
void DisableXField()
Use these functions to disable a certain field component.
void Node2Index(const size_t node, unsigned int &i, unsigned int &j, unsigned int &k) const
int Index2Element(const unsigned int i, const unsigned int j, const unsigned int k) const
Calculate the element index from the position in the x/y/z position vectors (m_xlines,...
ComponentFieldMap()=delete
Default constructor.