Skip to content

Commit

Permalink
First commit from Z2
Browse files Browse the repository at this point in the history
  • Loading branch information
sreeharipd committed Nov 5, 2024
1 parent c2b19be commit be88b5c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 57 deletions.
8 changes: 4 additions & 4 deletions exec/multispec/AdvanceTimestepBousq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,10 @@ if (use_ice_nucleation ==0){

} else {
// compute rhotot^{n+1/2} from rho^{n+1/2} in VALID REGION
ComputeRhotot(rho_old,rhotot_new);
ComputeRhotot(rho_new,rhotot_new);

// fill rho and rhotot ghost cells at t^{n+1/2}
FillRhoRhototGhost(rho_old,rhotot_new,geom);
FillRhoRhototGhost(rho_new,rhotot_new,geom);

// average rho_i^{n+1/2} to faces
//AverageCCToFace(rho_old,rho_fc,0,nspecies,SPEC_BC_COMP,geom);
Expand Down Expand Up @@ -687,7 +687,7 @@ if (use_ice_nucleation ==0){
}

phi_prd.FillBoundary(geom.periodicity());
MultiFabPhysBC(phi_prd,geom,0,nspecies,SPEC_BC_COMP);
MultiFabPhysBC(phi_prd,geom,0,1,SPEC_BC_COMP);
// advance phi to t+1
for (MFIter mfi(phi_new); mfi.isValid(); ++mfi )
{
Expand Down Expand Up @@ -728,8 +728,8 @@ if (use_ice_nucleation ==0){
phiNew(i,j,k,n+1) = 1-phiNew(i,j,k,n);
});
}

ComputeRhotot(phi_new,phitot_new);

// compute reversible stress tensor ---added term
ComputeDivFHReversibleStress(div_reversible_stress,phitot_new,phi_new,geom);

Expand Down
2 changes: 1 addition & 1 deletion exec/multispec/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ USE_MPI = TRUE
USE_OMP = FALSE
USE_CUDA = FALSE
COMP = gnu
DIM = 2
DIM = 3
DSMC = FALSE
MAX_SPEC = 8
# MAX_ELEM needs to be MAX_SPEC*(MAX_SPEC-1)/2
Expand Down
31 changes: 14 additions & 17 deletions exec/multispec/_Examples/_Validation/inputs_laplace
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
plot_base_name = plt

# number of cells in domain. IMP: 0.5 nm or less for deterministic simulations
n_cells = 192 192
n_cells = 96 96
# max number of cells in a box
max_grid_size = 96 96
max_grid_size = 48 48

# Time-step control
fixed_dt = 1.e-13
Expand All @@ -27,21 +27,20 @@

use_ice_nucleation = 1

#----------------------
# Thermodynamic and transport properties:
#------------------------------------------------------------------------------------------------------------------------------------
# Temperature (K) | 230 235 240 245 250 255 260 265 270
#------------------------------------------------------------------------------------------------------------------------------------
# c0_water | 0.1099 0.0957 0.082 0.0687 0.0558 0.0431 0.0308 0.0186 0.0066
# c0_ice | 1.0637 1.0591 1.0539 1.048 1.0415 1.0341 1.0259 1.0167 1.0064
# mu_water (Poise) | 0.9124 0.2588 0.1279 0.0782 0.0536 0.0394 0.0304 0.0243 0.0200
# fh_chi | 2.6194 2.5637 2.5103 2.4591 2.4099 2.3626 2.3172 2.2735 2.2314
# fh_kappa | 2.563e-15 2.508e-15 2.456e-15 2.406e-15 2.358e-15 2.311e-15 2.267e-15 2.224e-15 2.183e-15
# rho (g/cm^3) | 0.9453 0.9676 0.9789 0.9862 0.9912 0.9946 0.997 0.9986 0.9995
#------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------
# Thermodynamic and transport properties |
#-------------------------------------------------------------------------------------------
# Temperature (K) | 235 | 240 | 245 | 250 | 255 | 260 | 265 | 270 |
#-------------------------------------------------------------------------------------------
# c0_water | 0.0957 | 0.0820 | 0.0687 | 0.0558 | 0.0431 | 0.0308 | 0.0186 | 0.0066 |
# c0_ice | 1.0591 | 1.0539 | 1.0480 | 1.0415 | 1.0341 | 1.0259 | 1.0167 | 1.0064 |
# mu_water (Poise) | 0.2588 | 0.1279 | 0.0782 | 0.0536 | 0.0394 | 0.0304 | 0.0243 | 0.0200 |
# rho (g/cm^3) | 0.9676 | 0.9789 | 0.9862 | 0.9912 | 0.9946 | 0.9970 | 0.9986 | 0.9995 |
#-------------------------------------------------------------------------------------------

