Skip to content

Commit

Permalink
Con2PrimFactory: Make BH parameters accessible, compiling version, no…
Browse files Browse the repository at this point in the history
…t tested
  • Loading branch information
Michail Chabanov committed Nov 26, 2024
1 parent b6358f4 commit 8398838
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 28 deletions.
13 changes: 8 additions & 5 deletions AsterX/src/con2prim.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void AsterX_Con2Prim_typeEoS(CCTK_ARGUMENTS, EOSIDType &eos_cold,
const PointDesc
&p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
// Note that HydroBaseX gfs are NaN when entering this loop due
// explicit dependence on conservatives from AsterX ->
// dependents tag
// explicit dependence on conservatives from
// AsterX -> dependents tag

// Setting up atmosphere
CCTK_REAL rho_atm = 0.0; // dummy initialization
Expand Down Expand Up @@ -93,15 +93,18 @@ void AsterX_Con2Prim_typeEoS(CCTK_ARGUMENTS, EOSIDType &eos_cold,

// Construct Noble c2p object:
c2p_2DNoble c2p_Noble(eos_th, atmo, max_iter, c2p_tol, rho_strict, vw_lim,
B_lim, Ye_lenient, cons_error_limit, use_z);
B_lim, Ye_lenient, cons_error_limit, use_z,
alp_thresh, rho_BH, eps_BH, vwlim_BH);

// Construct Palenzuela c2p object:
c2p_1DPalenzuela c2p_Pal(eos_th, atmo, max_iter, c2p_tol, rho_strict,
vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z);
vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z,
alp_thresh, rho_BH, eps_BH, vwlim_BH);

// Construct Entropy c2p object:
c2p_1DEntropy c2p_Ent(eos_th, atmo, max_iter, c2p_tol, rho_strict,
vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z);
vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z,
alp_thresh, rho_BH, eps_BH, vwlim_BH);

