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

Entropy #78

Merged
merged 60 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
1523889
AsterX: Add grid functions for advection of entropy density
May 23, 2024
4714f54
Merge branch 'original' into entropy
Aug 8, 2024
ae022b3
AsterX: Add entropy evolution - not tested
Aug 9, 2024
de65ffb
AsterX: Update with fix in reconstruction of B
Aug 9, 2024
ba075e9
Con2PrimFactory: Start implementing entropy inversion based on Palenz…
Aug 10, 2024
745eee5
Con2PrimFactory: Minimal change
Aug 14, 2024
85ffd8d
Con2PrimFactory: Add master function for entropy inversion
Aug 15, 2024
2a86589
Con2PrimFactory: Modify solve function
Aug 15, 2024
9d0248f
Merge branch 'original' into entropy
Aug 15, 2024
7cd86a6
Merge branch 'original' into entropy
Aug 17, 2024
446baf7
AsterX: Solve merge conflict in schedule
MChabanov Aug 19, 2024
e8028e3
Con2PrimFactory: Include entropy as prim and cons
Aug 23, 2024
16cd18c
Con2PrimFactory: First draft of entropy inversion file
Aug 24, 2024
a313b3f
EntropyInitial: Set entropy
Sep 20, 2024
9fd5e88
AsterX: Fix merge conflict
Oct 9, 2024
aed869f
Con2PrimFactory: Small change
Oct 22, 2024
143ca19
Merge remote-tracking branch 'upstream/main' into entropy
Oct 22, 2024
738eb65
Con2PrimFactory: Rearrange limiting order
Oct 24, 2024
9f2634c
Con2PrimFactory: Add check on conservatives after failure
Oct 24, 2024
fef8269
EOSX: Remove swp file
Nov 1, 2024
7630ce0
Compiling version
Nov 4, 2024
dcdf11b
Add entropy c2p to AsterX
Nov 5, 2024
5602794
Con2PrimFactory: Add entropy inversion to other c2ps
Nov 5, 2024
50b98aa
AsterX: Couple properly to entropy inversion
Nov 7, 2024
ef98499
AsterX: Minor improvement
Nov 7, 2024
c135367
Con2PrimFactory: Add copy assignment, explicit const keyword, more sm…
Nov 7, 2024
8f3978f
Con2PrimFactory: Consistent changes among all c2ps
Nov 7, 2024
52cffed
Con2PrimFactory: Changes
Nov 8, 2024
62eff54
Con2PrimFactory: Move limiters to new function
Nov 8, 2024
e5702aa
Con2PrimFactory: Clean-up
Nov 8, 2024
5ab9ddb
AsterX: Small error
Nov 8, 2024
f6f9990
AsterX: Debug parameter
Nov 8, 2024
4f90fbf
AsterX: Remove debug info for c2p inversion
Nov 8, 2024
eabfea2
AsterX: Further small changes
Nov 8, 2024
fe90514
Con2PrimFactory: Add option to avoid v>1 in ToPrim
Nov 11, 2024
c4ba0f8
AsterX and Con2PrimFactory: Resolve conflicts
Nov 11, 2024
e2010d3
AsterX: typo
Nov 11, 2024
30e903e
Merge remote-tracking branch 'upstream/main' into entropy
Nov 11, 2024
a7c9dfb
Con2PrimFactory: Minor changes and bug
Nov 13, 2024
62926db
Con2PrimFactory: Safety checks and more
Nov 18, 2024
d30ddc4
AsterX: Remove unused bool
Nov 18, 2024
9ddbd14
Con2PrimFactory: Readjust hard-coded safety limit
Nov 18, 2024
a4cb0ef
EOSX: Lower limit on density
Nov 19, 2024
8329bd2
Con2PrimFactory: Check for physicality before exiting loop
Nov 20, 2024
a8ddcd4
Con2PrimFactory: Resolve conflicts
Nov 20, 2024
ad93d01
Con2PrimFactory: Hard-coded c2p limits in Noble
Nov 21, 2024
f4d380f
AsterSeeds: Add entropy initialization to AsterSeeds
Nov 21, 2024
7f9a1e2
Con2PrimFactory: Default cons_error is not active, include entropy c2…
Nov 21, 2024
88f3886
Con2PrimFactory: NaN checks, C2P unit test
Nov 22, 2024
800bda4
Con2PrimFactory: Typo
Nov 22, 2024
5046dec
AsterX: Comments and consistent use of entropy and kappa
Nov 25, 2024
3610689
AsterX: Debug comments related to v>1
Nov 25, 2024
6995bdb
AsterX: Rewrite C2P failure code
Nov 25, 2024
cb3c9df
Con2PrimFactory: Change meaning of rho_strict temporarily
Nov 25, 2024
b6358f4
AsterX: Consistent variable naming
Nov 25, 2024
8398838
Con2PrimFactory: Make BH parameters accessible, compiling version, no…
Nov 26, 2024
fe01ad6
Con2PrimFactory: Add comment on safety against non-finite values with…
Nov 26, 2024
83084bb
AsterX: Remove rho-strict
Nov 26, 2024
1ee3a88
AsterX: Final changes, remove EntropyInitial, change C2P interface, m…
Nov 26, 2024
f01a14a
AsterSeeds: Trivial test_type option, if ID written by another thorn
Dec 2, 2024
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
7 changes: 7 additions & 0 deletions AsterSeeds/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,14 @@ REAL dipole_z[2] "z-coordinate of the dipole center" STEERABLE=ALWAYS
*:* :: "Anything"
} 0.0