k_B = 1.3806488e-16 # Boltzmann's constant [units: cm2*g*s-2*K-1]
T_init = 255.0 # [units: K] IMP: Change visc_coef, rho, fh_chi, fh_kappa, c_init_1, c_init_2 accordingly.
M_phi = 0.09752

# Viscous friction L phi operator
# if abs(visc_type) = 1, L = div beta grad
Expand All @@ -54,14 +53,12 @@

nspecies = 2
#molmass = 2.98e-23 2.98e-23 # molecular masses for nspecies (mass per molecule, *not* molar mass)
use_flory_huggins = 1
#use_flory_huggins = 1

fh_monomers = 1. 1.
monomer_mass = 2.98e-23
rho0 = 0.9946
rhobar = 0.9946 0.9946 # pure component densities for all species. Same for ice and water for now.
fh_chi = 0. 2.3626 2.3626 0. # = 2.79e09/(rhobar*k_B*T_init/monomer_mass) ~ 602.478/T_init. Off-diagonal terms should be identical.
fh_kappa = 0. 2.311e-15 2.311e-15 0. # = 2.73e-6/(rhobar*k_B*T_init/monomer_mass) ~ 5.895e-13/T_init. Off-diagonal terms should be identical.

is_ideal_mixture = 0

Expand Down
37 changes: 17 additions & 20 deletions exec/multispec/_Examples/_Validation/inputs_spectrum
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
prob_lo = 0. 0. # physical lo coordinate
prob_hi = 256e-7 64e-7 # physical hi coordinate

cell_depth = 1.0e-7
cell_depth = 5.0e-7

# refer to Init.cpp
prob_type = 16
chk_base_name = chk
plot_base_name = plt

# number of cells in domain. IMP: 0.5 nm for deterministic simulations
n_cells = 256 64
n_cells = 512 128
# max number of cells in a box
max_grid_size = 32 64
max_grid_size = 64 128

# Time-step control
fixed_dt = 1.e-13
Expand All @@ -27,21 +27,20 @@

use_ice_nucleation = 1

#----------------------
# Thermodynamic and transport properties:
#------------------------------------------------------------------------------------------------------------------------------------
# Temperature (K) | 230 235 240 245 250 255 260 265 270
#------------------------------------------------------------------------------------------------------------------------------------
# c0_water | 0.1099 0.0957 0.082 0.0687 0.0558 0.0431 0.0308 0.0186 0.0066
# c0_ice | 1.0637 1.0591 1.0539 1.048 1.0415 1.0341 1.0259 1.0167 1.0064
# mu_water (Poise) | 0.9124 0.2588 0.1279 0.0782 0.0536 0.0394 0.0304 0.0243 0.0200
# fh_chi | 2.6194 2.5637 2.5103 2.4591 2.4099 2.3626 2.3172 2.2735 2.2314
# fh_kappa | 2.563e-15 2.508e-15 2.456e-15 2.406e-15 2.358e-15 2.311e-15 2.267e-15 2.224e-15 2.183e-15
# rho (g/cm^3) | 0.9453 0.9676 0.9789 0.9862 0.9912 0.9946 0.997 0.9986 0.9995
#------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------
# Thermodynamic and transport properties |
#-------------------------------------------------------------------------------------------
# Temperature (K) | 235 | 240 | 245 | 250 | 255 | 260 | 265 | 270 |
#-------------------------------------------------------------------------------------------
# c0_water | 0.0957 | 0.0820 | 0.0687 | 0.0558 | 0.0431 | 0.0308 | 0.0186 | 0.0066 |
# c0_ice | 1.0591 | 1.0539 | 1.0480 | 1.0415 | 1.0341 | 1.0259 | 1.0167 | 1.0064 |
# mu_water (Poise) | 0.2588 | 0.1279 | 0.0782 | 0.0536 | 0.0394 | 0.0304 | 0.0243 | 0.0200 |
# rho (g/cm^3) | 0.9676 | 0.9789 | 0.9862 | 0.9912 | 0.9946 | 0.9970 | 0.9986 | 0.9995 |
#-------------------------------------------------------------------------------------------

