1#ifndef G_COMPONENT_GRID_H
2#define G_COMPONENT_GRID_H
27 bool SetMesh(
const unsigned int nx,
const unsigned int ny,
28 const unsigned int nz,
const double xmin,
const double xmax,
29 const double ymin,
const double ymax,
const double zmin,
32 bool GetMesh(
unsigned int& nx,
unsigned int& ny,
unsigned int& nz,
33 double& xmin,
double& xmax,
double& ymin,
double& ymax,
34 double& zmin,
double& zmax)
const;
62 const bool withPotential,
const bool withFlag,
63 const double scaleX = 1.,
const double scaleE = 1.,
64 const double scaleP = 1.);
68 const std::string& format,
const bool withPotential,
69 const double scaleX = 1.,
const double scaleE = 1.,
70 const double scaleP = 1.);
73 const std::string& format,
const double time,
74 const bool withPotential,
const double scaleX = 1.,
75 const double scaleE = 1.,
const double scaleP = 1.);
83 const double scaleX = 1.,
const double scaleB = 1.);
91 const std::string& fmt);
99 const std::string& filename,
const std::string& fmt);
103 const unsigned int k,
double& v,
double& ex,
double& ey,
121 const unsigned int col,
const double scaleX = 1.);
124 const unsigned int col,
const double scaleX = 1.);
133 const double scaleX = 1.,
134 const double scaleV = 1.e-9);
137 const double scaleX = 1.,
const double scaleV = 1.e-9);
140 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
141 double& ey,
double& ez,
double& v, Medium*& m,
142 int& status)
override;
143 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
144 double& ey,
double& ez, Medium*& m,
int& status)
override;
145 using Component::ElectricField;
147 double& wx,
double& wy,
double& wz,
148 const std::string& label)
override;
150 const std::string& label)
override;
152 const double t,
double& wx,
double& wy,
double& wz,
153 const std::string& label)
override;
155 const double z,
const double t,
156 const std::string& label)
override;
157 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
158 double& by,
double& bz,
int& status)
override;
160 Medium*
GetMedium(
const double x,
const double y,
const double z)
override;
164 double& eymax,
double& ezmin,
double& ezmax);
166 double& ymax,
double& zmax)
override;
168 double& ymax,
double& zmax)
override;
176 double& att)
override;
178 double& att)
override;
183 double& mu)
override;
185 double& mu)
override;
191 double& vx,
double& vy,
double& vz)
override;
192 bool HoleVelocity(
const double x,
const double y,
const double z,
double& vx,
193 double& vy,
double& vz)
override;
207 std::vector<std::vector<std::vector<Node> > >
m_efields;
209 std::vector<std::vector<std::vector<Node> > >
m_bfields;
211 std::vector<std::vector<std::vector<Node> > >
m_wfields;
213 std::vector<std::vector<std::vector<std::vector<Node> > > >
m_wdfields;
224 std::vector<std::vector<std::vector<bool> > >
m_active;
227 std::array<unsigned int, 3>
m_nX = {{1, 1, 1}};
228 std::array<double, 3>
m_xMin = {{0., 0., 0.}};
229 std::array<double, 3>
m_xMax = {{0., 0., 0.}};
230 std::array<double, 3>
m_sX = {{0., 0., 0.}};
242 bool LoadMesh(
const std::string& filename, std::string format,
243 const double scaleX);
246 bool LoadData(
const std::string& filename, std::string format,
247 const bool withPotential,
const bool withFlag,
248 const double scaleX,
const double scaleF,
const double scaleP,
249 std::vector<std::vector<std::vector<Node> > >& field);
251 bool LoadData(
const std::string& filename, std::string format,
253 std::vector<std::vector<std::vector<double> > >& tab,
254 const unsigned int col);
260 bool GetField(
const double x,
const double y,
const double z,
261 const std::vector<std::vector<std::vector<Node> > >& field,
262 double& fx,
double& fy,
double& fz,
double& p,
bool& active);
264 bool GetData(
const double x,
const double y,
const double z,
265 const std::vector<std::vector<std::vector<double> > >& table,
269 double Reduce(
const double xin,
const double xmin,
const double xmax,
270 const bool simplePeriodic,
const bool mirrorPeriodic,
271 bool& isMirrored)
const;
273 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
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
void UpdatePeriodicity() override
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.
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
bool HasMagneticField() const override
bool GetElementaryCell(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
void Initialise(std::vector< std::vector< std::vector< Node > > > &fields)
Set the dimensions of a table according to the mesh.
std::vector< std::vector< std::vector< Node > > > m_wfields
Prompt weighting field values and potentials.
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
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
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 DelayedWeightingField(const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label) override
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
Coordinates m_coordinates
Medium * GetMedium(const double x, const double y, const double z) override
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
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
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
bool ElectronMobility(const double x, const double y, const double z, double &mu) override
std::vector< std::vector< std::vector< Node > > > m_hVelocity
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
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
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.
bool HoleAttachment(const double x, const double y, const double z, double &att) override
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
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
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
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.)
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.