1#ifndef G_COMPONENT_GRID_H
2#define G_COMPONENT_GRID_H
19 void Clear()
override { Reset(); }
21 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
22 double& ey,
double& ez,
double& v,
Medium*& m,
23 int& status)
override;
24 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
25 double& ey,
double& ez,
Medium*& m,
int& status)
override;
27 void WeightingField(
const double x,
const double y,
const double z,
28 double& wx,
double& wy,
double& wz,
29 const std::string& label)
override;
31 const std::string& label)
override;
33 const double t,
double& wx,
double& wy,
double& wz,
34 const std::string& label)
override;
36 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
37 double& by,
double& bz,
int& status)
override;
39 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
43 double& eymax,
double& ezmin,
double& ezmax);
45 double& xmax,
double& ymax,
double& zmax)
override;
47 double& xmax,
double& ymax,
double& zmax)
override;
55 bool SetMesh(
const unsigned int nx,
const unsigned int ny,
56 const unsigned int nz,
const double xmin,
const double xmax,
57 const double ymin,
const double ymax,
const double zmin,
60 bool GetMesh(
unsigned int& nx,
unsigned int& ny,
unsigned int& nz,
61 double& xmin,
double& xmax,
double& ymin,
double& ymax,
62 double& zmin,
double& zmax)
const;
81 const bool withPotential,
const bool withFlag,
82 const double scaleX = 1.,
const double scaleE = 1.,
83 const double scaleP = 1.);
87 const std::string& format,
const bool withPotential,
88 const double scaleX = 1.,
const double scaleE = 1.,
89 const double scaleP = 1.);
92 const std::string& format,
const double time,
93 const bool withPotential,
const double scaleX = 1.,
94 const double scaleE = 1.,
const double scaleP = 1.);
102 const double scaleX = 1.,
const double scaleB = 1.);
110 const std::string& format);
118 const std::string& filename,
119 const std::string& format);
123 const unsigned int k,
double& v,
double& ex,
double& ey,
141 const std::string& fmt,
142 const unsigned int col,
143 const double scaleX = 1.);
146 const std::string& fmt,
147 const unsigned int col,
148 const double scaleX = 1.);
151 return !(m_eAttachment.empty() && m_hAttachment.empty());
154 double& att)
override;
155 bool HoleAttachment(
const double x,
const double y,
const double z,
156 double& att)
override;
165 const std::string& fmt,
166 const double scaleX = 1.,
167 const double scaleV = 1.e-9);
170 const std::string& fmt,
171 const double scaleX = 1.,
172 const double scaleV = 1.e-9);
175 return !(m_eVelocity.empty() && m_hVelocity.empty());
178 double& vx,
double& vy,
double& vz)
override;
179 bool HoleVelocity(
const double x,
const double y,
const double z,
180 double& vx,
double& vy,
double& vz)
override;
191 Medium* m_medium =
nullptr;
198 std::vector<std::vector<std::vector<Node> > > m_efields;
200 std::vector<std::vector<std::vector<Node> > > m_bfields;
202 std::vector<std::vector<std::vector<Node> > > m_wfields;
204 std::vector<std::vector<std::vector<std::vector<Node> > > > m_wdfields;
205 std::vector<double> m_wdtimes;
207 std::vector<std::vector<std::vector<double> > > m_eAttachment;
208 std::vector<std::vector<std::vector<double> > > m_hAttachment;
210 std::vector<std::vector<std::vector<Node> > > m_eVelocity;
211 std::vector<std::vector<std::vector<Node> > > m_hVelocity;
213 std::vector<std::vector<std::vector<bool> > > m_active;
216 std::array<unsigned int, 3> m_nX = {{1, 1, 1}};
217 std::array<double, 3> m_xMin = {{0., 0., 0.}};
218 std::array<double, 3> m_xMax = {{0., 0., 0.}};
219 std::array<double, 3> m_sX = {{0., 0., 0.}};
221 bool m_hasMesh =
false;
222 bool m_hasPotential =
false;
225 std::array<double, 3> m_wFieldOffset = {{0., 0., 0.}};
228 double m_pMin = 0., m_pMax = 0.;
231 bool LoadMesh(
const std::string& filename, std::string format,
232 const double scaleX);
235 bool LoadData(
const std::string& filename, std::string format,
236 const bool withPotential,
const bool withFlag,
237 const double scaleX,
const double scaleF,
const double scaleP,
238 std::vector<std::vector<std::vector<Node> > >& field);
240 bool LoadData(
const std::string& filename, std::string format,
242 std::vector<std::vector<std::vector<double> > >& tab,
243 const unsigned int col);
245 void Reset()
override;
246 void UpdatePeriodicity()
override;
249 bool GetField(
const double x,
const double y,
const double z,
250 const std::vector<std::vector<std::vector<Node> > >& field,
251 double& fx,
double& fy,
double& fz,
double& p,
bool& active);
253 bool GetData(
const double x,
const double y,
const double z,
254 const std::vector<std::vector<std::vector<double> > >& table,
258 double Reduce(
const double xin,
const double xmin,
const double xmax,
259 const bool simplePeriodic,
const bool mirrorPeriodic,
260 bool& isMirrored)
const;
262 void Initialise(std::vector<std::vector<std::vector<Node> > >& fields);
264 Format GetFormat(std::string fmt);
Component for interpolating field maps on a regular mesh.
bool ElectronVelocity(const double x, const double y, const double z, double &vx, double &vy, double &vz) override
Get the electron drift velocity.
bool LoadElectronVelocity(const std::string &fname, const std::string &fmt, const double scaleX=1., const double scaleV=1.e-9)
~ComponentGrid()
Destructor.
bool HasVelocityMap() const override
Does the component have velocity maps?
bool SaveElectricField(Component *cmp, const std::string &filename, const std::string &format)
bool SetMesh(const unsigned int nx, const unsigned int ny, const unsigned int nz, const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax)
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the coordinates of the elementary cell.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
ComponentGrid()
Constructor.
bool LoadElectricField(const std::string &filename, const std::string &format, const bool withPotential, const bool withFlag, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
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
bool GetMesh(unsigned int &nx, unsigned int &ny, unsigned int &nz, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax) const
Retrieve the parameters of the grid.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
void Print()
Print information about the mesh and the available data.
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
void SetMedium(Medium *m)
Set the medium.
Medium * GetMedium() const
Get the medium.
bool LoadMagneticField(const std::string &filename, const std::string &format, const double scaleX=1., const double scaleB=1.)
Import magnetic field values from a file.
bool GetElectricField(const unsigned int i, const unsigned int j, const unsigned int k, double &v, double &ex, double &ey, double &ez) const
Return the field at a given node.
bool HoleVelocity(const double x, const double y, const double z, double &vx, double &vy, double &vz) override
Get the hole drift velocity.
bool LoadWeightingField(const std::string &filename, const std::string &format, const bool withPotential, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
Import (prompt) weighting field from file.
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 LoadHoleVelocity(const std::string &fname, const std::string &fmt, const double scaleX=1., const double scaleV=1.e-9)
Import a map of hole drift velocities from a file.
void Clear() override
Reset.
bool HoleAttachment(const double x, const double y, const double z, double &att) override
Get the hole attachment coefficient.
bool GetElectricFieldRange(double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
bool ElectronAttachment(const double x, const double y, const double z, double &att) override
Get the electron attachment coefficient.
void SetWeightingFieldOffset(const double x, const double y, const double z)
bool LoadHoleAttachment(const std::string &fname, const std::string &fmt, const unsigned int col, const double scaleX=1.)
Import hole attachment coefficients from a file.
bool SaveWeightingField(Component *cmp, const std::string &id, const std::string &filename, const std::string &format)
bool HasAttachmentMap() const override
Does the component have attachment maps?
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
bool LoadElectronAttachment(const std::string &fname, const std::string &fmt, const unsigned int col, const double scaleX=1.)
Abstract base class for components.
Abstract base class for media.