From 9bb2328d9deb41ee5d5dcae7662835199905bcfa Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Thu, 7 Dec 2023 12:16:48 -0500 Subject: [PATCH 1/2] fixed dual-energy formalism synchronization. --- src/hydro/hydro_cuda.cu | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hydro/hydro_cuda.cu b/src/hydro/hydro_cuda.cu index c74654c0e..fa060e811 100644 --- a/src/hydro/hydro_cuda.cu +++ b/src/hydro/hydro_cuda.cu @@ -839,6 +839,7 @@ __global__ void Select_Internal_Energy_1D(Real *dev_conserved, int nx, int n_gho int imo, ipo; n_cells = nx; + Real eta_1 = DE_ETA_1; Real eta_2 = DE_ETA_2; // get a global thread ID @@ -864,7 +865,10 @@ __global__ void Select_Internal_Energy_1D(Real *dev_conserved, int nx, int n_gho Emax = fmax(dev_conserved[4 * n_cells + imo], E); Emax = fmax(Emax, dev_conserved[4 * n_cells + ipo]); - if (U_total / Emax > eta_2) { + // We only use the "advected" internal energy if both: + // - the thermal energy divided by total energy is a small fraction (smaller than eta_1) + // - AND we aren't masking shock heating (details controlled by Emax & eta_2) + if ((U_total / E > eta_1) or (U_total / Emax > eta_2)) { U = U_total; } else { U = U_advected; @@ -887,6 +891,7 @@ __global__ void Select_Internal_Energy_2D(Real *dev_conserved, int nx, int ny, i int imo, ipo, jmo, jpo; n_cells = nx * ny; + Real eta_1 = DE_ETA_1; Real eta_2 = DE_ETA_2; // get a global thread ID @@ -922,7 +927,10 @@ __global__ void Select_Internal_Energy_2D(Real *dev_conserved, int nx, int ny, i Emax = fmax(Emax, dev_conserved[4 * n_cells + jmo]); Emax = fmax(Emax, dev_conserved[4 * n_cells + jpo]); - if (U_total / Emax > eta_2) { + // We only use the "advected" internal energy if both: + // - the thermal energy divided by total energy is a small fraction (smaller than eta_1) + // - AND we aren't masking shock heating (details controlled by Emax & eta_2) + if ((U_total / E > eta_1) or (U_total / Emax > eta_2)) { U = U_total; } else { U = U_advected; @@ -945,6 +953,7 @@ __global__ void Select_Internal_Energy_3D(Real *dev_conserved, int nx, int ny, i int imo, ipo, jmo, jpo, kmo, kpo; n_cells = nx * ny * nz; + Real eta_1 = DE_ETA_1; Real eta_2 = DE_ETA_2; // get a global thread ID @@ -987,7 +996,10 @@ __global__ void Select_Internal_Energy_3D(Real *dev_conserved, int nx, int ny, i Emax = fmax(Emax, dev_conserved[4 * n_cells + kmo]); Emax = fmax(Emax, dev_conserved[4 * n_cells + kpo]); - if (U_total / Emax > eta_2) { + // We only use the "advected" internal energy if both: + // - the thermal energy divided by total energy is a small fraction (smaller than eta_1) + // - AND we aren't masking shock heating (details controlled by Emax & eta_2) + if ((U_total / E > eta_1) or (U_total / Emax > eta_2)) { U = U_total; } else { U = U_advected; From fc8f8d7c5c031fc452884f9fc2d1ba8a48a776c3 Mon Sep 17 00:00:00 2001 From: Matthew Abruzzo Date: Wed, 20 Dec 2023 14:45:16 -0500 Subject: [PATCH 2/2] revert de formalism behavior in cosmological simulations until future tests are performed. --- src/global/global.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/global/global.h b/src/global/global.h index 8abe358fc..8634ae3f2 100644 --- a/src/global/global.h +++ b/src/global/global.h @@ -53,10 +53,25 @@ typedef double Real; #define TEMP_FLOOR 1e-3 #define DENS_FLOOR 1e-5 // in code units -// Parameter for Enzo dual Energy Condition -#define DE_ETA_1 \ - 0.001 // Ratio of U to E for which Internal Energy is used to compute the - // Pressure +// Parameters for Enzo dual Energy Condition +// - Prior to GH PR #356, DE_ETA_1 nominally had a value of 0.001 in all +// simulations (in practice, the value of DE_ETA_1 had minimal significance +// in those simulations). In PR #356, we revised the internal-energy +// synchronization to account for the value of DE_ETA_1. This was necessary +// for non-cosmology simulations. +// - In Cosmological simulation, we set DE_ETA_1 to a large number (it doesn't +// really matter what, as long as its >=1) to maintain the older behavior +// - In the future, we run tests and revisit the choice of DE_ETA_1 in +// cosmological simulations +#ifdef COSMOLOGY + #define DE_ETA_1 10.0 +#else + #define DE_ETA_1 \ + 0.001 // Ratio of U to E for which Internal Energy is used to compute the + // Pressure. This also affects when the Internal Energy is used for + // the update. +#endif + #define DE_ETA_2 \ 0.035 // Ratio of U to max(E_local) used to select which Internal Energy is // used for the update.