-
Notifications
You must be signed in to change notification settings - Fork 2
Output Format
One of the goals of iharm2d_v4
is to provide users with a GRMHD code that is as similar to production (HARM-based) GRMHD codes (e.g., iharm3d
) as possible while doing away with several dependencies. Therefore, iharm2d_v4
writes fluid output to ASCII files.
The goal of this page is to explain the grid file and the fluid dump files that are written out by io.c
. The grid is generated during problem initialization and cached in the struct GridGeom
. The grid file - dumps/grid
- is written only at the start of the simulation. The fluid state data meanwhile is continuously updated in the FluidState
struct, and based on the cadence provided (Dtd
) in param.dat
, the code regularly writes output to dump files dumps/dump_*
.
The grid file contains the grid coordinates, the covariant and contravariant components of the metric, the Jacobian (iharm2d_v4
this corresponds to X2. The slower-changing index corresponds to X1.
If one wants to read the grid file in python, the code would something look like,
grid = numpy.loadtxt(os.path.join(dumpsdir,'grid'))
x = grid[:,0].reshape((n1,n2))
z = grid[:,1].reshape((n1,n2))
r = grid[:,2].reshape((n1,n2))
th = grid[:,3].reshape((n1,n2))
x1 = grid[:,4].reshape((n1,n2))
x2 = grid[:,5].reshape((n1,n2))
gdet = grid[:,6].reshape((n1,n2))
lapse = grid[:,7].reshape((n1,n2))
gcon = grid[:,8:24].reshape((n1, n2, ndim, ndim))
gcov = grid[:,24:].reshape((n1, n2, ndim, ndim))
where n1
and n2
are the number of grid zones along X1 and X2 which can be read from the fluid dump header or the simulation compile-time parameter file parameters.h
. ndim
is the number of spacetime dimensions, or equivalently the matrix dimensions of the metric when represented in a coordinate basis, it's value is 4
. grid
is a numpy array that contains all the data stored in the grid file.
Just like iharm3d
(see this), the fluid dump output can be schematically separated into two parts: the header - which in this case is the first line of the ASCII file - and the fluid state data.
The header (for the torus problem) contains,
Variable | Description | Type | Notes |
---|---|---|---|
mad_type |
Is the simulation SANE (0) or MAD (1)? | int | |
problem_type | Type of physical problem | string | "torus" in this case |
rin |
Inner radius of Fishbone-Moncrief torus | double | in code units |
rmax |
Pressure maximum radius of Fishbone-Moncrief torus | double | in code units |
beta |
Ratio of maximum fluid pressure to maximum magnetic pressure | double | |
u_jitter |
Perturbation to the fluid internal energy | double | |
VERSION |
Code version | string | |
has_electrons |
Were electrons enabled? | int | |
gridfile |
Grid file name | string | |
metric | Type of metric | string | Can be MINKOWSKI, MKS or FMKS |
reconstruction | Reconstruction scheme | string | Can be LINEAR, WENO or MP5 |
N1 |
Number of grid zones along X1 | int | |
N2 |
Number of grid zones along X2 | int | |
n_prims |
Number of primitives | int | Typically 8 for the vanilla ideal GRMHD problem |
n_prims_passive |
Number of passive primitives | int | Set to 0 for now |
game |
Adiabatic index of electrons | double | Only if ELECTRONS were enabled |
gamp |
Adiabatic index of protons | double | Only if ELECTRONS were enabled |
fel0 |
Initial fraction of internal energy for electrons | double | Only if ELECTRONS were enabled |
tptemin |
Minimum ratio of temperature of protons to electrons | double | Only if ELECTRONS were enabled |
tptemax |
Minimum ratio of temperature of protons to electrons | double | Only if ELECTRONS were enabled |
gam |
Adiabatic index of the fluid | double | |
cour |
Courant number | double | |
tf |
Final simulation time | double | in code units |
startx1 | Logical grid left edge (X1) | double | |
startx2 | Logical grid left edge (X2) | double | |
dx1 | Logical grid width along X1 | double | |
dx2 | Logical grid width along X2 | double | |
n_dim |
Number of spacetime dimensions | int | 4 |
poly_xt | FMKS coordinate transform parameter | double | Only if FMKS metric |
poly_alpha | FMKS coordinate transform parameter | double | Only if FMKS metric |
mks_smooth | FMKS coordinate transform parameter | double | Only if FMKS metric |
Rin |
Domain inner edge | double | Only if FMKS/MKS metric |
Rout |
Domain outer edge | double | Only if FMKS/MKS metric |
Rhor |
Event horizon radius | double | Only if FMKS/MKS metric |
Risco |
ISCO radius | double | Only if FMKS/MKS metric |
hslope |
MKS coordinate transformation parameter | double | Only if FMKS/MKS metric |
a |
Black hole spin | double | Only if FMKS/MKS metric |
t |
Simulation time | double | in code units |
dt |
Timestep | double | in code units |
nstep |
Timestep number | int | |
dump_cnt |
Dump number | int | |
Dtd |
Dump cadence | double | in code units |
Dtf |
Full fluid state cadence | double | Not used presently. Every dump is full fluid state dump |
The fluid state data contains,
Variable | Description | Type | Notes |
---|---|---|---|
p | Primitives |
N1 xN2 xn_prims array of doubles |
For vanilla, ideal GRMHD this contains arrays of RHO ,UU ,U1 ,U2 ,U3 ,B1 ,B2 , and B3
|
jcon | The 4-current |
N1 xN2 xn_dim array of doubles |
|
gamma | Lorentz factor |
N1 xN2 array of doubles |
|
divB | Magnetic field divergence values |
N1 xN2 array of doubles |
|
fail_save |
Zones where UtoP failed |
N1 xN2 array of ints |
See u_top.c to understand failure code |
fflag |
Zones where fixup routine failed |
N1 xN2 array of ints |
One can read the fluid primitives like,
prims = np.loadtxt('dumps/dump_000000000',skiprows=1)
rho = prims[:,0].reshape((n1,n2))
uu = prims[:,1].reshape((n1,n2))
U1 = prims[:,2].reshape((n1,n2))
U2 = prims[:,3].reshape((n1,n2))
U3 = prims[:,4].reshape((n1,n2))
B1 = prims[:,5].reshape((n1,n2))
B2 = prims[:,6].reshape((n1,n2))
B3 = prims[:,7].reshape((n1,n2))
If you would like to write your own python script to read and plot iharm2d_v4
output, this page in addition to files/scripts/plot_torus.py
should prove to be a good reference.