This module is currently under development
IllinoisGRMHD
so that it can be properly used by the Einstein Toolkit¶This module is organized as follows
We will now use the cmdline_helper.py NRPy+ module to create the source directory within the IllinoisGRMHD
NRPy+ directory, if it does not exist yet.
# Step 0: Creation of the IllinoisGRMHD source directory
# Step 0a: Add NRPy's directory to the path
# https://stackoverflow.com/questions/16780014/import-file-from-parent-directory
import os,sys
nrpy_dir_path = os.path.join("..","..")
if nrpy_dir_path not in sys.path:
sys.path.append(nrpy_dir_path)
# Step 0b: Load up cmdline_helper and create the directory
import cmdline_helper as cmd
IGM_src_dir_path = os.path.join("..","src")
cmd.mkdir(IGM_src_dir_path)
# Step 0c: For this tutorial module we will also need IllinoisGRMHD's main directory path
IGM_main_dir_path = ".."
# Step 0d: Create the output file path
outfile_path__make_code_defn = os.path.join(IGM_src_dir_path, "make.code.defn")
outfile_path__configuration__ccl = os.path.join(IGM_main_dir_path,"configuration.ccl")
outfile_path__interface__ccl = os.path.join(IGM_main_dir_path,"interface.ccl")
outfile_path__param__ccl = os.path.join(IGM_main_dir_path,"param.ccl")
outfile_path__schedule__ccl = os.path.join(IGM_main_dir_path,"schedule.ccl")
outfile_path__code_validation__txt = "code_validation.txt"
%%writefile $outfile_path__make_code_defn
# Main make.code.defn file for thorn IllinoisGRMHD
# Source files in this directory
SRCS = InitSymBound.C MoL_registration.C \
\
postpostinitial__set_symmetries__copy_timelevels.C \
\
convert_ADM_to_BSSN__enforce_detgtij_eq_1__and_compute_gtupij.C \
\
driver_evaluate_MHD_rhs.C \
compute_B_and_Bstagger_from_A.C \
driver_conserv_to_prims.C \
symmetry__set_gzs_staggered_gfs.C \
\
outer_boundaries.C
Writing ../src/make.code.defn
%%writefile $outfile_path__configuration__ccl
# Configuration definition for thorn IllinoisGRMHD
REQUIRES EOS_Omni Boundary CartGrid3D SpaceMask
PROVIDES IllinoisGRMHD
{
}
Writing ../configuration.ccl
%%writefile $outfile_path__interface__ccl
# Interface definition for thorn IllinoisGRMHD
implements: IllinoisGRMHD
inherits: ADMBase, Boundary, SpaceMask, Tmunubase, HydroBase, grid
includes header: IllinoisGRMHD_headers.h in IllinoisGRMHD_headers.h
USES INCLUDE: Symmetry.h
public:
#vvvvvvvv EVOLVED VARIABLES vvvvvvvv#
#cctk_real grmhd_conservatives type = GF TAGS='prolongation="Lag3"' Timelevels=3
cctk_real grmhd_conservatives type = GF Timelevels=3
{
rho_star,tau,mhd_st_x,mhd_st_y,mhd_st_z # Note that st = Stilde, as mhd_st_i = \tilde{S}_i.
} "Evolved mhd variables"
# These variables are semi-staggered:
# Ax is defined on the semi-staggered grid (i,j+1/2,k+1/2)
# WARNING: WILL NOT WORK PROPERLY WITHOUT SEMI-STAGGERED PROLONGATION/RESTRICTION:
cctk_real em_Ax type = GF Timelevels=3 tags='Prolongation="STAGGER011"'
{
Ax
} "x-component of the vector potential, evolved when constrained_transport_scheme==3"
# Ay is defined on the semi-staggered grid (i+1/2,j,k+1/2)
# WARNING: WILL NOT WORK PROPERLY WITHOUT SEMI-STAGGERED PROLONGATION/RESTRICTION:
cctk_real em_Ay type = GF Timelevels=3 tags='Prolongation="STAGGER101"'
{
Ay
} "y-component of the vector potential, evolved when constrained_transport_scheme==3"
# WARNING: WILL NOT WORK PROPERLY WITHOUT SEMI-STAGGERED PROLONGATION/RESTRICTION:
# Az is defined on the semi-staggered grid (i+1/2,j+1/2,k)
cctk_real em_Az type = GF Timelevels=3 tags='Prolongation="STAGGER110"'
{
Az
} "z-component of the vector potential, evolved when constrained_transport_scheme==3"
# psi6phi is defined on the staggered grid (i+1/2,j+1/2,k+1/2)
# WARNING: WILL NOT WORK PROPERLY WITHOUT FULLY-STAGGERED PROLONGATION/RESTRICTION:
#
cctk_real em_psi6phi type = GF Timelevels=3 tags='Prolongation="STAGGER111"'
{
psi6phi
} "sqrt{gamma} Phi, where Phi is the em scalar potential"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv PRIMITIVE VARIABLES vvvvvvv#
# TODO: split into groups with well defined symmetry properties: (rho_b, P, u0), (vx,vy,vz)
cctk_real grmhd_primitives_allbutBi type = GF TAGS='InterpNumTimelevels=1 prolongation="none"'
{
rho_b,P,vx,vy,vz
} "Primitive variables density, pressure, and components of three velocity v^i. Note that v^i is defined in terms of 4-velocity as: v^i = u^i/u^0. Note that this definition differs from the Valencia formalism."
# It is useful to split Bi from Bi_stagger, since we're generally only interested in outputting Bi for diagnostics
cctk_real grmhd_primitives_Bi type = GF TAGS='InterpNumTimelevels=1 prolongation="none"'
{
Bx,By,Bz
} "B-field components defined at vertices."
cctk_real grmhd_primitives_Bi_stagger type = GF TAGS='InterpNumTimelevels=1 prolongation="none"'
{
Bx_stagger,By_stagger,Bz_stagger
} "B-field components defined at staggered points [Bx_stagger at (i+1/2,j,k),By_stagger at (i,j+1/2,k),Bz_stagger at (i,j,k+1/2)]."
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv BSSN-based quantities, computed from ADM quantities.v vvvvvvv#
cctk_real BSSN_quantities type = GF TAGS='prolongation="none" Checkpoint="no"'
{
gtxx,gtxy,gtxz,gtyy,gtyz,gtzz,gtupxx,gtupxy,gtupxz,gtupyy,gtupyz,gtupzz,phi_bssn,psi_bssn,lapm1
} "BSSN quantities, computed from ADM quantities"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
private:
#vvvvvvv DIAGNOSTIC GRIDFUNCTIONS vvvvvvv#
cctk_real diagnostic_gfs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
failure_checker
} "Gridfunction to track conservative-to-primitives solver fixes. Beware that this gridfunction is overwritten at each RK substep."
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv TEMPORARY VARIABLES FOR RECONSTRUCTION vvvvvvv#
cctk_real grmhd_primitives_reconstructed_temps type = GF TAGS='prolongation="none" Checkpoint="no"'
{
ftilde_gf,temporary,
rho_br,Pr,vxr,vyr,vzr,Bxr,Byr,Bzr,Bx_staggerr,By_staggerr,Bz_staggerr,
rho_bl,Pl,vxl,vyl,vzl,Bxl,Byl,Bzl,Bx_staggerl,By_staggerl,Bz_staggerl,
vxrr,vxrl,vyrr,vyrl,vzrr,vzrl,vxlr,vxll,vylr,vyll,vzlr,vzll
} "Temporary variables used for primitives reconstruction"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv RHS VARIABLES vvvvvvv#
cctk_real grmhd_conservatives_rhs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
rho_star_rhs,tau_rhs,st_x_rhs,st_y_rhs,st_z_rhs
} "Storage for the right-hand side of the partial_t rho_star, partial_t tau, and partial_t tilde{S}_i equations. Needed for MoL timestepping."
cctk_real em_Ax_rhs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
Ax_rhs
} "Storage for the right-hand side of the partial_t A_x equation. Needed for MoL timestepping."
cctk_real em_Ay_rhs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
Ay_rhs
} "Storage for the right-hand side of the partial_t A_y equation. Needed for MoL timestepping."
cctk_real em_Az_rhs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
Az_rhs
} "Storage for the right-hand side of the partial_t A_z equation. Needed for MoL timestepping."
cctk_real em_psi6phi_rhs type = GF TAGS='prolongation="none" Checkpoint="no"'
{
psi6phi_rhs
} "Storage for the right-hand side of the partial_t (psi^6 Phi) equation. Needed for MoL timestepping."
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv TEMPORARY VARIABLES USEFUL FOR A-FIELD EVOLUTION vvvvvvv#
cctk_real grmhd_cmin_cmax_temps type = GF TAGS='prolongation="none" Checkpoint="no"'
{
cmin_x,cmax_x,
cmin_y,cmax_y,
cmin_z,cmax_z
} "Store min and max characteristic speeds in all three directions."
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv TEMPORARY VARIABLES USEFUL FOR FLUX COMPUTATION vvvvvvv#
cctk_real grmhd_flux_temps type = GF TAGS='prolongation="none" Checkpoint="no"'
{
rho_star_flux,tau_flux,st_x_flux,st_y_flux,st_z_flux
} "Temporary variables for storing the flux terms of tilde{S}_i."
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
#vvvvvvv T^{\mu \nu}, stored to avoid expensive recomputation vvvvvvv#
cctk_real TUPmunu type = GF TAGS='prolongation="none" Checkpoint="no"'
{
TUPtt,TUPtx,TUPty,TUPtz,TUPxx,TUPxy,TUPxz,TUPyy,TUPyz,TUPzz
} "T^{mu nu}, stored to avoid expensive recomputation"
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#
###########################################################################
####################################################
### Functions provided by MoL for registration ###
####################################################
CCTK_INT FUNCTION MoLRegisterEvolved(CCTK_INT IN EvolvedIndex, \
CCTK_INT IN RHSIndex)
CCTK_INT FUNCTION MoLRegisterEvolvedSlow(CCTK_INT IN EvolvedIndex, \
CCTK_INT IN RHSIndexSlow)
CCTK_INT FUNCTION MoLRegisterConstrained(CCTK_INT IN ConstrainedIndex)
CCTK_INT FUNCTION MoLRegisterEvolvedGroup(CCTK_INT IN EvolvedIndex, \
CCTK_INT IN RHSIndex)
CCTK_INT FUNCTION MoLRegisterEvolvedGroupSlow(CCTK_INT IN EvolvedIndex, \
CCTK_INT IN RHSIndexSlow)
CCTK_INT FUNCTION MoLRegisterConstrainedGroup(CCTK_INT IN ConstrainedIndex)
CCTK_INT FUNCTION MoLRegisterSaveAndRestoreGroup(CCTK_INT IN SandRIndex)
USES FUNCTION MoLRegisterEvolved
USES FUNCTION MoLRegisterEvolvedSlow
USES FUNCTION MoLRegisterConstrained
USES FUNCTION MoLRegisterEvolvedGroup
USES FUNCTION MoLRegisterEvolvedGroupSlow
USES FUNCTION MoLRegisterConstrainedGroup
USES FUNCTION MoLRegisterSaveAndRestoreGroup
#########################################
### Aliased functions from Boundary ###
#########################################
CCTK_INT FUNCTION Boundary_SelectVarForBC(CCTK_POINTER_TO_CONST IN GH, \
CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, \
CCTK_STRING IN var_name, CCTK_STRING IN bc_name)
CCTK_INT FUNCTION Boundary_SelectGroupForBC(CCTK_POINTER_TO_CONST IN GH, \
CCTK_INT IN faces, CCTK_INT IN boundary_width, CCTK_INT IN table_handle, \
CCTK_STRING IN group_name, CCTK_STRING IN bc_name)
USES FUNCTION Boundary_SelectVarForBC
USES FUNCTION Boundary_SelectGroupForBC
###########################################################################
#########################################
### Aliased functions from Carpet ###
#########################################
CCTK_INT FUNCTION \
GetRefinementLevel \
(CCTK_POINTER_TO_CONST IN cctkGH)
USES FUNCTION GetRefinementLevel
Writing ../interface.ccl
%%writefile $outfile_path__param__ccl
# Parameter definitions for thorn IllinoisGRMHD
shares: ADMBase
USES CCTK_INT lapse_timelevels
USES CCTK_INT shift_timelevels
USES CCTK_INT metric_timelevels
#########################################################
restricted:
#########################################################
# Verbosity Level
KEYWORD verbose "Determines how much evolution information is output" STEERABLE=ALWAYS
{
"no" :: "Complete silence"
"essential" :: "Essential health monitoring of the GRMHD evolution: Information about conservative-to-primitive fixes, etc."
"essential+iteration output" :: "Outputs health monitoring information, plus a record of which RK iteration. Very useful for backtracing a crash."
} "essential+iteration output"
#########################################################
#########################################################
# SPEED LIMIT: Set maximum relativistic gamma factor
#
REAL GAMMA_SPEED_LIMIT "Maximum relativistic gamma factor."
{
1:* :: "Positive > 1, though you'll likely have troubles far above 10."
} 10.0
#########################################################
#########################################################
# CONSERV TO PRIMS PARAMETERS
# FIXME: Enable this parameter! IllinoisGRMHD is currently hard-coded to tau_stildefix_enable=2.
#INT tau_stildefix_enable "tau<0 fix in primitive_vars_hybrid2 to reduce number of Font fixes, especially in puncture+matter evolutions" STEERABLE=ALWAYS
#{
# 0:3 :: "zero (disable), one (enable everywhere), or two (enable only where Psi6 > Psi6threshold [i.e., inside the horizon, where B's are set to zero], or three (kludge: set B=0 if tau<0 inside horizon))"
#} 0
BOOLEAN update_Tmunu "Update Tmunu, for RHS of Einstein's equations?" STEERABLE=ALWAYS
{
} "yes"
############################
# Limiters on tau and rho_b:
REAL tau_atm "Floor value on the energy variable tau (cf. tau_stildefix_enable). Given the variety of systems this code may encounter, there *is no reasonable default*. Effectively the current (enormous) value should disable the tau_atm floor. Please set this in your initial data thorn, and reset at will during evolutions." STEERABLE=ALWAYS
{
0:* :: "Positive"
} 1e100
REAL rho_b_atm "Floor value on the baryonic rest mass density rho_b (atmosphere). Given the variety of systems this code may encounter, there *is no reasonable default*. Your run will die unless you override this default value in your initial data thorn." STEERABLE=ALWAYS
{
*:* :: "Allow for negative values. This enables us to debug the code and verify if rho_b_atm is properly set."
} 1e200
REAL rho_b_max "Ceiling value on the baryonic rest mass density rho_b. The enormous value effectively disables this ceiling by default. It can be quite useful after a black hole has accreted a lot of mass, leading to enormous densities inside the BH. To enable this trick, set rho_b_max in your initial data thorn! You are welcome to change this parameter mid-run (after restarting from a checkpoint)." STEERABLE=ALWAYS
{
0:* :: "Note that you will have problems unless rho_b_atm<rho_b_max"
} 1e300
############################
INT conserv_to_prims_debug "0: no, 1: yes" STEERABLE=ALWAYS
{
0:1 :: "zero (no) or one (yes)"
} 0
REAL Psi6threshold "Where Psi^6 > Psi6threshold, we assume we're inside the horizon in the primitives solver, and certain limits are relaxed or imposed" STEERABLE=ALWAYS
{
*:* :: "Can set to anything"
} 1e100
#########################################################
#########################################################
# EQUATION OF STATE PARAMS, LOOK FOR MORE IN interface.ccl!
INT neos "number of parameters in EOS table. If you want to increase from the default max value, you MUST also set eos_params_arrays1 and eos_params_arrays2 in interface.ccl to be consistent!"
{
1:10 :: "Any integer between 1 and 10"
} 1
REAL Gamma_th "thermal gamma parameter"
{
0:* :: "Physical values"
-1 :: "forbidden value to make sure it is explicitly set in the parfile"
} -1
REAL K_ppoly_tab0 "Also known as k_tab[0], this is the polytropic constant for the lowest density piece of the piecewise polytrope. All other k_tab EOS array elements are set from user-defined rho_tab EOS array elements and by enforcing continuity in the equation of state."
{
0:* :: "Physical values"
-1 :: "forbidden value to make sure it is explicitly set in the parfile"
} -1
REAL rho_ppoly_tab_in[10] "Set polytropic rho parameters"
{
0.0:* :: "after this time (inclusively)"
-1.0 :: "forbidden value to make sure it is explicitly set in the parfile"
} -1.0
REAL Gamma_ppoly_tab_in[11] "Set polytropic rho parameters"
{
0.0:* :: "after this time (inclusively)"
-1.0 :: "forbidden value to make sure it is explicitly set in the parfile"
} -1.0
#########################################################
#########################################################
# OUTER BOUNDARY CONDITION CHOICE
KEYWORD Matter_BC "Chosen Matter boundary condition"
{
"outflow" :: "Outflow boundary conditions"
"frozen" :: "Frozen boundaries"
} "outflow"
KEYWORD EM_BC "EM field boundary condition"
{
"copy" :: "Copy data from nearest boundary point"
"frozen" :: "Frozen boundaries"
} "copy"
#########################################################
#########################################################
# SYMMETRY BOUNDARY PARAMS. Needed for handling staggered gridfunctions.
KEYWORD Symmetry "Currently only no symmetry supported, though work has begun in adding equatorial-symmetry support. FIXME: Extend ET symmetry interface to support symmetries on staggered gridfunctions"
{
"none" :: "no symmetry, full 3d domain"
} "none"
REAL Sym_Bz "In-progress equatorial symmetry support: Symmetry parameter across z axis for magnetic fields = +/- 1"
{
-1.0:1.0 :: "Set to +1 or -1."
} 1.0
#########################################################
###############################################################################################
private:
#########################################################
# EVOLUTION PARAMS
REAL damp_lorenz "Damping factor for the generalized Lorenz gauge. Has units of 1/length = 1/M. Typically set this parameter to 1.5/(maximum Delta t on AMR grids)." STEERABLE=ALWAYS
{
*:* :: "any real"
} 0.0
#########################################################
Writing ../param.ccl
%%writefile $outfile_path__schedule__ccl
# Scheduler setup for IllinoisGRMHD
STORAGE: ADMBase::metric[metric_timelevels], ADMBase::curv[metric_timelevels], ADMBase::lapse[lapse_timelevels], ADMBase::shift[shift_timelevels]
STORAGE: IllinoisGRMHD::BSSN_quantities
STORAGE: grmhd_conservatives[3],em_Ax[3],em_Ay[3],em_Az[3],em_psi6phi[3]
STORAGE: grmhd_primitives_allbutBi,grmhd_primitives_Bi,grmhd_primitives_Bi_stagger,grmhd_primitives_reconstructed_temps,grmhd_conservatives_rhs,em_Ax_rhs,em_Ay_rhs,em_Az_rhs,em_psi6phi_rhs,grmhd_cmin_cmax_temps,grmhd_flux_temps,TUPmunu,diagnostic_gfs
####################
# RUN INITIALLY ONLY
schedule IllinoisGRMHD_RegisterVars in MoL_Register after BSSN_RegisterVars after lapse_RegisterVars
{
LANG: C
OPTIONS: META
} "Register evolved, rhs variables in IllinoisGRMHD for MoL"
# Tells the symmetry thorn how to apply symmetries on each gridfunction:
schedule IllinoisGRMHD_InitSymBound at BASEGRID after Lapse_InitSymBound
{
LANG: C
} "Schedule symmetries"
####################
####################
# POSTPOSTINITIAL
# HydroBase_Con2Prim in CCTK_POSTPOSTINITIAL sets conserv to prim then
# outer boundaries (OBs, which are technically disabled). The post OB
# SYNCs actually reprolongate the conservative variables, making cons
# and prims INCONSISTENT. So here we redo the con2prim, avoiding the
# SYNC afterward, then copy the result to other timelevels"
schedule GROUP IllinoisGRMHD_PostPostInitial at CCTK_POSTPOSTINITIAL before MoL_PostStep after HydroBase_Con2Prim
{
} "HydroBase_Con2Prim in CCTK_POSTPOSTINITIAL sets conserv to prim then outer boundaries (OBs, which are technically disabled). The post OB SYNCs actually reprolongate the conservative variables, making cons and prims INCONSISTENT. So here we redo the con2prim, avoiding the SYNC afterward, then copy the result to other timelevels"
schedule IllinoisGRMHD_InitSymBound in IllinoisGRMHD_PostPostInitial as postid before compute_b
{
SYNC: grmhd_conservatives,em_Ax,em_Ay,em_Az,em_psi6phi
LANG: C
} "Schedule symmetries -- Actually just a placeholder function to ensure prolongations / processor syncs are done BEFORE outer boundaries are updated."
# Easiest primitives to solve for: B^i
schedule IllinoisGRMHD_compute_B_and_Bstagger_from_A in IllinoisGRMHD_PostPostInitial as compute_b after postid after empostid after lapsepostid
{
# This is strictly a processor sync, as prolongation is disabled for all primitives & B^i's.
SYNC: grmhd_primitives_Bi,grmhd_primitives_Bi_stagger # FIXME: Are both SYNC's necessary?
LANG: C
} "Compute B and B_stagger from A SYNC: grmhd_primitives_Bi,grmhd_primitives_Bi_stagger"
# Nontrivial primitives solve, for P,rho_b,vx,vy,vz:
schedule IllinoisGRMHD_conserv_to_prims in IllinoisGRMHD_PostPostInitial after compute_b
{
LANG: C
} "Compute primitive variables from conservatives. This is non-trivial, requiring a Newton-Raphson root-finder."
# Copy data to other timelevels.
schedule IllinoisGRMHD_PostPostInitial_Set_Symmetries__Copy_Timelevels in IllinoisGRMHD_PostPostInitial as mhdpostid after compute_b after p2c
{
LANG: C
} "Compute post-initialdata quantities"
####################
####################
# RHS EVALUATION
schedule IllinoisGRMHD_driver_evaluate_MHD_rhs in MoL_CalcRHS as IllinoisGRMHD_RHS_eval after bssn_rhs after shift_rhs
{
LANG: C
} "Evaluate RHSs of GR Hydro & GRMHD equations"
####################
############################################################
# COMPUTE B FROM A & RE-SOLVE FOR PRIMITIVES
# After a full timestep, there are two types of boundaries that need filling:
# (A) Outer boundaries (on coarsest level)
# (B) AMR grid refinement boundaries
# (A) OUTER BOUNDARY STEPS:
# ( 0) Synchronize (prolongate/restrict) all evolved variables
# ( 1) Apply outer boundary conditions (BCs) on A_{\mu}
# ( 2) Compute B^i from A_i everywhere, synchronize (processor sync) B^i
# ( 3) Call con2prim to get consistent primitives {P,rho_b,vx,vy,vz} and conservatives at all points (if no restriction, really only need interior)
# ( 4) Apply outer BCs on {P,rho_b,vx,vy,vz}, recompute conservatives.
# (B) AMR GRID REFINEMENT BOUNDARY STEPS:
# Same as steps 0,2,3 above. Just need if() statements in steps 1,4 to prevent "outer boundaries" being updated
# Problem: all the sync's in outer boundary updates might just overwrite prolongated values.
############################################################
schedule IllinoisGRMHD_InitSymBound in HydroBase_Boundaries as Boundary_SYNCs before compute_B_postrestrict
{
SYNC: grmhd_conservatives,em_Ax,em_Ay,em_Az,em_psi6phi
LANG: C
} "Schedule symmetries -- Actually just a placeholder function to ensure prolongations / processor syncs are done BEFORE outer boundaries are updated."
schedule IllinoisGRMHD_outer_boundaries_on_A_mu in HydroBase_Boundaries after Boundary_SYNCs before mhd_conserv2prims_postrestrict
{
LANG: C
} "Apply linear extrapolation BCs on A_{mu}, so that BCs are flat on B^i."
# Easiest primitives to solve for: B^i.
# Note however that B^i depends on derivatives of A_{\mu}, so a SYNC is necessary on B^i.
schedule IllinoisGRMHD_compute_B_and_Bstagger_from_A in HydroBase_Boundaries after outer_boundaries_on_A_mu
{
# This is strictly a processor sync, as prolongation is disabled for all B^i's.
SYNC: grmhd_primitives_Bi,grmhd_primitives_Bi_stagger # FIXME: Are both SYNC's necessary?
LANG: C
} "Compute B and B_stagger from A, SYNC: grmhd_primitives_Bi,grmhd_primitives_Bi_stagger"
# Nontrivial primitives solve, for P,rho_b,vx,vy,vz.
schedule IllinoisGRMHD_conserv_to_prims in AddToTmunu after compute_B_and_Bstagger_from_A
{
LANG: C
} "Compute primitive variables from conservatives. This is non-trivial, requiring a Newton-Raphson root-finder."
schedule IllinoisGRMHD_outer_boundaries_on_P_rho_b_vx_vy_vz in AddToTmunu after IllinoisGRMHD_conserv_to_prims
{
# We must sync {P,rho_b,vx,vy,vz} here.
SYNC: grmhd_primitives_allbutBi
LANG: C
} "Apply outflow-only, flat BCs on {P,rho_b,vx,vy,vz}. Outflow only == velocities pointed inward from outer boundary are set to zero."
##########################################################
Writing ../schedule.ccl
%%writefile $outfile_path__code_validation__txt
0 0 0.129285232345409 0
6 0.375 0.127243949890016 0
12 0.75 0.12663194218958 9.99201e-16
18 1.125 0.126538236778999 0
24 1.5 0.126693696091085 0
30 1.875 0.126354095699745 0
36 2.25 0.125536381948334 0
42 2.625 0.124535850791511 0
48 3 0.123592701331336 -1.9984e-15
54 3.375 0.122798174115381 6.00908e-15
60 3.75 0.122119289857302 5.20001e-14
66 4.125 0.121490429374158 -7.219e-12
72 4.5 0.120874029334284 9.062e-12
78 4.875 0.120259717466328 8.073e-12
84 5.25 0.11967641900387 6.773e-12
90 5.625 0.119123915533179 3.9644e-11
96 6 0.118609688443716 8.7028e-11
102 6.375 0.118142085593448 1.0356e-10
108 6.75 0.117724554127494 -2.1806e-11
114 7.125 0.117368613539 -2.98919e-10
120 7.5 0.117103537221293 -6.55126e-10
126 7.875 0.116916242747612 -8.58055e-10
132 8.25 0.116788537512057 -6.40583e-10
138 8.625 0.116760604471516 1.2299e-10
144 9 0.116800459472318 1.17986e-09
150 9.375 0.116876502360487 2.30931e-09
156 9.75 0.117001584159343 3.22793e-09
162 10.125 0.117152245129722 3.70731e-09
168 10.5 0.117321427488885 3.80249e-09
174 10.875 0.117504914930401 3.18643e-09
180 11.25 0.117677337706038 1.53467e-09
186 11.625 0.11783535130534 -1.0388e-09
192 12 0.11797817411705 -4.09727e-09
198 12.375 0.118099716148388 -7.36175e-09
204 12.75 0.118197132134204 -1.11993e-08
210 13.125 0.118268160681997 -1.54798e-08
216 13.5 0.118308938021455 -1.879e-08
222 13.875 0.118311817073909 -1.9184e-08
228 14.25 0.118266030948925 -1.56794e-08
234 14.625 0.118178894932027 -8.96657e-09
240 15 0.118048178792271 -8.64983e-10
Writing code_validation.txt
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/src/make.code.defn"
original_IGM_file_name = "make.code.defn-original"
original_IGM_file_path = os.path.join(IGM_src_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__make_code_defn = !diff $original_IGM_file_path $outfile_path__make_code_defn
if Validation__make_code_defn == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for make.code.defn: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for make.code.defn: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__make_code_defn:
print(diff_line)
Validation test for make.code.defn: FAILED! Diff: 15a16 >
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/configuration.ccl"
original_IGM_file_name = "configuration-original.ccl"
original_IGM_file_path = os.path.join(IGM_main_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__configuration__ccl = !diff $original_IGM_file_path $outfile_path__configuration__ccl
if Validation__configuration__ccl == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for configuration.ccl: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for configuration.ccl: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__configuration__ccl:
print(diff_line)
Validation test for configuration.ccl: FAILED! Diff: 6a7 >
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/interface.ccl"
original_IGM_file_name = "interface-original.ccl"
original_IGM_file_path = os.path.join(IGM_main_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__interface__ccl = !diff $original_IGM_file_path $outfile_path__interface__ccl
if Validation__interface__ccl == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for interface.ccl: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for interface.ccl: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__interface__ccl:
print(diff_line)
Validation test for interface.ccl: FAILED! Diff: 46c46 < psi6phi --- > psi6phi 68,84d67 < #vvvvvvv EQUATION OF STATE VARIABLES vvvvvvv# < REAL eos_params_arrays1 TYPE=ARRAY DISTRIB=CONSTANT DIM=1 SIZE=10 < { < rho_tab,P_tab,eps_tab < } "Equation of state (EOS) parameters" < < REAL eos_params_arrays2 TYPE=ARRAY DISTRIB=CONSTANT DIM=1 SIZE=11 < { < k_tab,gamma_tab < } "Equation of state (EOS) parameters" < < REAL eos_params_scalar TYPE = SCALAR < { < n_poly < } "polytropic index" < #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# < 118,119c101,102 < { < Ax_rhs --- > { > Ax_rhs 123c106 < Ay_rhs --- > Ay_rhs 126,127c109,110 < { < Az_rhs --- > { > Az_rhs 131c114 < psi6phi_rhs --- > psi6phi_rhs 205a189 >
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/param.ccl"
original_IGM_file_name = "param-original.ccl"
original_IGM_file_path = os.path.join(IGM_main_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__param__ccl = !diff $original_IGM_file_path $outfile_path__param__ccl
if Validation__param__ccl == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for param.ccl: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for param.ccl: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__param__ccl:
print(diff_line)
Validation test for param.ccl: FAILED! Diff: 23c23 < # --- > # 79c79 < REAL gamma_th "thermal gamma parameter" --- > REAL Gamma_th "thermal gamma parameter" 85c85 < REAL K_poly "initial polytropic constant" --- > REAL K_ppoly_tab0 "Also known as k_tab[0], this is the polytropic constant for the lowest density piece of the piecewise polytrope. All other k_tab EOS array elements are set from user-defined rho_tab EOS array elements and by enforcing continuity in the equation of state." 87,88c87,102 < 0:* :: "Positive" < } 1.0 --- > 0:* :: "Physical values" > -1 :: "forbidden value to make sure it is explicitly set in the parfile" > } -1 > > REAL rho_ppoly_tab_in[10] "Set polytropic rho parameters" > { > 0.0:* :: "after this time (inclusively)" > -1.0 :: "forbidden value to make sure it is explicitly set in the parfile" > } -1.0 > > REAL Gamma_ppoly_tab_in[11] "Set polytropic rho parameters" > { > 0.0:* :: "after this time (inclusively)" > -1.0 :: "forbidden value to make sure it is explicitly set in the parfile" > } -1.0 > 129a144,145 > >
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/schedule.ccl"
original_IGM_file_name = "schedule-original.ccl"
original_IGM_file_path = os.path.join(IGM_main_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__schedule__ccl = !diff $original_IGM_file_path $outfile_path__schedule__ccl
if Validation__schedule__ccl == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for schedule.ccl: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for schedule.ccl: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__schedule__ccl:
print(diff_line)
Validation test for schedule.ccl: FAILED! Diff: 6c6 < STORAGE: grmhd_conservatives[3],em_Ax[3],em_Ay[3],em_Az[3],em_psi6phi[3] --- > STORAGE: grmhd_conservatives[3],em_Ax[3],em_Ay[3],em_Az[3],em_psi6phi[3] 8d7 < STORAGE: eos_params_arrays1,eos_params_arrays2,eos_params_scalar 28c27 < # outer boundaries (OBs, which are technically disabled). The post OB --- > # outer boundaries (OBs, which are technically disabled). The post OB 30c29 < # and prims INCONSISTENT. So here we redo the con2prim, avoiding the --- > # and prims INCONSISTENT. So here we redo the con2prim, avoiding the 122a122 >
# Verify if the code generated by this tutorial module
# matches the original IllinoisGRMHD source code
# First download the original IllinoisGRMHD source code
import urllib
from os import path
original_IGM_file_url = "https://bitbucket.org/zach_etienne/wvuthorns/raw/5611b2f0b17135538c9d9d17c7da062abe0401b6/IllinoisGRMHD/code_validation.txt"
original_IGM_file_name = "code_validation-original.txt"
original_IGM_file_path = os.path.join(IGM_main_dir_path,original_IGM_file_name)
# Then download the original IllinoisGRMHD source code
# We try it here in a couple of ways in an attempt to keep
# the code more portable
try:
original_IGM_file_code = urllib.request.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
try:
original_IGM_file_code = urllib.urlopen(original_IGM_file_url).read().decode("utf-8")
# Write down the file the original IllinoisGRMHD source code
with open(original_IGM_file_path,"w") as file:
file.write(original_IGM_file_code)
except:
# If all else fails, hope wget does the job
!wget -O $original_IGM_file_path $original_IGM_file_url
# Perform validation
Validation__code_validation__txt = !diff $original_IGM_file_path $outfile_path__code_validation__txt
if Validation__code_validation__txt == []:
# If the validation passes, we do not need to store the original IGM source code file
!rm $original_IGM_file_path
print("Validation test for code_validation.txt: PASSED!")
else:
# If the validation fails, we keep the original IGM source code file
print("Validation test for code_validation.txt: FAILED!")
# We also print out the difference between the code generated
# in this tutorial module and the original IGM source code
print("Diff:")
for diff_line in Validation__code_validation__txt:
print(diff_line)
Validation test for code_validation.txt: FAILED! Diff: 41a42 >
The following code cell converts this Jupyter notebook into a proper, clickable $\LaTeX$-formatted PDF file. After the cell is successfully run, the generated PDF may be found in the root NRPy+ tutorial directory, with filename Tutorial-IllinoisGRMHD__Configuration_files.pdf (Note that clicking on this link may not work; you may need to open the PDF file through another means).
latex_nrpy_style_path = os.path.join(nrpy_dir_path,"latex_nrpy_style.tplx")
#!jupyter nbconvert --to latex --template $latex_nrpy_style_path --log-level='WARN' Tutorial-IllinoisGRMHD__Configuration_files.ipynb
#!pdflatex -interaction=batchmode Tutorial-IllinoisGRMHD__Configuration_files.tex
#!pdflatex -interaction=batchmode Tutorial-IllinoisGRMHD__Configuration_files.tex
#!pdflatex -interaction=batchmode Tutorial-IllinoisGRMHD__Configuration_files.tex
!rm -f Tut*.out Tut*.aux Tut*.log