Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/FerroX.H
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ void WritePlotfile(c_FerroX& rFerroX,
MultiFab& PoissonRHS,
Array< MultiFab, AMREX_SPACEDIM>& P_old,
Array< MultiFab, AMREX_SPACEDIM>& E,
Array< MultiFab, AMREX_SPACEDIM>& Jn,
Array< MultiFab, AMREX_SPACEDIM>& Jp,
MultiFab& hole_den,
MultiFab& e_den,
MultiFab& acceptor_den,
MultiFab& donor_den,
MultiFab& charge_den,
MultiFab& beta_cc,
MultiFab& MaterialMask,
Expand Down
56 changes: 48 additions & 8 deletions Source/FerroX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,12 @@ AMREX_GPU_MANAGED amrex::Real FerroX::dt;
int FerroX::plot_Phi;
int FerroX::plot_PoissonRHS;
int FerroX::plot_E;
int FerroX::plot_Jn;
int FerroX::plot_Jp;
int FerroX::plot_holes;
int FerroX::plot_electrons;
int FerroX::plot_acceptors;
int FerroX::plot_donors;
int FerroX::plot_charge;
int FerroX::plot_epsilon;
int FerroX::plot_mask;
Expand All @@ -189,8 +193,10 @@ AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::SC_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::DE_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::FE_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::SC_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::Channel_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::Channel_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::p_type_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::p_type_lo;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::n_type_hi;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FerroX::n_type_lo;

// material parameters
AMREX_GPU_MANAGED amrex::Real FerroX::epsilon_0;
Expand Down Expand Up @@ -228,6 +234,13 @@ AMREX_GPU_MANAGED int FerroX::use_Fermi_Dirac;
AMREX_GPU_MANAGED int FerroX::use_work_function;
AMREX_GPU_MANAGED amrex::Real FerroX::metal_work_function;


//Transport Model
AMREX_GPU_MANAGED amrex::Real FerroX::electron_mobility;
AMREX_GPU_MANAGED amrex::Real FerroX::hole_mobility;
AMREX_GPU_MANAGED amrex::Real FerroX::electron_diffusion_coefficient;
AMREX_GPU_MANAGED amrex::Real FerroX::hole_diffusion_coefficient;

// P and Phi Bc
AMREX_GPU_MANAGED amrex::Real FerroX::lambda;
AMREX_GPU_MANAGED amrex::GpuArray<int, AMREX_SPACEDIM> FerroX::P_BC_flag_lo;
Expand Down Expand Up @@ -303,10 +316,18 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM
pp.query("plot_PoissonRHS",plot_PoissonRHS);
plot_E = 1;
pp.query("plot_E",plot_E);
plot_Jn = 1;
pp.query("plot_Jn",plot_Jn);
plot_Jp = 1;
pp.query("plot_Jp",plot_Jp);
plot_holes = 1;
pp.query("plot_holes",plot_holes);
plot_electrons = 1;
pp.query("plot_electrons",plot_electrons);
plot_acceptors = 1;
pp.query("plot_acceptors",plot_acceptors);
plot_donors = 1;
pp.query("plot_donors",plot_donors);
plot_charge = 1;
pp.query("plot_charge",plot_charge);
plot_epsilon = 1;
Expand Down Expand Up @@ -445,11 +466,13 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM
for (int i=0; i<AMREX_SPACEDIM; ++i) {
DE_lo[i] = prob_lo[i] - 1.0;
SC_lo[i] = prob_lo[i] - 1.0;
Channel_lo[i] = prob_lo[i] - 1.0;
p_type_lo[i] = prob_lo[i] - 1.0;
n_type_lo[i] = prob_lo[i] - 1.0;

DE_hi[i] = prob_hi[i] + 1.0;
SC_hi[i] = prob_hi[i] + 1.0;
Channel_hi[i] = prob_hi[i] + 1.0;
p_type_hi[i] = prob_hi[i] + 1.0;
n_type_hi[i] = prob_hi[i] + 1.0;
t_phase_lo[i] = 1.0; //just a large number so that t_phase is NOT simulated by default
t_phase_hi[i] = 1.0;
}
Expand Down Expand Up @@ -495,15 +518,27 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM
}
}