# entropy

BOOLEAN set_entropy_postinitial "Set the entropy consistently in HydroBaseX_PostInitial" STEERABLE=always
{
} "yes"

SHARES: EOSX
USES KEYWORD evolution_eos
USES CCTK_REAL poly_gamma
USES CCTK_REAL poly_k
USES CCTK_REAL gl_gamma
Expand Down
11 changes: 11 additions & 0 deletions AsterSeeds/schedule.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,14 @@ if (CCTK_Equals(test_type, "3DTest")) {
}

}

#Initial conditions for entropy

schedule SetEntropy IN HydroBaseX_PostInitial
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function sets initial data for the HydroBaseX variable "entropy", I would recommend scheduling within the group " HydroBaseX_InitialData"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Collaborator Author

@MChabanov MChabanov Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had a quick look again at this point. The entropy requires valid pressures, densities etc. So, it should be executed after a thorn which is setting these quantities. That's comparable to the ID for the vector potential in the TOV or BNS case. As it stands now, I can't really schedule it in HydroBaseX_InitialData in full generality as it should always be run after something that sets rho, press, eps ... (if I don't introduce new schedule bins)

So, if there is no obvious problem with keeping it in HydroBaseX_PostInitial, we could keep it that way. Alternatively, we could do something similar as is done for the vector potential and use ODESolvers_Initial, but I am not sure if there is an advantage

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sounds good

{
LANG: C

READS: HydroBaseX::rho(everywhere) HydroBaseX::eps(everywhere)
WRITES: HydroBaseX::entropy(everywhere)

} "Set initial entropy"
40 changes: 40 additions & 0 deletions AsterSeeds/src/SetEntropy.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <loop.hxx>
#include <loop_device.hxx>

#include <cctk.h>
#include <cctk_Arguments.h>
#include <cctk_Parameters.h>

#include <cstdio>
#include <cstdbool>
#include <cmath>

#include "eos.hxx"
#include "eos_idealgas.hxx"

extern "C" void SetEntropy(CCTK_ARGUMENTS)
{

using namespace EOSX;

DECLARE_CCTK_ARGUMENTSX_SetEntropy;
DECLARE_CCTK_PARAMETERS;

if (set_entropy_postinitial) {

eos::range rgeps(eps_min, eps_max), rgrho(rho_min, rho_max),
rgye(ye_min, ye_max);

const eos_idealgas eos_th(gl_gamma, particle_mass, rgeps, rgrho, rgye);

grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {

entropy(p.I) = eos_th.kappa_from_valid_rho_eps_ye(rho(p.I),eps(p.I),1.0);

});
}
}


4 changes: 2 additions & 2 deletions AsterSeeds/src/make.code.defn
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SRCS = \
3D_tests.cxx \
atmosphere.cxx \
magTOV.cxx \
magBNS.cxx
magBNS.cxx \
SetEntropy.cxx

# Subdirectories containing source files
SUBDIRS =
4 changes: 4 additions & 0 deletions AsterX/configuration.ccl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Configuration definitions for thorn AsterX

REQUIRES Loop EOSX Con2PrimFactory ReconX AsterUtils

PROVIDES AsterX
{
}
18 changes: 17 additions & 1 deletion AsterX/interface.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ USES INCLUDE HEADER: fixmath.hxx
USES INCLUDE HEADER: loop_device.hxx
USES INCLUDE HEADER: eos_1p.hxx eos_polytropic.hxx
USES INCLUDE HEADER: eos.hxx eos_idealgas.hxx
USES INCLUDE HEADER: c2p.hxx c2p_2DNoble.hxx c2p_1DPalenzuela.hxx
USES INCLUDE HEADER: c2p.hxx c2p_2DNoble.hxx c2p_1DPalenzuela.hxx c2p_1DEntropy.hxx
USES INCLUDE HEADER: reconstruct.hxx
USES INCLUDE HEADER: aster_fd.hxx aster_interp.hxx aster_utils.hxx

