Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constants for the allowed values of SCREEN_METHOD #1401

Merged
merged 1 commit into from
Nov 29, 2023
Merged
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
12 changes: 6 additions & 6 deletions Make.Microphysics_extern
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ endif

SCREEN_METHOD ?= screen5
ifeq ($(SCREEN_METHOD), null)
DEFINES += -DSCREEN_METHOD=0
DEFINES += -DSCREEN_METHOD=SCREEN_METHOD_null
else ifeq ($(SCREEN_METHOD), screen5)
DEFINES += -DSCREEN_METHOD=1
DEFINES += -DSCREEN_METHOD=SCREEN_METHOD_screen5
else ifeq ($(SCREEN_METHOD), chugunov2007)
DEFINES += -DSCREEN_METHOD=2
DEFINES += -DSCREEN_METHOD=SCREEN_METHOD_chugunov2007
else ifeq ($(SCREEN_METHOD), chugunov2009)
DEFINES += -DSCREEN_METHOD=3
DEFINES += -DSCREEN_METHOD=SCREEN_METHOD_chugunov2009
else ifeq ($(SCREEN_METHOD), chabrier1998)
DEFINES += -DSCREEN_METHOD=4
DEFINES += -DSCREEN_METHOD=SCREEN_METHOD_chabrier1998
else
$(error Invalid value for SCREEN_METHOD)
endif
Expand Down Expand Up @@ -155,4 +155,4 @@ endif
clean::
@if [ -L helm_table.dat ]; then rm -f helm_table.dat; fi
@if [ -L reaclib_rate_metadata.dat ]; then rm -f reaclib_rate_metadata.dat; fi
$(foreach t, $(wildcard *_betadecay.dat *_electroncapture.dat nse*.tbl), $(shell if [ -L $t ]; then rm -f $t; fi))
$(foreach t, $(wildcard *_betadecay.dat *_electroncapture.dat nse*.tbl), $(shell if [ -L $t ]; then rm -f $t; fi))
4 changes: 2 additions & 2 deletions nse_solver/nse_solver.H
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void apply_nse_exponent(T& nse_state) {
// if we use chabrier1998 screening
// Get the required terms to calculate coulomb correction term, u_c

#if SCREEN_METHOD == 4
#if SCREEN_METHOD == SCREEN_METHOD_chabrier1998

// Find n_e for original state;
const amrex::Real n_e = nse_state.rho * nse_state.y_e / C::m_u;
Expand All @@ -113,7 +113,7 @@ void apply_nse_exponent(T& nse_state) {
// term for calculating u_c

// if use chabrier1998 screening, calculate the coulomb correction term
#if SCREEN_METHOD == 4
#if SCREEN_METHOD == SCREEN_METHOD_chabrier1998
gamma = std::pow(zion[n], 5.0_rt/3.0_rt) * Gamma_e;

// chemical potential for coulomb correction
Expand Down
35 changes: 21 additions & 14 deletions screening/screen.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#ifndef SCREEN_H
#define SCREEN_H

// these need to be defined before screen_data.H is included
#define SCREEN_METHOD_null 0
#define SCREEN_METHOD_screen5 1
#define SCREEN_METHOD_chugunov2007 2
#define SCREEN_METHOD_chugunov2009 3
#define SCREEN_METHOD_chabrier1998 4

#include <AMReX.H>
#include <AMReX_Algorithm.H>
#include <AMReX_Array.H>
Expand All @@ -16,15 +23,15 @@
using namespace amrex;
using namespace integrator_rp;

#if SCREEN_METHOD == 0
#if SCREEN_METHOD == SCREEN_METHOD_null
const std::string screen_name = "null";
#elif SCREEN_METHOD == 1
#elif SCREEN_METHOD == SCREEN_METHOD_screen5
const std::string screen_name = "screen5";
#elif SCREEN_METHOD == 2
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2007
const std::string screen_name = "chugunov2007";
#elif SCREEN_METHOD == 3
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2009
const std::string screen_name = "chugunov2009";
#elif SCREEN_METHOD == 4
#elif SCREEN_METHOD == SCREEN_METHOD_chabrier1998
const std::string screen_name = "chabrier1998";
#endif

Expand Down Expand Up @@ -169,7 +176,7 @@ fill_plasma_state(plasma_state_t& state, const Real temp, const Real dens, Array
}
}

#if SCREEN_METHOD == 1
#if SCREEN_METHOD == SCREEN_METHOD_screen5
template <int do_T_derivatives>
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void actual_screen5 (const plasma_state_t& state,
Expand Down Expand Up @@ -417,7 +424,7 @@ void actual_screen5 (const plasma_state_t& state,
}
}

#elif SCREEN_METHOD == 2
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2007
template <int do_T_derivatives>
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void chugunov2007 (const plasma_state_t& state,
Expand Down Expand Up @@ -613,7 +620,7 @@ void chugunov2007 (const plasma_state_t& state,
}
}

#elif SCREEN_METHOD == 3
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2009
template <int do_T_derivatives>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void chugunov2009_f0 (const Real gamma, const Real dlog_dT, Real& f, Real& df_dT)
Expand Down Expand Up @@ -783,7 +790,7 @@ void chugunov2009 (const plasma_state_t& state,
}
}

