Garfield++ v2r0
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)
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
 
bool GetVoltageRange (double &vmin, double &vmax)
 Calculate the voltage range [V].
 
void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
 
void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
 
double WeightingPotential (const double x, const double y, const double z, const std::string &label)
 
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 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
 
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 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 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)
 
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
 Geometry checks.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className
 Class name.
 
GeometryBasem_geometry
 Pointer to the geometry.
 
bool m_ready
 Ready for use?
 
bool m_activeTraps
 Does the component have traps?
 
bool m_hasVelocityMap
 Does the component have velocity maps?
 
bool m_xPeriodic
 Simple periodicity in x.
 
bool m_yPeriodic
 Simple periodicity in y.
 
bool m_zPeriodic
 Simple periodicity in z.
 
bool m_xMirrorPeriodic
 Mirror periodicity in x.
 
bool m_yMirrorPeriodic
 Mirror periodicity in y.
 
bool m_zMirrorPeriodic
 Mirror periodicity in z.
 
bool m_xAxiallyPeriodic
 Axial periodicity in x.
 
bool m_yAxiallyPeriodic
 Axial periodicity in y.
 
bool m_zAxiallyPeriodic
 Axial periodicity in z.
 
bool m_xRotationSymmetry
 Rotation symmetry around x-axis.
 
bool m_yRotationSymmetry
 Rotation symmetry around y-axis.
 
bool m_zRotationSymmetry
 Rotation symmetry around z-axis.
 
double m_bx0
 
double m_by0
 
double m_bz0
 
bool m_debug
 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.

9 m_efield(NULL),
10 m_potential(NULL),
11 m_wfield(NULL),
12 m_wpot(NULL),
13 m_bfield(NULL) {
14
15 m_className = "ComponentUser";
16}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:6
std::string m_className
Class name.

◆ ~ComponentUser()

Garfield::ComponentUser::~ComponentUser ( )
inline

Destructor.

Definition at line 16 of file ComponentUser.hh.

16{}

Member Function Documentation

◆ 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 
)
virtual

Implements Garfield::ComponentBase.

Definition at line 48 of file ComponentUser.cc.

51 {
52
53 if (!m_efield) {
54 ex = ey = ez = v = 0.;
55 m = NULL;
56 status = -10;
57 return;
58 }
59 m_efield(x, y, z, ex, ey, ez);
60
61 if (m_potential) {
62 m_potential(x, y, z, v);
63 } else {
64 v = 0.;
65 }
66
67 m = GetMedium(x, y, z);
68 if (!m) {
69 if (m_debug) {
70 std::cerr << m_className << "::ElectricField:\n";
71 std::cerr << " (" << x << ", " << y << ", " << z << ")"
72 << " is not inside a medium.\n";
73 }
74 status = -6;
75 return;
76 }
77
78 if (m->IsDriftable()) {
79 status = 0;
80 } else {
81 status = -5;
82 }
83}
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 
)
virtual

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 18 of file ComponentUser.cc.

20 {
21
22 if (!m_efield) {
23 ex = ey = ez = 0.;
24 m = NULL;
25 status = -10;
26 return;
27 }
28
29 m_efield(x, y, z, ex, ey, ez);
30 m = GetMedium(x, y, z);
31 if (!m) {
32 if (m_debug) {
33 std::cerr << m_className << "::ElectricField:\n";
34 std::cerr << " (" << x << ", " << y << ", " << z << ")"
35 << " is not inside a medium.\n";
36 }
37 status = -6;
38 return;
39 }
40
41 if (m->IsDriftable()) {
42 status = 0;
43 } else {
44 status = -5;
45 }
46}

◆ GetVoltageRange()

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

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 85 of file ComponentUser.cc.

85 {
86
87 vmin = vmax = 0.;
88 return false;
89}

◆ MagneticField()

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

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 91 of file ComponentUser.cc.

94 {
95
96 if (!m_bfield) {
97 bx = by = bz = 0.;
98 status = -10;
99 return;
100 }
101 m_bfield(x, y, z, bx, by, bz);
102 status = 0;
103
104}

◆ 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 124 of file ComponentUser.cc.

126 {
127
128 if (!f) {
129 std::cerr << m_className << "::SetElectricField:\n Null pointer.\n";
130 return;
131 }
132 m_efield = f;
133 m_ready = true;
134}
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 168 of file ComponentUser.cc.

170 {
171
172 if (!f) {
173 std::cerr << m_className << "::SetMagneticField:\n Null pointer.\n";
174 return;
175 }
176 m_bfield = f;
177}

◆ 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 136 of file ComponentUser.cc.

137 {
138
139 if (!f) {
140 std::cerr << m_className << "::SetPotential:\n Null pointer.\n";
141 return;
142 }
143 m_potential = f;
144}

◆ 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 146 of file ComponentUser.cc.

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

◆ 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 157 of file ComponentUser.cc.

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

◆ WeightingField()

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

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 106 of file ComponentUser.cc.

108 {
109
110 wx = wy = wz = 0.;
111 if (!m_wfield) return;
112 m_wfield(x, y, z, wx, wy, wz, label);
113}

◆ WeightingPotential()

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

Reimplemented from Garfield::ComponentBase.

Definition at line 115 of file ComponentUser.cc.

117 {
118
119 double v = 0.;
120 if (m_wpot) m_wpot(x, y, z, v, label);
121 return v;
122}

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