/* Get covariant metric */
const smat<CCTK_REAL, 3> glo(
Expand Down
13 changes: 10 additions & 3 deletions Con2PrimFactory/src/c2p.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ protected:
atmosphere atmo;
CCTK_REAL cons_error;
bool use_zprim;
// Parameters for BH interiors
CCTK_REAL alp_thresh;
CCTK_REAL rho_BH;
CCTK_REAL eps_BH;
CCTK_REAL vwlim_BH;

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
get_Ssq_Exact(const vec<CCTK_REAL, 3> &mom,
Expand All @@ -66,6 +71,8 @@ protected:
prims_floors_and_ceilings(const EOSType &eos_th, prim_vars &pv, const cons_vars &cv,
const smat<CCTK_REAL, 3> &glo, c2p_report &rep) const;

public:

template <typename EOSType>
CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline void
bh_interior_fail(const EOSType &eos_th, prim_vars &pv, cons_vars &cv,
Expand Down Expand Up @@ -179,11 +186,11 @@ c2p::bh_interior_fail(const EOSType &eos_th, prim_vars &pv, cons_vars &cv,
pv.rho = rho_BH; // typically set to 0.01% to 1% of rho_max of initial
// NS or disk
pv.eps = eps_BH;
pv.Ye = Ye_atmo;
pv.Ye = 0.5;
pv.press =
eos_th.press_from_valid_rho_eps_ye(rho_BH, eps_BH, Ye_atmo);
eos_th.press_from_valid_rho_eps_ye(rho_BH, eps_BH, 0.5);
pv.entropy =
eos_th.kappa_from_valid_rho_eps_ye(rho_BH, eps_BH, Ye_atmo);
eos_th.kappa_from_valid_rho_eps_ye(rho_BH, eps_BH, 0.5);
// check on velocities
CCTK_REAL wlim_BH = sqrt(1.0 + vwlim_BH * vwlim_BH);
CCTK_REAL vlim_BH = vwlim_BH / wlim_BH;
Expand Down
17 changes: 12 additions & 5 deletions Con2PrimFactory/src/c2p_1DEntropy.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public:
CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_1DEntropy(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z);
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in);

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
get_Ssq_Exact(const vec<CCTK_REAL, 3> &mom, const smat<CCTK_REAL, 3> &gup) const;
Expand Down Expand Up @@ -57,10 +57,10 @@ CCTK_HOST CCTK_DEVICE
CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_1DEntropy::c2p_1DEntropy(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z) {
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in) {

GammaIdealFluid = eos_th.gamma;
// Base
maxIterations = maxIter;
tolerance = tol;
rho_strict = rho_str;
Expand All @@ -72,6 +72,13 @@ CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_1DEntropy::c2p_1DEntropy(
atmo = atm;
cons_error = consError;
use_zprim = use_z;
alp_thresh = alp_thresh_in;
rho_BH = rho_BH_in;
eps_BH = eps_BH_in;
vwlim_BH = vwlim_BH_in;

// Derived
GammaIdealFluid = eos_th.gamma;
}

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
Expand Down
17 changes: 12 additions & 5 deletions Con2PrimFactory/src/c2p_1DPalenzuela.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public:
CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_1DPalenzuela(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z);
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in);

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
get_Ssq_Exact(const vec<CCTK_REAL, 3> &mom,
Expand Down Expand Up @@ -61,10 +61,10 @@ CCTK_HOST CCTK_DEVICE
CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_1DPalenzuela::c2p_1DPalenzuela(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z) {
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in) {

GammaIdealFluid = eos_th.gamma;
// Base
maxIterations = maxIter;
tolerance = tol;
rho_strict = rho_str;
Expand All @@ -76,6 +76,13 @@ CCTK_HOST CCTK_DEVICE
atmo = atm;
cons_error = consError;
use_zprim = use_z;
alp_thresh = alp_thresh_in;
rho_BH = rho_BH_in;
eps_BH = eps_BH_in;
vwlim_BH = vwlim_BH_in;

// Derived
GammaIdealFluid = eos_th.gamma;
}

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
Expand Down
17 changes: 12 additions & 5 deletions Con2PrimFactory/src/c2p_2DNoble.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public:
CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_2DNoble(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z);
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in);

CCTK_HOST CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline CCTK_REAL
get_Ssq_Exact(const vec<CCTK_REAL, 3> &mom,
Expand Down Expand Up @@ -73,10 +73,10 @@ CCTK_HOST
CCTK_DEVICE CCTK_ATTRIBUTE_ALWAYS_INLINE inline c2p_2DNoble::c2p_2DNoble(
const EOSType &eos_th, const atmosphere &atm, CCTK_INT maxIter, CCTK_REAL tol,
CCTK_REAL rho_str, CCTK_REAL vwlim, CCTK_REAL B_lim, bool ye_len,
CCTK_REAL consError,
bool use_z) {
CCTK_REAL consError, bool use_z, CCTK_REAL alp_thresh_in,
CCTK_REAL rho_BH_in, CCTK_REAL eps_BH_in, CCTK_REAL vwlim_BH_in) {

GammaIdealFluid = eos_th.gamma;
// Base
maxIterations = maxIter;
tolerance = tol;
rho_strict = rho_str;
Expand All @@ -88,6 +88,13 @@ CCTK_HOST
atmo = atm;
cons_error = consError;
use_zprim = use_z;
alp_thresh = alp_thresh_in;
rho_BH = rho_BH_in;
eps_BH = eps_BH_in;
vwlim_BH = vwlim_BH_in;

// Derived
GammaIdealFluid = eos_th.gamma;
Zmin = eos_th.rgrho.min;
}

Expand Down
17 changes: 12 additions & 5 deletions Con2PrimFactory/src/test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ extern "C" void Con2PrimFactory_Test(CCTK_ARGUMENTS) {
const smat<CCTK_REAL, 3> g{1.0, 0.0, 0.0,
1.0, 0.0, 1.0}; // xx, xy, xz, yy, yz, zz

// Set BH limiters
const CCTK_REAL alp_thresh = -1.;
const CCTK_REAL rho_BH = 1e20;
const CCTK_REAL eps_BH = 1e20;
const CCTK_REAL vwlim_BH = 1e20;

// Con2Prim objects
// (eos_th, atmo, max_iter, c2p_tol, rho_strict,
// vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z)
c2p_2DNoble c2p_Noble(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false);
c2p_1DPalenzuela c2p_Pal(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false);
c2p_1DEntropy c2p_Ent(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false);
// vw_lim, B_lim, Ye_lenient, cons_error_limit, use_z, alp_thresh,
// rho_BH, eps_BH, vwlim_BH)
c2p_2DNoble c2p_Noble(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false, alp_thresh, rho_BH, eps_BH, vwlim_BH);
c2p_1DPalenzuela c2p_Pal(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false, alp_thresh, rho_BH, eps_BH, vwlim_BH);
c2p_1DEntropy c2p_Ent(eos_th, atmo, 100, 1e-8, 1e8, 1, 1, true,-1.,false, alp_thresh, rho_BH, eps_BH, vwlim_BH);

// Construct error report object:
c2p_report rep_Noble;
Expand All @@ -69,7 +76,7 @@ extern "C" void Con2PrimFactory_Test(CCTK_ARGUMENTS) {
prim_vars pv_seeds{rho_in, eps_in, Ye_in, press_in, entropy_in, vup_in, wlor_in, Bup_in};

// cons_vars cv{dens(p.I), {momx(p.I), momy(p.I), momz(p.I)}, tau(p.I),
// dummy_dYe, {dBx(p.I), dBy(p.I), dBz(p.I)}};
// dummy_dYe, DEnt, {dBx(p.I), dBy(p.I), dBz(p.I)}};

cons_vars cv_Noble;
cons_vars cv_Pal;
Expand Down

0 comments on commit 8398838

Please sign in to comment.