#elif SCREEN_METHOD == 4
#elif SCREEN_METHOD == SCREEN_METHOD_chabrier1998
template <int do_T_derivatives>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void chabrier1998_helmholtz_F(const Real gamma, const Real dgamma_dT, Real& f, Real& df_dT) {
Expand Down Expand Up @@ -945,18 +952,18 @@ void actual_screen(const plasma_state_t& state,
const scrn::screen_factors_t& scn_fac,
Real& scor, Real& scordt)
{
#if SCREEN_METHOD == 0
#if SCREEN_METHOD == SCREEN_METHOD_null
// null screening
amrex::ignore_unused(state, scn_fac);
scor = 1.0_rt;
scordt = 0.0_rt;
#elif SCREEN_METHOD == 1
#elif SCREEN_METHOD == SCREEN_METHOD_screen5
actual_screen5<do_T_derivatives>(state, scn_fac, scor, scordt);
#elif SCREEN_METHOD == 2
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2007
chugunov2007<do_T_derivatives>(state, scn_fac, scor, scordt);
#elif SCREEN_METHOD == 3
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2009
chugunov2009<do_T_derivatives>(state, scn_fac, scor, scordt);
#elif SCREEN_METHOD == 4
#elif SCREEN_METHOD == SCREEN_METHOD_chabrier1998
chabrier1998<do_T_derivatives>(state, scn_fac, scor, scordt);
#endif
}
Expand Down
16 changes: 8 additions & 8 deletions screening/screen_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace scrn {
// ztilde = effective ion radius factor for a MCP
// ztilde3 = ztilde**3

#if SCREEN_METHOD == 1
#if SCREEN_METHOD == SCREEN_METHOD_screen5
amrex::Real zs53 = 0.0;
amrex::Real z1_53 = 0.0;
amrex::Real z2_53 = 0.0;
Expand All @@ -41,10 +41,10 @@ namespace scrn {
amrex::Real zhat2 = 0.0;
amrex::Real lzav = 0.0;
amrex::Real aznut = 0.0;
#elif SCREEN_METHOD == 2
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2007
amrex::Real ztilde = 0.0;
amrex::Real ztilde3 = 0.0;
#elif SCREEN_METHOD == 3
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2009
amrex::Real zs52 = 0.0;
amrex::Real z1_52 = 0.0;
amrex::Real z2_52 = 0.0;
Expand All @@ -53,7 +53,7 @@ namespace scrn {
amrex::Real z2_53 = 0.0;
amrex::Real aznut = 0.0;
amrex::Real ztilde = 0.0;
#elif SCREEN_METHOD == 4
#elif SCREEN_METHOD == SCREEN_METHOD_chabrier1998
amrex::Real zs53 = 0.0;
amrex::Real z1_53 = 0.0;
amrex::Real z2_53 = 0.0;
Expand Down Expand Up @@ -87,7 +87,7 @@ namespace scrn {
scn_fac.z2 = z2;
scn_fac.a2 = a2;

#if SCREEN_METHOD == 1
#if SCREEN_METHOD == SCREEN_METHOD_screen5
scn_fac.zs53 = gcem::pow(z1 + z2, 5.0_rt / 3.0_rt);
scn_fac.z1_53 = gcem::pow(z1, 5.0_rt / 3.0_rt);
scn_fac.z2_53 = gcem::pow(z2, 5.0_rt / 3.0_rt);
Expand All @@ -101,12 +101,12 @@ namespace scrn {
scn_fac.aznut = gcem::pow(z1 * z1 * z2 * z2 * a1 * a2 / (a1 + a2),
1.0_rt / 3.0_rt);

#elif SCREEN_METHOD == 2
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2007
scn_fac.ztilde = 0.5_rt * (gcem::pow(z1, 1.0_rt / 3.0_rt) +
gcem::pow(z2, 1.0_rt / 3.0_rt));
scn_fac.ztilde3 = gcem::pow(scn_fac.ztilde, 3);

#elif SCREEN_METHOD == 3
#elif SCREEN_METHOD == SCREEN_METHOD_chugunov2009
scn_fac.zs52 = gcem::pow(z1 + z2, 5.0_rt / 2.0_rt);
scn_fac.z1_52 = gcem::pow(z1, 5.0_rt / 2.0_rt);
scn_fac.z2_52 = gcem::pow(z2, 5.0_rt / 2.0_rt);
Expand All @@ -118,7 +118,7 @@ namespace scrn {
scn_fac.ztilde = 0.5_rt * (gcem::pow(z1, 1.0_rt / 3.0_rt) +
gcem::pow(z2, 1.0_rt / 3.0_rt));

#elif SCREEN_METHOD == 4
#elif SCREEN_METHOD == SCREEN_METHOD_chabrier1998
scn_fac.zs53 = gcem::pow(z1 + z2, 5.0_rt / 3.0_rt);
scn_fac.z1_53 = gcem::pow(z1, 5.0_rt/3.0_rt);
scn_fac.z2_53 = gcem::pow(z2, 5.0_rt/3.0_rt);
Expand Down