Expand All @@ -23,11 +23,24 @@ CCTK_REAL mom TYPE=gf CENTERING={ccc} TAGS='rhs="momrhs" dependents="HydroBaseX:

CCTK_REAL tau TYPE=gf CENTERING={ccc} TAGS='rhs="taurhs" dependents="HydroBaseX::eps HydroBaseX::press HydroBaseX::temperature HydroBaseX::Ye HydroBaseX::Bvec TmunuBaseX::eTij"' "Conserved internal energy density"

# DEnt is the conserved "evolved" entropy.
# The corresponding primitive is stored in HydroBaseX::entropy.
# However, note that this gf stores the "evolved" entropy which is
# not necessarily the "physical" entropy. This depends on the EOS, e.g.
# for the ideal gas we have entropy = p rho^(-gamma).
# The distinction between "evolved" and "physical" entropy is made
# explicit in EOSX where functions with "entropy_..." and "kappa_..."
# refer to "physical" and "evolved" entropy, respectively. In this
# evolution thorn we always refer to DEnt and entropy to describe
# the "evolved" quantities.
CCTK_REAL DEnt TYPE=gf CENTERING={ccc} TAGS='rhs="DEntrhs" dependents="HydroBaseX::entropy AsterX::flux_x AsterX::flux_y AsterX::flux_z"' "Advected entropy density"

CCTK_REAL flux_x TYPE=gf CENTERING={vcc} TAGS='checkpoint="no"'
{
fxdens
fxmomx fxmomy fxmomz
fxtau
fxDEnt
fxBx fxBy fxBz
} "Fluxes in x direction"

Expand All @@ -36,6 +49,7 @@ CCTK_REAL flux_y TYPE=gf CENTERING={cvc} TAGS='checkpoint="no"'
fydens
fymomx fymomy fymomz
fytau
fyDEnt
fyBx fyBy fyBz
} "Fluxes in y direction"

Expand All @@ -44,6 +58,7 @@ CCTK_REAL flux_z TYPE=gf CENTERING={ccv} TAGS='checkpoint="no"'
fzdens
fzmomx fzmomy fzmomz
fztau
fzDEnt
fzBx fzBy fzBz
} "Fluxes in z direction"

Expand All @@ -56,6 +71,7 @@ CCTK_REAL momrhs TYPE=gf CENTERING={ccc} TAGS='checkpoint="no"'

CCTK_REAL taurhs TYPE=gf CENTERING={ccc} TAGS='checkpoint="no"' "Conserved internal energy density RHS"

CCTK_REAL DEntrhs TYPE=gf CENTERING={ccc} TAGS='checkpoint="no"' "Advected entropy density RHS"

CCTK_REAL Avec_x TYPE=gf CENTERING={cvv} TAGS='rhs="Avec_x_rhs"' "x-component of vector potential"
CCTK_REAL Avec_y TYPE=gf CENTERING={vcv} TAGS='rhs="Avec_y_rhs"' "y-component of vector potential"
Expand Down
1 change: 0 additions & 1 deletion AsterX/par/Scaling_magTOV_Z4c_unigrid.par
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ Con2PrimFactory::unit_test = "yes"
Con2PrimFactory::B_lim = 1e8
Con2PrimFactory::vw_lim = 1e8
Con2PrimFactory::Ye_lenient = "yes"
Con2PrimFactory::rho_strict = 6.4e-05

EOSX::evolution_eos = "IdealGas"
EOSX::gl_gamma = 2.0
Expand Down
1 change: 0 additions & 1 deletion AsterX/par/magTOV_Cowling_unigrid.par
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ Con2PrimFactory::unit_test = "yes"
Con2PrimFactory::B_lim = 1e8
Con2PrimFactory::vw_lim = 1e8
Con2PrimFactory::Ye_lenient = "yes"
Con2PrimFactory::rho_strict = 6.4e-05

EOSX::evolution_eos = "IdealGas"
EOSX::gl_gamma = 2.0
Expand Down
1 change: 0 additions & 1 deletion AsterX/par/magTOV_Z4c_AMR.par
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ Con2PrimFactory::unit_test = "yes"
Con2PrimFactory::B_lim = 1e8
Con2PrimFactory::vw_lim = 1e8
Con2PrimFactory::Ye_lenient = "yes"
Con2PrimFactory::rho_strict = 6.4e-05

