Skip to content

Commit

Permalink
fh_kappa term in computeFHDivRevStress
Browse files Browse the repository at this point in the history
  • Loading branch information
Sreehari Perumanath committed Apr 5, 2024
1 parent fe16e61 commit bbca865
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
23 changes: 11 additions & 12 deletions exec/multispec/AdvanceTimestepBousq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,25 +669,26 @@ if (use_ice_nucleation ==0){
{

phiPrd(i,j,k) = phiOld(i,j,k,n)
+ dt/2 * Mobility * 2 * GradEnCoef *
+ dt/2 * M_phi * 2 * GradEnCoef *
( (phiOld(i+1,j,k,n) - 2.*phiOld(i,j,k,n) + phiOld(i-1,j,k,n)) / (dx[0]*dx[0])
+(phiOld(i,j+1,k,n) - 2.*phiOld(i,j,k,n) + phiOld(i,j-1,k,n)) / (dx[1]*dx[1])
)
- dt/2 * ((u(i+1,j,k)+u_old(i+1,j,k))/2*(phiOld(i+1,j,k,n)+phiOld(i,j,k,n))/2-(u(i,j,k)+u_old(i,j,k))/2*(phiOld(i,j,k,n)+phiOld(i-1,j,k,n))/2)/dx[0]
- dt/2 * ((v(i,j+1,k)+v_old(i,j+1,k))/2*(phiOld(i,j+1,k,n)+phiOld(i,j,k,n))/2-(v(i,j,k)+v_old(i,j,k))/2*(phiOld(i,j,k,n)+phiOld(i,j-1,k,n))/2)/dx[1]
#if (AMREX_SPACEDIM == 3)
+ dt/2 * Mobility * 2 * GradEnCoef * (phiOld(i,j,k+1,n) - 2.*phiOld(i,j,k,n) + phiOld(i,j,k-1,n)) / (dx[2]*dx[2])
+ dt/2 * M_phi * 2 * GradEnCoef * (phiOld(i,j,k+1,n) - 2.*phiOld(i,j,k,n) + phiOld(i,j,k-1,n)) / (dx[2]*dx[2])
- dt/2 * ((w(i,j,k+1)+w_old(i,j,k+1))/2*(phiOld(i,j,k+1,n)+phiOld(i,j,k,n))/2-(w(i,j,k)+w_old(i,j,k))/2*(phiOld(i,j,k,n)+phiOld(i,j,k-1,n))/2)/dx[2]
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*Mobility*dt/(dx[0]*dx[1]*dx[2]))*amrex::RandomNormal(0,1)/sqrt(2)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*M_phi*dt/(dx[0]*dx[1]*dx[2]))*amrex::RandomNormal(0,1)/sqrt(2)
#elif (AMREX_SPACEDIM == 2)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*Mobility*dt/(dx[0]*dx[1]*cell_depth))*amrex::RandomNormal(0,1)/sqrt(2)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*M_phi*dt/(dx[0]*dx[1]*cell_depth))*amrex::RandomNormal(0,1)/sqrt(2)
#endif
- dt/2 * Mobility * EnScale*(2*phiOld(i,j,k,n)*(phiOld(i,j,k,n)-1)*(phiOld(i,j,k,n)-1)+2*phiOld(i,j,k,n)*phiOld(i,j,k,n)*(phiOld(i,j,k,n)-1) - PotWellDepr)
- dt/2 * M_phi * EnScale*(2*phiOld(i,j,k,n)*(phiOld(i,j,k,n)-1)*(phiOld(i,j,k,n)-1)+2*phiOld(i,j,k,n)*phiOld(i,j,k,n)*(phiOld(i,j,k,n)-1) - PotWellDepr)
;
});
}

