1#ifndef G_COMPONENT_GRID_H
2#define G_COMPONENT_GRID_H
28 bool SetMesh(
const unsigned int nx,
const unsigned int ny,
29 const unsigned int nz,
const double xmin,
const double xmax,
30 const double ymin,
const double ymax,
const double zmin,
33 bool GetMesh(
unsigned int& nx,
unsigned int& ny,
unsigned int& nz,
34 double& xmin,
double& xmax,
double& ymin,
double& ymax,
35 double& zmin,
double& zmax)
const;
63 const bool withPotential,
const bool withFlag,
64 const double scaleX = 1.,
const double scaleE = 1.,
65 const double scaleP = 1.);
69 const std::string& format,
const bool withPotential,
70 const double scaleX = 1.,
const double scaleE = 1.,
71 const double scaleP = 1.);
74 const std::string& format,
const double time,
75 const bool withPotential,
const double scaleX = 1.,
76 const double scaleE = 1.,
const double scaleP = 1.);
84 const double scaleX = 1.,
const double scaleB = 1.);
92 const std::string& fmt);
95 const std::string& fmt);
109 const std::string& filename,
const std::string& fmt);
113 const unsigned int k,
double& v,
double& ex,
double& ey,
131 const unsigned int col,
const double scaleX = 1.);
134 const unsigned int col,
const double scaleX = 1.);
143 const double scaleX = 1.,
144 const double scaleV = 1.e-9);
147 const double scaleX = 1.,
const double scaleV = 1.e-9);
150 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
151 double& ey,
double& ez,
double& v,
Medium*& m,
152 int& status)
override;
153 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
154 double& ey,
double& ez,
Medium*& m,
int& status)
override;
157 double& wx,
double& wy,
double& wz,
158 const std::string& label)
override;
160 const std::string& label)
override;
162 const double t,
double& wx,
double& wy,
double& wz,
163 const std::string& label)
override;
165 const double z,
const double t,
166 const std::string& label)
override;
167 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
168 double& by,
double& bz,
int& status)
override;
174 double& eymax,
double& ezmin,
double& ezmax);
176 double& ymax,
double& zmax)
override;
178 double& ymax,
double& zmax)
override;
186 double& att)
override;
188 double& att)
override;
193 double& mu)
override;
195 double& mu)
override;
201 double& vx,
double& vy,
double& vz)
override;
202 bool HoleVelocity(
const double x,
const double y,
const double z,
double& vx,
203 double& vy,
double& vz)
override;
210 std::vector<ComponentGrid::Node> > >& efields){
215 const double xShift = 0.,
216 const double yShift = 0.,
217 const double zShift = 0.);
223 bool GetNodeIndex(
double x,
const double y,
const double z,
unsigned int& i,
unsigned int& j,
unsigned int& k);
233 std::vector<std::vector<std::vector<Node> > >
m_efields;
235 std::vector<std::vector<std::vector<Node> > >
m_bfields;
237 std::vector<std::vector<std::vector<Node> > >
m_wfields;
239 std::vector<std::vector<std::vector<std::vector<Node> > > >
m_wdfields;
250 std::vector<std::vector<std::vector<bool> > >
m_active;
253 std::array<unsigned int, 3>
m_nX = {{1, 1, 1}};
254 std::array<double, 3>
m_xMin = {{0., 0., 0.}};
255 std::array<double, 3>
m_xMax = {{0., 0., 0.}};
256 std::array<double, 3>
m_sX = {{0., 0., 0.}};
268 bool LoadMesh(
const std::string& filename, std::string format,
269 const double scaleX);
272 bool LoadData(
const std::string& filename, std::string format,
273 const bool withPotential,
const bool withFlag,
274 const double scaleX,
const double scaleF,
const double scaleP,
275 std::vector<std::vector<std::vector<Node> > >& field);
277 bool LoadData(
const std::string& filename, std::string format,
279 std::vector<std::vector<std::vector<double> > >& tab,
280 const unsigned int col);
286 bool GetField(
const double x,
const double y,
const double z,
287 const std::vector<std::vector<std::vector<Node> > >& field,
288 double& fx,
double& fy,
double& fz,
double& p,
bool& active);
290 bool GetData(
const double x,
const double y,
const double z,
291 const std::vector<std::vector<std::vector<double> > >& table,
295 double Reduce(
const double xin,
const double xmin,
const double xmax,
296 const bool simplePeriodic,
const bool mirrorPeriodic,
297 bool& isMirrored)
const;
299 void Initialise(std::vector<std::vector<std::vector<Node> > >& fields);
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)
Import a map of electron drift velocities from a file.
~ComponentGrid()
Destructor.
void SetCylindricalCoordinates()
Use cylindrical coordinates.
bool HasVelocityMap() const override
Does the component have velocity maps?
void UpdatePeriodicity() override
Verify periodicities.
std::vector< std::vector< std::vector< double > > > m_hMobility
bool GetField(const double x, const double y, const double z, const std::vector< std::vector< std::vector< Node > > > &field, double &fx, double &fy, double &fz, double &p, bool &active)
Interpolation of the field and potential at a given point.
bool SaveElectricField(Component *cmp)
Export the electric field and potential of a component.
std::vector< std::vector< std::vector< std::vector< Node > > > > m_wdfields
Delayed weighting field values and potentials.
std::vector< std::vector< std::vector< Node > > > m_eVelocity
Velocity maps for electrons and holes.
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)
Define the grid.
std::vector< std::vector< std::vector< bool > > > m_active
Active medium flag.
double DelayedWeightingPotential(const double x, const double y, const 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.
bool HasMagneticField() const override
Does the component have a non-zero magnetic field?
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the coordinates of the elementary cell.
void Initialise(std::vector< std::vector< std::vector< Node > > > &fields)
Set the dimensions of a table according to the mesh.
void GetFieldOnGrid(std::vector< std::vector< std::vector< ComponentGrid::Node > > > &efields)
Get field values on all nodes.
std::vector< std::vector< std::vector< Node > > > m_wfields
Prompt weighting field values and potentials.
bool AddElectricField(ComponentGrid *cmp, const double scale=1., const double xShift=0., const double yShift=0., const double zShift=0.)
Add the field values of cmp to current grid.
std::array< double, 3 > m_wFieldOffset
bool SaveElectricField(Component *cmp, const std::string &filename, const std::string &fmt)
Export the electric field and potential of a component to a text file.
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.)
Import electric field and potential values from a file.
bool HoleMobility(const double x, const double y, const double z, double &mu) override
Get the hole Mobility coefficient.
bool LoadData(const std::string &filename, std::string format, const double scaleX, std::vector< std::vector< std::vector< double > > > &tab, const unsigned int col)
Load scalar data (e. g. attachment coefficients) from file.
void Reset() override
Reset the component.
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
Calculate the delayed weighting field at a given point and time and for a given electrode.
std::vector< std::vector< std::vector< Node > > > m_efields
Electric field values and potentials.
bool LoadWeightingField(const std::string &filename, const std::string &format, const double time, const bool withPotential, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
Import delayed weighting field from file.
std::array< double, 3 > m_xMax
bool HasMobilityMap() const override
Does the component have maps of the low-field mobility?
Coordinates m_coordinates
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
double Reduce(const double xin, const double xmin, const double xmax, const bool simplePeriodic, const bool mirrorPeriodic, bool &isMirrored) const
Reduce a coordinate to the basic cell (in case of periodicity).
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.
std::vector< std::vector< std::vector< Node > > > m_bfields
Magnetic field values.
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.
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 LoadData(const std::string &filename, std::string format, const bool withPotential, const bool withFlag, const double scaleX, const double scaleF, const double scaleP, std::vector< std::vector< std::vector< Node > > > &field)
Read electric field and potential from file.
void Print()
Print information about the mesh and the available data.
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
bool ElectronMobility(const double x, const double y, const double z, double &mu) override
std::vector< std::vector< std::vector< Node > > > m_hVelocity
bool SaveElectricFieldROOT(Component *cmp, const std::string &filename, const std::string &fmt)
void SetMedium(Medium *m)
Set the medium.
Medium * GetMedium() const
Get the medium.
std::vector< std::vector< std::vector< double > > > m_hAttachment
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.
std::array< double, 3 > m_sX
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.
Format GetFormat(std::string fmt)
Decode a format string.
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.
bool GetData(const double x, const double y, const double z, const std::vector< std::vector< std::vector< double > > > &table, double &value)
Interpolation in a table of scalars.
void Clear() override
Reset.
bool AddElectricField(Component *cmp, const double scale)
Add the field values of cmp to current grid.
bool HoleAttachment(const double x, const double y, const double z, double &att) override
Get the hole attachment coefficient.
bool LoadMesh(const std::string &filename, std::string format, const double scaleX)
Read/determine mesh parameters from file.
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
Calculate the magnetic field at a given point.
std::array< double, 3 > m_xMin
std::array< unsigned int, 3 > m_nX
bool ElectronAttachment(const double x, const double y, const double z, double &att) override
Get the electron attachment coefficient.
void SetCartesianCoordinates()
Use Cartesian coordinates (default).
void SetWeightingFieldOffset(const double x, const double y, const double z)
Offset coordinates in the weighting field, such that the same numerical weighting field map can be us...
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.
std::vector< std::vector< std::vector< double > > > m_eMobility
Mobility maps for electrons and holes.
bool HasAttachmentMap() const override
Does the component have maps of the attachment coefficient?
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.
bool GetNodeIndex(double x, const double y, const double z, unsigned int &i, unsigned int &j, unsigned int &k)
Gives the closest node index (i, j, k) to coordinate (x, y, z).
bool LoadElectronAttachment(const std::string &fname, const std::string &fmt, const unsigned int col, const double scaleX=1.)
Import electron attachment coefficients from a file.
bool SaveWeightingField(Component *cmp, const std::string &id, const std::string &filename, const std::string &fmt)
Export the weighting field and potential of a component to a text file.
std::vector< std::vector< std::vector< double > > > m_eAttachment
Attachment maps for electrons and holes.
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
Calculate the drift field at given point.
Component()=delete
Default constructor.
Abstract base class for components.