EOSX::evolution_eos = "IdealGas"
EOSX::gl_gamma = 2.0
Expand Down
7 changes: 6 additions & 1 deletion AsterX/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ BOOLEAN use_uct "Shall we use the Upwind-CT method to compute the electric field
{
} "no"

BOOLEAN use_entropy_fix "Shall we use inversion based on entropy as a backup?" STEERABLE=always
{
} "no"

KEYWORD flux_type "Flux solver" STEERABLE=always
{
"LxF" :: ""
Expand Down Expand Up @@ -108,7 +112,6 @@ USES CCTK_REAL p_atmo
USES CCTK_REAL Ye_atmo
USES CCTK_REAL B_lim
USES CCTK_REAL vw_lim
USES CCTK_REAL rho_strict
USES BOOLEAN Ye_lenient
USES CCTK_INT max_iter
USES CCTK_REAL c2p_tol
Expand All @@ -120,6 +123,8 @@ USES CCTK_REAL alp_thresh
USES CCTK_REAL rho_BH
USES CCTK_REAL eps_BH
USES CCTK_REAL vwlim_BH
USES CCTK_REAL cons_error_limit
USES BOOLEAN use_z

SHARES: ReconX
USES KEYWORD reconstruction_method
Expand Down
38 changes: 21 additions & 17 deletions AsterX/schedule.ccl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Schedule definitions for thorn AsterX

STORAGE: dens mom tau dB Psi HydroBaseX::Bvec dBx_stag dBy_stag dBz_stag
STORAGE: dens mom tau DEnt dB Psi HydroBaseX::Bvec dBx_stag dBy_stag dBz_stag
STORAGE: flux_x flux_y flux_z
STORAGE: densrhs momrhs taurhs Avec_x_rhs Avec_y_rhs Avec_z_rhs Psi_rhs
STORAGE: densrhs momrhs taurhs DEntrhs Avec_x_rhs Avec_y_rhs Avec_z_rhs Psi_rhs
STORAGE: ADMBaseX::metric ADMBaseX::lapse ADMBaseX::shift ADMBaseX::curv
STORAGE: Aux_in_RHSof_A_Psi
STORAGE: TmunuBaseX::eTtt TmunuBaseX::eTti TmunuBaseX::eTij
Expand Down Expand Up @@ -69,12 +69,13 @@ SCHEDULE AsterX_Prim2Con_Initial IN AsterX_InitialGroup AFTER AsterX_ComputeBFro
LANG: C
READS: ADMBaseX::metric(interior)
READS: HydroBaseX::rho(interior) HydroBaseX::vel(interior) HydroBaseX::eps(interior) HydroBaseX::press(interior) HydroBaseX::Bvec(interior)
WRITES: dens(interior) tau(interior) mom(interior) dB(interior)
READS: HydroBaseX::entropy(interior)
WRITES: dens(interior) tau(interior) DEnt(interior) mom(interior) dB(interior)
WRITES: Psi(everywhere)
WRITES: saved_prims
WRITES: zvec
WRITES: svec
SYNC: dens tau mom dB
SYNC: dens tau DEnt mom dB
SYNC: saved_prims
SYNC: zvec
SYNC: svec
Expand All @@ -86,15 +87,15 @@ SCHEDULE AsterX_Sync AT postregrid
{
LANG: C
OPTIONS: global
SYNC: dens tau mom Avec_x Avec_y Avec_z Psi
SYNC: dens tau mom DEnt Avec_x Avec_y Avec_z Psi
SYNC: saved_prims
} "Synchronize"

SCHEDULE AsterX_Sync IN ODESolvers_PostStep
{
LANG: C
OPTIONS: global
SYNC: dens tau mom Avec_x Avec_y Avec_z Psi
SYNC: dens tau mom DEnt Avec_x Avec_y Avec_z Psi
} "Synchronize"


Expand Down Expand Up @@ -124,21 +125,23 @@ SCHEDULE AsterX_Con2Prim IN AsterX_Con2PrimGroup AFTER AsterX_ComputedBFromdBsta
LANG: C
READS: ADMBaseX::metric(interior)
READS: ADMBaseX::lapse(everywhere)
READS: dens(interior) tau(interior) mom(interior) dB(interior)
READS: dens(interior) tau(interior) DEnt(interior) mom(interior) dB(interior)
READS: saved_prims(interior)
READS: Avec_x(interior) Avec_y(interior) Avec_z(interior)
WRITES: con2prim_flag(interior)
WRITES: HydroBaseX::rho(interior) HydroBaseX::vel(interior) HydroBaseX::eps(interior) HydroBaseX::press(interior) HydroBaseX::Bvec(interior)
WRITES: HydroBaseX::rho(interior) HydroBaseX::vel(interior) HydroBaseX::eps(interior) HydroBaseX::press(interior) HydroBaseX::Bvec(interior)
WRITES: HydroBaseX::entropy(interior)
WRITES: saved_prims(interior)
WRITES: zvec(interior)
WRITES: svec(interior)
WRITES: dens(interior) tau(interior) mom(interior) dB(interior)
WRITES: dens(interior) tau(interior) DEnt(interior) mom(interior) dB(interior)
SYNC: con2prim_flag
SYNC: HydroBaseX::rho HydroBaseX::vel HydroBaseX::eps HydroBaseX::press HydroBaseX::Bvec
SYNC: HydroBaseX::rho HydroBaseX::vel HydroBaseX::eps HydroBaseX::press HydroBaseX::Bvec
SYNC: HydroBaseX::entropy
SYNC: saved_prims
SYNC: zvec
SYNC: svec
SYNC: dens tau mom dB
SYNC: dens tau DEnt mom dB
} "Calculate primitive variables from conservative variables"


