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 GetElementNodes (const size_t i, std::vector< size_t > &nodes) const override
Get the indices of the nodes constituting a given element.
bool GetElementRegion (const size_t i, size_t &mat, bool &drift) const override
Get the region/material of a mesh element and a flag whether it is associated to an active medium.
size_t GetNumberOfNodes () const override
Return the number of mesh nodes.
bool GetNode (const size_t i, double &x, double &y, double &z) const override
Get the coordinates of a mesh node.
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
Calculate the drift field at given point.
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
Calculate the weighting field at a given point and for a given electrode.
double WeightingPotential (const double x, const double y, const double z, const std::string &label) override
Calculate the weighting potential at a given point.
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")
Import of field data based on binary files.
bool SetWeightingField (std::string prnsol, std::string label, bool isBinary=true)
Initialise a weighting field.
void SetRangeZ (const double zmin, const double zmax)
void DisableXField ()
Use these functions to disable a certain field component.
void DisableYField ()
void DisableZField ()
void EnableShaping ()
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).
void DisableShaping ()
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, m_ylines, m_zlines).
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.
ComponentFieldMap ()=delete
Default constructor.
ComponentFieldMap (const std::string &name)
Constructor.
virtual ~ComponentFieldMap ()
Destructor.
bool Check ()
Check element aspect ratio.
void PrintRange ()
Show x, y, z, V and angular ranges.
void PrintMaterials ()
List all currently defined materials.
void DriftMedium (const size_t imat)
Flag a field map material as a drift medium.
void NotDriftMedium (const size_t 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 size_t imat) const
Return the relative permittivity of a field map material.
double GetConductivity (const size_t imat) const
Return the conductivity of a field map material.
void SetMedium (const size_t imat, Medium *medium)
Associate a field map material with a Medium object.
Medium * GetMedium (const size_t imat) const
Return the Medium associated to a field map material.
void SetGas (Medium *medium)
Associate all field map materials with a relative permittivity of unity to a given Medium class.
size_t GetNumberOfElements () const override
Return the number of mesh elements.
bool GetElementNodes (const size_t i, std::vector< size_t > &nodes) const override
Get the indices of the nodes constituting a given element.
bool GetElementRegion (const size_t i, size_t &mat, bool &drift) const override
Get the region/material of a mesh element and a flag whether it is associated to an active medium.
bool GetElement (const size_t i, double &vol, double &dmin, double &dmax) const
Return the volume and aspect ratio of a mesh element.
size_t GetNumberOfNodes () const override
Return the number of mesh nodes.
bool GetNode (const size_t i, double &x, double &y, double &z) const override
Get the coordinates of a mesh node.
double GetPotential (const size_t i) const
Return the potential at a given node.
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)
Enable or disable the usage of the tetrahedral tree for searching the element in the mesh.
void EnableConvergenceWarnings (const bool on=true)
Enable or disable warnings that the calculation of the local coordinates did not achieve the requested precision.
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
Calculate the drift field at given point.
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).
__DEVICE__ void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
Calculate the weighting field at a given point and for a given electrode.
double WeightingPotential (const double x, const double y, const double z, const std::string &label) override
Calculate the weighting potential at a given point.
double DelayedWeightingPotential (double x, double y, double z, const double t, const std::string &label) override
Calculate the delayed weighting potential at a given point and time and for a given electrode.
void DelayedWeightingPotentials (const double x, const double y, const double z, const std::string &label, std::vector< double > &dwp) override
Calculate the delayed weighting potentials at a given point and for a given electrode, for a set of pre-defined times.
bool IsInBoundingBox (const double x, const double y, const double z) const
bool Is3d () override
Does the component have a 3D field (map)?
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.
std::map< std::string, std::vector< double > > GetWeightingPotentials ()
bool GetVoltageRange (double &vmin, double &vmax) override
Calculate the voltage range [V].
void CopyWeightingPotential (const std::string &label, const std::string &labelSource, const double x, const double y, const double z, const double alpha, const double beta, const double gamma)
Makes a weighting potential copy of a imported map which can be translated and rotated.
double CreateGPUTransferObject (ComponentGPU *&comp_gpu) override
Create and initialise GPU Transfer class.
std::array< double, 3 > ElectricField (const double x, const double y, const double z)
Calculate the drift field [V/cm] at (x, y, z).
Component ()=delete
Default constructor.
Component (const std::string &name)
Constructor.
virtual ~Component ()=default
Destructor.
virtual void SetGeometry (Geometry *geo)
Define the geometry.
virtual void Clear ()
Reset.
std::array< double, 3 > ElectricField (const double x, const double y, const double z)
Calculate the drift field [V/cm] at (x, y, z).
virtual double ElectricPotential (const double x, const double y, const double z)
Calculate the (drift) electrostatic potential [V] at (x, y, z).
virtual const std::vector< double > & DelayedSignalTimes (const std::string &)
Return the time steps at which the delayed weighting potential/field are stored/evaluated.
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)
Calculate the delayed weighting field at a given point and time and for a given electrode.
virtual void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
Calculate the magnetic field at a given point.
void SetMagneticField (const double bx, const double by, const double bz)
Set a constant magnetic field.
virtual bool IsReady ()
Ready for use?
double CellSizeX ()
double CellSizeY ()
double CellSizeZ ()
double IntegrateFluxCircle (const double xc, const double yc, const double r, const unsigned int nI=50)
Integrate the normal component of the electric field over a circle.
double IntegrateFluxSphere (const double xc, const double yc, const double zc, const double r, const unsigned int nI=20)
Integrate the normal component of the electric field over a sphere.
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)
Integrate the normal component of the electric field over a parallelogram.
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)
Integrate the normal component of the weighting field over a parallelogram.
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)
Integrate the electric field flux through a line from (x0,y0,z0) to (x1,y1,z1) along a direction (xp,yp,zp).
virtual bool CrossedWire (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)
Determine whether the line between two points crosses a wire.
virtual bool InTrapRadius (const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
Determine whether a particle is inside the trap radius of a wire.
virtual bool CrossedPlane (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc)
Determine whether the line between two points crosses a plane.
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 EnableTriangleSymmetricXY (const bool on=true, const bool oct=2)
Enable triangular periodicity in the plane.
void EnableTriangleSymmetricXZ (const bool on=true, const bool oct=2)
Enable triangular periodicity in the plane.
void EnableTriangleSymmetricYZ (const bool on=true, const bool oct=2)
Enable triangular periodicity in the plane.
void EnableDebugging (const bool on=true)
Switch on debugging messages.
void DisableDebugging ()
Switch off debugging messages.
virtual bool HasMagneticField () const
Does the component have a non-zero magnetic field?
virtual bool HasTownsendMap () const
Does the component have maps of the Townsend coefficient?
virtual bool HasAttachmentMap () const
Does the component have maps of the attachment coefficient?
virtual bool HasMobilityMap () const
Does the component have maps of the low-field mobility?
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 ElectronMobility (const double, const double, const double, double &mu)
virtual bool HoleMobility (const double, const double, const double, double &mu)
Get the hole Mobility coefficient.
virtual bool ElectronTownsend (const double, const double, const double, double &alpha)
Get the electron Townsend coefficient.
virtual bool HoleTownsend (const double, const double, const double, double &alpha)
Get the hole Townsend 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 double StepSizeHint ()
void SetRange () override
double GetElementVolume (const size_t i) const override
void GetAspectRatio (const size_t i, double &dmin, double &dmax) 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.
void Reset () override
Reset the component.
void Prepare ()
void UpdatePeriodicity () override
Verify periodicities.
void UpdatePeriodicity2d ()
void UpdatePeriodicityCommon ()
bool SetDefaultDriftMedium ()
Find lowest epsilon, check for eps = 0, set default drift media flags.
__DEVICE__ int Field (const double x, const double y, const double z, double &fx, double &fy, double &fz, int &iel, const std::vector< double > &potentials) const
Compute the electric/weighting field.
double Potential (const double x, const double y, const double z, const std::vector< double > &potentials) const
Compute the electrostatic/weighting potential.
int FindElement5 (const double x, const double y, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det) const
Find the element for a point in curved quadratic quadrilaterals.
__DEVICE__ 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) const
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) const
Find the element for a point in a cube.
__DEVICE__ 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.
__DEVICE__ void UnmapFields (double &ex, double &ey, double &ez, const double xpos, const double ypos, const double zpos, const bool xmirrored, const bool ymirrored, const bool zmirrored, const double rcoordinate, const double rotation) const
Move (ex, ey, ez) to global coordinates.
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 size_t i, const std::vector< double > &potential) const
void TimeInterpolation (const double t, double &f0, double &f1, int &i0, int &i1)
Interpolation of potential between two time slices.
int Coordinates3 (const double x, const double y, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, const std::array< double, 8 > &xn, const std::array< double, 8 > &yn) const
Calculate local coordinates for curved quadratic triangles.
int Coordinates4 (const double x, const double y, double &t1, double &t2, double &t3, double &t4, double &det, const std::array< double, 8 > &xn, const std::array< double, 8 > &yn) const
Calculate local coordinates for linear quadrilaterals.
int Coordinates5 (const double x, const double y, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, const std::array< double, 8 > &xn, const std::array< double, 8 > &yn) const
Calculate local coordinates for curved quadratic quadrilaterals.
__DEVICE__ void Coordinates12 (const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, const std::array< double, 10 > &xn, const std::array< double, 10 > &yn, const std::array< double, 10 > &zn, const std::array< std::array< double, 3 >, 4 > &w) const
Calculate local coordinates in linear tetrahedra.
__DEVICE__ int Coordinates13 (const double x, const double y, const double z, double &t1, double &t2, double &t3, double &t4, double jac[4][4], double &det, const std::array< double, 10 > &xn, const std::array< double, 10 > &yn, const std::array< double, 10 > &zn, const std::array< std::array< double, 3 >, 4 > &w) const
Calculate local coordinates for curved quadratic tetrahedra.
int CoordinatesCube (const double x, const double y, const double z, double &t1, double &t2, double &t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN, const Element &element) const
Calculate local coordinates for a cube.
void JacobianCube (const Element &element, const double t1, const double t2, const double t3, TMatrixD *&jac, std::vector< TMatrixD * > &dN) const
Calculate Jacobian for a cube.
void CalculateElementBoundingBoxes ()
Calculate the bounding boxes of all elements after initialization.
bool InitializeTetrahedralTree ()
Initialize the tetrahedral tree.
enum class ElementType { Unknown = 0
, Serendipity = 5
, CurvedTetrahedron = 13
}
static double ScalingFactor (std::string unit)
static double Potential3 (const std::array< double, 6 > &v, const std::array< double, 3 > &t)
Interpolate the potential in a triangle.
static void Field3 (const std::array< double, 6 > &v, const std::array< double, 3 > &t, double jac[4][4], const double det, double &ex, double &ey)
Interpolate the field in a triangle.
static double Potential5 (const std::array< double, 8 > &v, const std::array< double, 2 > &t)
Interpolate the potential in a curved quadrilateral.
static void Field5 (const std::array< double, 8 > &v, const std::array< double, 2 > &t, double jac[4][4], const double det, double &ex, double &ey)
Interpolate the field in a curved quadrilateral.
static double Potential13 (const std::array< double, 10 > &v, const std::array< double, 4 > &t)
Interpolate the potential in a curved quadratic tetrahedron.
static __DEVICE__ void Field13 (const std::array< double, 10 > &v, const std::array< double, 4 > &t, double jac[4][4], const double det, double &ex, double &ey, double &ez)
Interpolate the field in a curved quadratic tetrahedron.
static int ReadInteger (char *token, int def, bool &error)
static double ReadDouble (char *token, double def, bool &error)
static void Jacobian3 (const std::array< double, 8 > &xn, const std::array< double, 8 > &yn, const double u, const double v, const double w, double &det, double jac[4][4])
Calculate Jacobian for curved quadratic triangles.
static void Jacobian5 (const std::array< double, 8 > &xn, const std::array< double, 8 > &yn, const double u, const double v, double &det, double jac[4][4])
Calculate Jacobian for curved quadratic quadrilaterals.
static __DEVICE__ void Jacobian13 (const std::array< double, 10 > &xn, const std::array< double, 10 > &yn, const std::array< double, 10 > &zn, const double fourt0, const double fourt1, const double fourt2, const double fourt3, double &det, double jac[4][4])
Calculate Jacobian for curved quadratic tetrahedra.
static std::array< std::array< double, 3 >, 4 > Weights12 (const std::array< double, 10 > &xn, const std::array< double, 10 > &yn, const std::array< double, 10 > &zn)
bool m_is3d = true
ElementType m_elementType = ElementType::CurvedTetrahedron
std::vector< Element > m_elements
std::vector< int > m_elementIndices
std::vector< bool > m_degenerate
std::vector< std::array< double, 3 > > m_bbMin
std::vector< std::array< double, 3 > > m_bbMax
std::vector< std::array< std::array< double, 3 >, 4 > > m_w12
std::vector< Node > m_nodes
std::vector< double > m_pot
std::map< std::string, std::vector< double > > m_wpot
std::map< std::string, std::vector< std::vector< double > > > m_dwpot
std::vector< Material > m_materials
std::map< std::string, WeightingFieldCopy > m_wfieldCopies
bool m_hasBoundingBox = false
std::array< double, 3 > m_minBoundingBox = {{0., 0., 0.}}
std::array< double, 3 > m_maxBoundingBox = {{0., 0., 0.}}
bool m_cacheElemBoundingBoxes = false
Flag to check if bounding boxes of elements are cached.
std::array< double, 3 > m_mapmin = {{0., 0., 0.}}
std::array< double, 3 > m_mapmax = {{0., 0., 0.}}
std::array< double, 3 > m_mapamin = {{0., 0., 0.}}
std::array< double, 3 > m_mapamax = {{0., 0., 0.}}
std::array< double, 3 > m_mapna = {{0., 0., 0.}}
std::array< double, 3 > m_cells = {{0., 0., 0.}}
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
bool m_checkMultipleElement = false
Scan for multiple elements that contain a point.
bool m_useTetrahedralTree = true
std::unique_ptr< GARFIELD_CLASS_NAME (TetrahedralTree)> m_octree
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.
std::array< bool, 3 > m_triangleSymmetric = {{false, false, false}}
Triangle symmetric in the xy, xz, and yz plane.
int m_triangleSymmetricOct = 0
Triangle symmetric octant of imported map (0 < phi < Pi/4 --> octant 1).
const std::array< int, 4 > m_triangleOctRules = {1, 4, 5, 8}
Octants where |x| >= |y|.
bool m_outsideCone = false
std::vector< double > m_wdtimes
Time steps at which the delayed weighting potentials/fields are stored.