Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
|
#include <ComponentCST.hh>
Public Member Functions | |
ComponentCST () | |
Constructor. | |
~ComponentCST () | |
Destructor. | |
void | ShiftComponent (const double xShift, const double yShift, const double zShift) |
void | GetNumberOfMeshLines (unsigned int &nx, unsigned int &ny, unsigned int &nz) const |
size_t | GetNumberOfElements () const override |
Return the number of mesh elements. | |
bool | GetElement (const size_t i, size_t &mat, bool &drift, std::vector< size_t > &nodes) const override |
Return the material and node indices of a mesh element. | |
size_t | GetNumberOfNodes () const override |
bool | GetNode (const size_t i, double &x, double &y, double &z) const override |
void | GetElementBoundaries (unsigned int element, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const |
Medium * | GetMedium (const double x, const double y, const double z) override |
Get the medium at a given location (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 |
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 | 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 | Initialise (std::string elist, std::string nlist, std::string mplist, std::string prnsol, std::string unit="cm") |
bool | Initialise (std::string dataFile, std::string unit="cm") |
bool | SetWeightingField (std::string prnsol, std::string label, bool isBinary=true) |
void | SetRange () override |
Calculate x, y, z, V and angular ranges. | |
void | SetRangeZ (const double zmin, const double zmax) |
void | DisableXField () |
void | DisableYField () |
void | DisableZField () |
void | EnableShaping () |
void | DisableShaping () |
int | Index2Element (const unsigned int i, const unsigned int j, const unsigned int k) const |
bool | Coordinate2Index (const double x, const double y, const double z, unsigned int &i, unsigned int &j, unsigned int &k) const |
Public Member Functions inherited from Garfield::ComponentFieldMap | |
ComponentFieldMap ()=delete | |
Default constructor. | |
ComponentFieldMap (const std::string &name) | |
Constructor. | |
virtual | ~ComponentFieldMap () |
Destructor. | |
virtual void | SetRange () |
Calculate x, y, z, V and angular ranges. | |
void | PrintRange () |
Show x, y, z, V and angular ranges. | |
bool | IsInBoundingBox (const double x, const double y, const double z) const |
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 | GetVoltageRange (double &vmin, double &vmax) override |
Calculate the voltage range [V]. | |
void | PrintMaterials () |
List all currently defined materials. | |
void | DriftMedium (const unsigned int imat) |
Flag a field map material as a drift medium. | |
void | NotDriftMedium (const unsigned int imat) |
Flag a field map materials as a non-drift medium. | |
size_t | GetNumberOfMaterials () const |
Return the number of materials in the field map. | |
double | GetPermittivity (const unsigned int imat) const |
Return the permittivity of a field map material. | |
double | GetConductivity (const unsigned int imat) const |
Return the conductivity of a field map material. | |
void | SetMedium (const unsigned int imat, Medium *medium) |
Associate a field map material with a Medium class. | |
Medium * | GetMedium (const unsigned int i) const |
Return the Medium associated to a field map material. | |
virtual size_t | GetNumberOfElements () const |
Return the number of mesh elements. | |
bool | GetElement (const size_t i, double &vol, double &dmin, double &dmax) |
Return the volume and aspect ratio of a mesh element. | |
virtual bool | GetElement (const size_t i, size_t &mat, bool &drift, std::vector< size_t > &nodes) const |
Return the material and node indices of a mesh element. | |
virtual size_t | GetNumberOfNodes () const |
virtual bool | GetNode (const size_t i, double &x, double &y, double &z) const |
void | EnableCheckMapIndices (const bool on=true) |
void | EnableDeleteBackgroundElements (const bool on=true) |
Option to eliminate mesh elements in conductors (default: on). | |
void | EnableTetrahedralTreeForElementSearch (const bool on=true) |
void | EnableConvergenceWarnings (const bool on=true) |
virtual Medium * | GetMedium (const double x, const double y, const double z) |
Get the medium at a given location (x, y, z). | |
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 Medium * | GetMedium (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 direction. | |
void | EnablePeriodicityY (const bool on=true) |
Enable simple periodicity in the direction. | |
void | EnablePeriodicityZ (const bool on=true) |
Enable simple periodicity in the direction. | |
void | IsPeriodic (bool &perx, bool &pery, bool &perz) |
Return periodicity flags. | |
void | EnableMirrorPeriodicityX (const bool on=true) |
Enable mirror periodicity in the direction. | |
void | EnableMirrorPeriodicityY (const bool on=true) |
Enable mirror periodicity in the direction. | |
void | EnableMirrorPeriodicityZ (const bool on=true) |
Enable mirror periodicity in the direction. | |
void | IsMirrorPeriodic (bool &perx, bool &pery, bool &perz) |
Return mirror periodicity flags. | |
void | EnableAxialPeriodicityX (const bool on=true) |
Enable axial periodicity in the direction. | |
void | EnableAxialPeriodicityY (const bool on=true) |
Enable axial periodicity in the direction. | |
void | EnableAxialPeriodicityZ (const bool on=true) |
Enable axial periodicity in the direction. | |
void | IsAxiallyPeriodic (bool &perx, bool &pery, bool &perz) |
Return axial periodicity flags. | |
void | EnableRotationSymmetryX (const bool on=true) |
Enable rotation symmetry around the axis. | |
void | EnableRotationSymmetryY (const bool on=true) |
Enable rotation symmetry around the axis. | |
void | EnableRotationSymmetryZ (const bool on=true) |
Enable rotation symmetry around the 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) |
Protected Member Functions | |
void | UpdatePeriodicity () override |
Verify periodicities. | |
double | GetElementVolume (const unsigned int i) override |
void | GetAspectRatio (const unsigned int i, double &dmin, double &dmax) 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 |
Protected Member Functions inherited from Garfield::ComponentFieldMap | |
void | Reset () override |
Reset the component. | |
void | Prepare () |
void | UpdatePeriodicity2d () |
void | UpdatePeriodicityCommon () |
bool | SetDefaultDriftMedium () |
Find lowest epsilon, check for eps = 0, set default drift media flags. | |
int | FindElement5 (const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det) |
Find the element for a point in curved quadratic quadrilaterals. | |
int | FindElement13 (const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det) |
Find the element for a point in curved quadratic tetrahedra. | |
int | FindElementCube (const double x, const double y, const double z, double &t1, double &t2, double &t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN) |
Find the element for a point in a cube. | |
void | MapCoordinates (double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const |
Move (xpos, ypos, zpos) to field map coordinates. | |
void | UnmapFields (double &ex, double &ey, double &ez, double &xpos, double &ypos, double &zpos, bool &xmirrored, bool &ymirrored, bool &zmirrored, double &rcoordinate, double &rotation) const |
Move (ex, ey, ez) to global coordinates. | |
int | ReadInteger (char *token, int def, bool &error) |
double | ReadDouble (char *token, double def, bool &error) |
virtual double | GetElementVolume (const unsigned int i)=0 |
virtual void | GetAspectRatio (const unsigned int i, double &dmin, double &dmax)=0 |
size_t | GetWeightingFieldIndex (const std::string &label) const |
size_t | GetOrCreateWeightingFieldIndex (const std::string &label) |
void | PrintWarning (const std::string &header) |
void | PrintNotReady (const std::string &header) const |
void | PrintCouldNotOpen (const std::string &header, const std::string &filename) const |
void | PrintElement (const std::string &header, const double x, const double y, const double z, const double t1, const double t2, const double t3, const double t4, const Element &element, const unsigned int n, const int iw=-1) const |
virtual void | Reset ()=0 |
Reset the component. | |
virtual void | UpdatePeriodicity ()=0 |
Verify periodicities. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from Garfield::ComponentFieldMap | |
static double | ScalingFactor (std::string unit) |
Protected Attributes inherited from Garfield::ComponentFieldMap | |
bool | m_is3d = true |
std::vector< Element > | m_elements |
std::vector< Node > | m_nodes |
std::vector< Material > | m_materials |
std::vector< std::string > | m_wfields |
std::vector< bool > | m_wfieldsOk |
std::vector< bool > | m_dwfieldsOk |
std::vector< double > | m_wdtimes |
bool | m_hasBoundingBox = false |
std::array< double, 3 > | m_minBoundingBox |
std::array< double, 3 > | m_maxBoundingBox |
std::array< double, 3 > | m_mapmin |
std::array< double, 3 > | m_mapmax |
std::array< double, 3 > | m_mapamin |
std::array< double, 3 > | m_mapamax |
std::array< double, 3 > | m_mapna |
std::array< double, 3 > | m_cells |
double | m_mapvmin = 0. |
double | m_mapvmax = 0. |
std::array< bool, 3 > | m_setang |
bool | m_deleteBackground = true |
bool | m_warning = false |
unsigned int | m_nWarnings = 0 |
bool | m_printConvergenceWarnings = true |
Protected Attributes inherited from Garfield::Component | |
std::string | m_className = "Component" |
Class name. | |
Geometry * | m_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. | |
Component for importing and interpolating field maps from CST. This interface assumes a certain format of the ascii files Please find the tools to extract the field data from CST in the correct way here: http://www.desy.de/~zenker/garfieldpp.html
Definition at line 15 of file ComponentCST.hh.
Garfield::ComponentCST::ComponentCST | ( | ) |
Constructor.
Definition at line 80 of file ComponentCST.cc.
|
inline |
bool Garfield::ComponentCST::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. The operator used for the comparison is <=. Therefore, the last entry in the vector will never be returned for a point inside the mesh.
Definition at line 1084 of file ComponentCST.cc.
Referenced by Coordinate2Index(), GetMedium(), WeightingField(), and WeightingPotential().
|
protected |
Calculate the index in the vectors m_xlines, m_ylines, m_zlines, which is before the given coordinate.
x | The x coordinate mapped to the basic cell. |
y | The y coordinate mapped to the basic cell. |
z | The z coordinate mapped to the basic cell. |
i | The index of the m_xlines vector, where m_xlines.at(i) < x < m_xlines.at(i+1). |
j | The index of the m_ylines vector, where m_ylines.at(j) < y < m_ylines.at(j+1). |
k | The index of the m_zlines vector, where m_zlines.at(k) < z < m_zlines.at(k+1). |
position_mapped | The calculated mapped position (x,y,z) -> (x_mapped, y_mapped, z_mapped) |
mirrored | Information if x, y, or z direction is mirrored. |
Definition at line 1093 of file ComponentCST.cc.
|
inline |
Definition at line 181 of file ComponentCST.hh.
|
inline |
Use these functions to disable a certain field component. Is a field component is disabled ElectricField and WeightingField will return 0 for this component. This is useful if you want to have calculated global field distortions and you want to add the field of a GEM. If you would simply add both components the field component in drift direction would be added twice!
Definition at line 134 of file ComponentCST.hh.
|
inline |
Definition at line 135 of file ComponentCST.hh.
|
inline |
Definition at line 136 of file ComponentCST.hh.
|
overridevirtual |
Calculate the drift field [V/cm] and potential [V] at (x, y, z).
Implements Garfield::Component.
Definition at line 835 of file ComponentCST.cc.
|
overridevirtual |
Calculate the drift field at given point.
x,y,z | coordinates [cm]. |
ex,ey,ez | components of the electric field [V/cm]. |
m | pointer to the medium at this location. |
status | status 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 828 of file ComponentCST.cc.
|
inline |
If you calculate the electric field component in direction along a line in x direction this field component will be constant inside mesh elements (by construction). This can be observed by plotting in direction. If you plot in y direction the field will be smooth (also by construction). Yuri Piadyk proposed also to shape the electric field. This is done as follows. The field component calculated as described above is assumed to appear in the center of the mesh element.
| M1 P | M2 | x direction |-—x—x-|--—x---—|-->
__________ | ____________ |
element 1 element 2
Lets consider only the direction and we want to calculate . The field in the center of the element containing is . Without shaping it is along the direction in everywhere in element 1. The idea of the shaping is to do a linear interpolation of the between the field and . This results in a smooth electric field also in direction. If P would be left from the field in the left neighboring element would be considered. In addition it is also checked if the material in both elements used for the interpolation is the same. Else no interpolation is done.
Definition at line 180 of file ComponentCST.hh.
|
overrideprotectedvirtual |
Implements Garfield::ComponentFieldMap.
Definition at line 1161 of file ComponentCST.cc.
|
overridevirtual |
Return the material and node indices of a mesh element.
Reimplemented from Garfield::ComponentFieldMap.
Definition at line 977 of file ComponentCST.cc.
void Garfield::ComponentCST::GetElementBoundaries | ( | unsigned int | element, |
double & | xmin, | ||
double & | xmax, | ||
double & | ymin, | ||
double & | ymax, | ||
double & | zmin, | ||
double & | zmax | ||
) | const |
Definition at line 1016 of file ComponentCST.cc.
|
overrideprotectedvirtual |
Implements Garfield::ComponentFieldMap.
Definition at line 1176 of file ComponentCST.cc.
|
overridevirtual |
Get the medium at a given location (x, y, z).
Reimplemented from Garfield::Component.
Definition at line 1030 of file ComponentCST.cc.
|
overridevirtual |
Reimplemented from Garfield::ComponentFieldMap.
Definition at line 1002 of file ComponentCST.cc.
|
inlineoverridevirtual |
Return the number of mesh elements.
Reimplemented from Garfield::ComponentFieldMap.
Definition at line 27 of file ComponentCST.hh.
void Garfield::ComponentCST::GetNumberOfMeshLines | ( | unsigned int & | nx, |
unsigned int & | ny, | ||
unsigned int & | nz | ||
) | const |
Definition at line 970 of file ComponentCST.cc.
|
inlineoverridevirtual |
Reimplemented from Garfield::ComponentFieldMap.
Definition at line 30 of file ComponentCST.hh.
int Garfield::ComponentCST::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, m_ylines, m_zlines). This is public since it is used in ViewFEMesh::DrawCST.
Definition at line 1148 of file ComponentCST.cc.
Referenced by GetMedium(), and WeightingField().
bool Garfield::ComponentCST::Initialise | ( | std::string | dataFile, |
std::string | unit = "cm" |
||
) |
Import of field data based on binary files. See http://www.desy.de/~zenker/garfieldpp.html to get information about the binary files export from CST.
dataFile | The binary file containing the field data exported from CST. |
unit | The units used in the binary file. They are not necessarily equal to CST units. |
Definition at line 481 of file ComponentCST.cc.
bool Garfield::ComponentCST::Initialise | ( | std::string | elist, |
std::string | nlist, | ||
std::string | mplist, | ||
std::string | prnsol, | ||
std::string | unit = "cm" |
||
) |
Deprecated version of the interface based on text file import of field data.
elist | Information about the element material of mesh cells. Each line contains the element number and the material index: 0 3
...
|
nlist | Information about the mesh like this: xmax 136 ymax 79 zmax 425
x−l i n e s
0
8 . 9 2 8 5 7 e −07
1 . 7 8 5 7 1 e −06
...
y−l i n e s
0
8 . 9 2 8 5 7 e −07
1 . 7 8 5 7 1 e −06
...
z−l i n e s
0.0027
0.00270674
...
|
mplist | Information about material properties used in the simulation: |
prnsol | Information about the node potentials. Each line contains the node number and the potential: 0 1000.00
...
|
unit | The units used in the nlist input file |
Definition at line 87 of file ComponentCST.cc.
|
overridevirtual |
Calculate x, y, z, V and angular ranges.
Reimplemented from Garfield::ComponentFieldMap.
Definition at line 1048 of file ComponentCST.cc.
Referenced by Initialise(), and ShiftComponent().
void Garfield::ComponentCST::SetRangeZ | ( | const double | zmin, |
const double | zmax | ||
) |
Definition at line 1074 of file ComponentCST.cc.
bool Garfield::ComponentCST::SetWeightingField | ( | std::string | prnsol, |
std::string | label, | ||
bool | isBinary = true |
||
) |
Initialise a weighting field. This function can handle the deprecated text based file format (see Initialise( std::string elist...) for the expected file format, which is similar to prnsol. It also also handles binary files including the weighting field.
prnsol | The input file (binary/text file) |
label | The name of the weighting field to be added. If a weighting field with same name already exist it is replaced by the new one. |
isBinary | Depending on the file type you use, adapt this switch. |
Definition at line 664 of file ComponentCST.cc.
void Garfield::ComponentCST::ShiftComponent | ( | const double | xShift, |
const double | yShift, | ||
const double | zShift | ||
) |
Definition at line 814 of file ComponentCST.cc.
|
overrideprotectedvirtual |
Verify periodicities.
Implements Garfield::Component.
Definition at line 1156 of file ComponentCST.cc.
Referenced by Initialise(), and ShiftComponent().
|
overridevirtual |
Calculate the weighting field at a given point and for a given electrode.
x,y,z | coordinates [cm]. |
wx,wy,wz | components of the weighting field [1/cm]. |
label | name of the electrode |
Reimplemented from Garfield::Component.
Definition at line 842 of file ComponentCST.cc.
|
overridevirtual |
Calculate the weighting potential at a given point.
x,y,z | coordinates [cm]. |
label | name of the electrode. |
Reimplemented from Garfield::Component.
Definition at line 900 of file ComponentCST.cc.