From 16d8018be285ae5ef182d8feab0dec0183a2db94 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Mon, 19 Aug 2024 16:01:39 -0700 Subject: [PATCH] address a long-standing issue where sometimes its preferable to specify the avogadro number instead of Runiv. If avogadro is supplied, then Runiv is set to avogadro * k_b Default behavior is preserved as all codes presently set Runiv The code will abort if you try to specify both. --- exec/chemistry_testing/main.cpp | 10 +++++----- src_chemistry/chemistry_functions.cpp | 6 +++--- src_common/common_functions.cpp | 8 ++++++++ src_common/common_namespace.H | 1 + src_compressible/compressible_functions.cpp | 4 ++-- src_compressible/main_driver.cpp | 2 +- src_compressible_stag/reservoirStag.cpp | 4 +--- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/exec/chemistry_testing/main.cpp b/exec/chemistry_testing/main.cpp index 2577074eb..a17d4f476 100644 --- a/exec/chemistry_testing/main.cpp +++ b/exec/chemistry_testing/main.cpp @@ -201,14 +201,14 @@ void main_main(const char* argv) for (int n=0; n n_old; GpuArray n_new; - for (int n=0; n ck; // molar concentrations for (int n=0; n m_s; - for (int n=0; n m_s; - for (int n=0; n common::T_init; AMREX_GPU_MANAGED int common::algorithm_type; int common::barodiffusion_type; @@ -764,6 +765,13 @@ void InitializeCommonNamespace() { pp.query("k_B",k_B); pp.query("h_bar",h_bar); pp.query("Runiv",Runiv); + avogadro = Runiv / k_B; + if (pp.query("avogadro",avogadro) ) { + Runiv = k_B * avogadro; + } + if (pp.query("Runiv",Runiv) && pp.query("avogadro",avogadro)) { + Abort("Cannot specify both Runiv and avogadro"); + } if (pp.queryarr("T_init",temp)) { for (int i=0; i T_init; // Algorithm control / selection diff --git a/src_compressible/compressible_functions.cpp b/src_compressible/compressible_functions.cpp index 8ab3611a7..96bb6f502 100644 --- a/src_compressible/compressible_functions.cpp +++ b/src_compressible/compressible_functions.cpp @@ -229,13 +229,13 @@ void InitConsVar(MultiFab& cons, Real pscale = 884.147e3; // rho0 = m * p / (k_B * T) - Real rhoscale = molmass[0] / (Runiv / k_B) * pscale / (k_B * T_init[0]); + Real rhoscale = molmass[0] / avogadro * pscale / (k_B * T_init[0]); // compute pressure (needed to compute density) Real pres = pscale+rhoscale*velscale*velscale*cos(2.*pi*x/Lf)*cos(4.*pi*y/Lf)*(cos(4.*pi*z/Lf)+2.); // density - cu(i,j,k,0) = (molmass[0] / (Runiv / k_B)) * pres / (k_B * T_init[0]); + cu(i,j,k,0) = (molmass[0] / avogadro) * pres / (k_B * T_init[0]); // momentum cu(i,j,k,1) = velscale*cu(i,j,k,0)*sin(2.*pi*x/Lf)*cos(2.*pi*y/Lf)*cos(2.*pi*z/Lf); diff --git a/src_compressible/main_driver.cpp b/src_compressible/main_driver.cpp index f682dc08b..504ae956a 100644 --- a/src_compressible/main_driver.cpp +++ b/src_compressible/main_driver.cpp @@ -337,7 +337,7 @@ void main_driver(const char* argv) p0 = 884.147e3; dProb = (AMREX_SPACEDIM==2) ? 1./(n_cells[0]*n_cells[1]) : 1./(n_cells[0]*n_cells[1]*n_cells[2]); - rho0 = molmass[0] / (Runiv / k_B) * p0 / (k_B * T_init[0]); + rho0 = molmass[0] / avogadro * p0 / (k_B * T_init[0]); nu0 = 0.185; } diff --git a/src_compressible_stag/reservoirStag.cpp b/src_compressible_stag/reservoirStag.cpp index b59bf5627..54a0807c4 100644 --- a/src_compressible_stag/reservoirStag.cpp +++ b/src_compressible_stag/reservoirStag.cpp @@ -21,11 +21,9 @@ ComputeFluxMomReservoir(const MultiFab& cons0_in, const MultiFab& prim0_in, const GpuArray dx = geom.CellSizeArray(); Box dom(geom.Domain()); - Real N_A = Runiv/k_B; // Avagadro's number - GpuArray mass; for (int l=0;l