phi_prd.FillBoundary(geom.periodicity());
MultiFabPhysBC(phi_prd,geom,0,nspecies,SPEC_BC_COMP);
// advance phi to t+1
for (MFIter mfi(phi_new); mfi.isValid(); ++mfi )
{
Expand All @@ -709,20 +710,20 @@ if (use_ice_nucleation ==0){
{

phiNew(i,j,k,n) = phiOld(i,j,k,n)
+ dt * Mobility * 2 * GradEnCoef *
+ dt * M_phi * 2 * GradEnCoef *
( (phiPrd(i+1,j,k) - 2.*phiPrd(i,j,k) + phiPrd(i-1,j,k)) / (dx[0]*dx[0])
+(phiPrd(i,j+1,k) - 2.*phiPrd(i,j,k) + phiPrd(i,j-1,k)) / (dx[1]*dx[1])
)
- dt * ((u(i+1,j,k)+u_old(i+1,j,k))/2*(phiPrd(i+1,j,k)+phiPrd(i,j,k))/2-(u(i,j,k)+u_old(i,j,k))/2*(phiPrd(i,j,k)+phiPrd(i-1,j,k))/2)/dx[0]
- dt * ((v(i,j+1,k)+v_old(i,j+1,k))/2*(phiPrd(i,j+1,k)+phiPrd(i,j,k))/2-(v(i,j,k)+v_old(i,j,k))/2*(phiPrd(i,j,k)+phiPrd(i,j-1,k))/2)/dx[1]
#if (AMREX_SPACEDIM == 3)
+ dt * Mobility * 2 * GradEnCoef * (phiPrd(i,j,k+1) - 2.*phiPrd(i,j,k) + phiPrd(i,j,k-1)) / (dx[2]*dx[2])
+ dt * M_phi * 2 * GradEnCoef * (phiPrd(i,j,k+1) - 2.*phiPrd(i,j,k) + phiPrd(i,j,k-1)) / (dx[2]*dx[2])
- dt * ((w(i,j,k+1)+w_old(i,j,k+1))/2*(phiPrd(i,j,k+1)+phiPrd(i,j,k))/2-(w(i,j,k)+w_old(i,j,k))/2*(phiPrd(i,j,k)+phiPrd(i,j,k-1))/2)/dx[2]
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*Mobility*dt/(dx[0]*dx[1]*dx[2]))*amrex::RandomNormal(0,1)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*M_phi*dt/(dx[0]*dx[1]*dx[2]))*amrex::RandomNormal(0,1)
#elif (AMREX_SPACEDIM == 2)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*Mobility*dt/(dx[0]*dx[1]*cell_depth))*amrex::RandomNormal(0,1)
+ variance_coef_mass*sqrt(2.0*k_B*T_init[0]*M_phi*dt/(dx[0]*dx[1]*cell_depth))*amrex::RandomNormal(0,1)
#endif
- dt * Mobility * EnScale*(2*phiPrd(i,j,k)*(phiPrd(i,j,k)-1)*(phiPrd(i,j,k)-1)+2*phiPrd(i,j,k)*phiPrd(i,j,k)*(phiPrd(i,j,k)-1) - PotWellDepr)
- dt * M_phi * EnScale*(2*phiPrd(i,j,k)*(phiPrd(i,j,k)-1)*(phiPrd(i,j,k)-1)+2*phiPrd(i,j,k)*phiPrd(i,j,k)*(phiPrd(i,j,k)-1) - PotWellDepr)
;

phiNew(i,j,k,n+1) = 1-phiNew(i,j,k,n);
Expand All @@ -735,8 +736,6 @@ if (use_ice_nucleation ==0){

MultiFab::Copy(phi_old,phi_new,0,0,nspecies,0);

amrex::Print() << "Mobility = " << Mobility <<"\n";

amrex::Print() << "Advanced phi (phi1_avg = " << phi_new.sum(0)/(n_cells[0]*n_cells[1]
#if (AMREX_SPACEDIM == 3)
*n_cells[2]
Expand Down
5 changes: 3 additions & 2 deletions src_multispec/ComputeDivReversibleStress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ void ComputeDivFHReversibleStress(std::array<MultiFab,AMREX_SPACEDIM>& div_rever
// rho to conc - VALID REGION ONLY
ConvertRhoCToC(rho_in,rhotot_in,conc,1);

Real scale_factor = rhobar[0]*k_B*T_init[0]/monomer_mass;

// fill conc ghost cells
conc.FillBoundary(geom.periodicity());
MultiFabPhysBC(conc,geom,0,nspecies,SPEC_BC_COMP);
MultiFabPhysBCFH(conc,geom,0,nspecies,scale_factor);

// JBB check what's in this
// Real scale_factor = rhobar[0]*k_B*T_init[0]/molmass[0];
Real scale_factor = rhobar[0]*k_B*T_init[0]/monomer_mass;

for ( MFIter mfi(node_grad_x_mf,TilingIfNotGPU()); mfi.isValid(); ++mfi ) {

Expand Down
18 changes: 15 additions & 3 deletions src_multispec/multispec_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AMREX_GPU_MANAGED int multispec::use_log_p
AMREX_GPU_MANAGED amrex::Real multispec::EnScale;
AMREX_GPU_MANAGED amrex::Real multispec::GradEnCoef;
AMREX_GPU_MANAGED amrex::Real multispec::PotWellDepr;
AMREX_GPU_MANAGED amrex::Real multispec::Mobility;
AMREX_GPU_MANAGED amrex::Real multispec::M_phi;
AMREX_GPU_MANAGED amrex::Real multispec::kc_tension;
AMREX_GPU_MANAGED amrex::Real multispec::alpha_gex;
AMREX_GPU_MANAGED amrex::Array2D<Real,0,MAX_SPECIES-1,0,MAX_SPECIES-1> multispec::fh_kappa;
Expand Down Expand Up @@ -94,7 +94,7 @@ void InitializeMultispecNamespace() {
EnScale = 2.79e09;
GradEnCoef = 2.73e-6;
PotWellDepr = -2.687e-05*T_init[0]*T_init[0]+0.009943*T_init[0]-0.7128; // For polynomial potential
Mobility = 0.0001808*T_init[0]*T_init[0]-0.08481*T_init[0]+9.968; // AC Mobility
M_phi = 674918.6*exp(-4229.416/T_init[0]); // AC Mobility
kc_tension = 0; // for RTIL
alpha_gex = 0; // for RTIL
n_gex = 1; // for RTIL
Expand Down Expand Up @@ -208,7 +208,7 @@ void InitializeMultispecNamespace() {
pp.query("use_log_potential",use_log_potential);
pp.query("monomer_mass",monomer_mass);
pp.query("kc_tension",kc_tension);
pp.query("Mobility",Mobility);
pp.query("M_phi",M_phi);
pp.query("fh_tension",fh_tension);
pp.query("alpha_gex",alpha_gex);
pp.query("n_gex",n_gex);
Expand Down Expand Up @@ -311,4 +311,16 @@ void InitializeMultispecNamespace() {
pp.query("zero_charge_on_wall_type",zero_charge_on_wall_type);
pp.query("zero_eps_on_wall_left_end",zero_eps_on_wall_left_end);
pp.query("zero_eps_on_wall_right_start",zero_eps_on_wall_right_start);


for (int i=0; i<nspecies; ++i) {
for (int j=0; j<nspecies; ++j) {
fh_kappa(i,j) = 0.;
fh_chi(i,j) = 0.;
if (i != j){
fh_kappa(i,j) = GradEnCoef*monomer_mass/(rho0*k_B*T_init[0]);
fh_chi(i,j) = EnScale*monomer_mass/(rho0*k_B*T_init[0]);
}
}
}
}
2 changes: 1 addition & 1 deletion src_multispec/multispec_namespace.H
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ namespace multispec {
extern AMREX_GPU_MANAGED amrex::Real EnScale;
extern AMREX_GPU_MANAGED amrex::Real GradEnCoef;
extern AMREX_GPU_MANAGED amrex::Real PotWellDepr;
extern AMREX_GPU_MANAGED amrex::Real Mobility;
extern AMREX_GPU_MANAGED amrex::Real M_phi;
}

0 comments on commit bbca865

Please sign in to comment.