k_B = 1.3806488e-16 # Boltzmann's constant [units: cm2*g*s-2*K-1]
T_init = 255.0 # [units: K] IMP: Change visc_coef, rho, fh_chi, fh_kappa, c_init_1, c_init_2 accordingly.
T_init = 255.0 # [units: K] IMP: Change visc_coef, rho, c_init_1, c_init_2 accordingly.
M_phi = 0.09752

# Viscous friction L phi operator
# if abs(visc_type) = 1, L = div beta grad
Expand All @@ -54,21 +53,19 @@

nspecies = 2
#molmass = 2.98e-23 2.98e-23 # molecular masses for nspecies (mass per molecule, *not* molar mass)
use_flory_huggins = 1
#use_flory_huggins = 1

fh_monomers = 1. 1.
monomer_mass = 2.98e-23
rho0 = 0.9946
rhobar = 0.9946 0.9946 # pure component densities for all species. Same for ice and water for now.
fh_chi = 0. 2.3626 2.3626 0. # = 2.79e09/(rhobar*k_B*T_init/monomer_mass) ~ 602.478/T_init. Off-diagonal terms should be identical.
fh_kappa = 0. 2.311e-15 2.311e-15 0. # = 2.73e-6/(rhobar*k_B*T_init/monomer_mass) ~ 5.895e-13/T_init. Off-diagonal terms should be identical.

is_ideal_mixture = 0

# initial values for c
c_init_1 = 1.0341 0.0431 # ice ~ -1.605e-05*T_init^2+0.006603*T_init+0.3938
c_init_2 = 0.0431 1.0341 # water ~ -0.002575*T_init+0.7005
smoothing_width = 0.75
smoothing_width = 0.25
film_thickness = 32.e-7

# These are lower-triangules of symmetric matrices represented as vectors
Expand Down
5 changes: 2 additions & 3 deletions src_multispec/ComputeDivReversibleStress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ 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,scale_factor);
MultiFabPhysBC(conc,geom,0,nspecies,SPEC_BC_COMP);

// 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
2 changes: 1 addition & 1 deletion src_multispec/InitialProjection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void InitialProjection(std::array< MultiFab, AMREX_SPACEDIM >& umac,
sMassFlux.fillMassStochastic();
}

if (use_ice_nucleation ==0) {
if (use_ice_nucleation ==0) {
ComputeMassFluxdiv(rho,rhotot,Temp,diff_mass_fluxdiv,stoch_mass_fluxdiv,
diff_mass_flux,stoch_mass_flux,sMassFlux,dt_eff,time,geom,weights,
charge_old,grad_Epot_old,Epot,permittivity);
Expand Down
21 changes: 10 additions & 11 deletions src_multispec/multispec_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ void InitializeMultispecNamespace() {
pp.query("n_gex",n_gex);
pp.query("chi_iterations",chi_iterations);
pp.query("temp_type",temp_type);
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]);
}
}
}
if(pp.queryarr("fh_kappa",temp)) {
for (int i=0; i<nspecies; ++i) {
for (int j=0; j<nspecies; ++j) {
Expand Down Expand Up @@ -287,15 +297,4 @@ 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]);
}
}
}
}

0 comments on commit be88b5c

Please sign in to comment.