13 const double z,
double& ex,
double& ey,
14 double& ez,
Medium*& m,
int& status) {
21 std::cout <<
m_className <<
"::ElectricField: No medium at ("
22 << x <<
", " << y <<
", " << z <<
").\n";
36 const double z,
double& ex,
double& ey,
37 double& ez,
double& v,
Medium*& m,
43 v = m_v0 - (x - m_x0) * m_fx - (y - m_y0) * m_fy - (z - m_z0) * m_fz;
47 std::cerr <<
m_className <<
"::ElectricField: Potential not defined.\n";
54 std::cout <<
m_className <<
"::ElectricField: No medium at ("
55 << x <<
", " << y <<
", " << z <<
").\n";
69 if (!m_hasPotential)
return false;
72 std::cerr <<
m_className <<
"::GetVoltageRange: Geometry not set.\n";
75 double xmin, ymin, zmin;
76 double xmax, ymax, zmax;
79 <<
" Could not determine the bounding box.\n";
83 const double pxmin = m_v0 - (xmin - m_x0) * m_fx;
84 const double pxmax = m_v0 - (xmax - m_x0) * m_fx;
85 const double pymin = m_v0 - (ymin - m_y0) * m_fy;
86 const double pymax = m_v0 - (ymax - m_y0) * m_fy;
87 const double pzmin = m_v0 - (zmin - m_z0) * m_fz;
88 const double pzmax = m_v0 - (zmax - m_z0) * m_fz;
90 p[0] = pxmin + pymin + pzmin;
91 p[1] = pxmin + pymin + pzmax;
92 p[2] = pxmin + pymax + pzmin;
93 p[3] = pxmin + pymax + pzmax;
94 p[4] = pxmax + pymin + pzmin;
95 p[5] = pxmax + pymin + pzmax;
96 p[6] = pxmax + pymax + pzmin;
97 p[7] = pxmax + pymax + pzmax;
99 for (
int i = 7; i--;) {
100 if (p[i] > vmax) vmax = p[i];
101 if (p[i] < vmin) vmin = p[i];
108 const double z,
double& wx,
double& wy,
109 double& wz,
const std::string& label) {
110 if (!m_hasWeightingField || label != m_wfield)
return;
116 std::cout <<
m_className <<
"::WeightingField: No medium at ("
117 << x <<
", " << y <<
", " << z <<
")\n";
128 const std::string& label) {
129 if (!m_hasWeightingPotential || label != m_wfield)
return 0.;
134 return m_w0 - (x - m_wx0) * m_fwx - (y - m_wy0) * m_fwy - (z - m_wz0) * m_fwz;
142 if (m_fx * m_fx + m_fy * m_fy + m_fz * m_fz > Small)
return;
144 std::cerr <<
m_className <<
"::SetElectricField: Field set to zero.\n";
149 const double z,
const double v) {
154 m_hasPotential =
true;
159 const std::string label) {
164 m_hasWeightingField =
true;
168 const double z,
const double v) {
169 if (!m_hasWeightingField) {
170 std::cerr <<
m_className <<
"::SetWeightingPotential:\n"
171 <<
" Set the weighting field first!\n";
178 m_hasWeightingPotential =
true;
181void ComponentConstant::Reset() {
182 m_fx = m_fy = m_fz = 0.;
183 m_hasPotential =
false;
184 m_hasWeightingField =
false;
185 m_hasWeightingPotential =
false;
190void ComponentConstant::UpdatePeriodicity() {
192 std::cerr <<
m_className <<
"::UpdatePeriodicity:\n"
193 <<
" Periodicities are not supported.\n";
Abstract base class for components.
GeometryBase * m_geometry
Pointer to the geometry.
bool m_ready
Ready for use?
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
std::string m_className
Class name.
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).
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
void SetElectricField(const double ex, const double ey, const double ez)
Set the components of the electric field [V / cm].
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
void SetPotential(const double x, const double y, const double z, const double v=0.)
Specify the potential at a given point.
void SetWeightingPotential(const double x, const double y, const double z, const double v=0.)
Specify the weighting potential at a given point.
void SetWeightingField(const double wx, const double wy, const double wz, const std::string label)
Set the components of the weighting field [1 / cm].
ComponentConstant()
Constructor.
Abstract base class for media.
bool IsDriftable() const
Is charge carrier transport enabled in this medium?