if (pp.queryarr("Channel_lo",temp)) {
if (pp.queryarr("p_type_lo",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
p_type_lo[i] = temp[i];
}
}

if (pp.queryarr("p_type_hi",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
Channel_lo[i] = temp[i];
p_type_hi[i] = temp[i];
}
}

if (pp.queryarr("Channel_hi",temp)) {
if (pp.queryarr("n_type_lo",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
Channel_hi[i] = temp[i];
n_type_lo[i] = temp[i];
}
}

if (pp.queryarr("n_type_hi",temp)) {
for (int i=0; i<AMREX_SPACEDIM; ++i) {
n_type_hi[i] = temp[i];
}
}

Expand Down Expand Up @@ -553,6 +588,11 @@ void InitializeFerroXNamespace(const amrex::GpuArray<amrex::Real, AMREX_SPACEDIM

intrinsic_carrier_concentration = std::sqrt(Nc*Nv)*exp(-0.5*q*bandgap/(kb*T));

electron_mobility = 1400.0*1.e-4;
hole_mobility = 450.0*1.e-4;
electron_diffusion_coefficient = electron_mobility*kb*T/q;
hole_diffusion_coefficient = hole_mobility*kb*T/q;

use_Fermi_Dirac = 1;
pp.query("use_Fermi_Dirac",use_Fermi_Dirac);

Expand Down
17 changes: 14 additions & 3 deletions Source/FerroX_namespace.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace FerroX {
extern int plot_Phi;
extern int plot_PoissonRHS;
extern int plot_E;
extern int plot_Jn;
extern int plot_Jp;
extern int plot_holes;
extern int plot_electrons;
extern int plot_acceptors;
extern int plot_donors;
extern int plot_charge;
extern int plot_epsilon;
extern int plot_mask;
Expand All @@ -27,8 +31,10 @@ namespace FerroX {
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> DE_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> FE_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> SC_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> Channel_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> Channel_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> p_type_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> p_type_lo;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> n_type_hi;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> n_type_lo;

// material parameters
extern AMREX_GPU_MANAGED amrex::Real epsilon_0;
Expand Down Expand Up @@ -65,7 +71,12 @@ namespace FerroX {
extern AMREX_GPU_MANAGED int use_Fermi_Dirac;
extern AMREX_GPU_MANAGED int use_work_function;
extern AMREX_GPU_MANAGED amrex::Real metal_work_function;


//Transport model
extern AMREX_GPU_MANAGED amrex::Real electron_mobility;
extern AMREX_GPU_MANAGED amrex::Real hole_mobility;
extern AMREX_GPU_MANAGED amrex::Real electron_diffusion_coefficient;
extern AMREX_GPU_MANAGED amrex::Real hole_diffusion_coefficient;

// P and Phi Bc
extern AMREX_GPU_MANAGED amrex::Real lambda;
Expand Down
10 changes: 9 additions & 1 deletion Source/Input/GeometryProperties/EmbeddedBoundaries.H
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ public:

amrex::MultiFab& get_soln_mf (int i) {return (*m_p_soln_mf[i]);}
//amrex::MultiFab& get_beta_mf (int i) {return (*m_p_beta_mf[i]);}
void clear_soln_mf() { m_p_soln_mf.clear(); };
//void clear_soln_mf() { m_p_soln_mf.clear(); };
void clear_soln_mf()
{
for (int i = 0; i < m_p_soln_mf.size(); ++i)
{
m_p_soln_mf[i].reset();
}
m_p_soln_mf.clear();
};
//void clear_beta_mf() { m_p_beta_mf.clear(); };

void BuildGeometry(const amrex::Geometry* geom, const amrex::BoxArray* ba, const amrex::DistributionMapping* dm);
Expand Down
53 changes: 52 additions & 1 deletion Source/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ void WritePlotfile(c_FerroX& rFerroX,
MultiFab& PoissonRHS,
Array< MultiFab, AMREX_SPACEDIM>& P_old,
Array< MultiFab, AMREX_SPACEDIM>& E,
Array< MultiFab, AMREX_SPACEDIM>& Jn,
Array< MultiFab, AMREX_SPACEDIM>& Jp,
MultiFab& hole_den,
MultiFab& e_den,
MultiFab& acceptor_den,
MultiFab& donor_den,
MultiFab& charge_den,
MultiFab& beta_cc,
MultiFab& MaterialMask,
Expand Down Expand Up @@ -55,6 +59,20 @@ void WritePlotfile(c_FerroX& rFerroX,
var_names.push_back("Ez");
}

if (plot_Jn) {
nvar += 3;
var_names.push_back("Jnx");
var_names.push_back("Jny");
var_names.push_back("Jnz");
}

if (plot_Jp) {
nvar += 3;
var_names.push_back("Jpx");
var_names.push_back("Jpy");
var_names.push_back("Jpz");
}

if (plot_holes) {
++nvar;
var_names.push_back("holes");
Expand All @@ -65,6 +83,16 @@ void WritePlotfile(c_FerroX& rFerroX,
var_names.push_back("electrons");
}

if (plot_acceptors) {
++nvar;
var_names.push_back("acceptors");
}

if (plot_donors) {
++nvar;
var_names.push_back("donors");
}

if (plot_charge) {
++nvar;
var_names.push_back("charge");
Expand Down Expand Up @@ -134,6 +162,18 @@ void WritePlotfile(c_FerroX& rFerroX,
MultiFab::Copy(Plt, E[2], 0, counter++, 1, 0);
}

if (plot_Jn) {
MultiFab::Copy(Plt, Jn[0], 0, counter++, 1, 0);
MultiFab::Copy(Plt, Jn[1], 0, counter++, 1, 0);
MultiFab::Copy(Plt, Jn[2], 0, counter++, 1, 0);
}

if (plot_Jp) {
MultiFab::Copy(Plt, Jp[0], 0, counter++, 1, 0);
MultiFab::Copy(Plt, Jp[1], 0, counter++, 1, 0);
MultiFab::Copy(Plt, Jp[2], 0, counter++, 1, 0);
}

if (plot_holes) {
MultiFab::Copy(Plt, hole_den, 0, counter++, 1, 0);
}
Expand All @@ -142,6 +182,14 @@ void WritePlotfile(c_FerroX& rFerroX,
MultiFab::Copy(Plt, e_den, 0, counter++, 1, 0);
}

if (plot_acceptors) {
MultiFab::Copy(Plt, acceptor_den, 0, counter++, 1, 0);
}

if (plot_donors) {
MultiFab::Copy(Plt, donor_den, 0, counter++, 1, 0);
}

if (plot_charge) {
MultiFab::Copy(Plt, charge_den, 0, counter++, 1, 0);
}
Expand Down Expand Up @@ -175,4 +223,7 @@ void WritePlotfile(c_FerroX& rFerroX,
}

WriteSingleLevelPlotfile(pltfile, Plt, var_names, geom, time, plt_step);
}
#ifdef AMREX_USE_EB
EB_WriteSingleLevelPlotfile(pltfile, Plt, var_names, geom, time, plt_step);
#endif
}
32 changes: 32 additions & 0 deletions Source/Solver/ChargeDensity.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,35 @@ void ComputeRho(MultiFab& PoissonPhi,
MultiFab& p_den,
const MultiFab& MaterialMask);

void CalculateDriftDiffusionCurrents(
amrex::Array<amrex::MultiFab, AMREX_SPACEDIM>& Jn, // OUT: Electron current density components (x,y,z)
amrex::Array<amrex::MultiFab, AMREX_SPACEDIM>& Jp, // OUT: Hole current density components (x,y,z)
const amrex::MultiFab& e_den, // IN: Electron density
const amrex::MultiFab& p_den, // IN: Hole density
const amrex::MultiFab& PoissonPhi, // IN: Electric potential
const amrex::Geometry& geom // IN: Simulation geometry
);
/*
void Compute_Effective_Potentials(const MultiFab& PoissonPhi,
MultiFab& e_potential,
MultiFab& p_potential,
const Geometry& geom);
*/

void Compute_Effective_Potentials(const MultiFab& PoissonPhi,
const MultiFab& e_den,
const MultiFab& p_den,
MultiFab& e_potential,
MultiFab& p_potential,
const Geometry& geom);

void ComputeRho_DriftDiffusion(MultiFab& PoissonPhi,
MultiFab& rho,
Array<MultiFab, AMREX_SPACEDIM> &Jn,
Array<MultiFab, AMREX_SPACEDIM> &Jp,
MultiFab& e_den,
MultiFab& p_den,
MultiFab& e_den_old,
MultiFab& p_den_old,
MultiFab& MaterialMask,
const Geometry& geom);
Loading