Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ComponentUser Class Reference

Simple component with electric field given by a user function. More...

#include <ComponentUser.hh>

+ Inheritance diagram for Garfield::ComponentUser:

Public Member Functions

 ComponentUser ()
 Constructor.
 
 ~ComponentUser ()
 Destructor.
 
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).
 
bool GetVoltageRange (double &vmin, double &vmax) override
 Calculate the voltage range [V].
 
void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
 
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
 
void DelayedWeightingField (const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label) override
 
void SetElectricField (void(*f)(const double, const double, const double, double &, double &, double &))
 Set the function to be called for calculating the electric field.
 
void SetPotential (void(*f)(const double, const double, const double, double &))
 Set the function to be called for calculating the potential.
 
void SetWeightingField (void(*f)(const double, const double, const double, double &, double &, double &, const std::string))
 Set the function to be called for calculating the weighting field.
 
void SetWeightingPotential (void(*f)(const double, const double, const double, double &, const std::string))
 Set the function to be called for calculating the weighting potential.
 
void SetDelayedWeightingField (void(*f)(const double, const double, const double, const double, double &, double &, double &, const std::string))
 Set the function to be called for calculating the delayed weighting field.
 
void SetMagneticField (void(*f)(const double, const double, const double, double &, double &, double &))
 Set the function to be called for calculating the magnetic field.
 
- Public Member Functions inherited from Garfield::ComponentBase
 ComponentBase ()
 Constructor.
 
virtual ~ComponentBase ()
 Destructor.
 
virtual void SetGeometry (GeometryBase *geo)
 Define the geometry.
 
virtual void Clear ()
 Reset.
 
