1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
#ifndef ELECTRON_DENSITY_H
#define ELECTRON_DENSITY_H
#include <map>
#include <string>
#include <fstream>
#include "ATC_TypeDefs.h"
#include "Function.h"
const double tol = 1.e-8;
namespace ATC {
/**
* @class ElectronChargeDensity
* @brief Base class for models of extrinsic electric charges
*/
class ElectronChargeDensity
{
public:
ElectronChargeDensity() {};
virtual ~ElectronChargeDensity() {};
virtual bool electron_charge_density(const FIELD_MATS & /* fields */,
DENS_MAT & /* flux */) const { return false; };
virtual void D_electron_charge_density(const FieldName /* fieldName */,
const FIELD_MATS & /* fields */,
DENS_MAT & /* flux */) const
{ throw ATC_Error("Charge density D_electron_charge_density unimplemented function");}
virtual void band_edge_potential(const FIELD_MATS & /* fields */,
DENS_MAT & /* density */) const
{ throw ATC_Error("Charge density band_edge_potential unimplemented function");}
};
//-----------------------------------------------------------------------
/**
* @class ElectronChargeDensityInterpolation
* @brief Class for models of electron charge density as a tabular function of electric potential
*/
class ElectronChargeDensityInterpolation : public ElectronChargeDensity
{
public:
ElectronChargeDensityInterpolation(std::fstream &matfile,std::map<std::string,double> & parameters);
virtual ~ElectronChargeDensityInterpolation() {};
virtual bool electron_charge_density(const FIELD_MATS &fields,
DENS_MAT &flux) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
flux.reset(nNodes,1,false);
for (int i = 0; i < nNodes; i++) { // a mapping of a vector
flux(i,0) = n_.f(phi(i,0));
}
flux *= -1.;
return true;
};
virtual void D_electron_charge_density(const FieldName /* field */,
const FIELD_MATS &fields,
DENS_MAT &coef) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
coef.reset(nNodes,1,false);
for (int i = 0; i < nNodes; i++) {
coef(i,0) = n_.dfdt(phi(i,0));
coef(i,0) = n_.dfdt(phi(i,0));
}
coef *= -1.;
}
private:
InterpolationFunction n_;
};
//-----------------------------------------------------------------------
/**
* @class ElectronChargeDensityLinear
* @brief Class for models of electron charge density proportional to electric potential
*/
class ElectronChargeDensityLinear : public ElectronChargeDensity
{
public:
ElectronChargeDensityLinear(std::fstream &matfile,std::map<std::string,double> & parameters);
virtual ~ElectronChargeDensityLinear() {};
virtual bool electron_charge_density(const FIELD_MATS &fields,
DENS_MAT &flux) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
flux = phi_field->second;
flux *= -C_;
return true;
};
virtual void D_electron_charge_density(const FieldName /* field */,
const FIELD_MATS &fields,
DENS_MAT &coef) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
coef.reset(nNodes,1,false);
coef = -C_;
}
private:
double C_;
};
//-----------------------------------------------------------------------
/**
* @class ElectronChargeDensityExponential
* @brief Class for models of electron charge density dependent on difference between electric potential and the Fermi level n = n_i exp ( (phi-E_i) / kB T)
*/
class ElectronChargeDensityExponential : public ElectronChargeDensity
{
public:
ElectronChargeDensityExponential(std::fstream &matfile,std::map<std::string,double> & parameters);
virtual ~ElectronChargeDensityExponential() {};
double n(const double phi, double T) const
{
return -intrinsicConcentration_*exp((phi-intrinsicEnergy_)/(kBeV_*T));
}
double dndphi(const double phi, double T) const
{
return n(phi,T)/(kBeV_*T);
}
virtual bool electron_charge_density(const FIELD_MATS &fields,
DENS_MAT &density) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
FIELD_MATS::const_iterator T_field = fields.find(TEMPERATURE);
double T = 300;
bool hasTref = (referenceTemperature_ > 0 );
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
density.resize(nNodes,1);
if (hasTref) {
T = referenceTemperature_;
for (int i = 0; i < nNodes; i++) {
density(i,0) = n(phi(i,0),T); }
}
else {
const DENS_MAT & temp = T_field->second;
for (int i = 0; i < nNodes; i++) {
density(i,0) = n(phi(i,0),temp(i,0)); }
}
density *= -1.;
return true;
};
virtual void D_electron_charge_density(const FieldName /* field */,
const FIELD_MATS &fields,
DENS_MAT &coef) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
FIELD_MATS::const_iterator T_field = fields.find(TEMPERATURE);
double T = 300;
bool hasTref = (referenceTemperature_ > 0 );
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
coef.resize(nNodes,1);
if (hasTref) {
T = referenceTemperature_;
for (int i = 0; i < nNodes; i++) {
coef(i,0) = dndphi(phi(i,0),T); }
}
else {
const DENS_MAT & temp = T_field->second;
for (int i = 0; i < nNodes; i++) {
coef(i,0) = dndphi(phi(i,0),temp(i,0)); }
}
coef *= -1.;
};
protected:
double intrinsicConcentration_,intrinsicEnergy_;
double referenceTemperature_;
};
//-----------------------------------------------------------------------
/**
* @class ElectronChargeDensityFermiDirac
* @brief Class for models of electron charge density based on Fermi-Dirac statistics
*/
class ElectronChargeDensityFermiDirac : public ElectronChargeDensity
{
public:
ElectronChargeDensityFermiDirac(std::fstream &matfile,std::map<std::string,double> & parameters);
virtual ~ElectronChargeDensityFermiDirac() {};
double fermi_dirac(const double E, const double T) const
{
double f = 1.0;
if (T > 0) f = 1.0 / ( exp((E-Ef_)/kBeV_/T)+1.0 );
else if (E > Ef_) f = 0;
return f;
};
virtual bool electron_charge_density(const FIELD_MATS &fields,
DENS_MAT &density) const
{
// psi : the inhomogeneous solution
FIELD_MATS::const_iterator psi_field = fields.find(ELECTRON_WAVEFUNCTION);
const DENS_MAT & psi = psi_field->second;
FIELD_MATS::const_iterator psis_field = fields.find(ELECTRON_WAVEFUNCTIONS);
// if (psis_field==fields.end())
//throw ATC_Error("Wavefunctions not defined");
const DENS_MAT & psis = psis_field->second;
FIELD_MATS::const_iterator E_field = fields.find(ELECTRON_WAVEFUNCTION_ENERGIES);
const DENS_MAT & Es = E_field->second;
FIELD_MATS::const_iterator T_field = fields.find(ELECTRON_TEMPERATURE);
const DENS_MAT & Ts = T_field->second;
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = phi_field->second;
int nNodes = psi.nRows();
density.reset(nNodes,1);
double T = referenceTemperature_;
int count = 0;
for (int i = 0; i < nNodes; i++) {
if (!hasReferenceTemperature_) { T = Ts(i,0); }
int j = 0;
for (j = 0; j < psis.nCols(); j++) {
double E = Es(j,0); // Eigenvalue
double f = fermi_dirac(E,T);
if (f < tol) break;
else count++;
density(i,0) -= psis(i,j)*psis(i,j)*f; // < 0
}
if (donorIonization_) {
double E = -1.0* phi(i,0);// units [eV] E = - |e| phi
if ( E + Eb_ > Ef_+Ed_) density(i,0) += Nd_; // > 0
}
}
return true;
};
virtual void D_electron_charge_density(const FieldName /* fieldName */,
const FIELD_MATS &fields,
DENS_MAT &coef) const
{
FIELD_MATS::const_iterator phi_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = phi_field->second;
int nNodes = phi.nRows();
coef.reset(nNodes,1,false);
}
virtual void band_edge_potential(const FIELD_MATS &fields,
DENS_MAT &density) const
{
FIELD_MATS::const_iterator p_field = fields.find(ELECTRIC_POTENTIAL);
const DENS_MAT & phi = p_field->second;
int nNodes = phi.nRows();
density.reset(nNodes,1,false);
density = Eb_;
};
protected:
double Ef_;
double referenceTemperature_;
double Ed_, Nd_;
double Eb_;
bool hasReferenceTemperature_, donorIonization_;
};
}
#endif
|