Expand All @@ -153,9 +156,10 @@ SCHEDULE AsterX_Fluxes IN AsterX_RHSGroup
READS: ADMBaseX::metric(everywhere)
READS: ADMBaseX::lapse(everywhere)
READS: ADMBaseX::shift(everywhere)
READS: dens(everywhere) tau(everywhere) mom(everywhere)
READS: dens(everywhere) tau(everywhere) mom(everywhere) DEnt(everywhere)
READS: HydroBaseX::rho(everywhere) HydroBaseX::vel(everywhere) HydroBaseX::press(everywhere) HydroBaseX::eps(everywhere)
READS: HydroBaseX::Bvec(everywhere)
READS: HydroBaseX::entropy(everywhere)
READS: dBx_stag(everywhere) dBy_stag(everywhere) dBz_stag(everywhere)
READS: zvec_x(everywhere) zvec_y(everywhere) zvec_z(everywhere)
READS: svec_x(everywhere) svec_y(everywhere) svec_z(everywhere)
Expand All @@ -181,8 +185,8 @@ SCHEDULE AsterX_SourceTerms IN AsterX_RHSGroup AFTER AsterX_Fluxes
READS: zvec_x(everywhere), zvec_y(everywhere), zvec_z(everywhere)
READS: svec_x(everywhere), svec_y(everywhere), svec_z(everywhere)
READS: HydroBaseX::Bvec(everywhere)
WRITES: densrhs(interior) taurhs(interior) momrhs(interior)
SYNC: densrhs taurhs momrhs
WRITES: densrhs(interior) taurhs(interior) momrhs(interior) DEntrhs(interior)
SYNC: densrhs taurhs momrhs DEntrhs
} "Calculate the source terms and compute the RHS of the hydro equations"

SCHEDULE AsterX_RHS IN AsterX_RHSGroup AFTER AsterX_SourceTerms
Expand All @@ -191,15 +195,15 @@ SCHEDULE AsterX_RHS IN AsterX_RHSGroup AFTER AsterX_SourceTerms
READS: ADMBaseX::metric(everywhere) ADMBaseX::lapse(everywhere) ADMBaseX::shift(everywhere)
READS: HydroBaseX::vel(everywhere) HydroBaseX::press(everywhere)
READS: flux_x(everywhere) flux_y(everywhere) flux_z(everywhere)
READS: densrhs(everywhere) taurhs(everywhere) momrhs(everywhere)
READS: densrhs(everywhere) taurhs(everywhere) momrhs(everywhere) DEntrhs(everywhere)
READS: Psi(everywhere)
READS: Aux_in_RHSof_A_Psi(everywhere)
READS: dBx_stag(everywhere) dBy_stag(everywhere) dBz_stag(everywhere)
READS: vtilde_xface(everywhere) vtilde_yface(everywhere) vtilde_zface(everywhere)
READS: a_xface(everywhere) a_yface(everywhere) a_zface(everywhere)
WRITES: densrhs(interior) taurhs(interior) momrhs(interior)
WRITES: densrhs(interior) taurhs(interior) momrhs(interior) DEntrhs(interior)
WRITES: Avec_x_rhs(interior) Avec_y_rhs(interior) Avec_z_rhs(interior) Psi_rhs(interior)
SYNC: densrhs taurhs momrhs
SYNC: densrhs taurhs momrhs DEntrhs
SYNC: Avec_x_rhs Avec_y_rhs Avec_z_rhs Psi_rhs
} "Update the RHS of the hydro equations with the flux contributions"

Expand Down
Loading