virtual MediumGetMedium (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 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.
 
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 IntegrateFlux (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)
 
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 $x$ direction.
 
void DisablePeriodicityX ()
 
void EnablePeriodicityY (const bool on=true)
 Enable simple periodicity in the $y$ direction.
 
void DisablePeriodicityY ()
 
void EnablePeriodicityZ (const bool on=true)
 Enable simple periodicity in the $z$ direction.
 
void DisablePeriodicityZ ()
 
void EnableMirrorPeriodicityX (const bool on=true)
 Enable mirror periodicity in the $x$ direction.
 
void DisableMirrorPeriodicityX ()
 
void EnableMirrorPeriodicityY (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityY ()
 
void EnableMirrorPeriodicityZ (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityZ ()
 
void EnableAxialPeriodicityX (const bool on=true)
 Enable axial periodicity in the $x$ direction.
 
void DisableAxialPeriodicityX ()
 
void EnableAxialPeriodicityY (const bool on=true)
 Enable axial periodicity in the $y$ direction.
 
void DisableAxialPeriodicityY ()
 
void EnableAxialPeriodicityZ (const bool on=true)
 Enable axial periodicity in the $z$ direction.
 
void DisableAxialPeriodicityZ ()
 
void EnableRotationSymmetryX (const bool on=true)
 Enable rotation symmetry around the $x$ axis.
 
void DisableRotationSymmetryX ()
 
void EnableRotationSymmetryY (const bool on=true)
 Enable rotation symmetry around the $y$ axis.
 
void DisableRotationSymmetryY ()
 
void EnableRotationSymmetryZ (const bool on=true)
 Enable rotation symmetry around the $z$ axis.
 
void DisableRotationSymmetryZ ()
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 
void ActivateTraps ()
 Request trapping to be taken care of by the component (for TCAD).
 
void DeactivateTraps ()
 
bool IsTrapActive ()
 
void ActivateVelocityMap ()
 Request velocity to be taken care of by the component (for TCAD).
 
void DectivateVelocityMap ()
 
bool IsVelocityActive ()
 
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 void ElectronVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 Get the electron drift velocity.
 
virtual void HoleVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 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)
 

Additional Inherited Members

virtual void Reset ()=0
 Reset the component.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className = "ComponentBase"
 Class name.
 
GeometryBasem_geometry = nullptr
 Pointer to the geometry.
 
bool m_ready = false
 Ready for use?
 
bool m_activeTraps = false
 Does the component have traps?
 
bool m_hasVelocityMap = false
 Does the component have velocity maps?
 
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.
 
double m_bx0 = 0.
 
double m_by0 = 0.
 
double m_bz0 = 0.
 
bool m_debug = false
 Switch on/off debugging messages.
 

Detailed Description

Simple component with electric field given by a user function.

Definition at line 10 of file ComponentUser.hh.

Constructor & Destructor Documentation

◆ ComponentUser()

Garfield::ComponentUser::ComponentUser ( )

Constructor.

Definition at line 7 of file ComponentUser.cc.

7 : ComponentBase() {
8 m_className = "ComponentUser";
9}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:9
std::string m_className
Class name.

◆ ~ComponentUser()

Garfield::ComponentUser::~ComponentUser ( )
inline

Destructor.

Definition at line 15 of file ComponentUser.hh.

15{}

Member Function Documentation

◆ DelayedWeightingField()

void Garfield::ComponentUser::DelayedWeightingField ( const double  x,
const double  y,
const double  z,
const double  t,
double &  wx,
double &  wy,
double &  wz,
const std::string &  label 
)
overridevirtual

Calculate the delayed weighting field at a given point and time and for a given electrode.

Parameters
x,y,zcoordinates [cm].
ttime [ns].
wx,wy,wzcomponents of the weighting field [1/cm].
labelname of the electrode

Reimplemented from Garfield::ComponentBase.

Definition at line 99 of file ComponentUser.cc.

102 {
103 wx = wy = wz = 0.;
104 if (m_dwfield) m_dwfield(x, y, z, t, wx, wy, wz, label);
105}

◆ ElectricField() [1/2]

void Garfield::ComponentUser::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
double &  v,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field [V/cm] and potential [V] at (x, y, z).

Implements Garfield::ComponentBase.

Definition at line 35 of file ComponentUser.cc.

38 {
39 if (!m_efield) {
40 ex = ey = ez = v = 0.;
41 m = nullptr;
42 status = -10;
43 return;
44 }
45 m_efield(x, y, z, ex, ey, ez);
46
47 if (m_potential) {
48 m_potential(x, y, z, v);
49 } else {
50 v = 0.;
51 }
52
53 m = GetMedium(x, y, z);
54 if (!m) {
55 if (m_debug) {
56 std::cerr << m_className << "::ElectricField:\n (" << x << ", " << y
57 << ", " << z << ") is not inside a medium.\n";
58 }
59 status = -6;
60 return;
61 }
62
63 status = m->IsDriftable() ? 0 : -5;
64}
bool m_debug
Switch on/off debugging messages.
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).

◆ ElectricField() [2/2]

void Garfield::ComponentUser::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field at given point.

Parameters
x,y,zcoordinates [cm].
ex,ey,ezcomponents of the electric field [V/cm].
mpointer to the medium at this location.
statusstatus 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::ComponentBase.

Definition at line 11 of file ComponentUser.cc.

13 {
14 if (!m_efield) {
15 ex = ey = ez = 0.;
16 m = nullptr;
17 status = -10;
18 return;
19 }
20
21 m_efield(x, y, z, ex, ey, ez);
22 m = GetMedium(x, y, z);
23 if (!m) {
24 if (m_debug) {
25 std::cerr << m_className << "::ElectricField:\n (" << x << ", " << y
26 << ", " << z << ") is not inside a medium.\n";
27 }
28 status = -6;
29 return;
30 }
31
32 status = m->IsDriftable() ? 0 : -5;
33}

◆ GetVoltageRange()

bool Garfield::ComponentUser::GetVoltageRange ( double &  vmin,
double &  vmax 
)
overridevirtual

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 66 of file ComponentUser.cc.

66 {
67 vmin = vmax = 0.;
68 return false;
69}

◆ MagneticField()

void Garfield::ComponentUser::MagneticField ( const double  x,
const double  y,
const double  z,
double &  bx,
double &  by,
double &  bz,
int &  status 
)
overridevirtual

Calculate the magnetic field at a given point.

Parameters
x,y,zcoordinates [cm].
bx,by,bzcomponents of the magnetic field [Tesla].
statusstatus flag.

Reimplemented from Garfield::ComponentBase.

Definition at line 71 of file ComponentUser.cc.

73 {
74 if (!m_bfield) {
75 bx = by = bz = 0.;
76 status = -10;
77 return;
78 }
79 m_bfield(x, y, z, bx, by, bz);
80 status = 0;
81}

◆ SetDelayedWeightingField()

void Garfield::ComponentUser::SetDelayedWeightingField ( void(*)(const double, const double, const double, const double, double &, double &, double &, const std::string)  f)

Set the function to be called for calculating the delayed weighting field.

Definition at line 147 of file ComponentUser.cc.

149 {
150
151 if (!f) {
152 std::cerr << m_className << "::SetDelayedWeightingField: Null pointer.\n";
153 return;
154 }
155 m_dwfield = f;
156}

◆ SetElectricField()

void Garfield::ComponentUser::SetElectricField ( void(*)(const double, const double, const double, double &, double &, double &)  f)

Set the function to be called for calculating the electric field.

Definition at line 107 of file ComponentUser.cc.

109 {
110 if (!f) {
111 std::cerr << m_className << "::SetElectricField: Null pointer.\n";
112 return;
113 }
114 m_efield = f;
115 m_ready = true;
116}
bool m_ready
Ready for use?

◆ SetMagneticField()

void Garfield::ComponentUser::SetMagneticField ( void(*)(const double, const double, const double, double &, double &, double &)  f)

Set the function to be called for calculating the magnetic field.

Definition at line 158 of file ComponentUser.cc.

160 {
161 if (!f) {
162 std::cerr << m_className << "::SetMagneticField: Null pointer.\n";
163 return;
164 }
165 m_bfield = f;
166}

◆ SetPotential()

void Garfield::ComponentUser::SetPotential ( void(*)(const double, const double, const double, double &)  f)

Set the function to be called for calculating the potential.

Definition at line 118 of file ComponentUser.cc.

119 {
120 if (!f) {
121 std::cerr << m_className << "::SetPotential: Null pointer.\n";
122 return;
123 }
124 m_potential = f;
125}

◆ SetWeightingField()

void Garfield::ComponentUser::SetWeightingField ( void(*)(const double, const double, const double, double &, double &, double &, const std::string)  f)

Set the function to be called for calculating the weighting field.

Definition at line 127 of file ComponentUser.cc.

129 {
130 if (!f) {
131 std::cerr << m_className << "::SetWeightingField: Null pointer.\n";
132 return;
133 }
134 m_wfield = f;
135}

◆ SetWeightingPotential()

void Garfield::ComponentUser::SetWeightingPotential ( void(*)(const double, const double, const double, double &, const std::string)  f)

Set the function to be called for calculating the weighting potential.

Definition at line 137 of file ComponentUser.cc.

139 {
140 if (!f) {
141 std::cerr << m_className << "::SetWeightingPotential: Null pointer.\n";
142 return;
143 }
144 m_wpot = f;
145}

◆ WeightingField()

void Garfield::ComponentUser::WeightingField ( const double  x,
const double  y,
const double  z,
double &  wx,
double &  wy,
double &  wz,
const std::string &  label 
)
overridevirtual

Calculate the weighting field at a given point and for a given electrode.

Parameters
x,y,zcoordinates [cm].
wx,wy,wzcomponents of the weighting field [1/cm].
labelname of the electrode

Reimplemented from Garfield::ComponentBase.

Definition at line 83 of file ComponentUser.cc.

85 {
86 wx = wy = wz = 0.;
87 if (!m_wfield) return;
88 m_wfield(x, y, z, wx, wy, wz, label);
89}

◆ WeightingPotential()

double Garfield::ComponentUser::WeightingPotential ( const double  x,
const double  y,
const double  z,
const std::string &  label 
)
overridevirtual

Calculate the weighting potential at a given point.

Parameters
x,y,zcoordinates [cm].
labelname of the electrode.
Returns
weighting potential [dimensionless].

Reimplemented from Garfield::ComponentBase.

Definition at line 91 of file ComponentUser.cc.

93 {
94 double v = 0.;
95 if (m_wpot) m_wpot(x, y, z, v, label);
96 return v;
97}

The documentation for this class was generated from the following files: