Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
1586aa1
Fix test scripts on some machines by specifying python3
c-prather Jan 10, 2022
b54dc15
Merge pull request #84 from AFD-Illinois/dev
avjoshi21 Oct 13, 2022
30fb98e
fix interpolation tearing artifact in plot_pol
gnwong Dec 4, 2022
542ecc0
add plotting script that supports both pol and unpol
gnwong Feb 14, 2023
1945713
minor bugfix to testing script
avjoshi21 Mar 21, 2023
4081a0d
update ipole to support cartesian z turning points for tracking subrings
gnwong Jun 2, 2023
b96896e
add parameter subring_dtheta to revert to previous dtheta/ds subring …
gnwong Jun 12, 2023
198adfc
Histogram of emission
c-prather Oct 18, 2022
f183161
add utilities to support athenak format and CKS
gnwong Oct 1, 2023
beda5f3
add first pass at athenak meshblock reader. can probably be easily ex…
gnwong Oct 2, 2023
2ee6e7a
clean up athenak model reader
gnwong Oct 2, 2023
ac15d01
avoid 'uninitialized' warnings in brems fits
gnwong Oct 2, 2023
46939f2
fix a few bugs in fastlight reader with dump cadence. test images agree.
gnwong Oct 2, 2023
1fe306e
rename meshblocks model to something more agnostic
gnwong Oct 2, 2023
907a9a2
fix files-not-closed bug
gnwong Oct 3, 2023
f7c9e52
unsigned integers cannot be negative
gnwong Oct 4, 2023
6660d64
add polar emission source histogram support for meshblock grids
gnwong Oct 14, 2023
bf4a48a
two's complement
gnwong Oct 18, 2023
f312cbe
update histogram to be 3d when desired
gnwong Nov 15, 2023
e88fc77
changed mac compilation to gcc13 with homebrew
avjoshi21 Dec 14, 2023
9631592
Update README.md
avjoshi21 Dec 14, 2023
cac8e8a
fix maybe-uninitialized warnings in symphony module
gnwong Mar 11, 2024
fec6a3d
fix FOV bug when plotting in GM/c^2
gnwong Mar 12, 2024
0f77361
Update README.md (#96)
cfgammie Jun 25, 2024
c01c3c8
Added BSD 3 License
avjoshi21 Nov 20, 2024
3c87d33
Merge pull request #98 from AFD-Illinois/avjoshi21-license
avjoshi21 Nov 20, 2024
09514b0
Fix setting final dump time in slow light
Feb 3, 2025
6571188
Update ipolarray.c
gnwong Mar 10, 2025
a224950
Update par.c
gnwong Mar 10, 2025
73ba7e4
Merge master
vedantdhruv96 Mar 12, 2025
e674835
initial commit
vedantdhruv96 Mar 12, 2025
e9d96c4
functions to read time, and attributes in the Info group more general…
vedantdhruv96 Mar 12, 2025
66c6917
modified par file parsing for block-based search
vedantdhruv96 Mar 13, 2025
10777b8
read parameters and set grid
vedantdhruv96 Mar 13, 2025
7295074
init_storage
vedantdhruv96 Mar 13, 2025
340b0e9
set_units
vedantdhruv96 Mar 13, 2025
d6278d3
set_tinterp_ns
vedantdhruv96 Mar 13, 2025
8e1a575
init storage
vedantdhruv96 Mar 13, 2025
d5386fd
load_kharma_data: read data from dump and assemble mesh
vedantdhruv96 Mar 14, 2025
2883434
populate ghost zones
vedantdhruv96 Mar 14, 2025
1a9e3a7
init physical quantities
vedantdhruv96 Mar 14, 2025
ba25691
function declarations
vedantdhruv96 Mar 14, 2025
6656573
compiles
vedantdhruv96 Mar 14, 2025
86bbb5a
compiles and reads dump prims
vedantdhruv96 Mar 15, 2025
352e51c
coordinates extern variables. don't need in model.c
vedantdhruv96 Mar 15, 2025
f6d12bf
more global variables to keep in mind
vedantdhruv96 Mar 15, 2025
939f19a
function name typo
vedantdhruv96 Mar 15, 2025
5d5d280
debug kharma reader
vedantdhruv96 Mar 23, 2025
106c8f9
pointers and stuff
vedantdhruv96 Mar 23, 2025
065831a
double precision for default gam_e, gam_p. model/iharm should not be …
vedantdhruv96 Mar 24, 2025
322af3a
default to non-debug mode for reader
vedantdhruv96 Mar 24, 2025
59f6dc8
electrons reader
vedantdhruv96 Mar 29, 2025
b22ed19
Fix reader and print model name
vedantdhruv96 Mar 30, 2025
2b0f413
Rhigh is default, i.e., USE_MIXED_TPTE (1). Electrons imager works!
vedantdhruv96 Mar 30, 2025
abae96a
enum used while reading entropy
vedantdhruv96 Mar 30, 2025
07c9cfa
KHARMA reader can now read old v5 output format
vedantdhruv96 Apr 4, 2025
dcfc533
save time out image.h5
vedantdhruv96 Apr 4, 2025
0ca88a2
unneccesary comment
vedantdhruv96 Apr 4, 2025
8157696
reset default makefile variable
avjoshi21 Apr 4, 2025
5a681b1
Merge pull request #101 from AFD-Illinois/feature/kharma
vedantdhruv96 Apr 4, 2025
f7807cf
Handle old format better
vedantdhruv96 May 1, 2025
53f30f0
reset default model to iharm for pr
avjoshi21 May 2, 2025
fbe2da3
Merge pull request #102 from AFD-Illinois/feature/kharma fixing issue…
avjoshi21 May 2, 2025
8e3d50e
write a fluid header for the KHARMA reader
vedantdhruv96 May 9, 2025
0da4db3
default to iharm problem
vedantdhruv96 May 9, 2025
a577724
Merge branch 'feature/kharma' of github.com:AFD-Illinois/ipole into f…
vedantdhruv96 May 9, 2025
8b702a6
fix compile on ias/callisto for new default configuration
gnwong Jun 9, 2025
5746cd5
resuppress linker output in makefile
gnwong Jun 9, 2025
3ce36da
Merge pull request #104 from gnwong/master
gnwong Jun 9, 2025
80b8c4e
batch reads for meshblock model for improved speed at binary load time
gnwong Jun 9, 2025
70a25ab
fixed fluid header
vedantdhruv96 Jun 15, 2025
905f05d
Merge pull request #103 from AFD-Illinois/feature/kharma
avjoshi21 Jun 15, 2025
a3ab26c
commented model.c
cfgammie Aug 16, 2025
2a71fe5
commented model.c
cfgammie Aug 16, 2025
ebb8761
added message to kharma model.c
avjoshi21 Aug 16, 2025
e01ee2d
Merge branch 'master' into cfgammie-patch-2
avjoshi21 Aug 16, 2025
fffa48f
Merge pull request #106 from AFD-Illinois/cfgammie-patch-2
avjoshi21 Aug 16, 2025
e933ec1
add more detailed profiling. also add omp pragma over boundary condit…
gnwong Aug 23, 2025
ab07203
Merge remote-tracking branch 'origin/master' into feature/fastloadbin
gnwong Aug 23, 2025
fd2d4e4
Merge pull request #105 from AFD-Illinois/feature/fastloadbin
gnwong Aug 23, 2025
a02ab2a
added Xtoijk_ghost and put in interpolate routine. untested
avjoshi21 Aug 23, 2025
d0202c7
fixed increment to ijk in Xtoijk_ghost
avjoshi21 Aug 23, 2025
8db14e3
better comments
avjoshi21 Aug 23, 2025
fdd4688
fixed ijk to be set to 0 if computed to be -1
avjoshi21 Aug 23, 2025
e4a6d29
Merge pull request #107 from AFD-Illinois/fix/Xtoijk-clarification
avjoshi21 Aug 23, 2025
3b5a0e4
suppress unused warning
gnwong Aug 24, 2025
6eafbe3
unset default SYSTEM_LIBDIR from makefile as it does more harm than good
avjoshi21 Feb 5, 2026
d13f720
Merge pull request #87 from AFD-Illinois/fix/test-scripts
avjoshi21 Feb 5, 2026
4564a61
Merge pull request #93 from AFD-Illinois/feature/compilemac
avjoshi21 Feb 5, 2026
e5809ed
Merge pull request #99 from AFD-Illinois/fix/slow-light-init
avjoshi21 Feb 5, 2026
ece23a5
removed hard coded paths from delta machine file
avjoshi21 Feb 13, 2026
cbbc370
corrected tf for kharma model based on pr#99
avjoshi21 Feb 13, 2026
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ test-resources
*.ppm
*.mp4
*.vtk

# vscode
.vscode/*
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2024, AFD Group at UIUC

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ $ sudo dnf install hdf5-devel hdf5-static gsl-devel
```
The packages are straightforward to compile from source as well.

To install ipole on macOS using ```gcc``` via homebrew, install
```bash
$ brew install gcc@13 hdf5 gsl
```

The native macOS version of ```clang``` does not support OpenMP parallelization, so on macOS with ```brew```, install
```bash
$ brew install llvm gsl hdf5
```
these should all be binary packages, no compiling should be required.
For the clang installation, change the ```HDF5_CC```, ```HDF5_CLINKER``` and ```GSL_DIR``` variables in the makefile. Please raise an issue in the event that neither of these methods work on macOS.

# Building

Expand Down Expand Up @@ -139,11 +145,11 @@ polarized transfer equation assuming constant coefficients. This
is intended to produce sensible results even when absorption or Faraday rotation
and conversion are large in a single step. A comparison of
polarized relativistic radiative transport schemes can be found in
Prather (2021, in prep).
Prather [2023](https://ui.adsabs.harvard.edu/abs/2023ApJ...950...35P/abstract).

If you are imaging GRMHD simulations, you will find guidance on how a GRMHD
simulation and analysis pipeline fits together in the PATOKA pipeline paper,
Wong (2021, in prep).
Wong [2022](https://ui.adsabs.harvard.edu/abs/2022ApJS..259...64W/abstract).

```ipole``` treats synchrotron emission and absorption but not bremsstrahlung or Compton
scattering. The transfer coefficients (emissivities, absorptivities, and rotativities)
Expand Down
5 changes: 5 additions & 0 deletions machines/callisto.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GSL_DIR = /opt/sns/gsl/gcc-4.8.5/2.5/

CFLAGS_CUSTOM += -I$(GSL_DIR)/include
SYSTEM_LIBDIR += -L$(GSL_DIR)/lib
MATH_LIB += -lgsl -lgslcblas -lm
34 changes: 34 additions & 0 deletions machines/delta.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Before building, make sure you have got the required modules,
# and have set the appropriate paths
#
# 1. Load gsl.
# `module load gsl`
#
# 2. Update LD_LIBRARY_PATH so that ipole knows where to look for shared libraries.
# `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/gsl-2.7.1-ytg74v2/lib`
#
# 3. Download and compile your own HDF5 (Delta's HDF5 is perpetually broken).
# `mkdir -p ~/software/hdf5; cd ~/software/hdf5`
# `wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.2/src/hdf5-1.12.2.tar.gz`
# `tar -xvzf hdf5-1.12.2.tar.gz`
# `cd hdf5-1.12.2`
# `module load gcc`
# `module load cmake`
# `mkdir build; cd build`
# `cmake -DCMAKE_INSTALL_PREFIX=~/software/hdf5/install -DBUILD_SHARED_LIBS=ON ..`
# `make -j$(nproc)`
# `make install`
#
# 4. Set environment variables for custom HDF5
# `export HDF5_DIR=$HOME/software/hdf5/install`
# `export PATH=$HDF5_DIR/bin:$PATH`
# `export LD_LIBRARY_PATH=$HDF5_DIR/lib:$LD_LIBRARY_PATH`
# `export CPATH=$HDF5_DIR/include:$CPATH`

CC=h5cc
GSL_DIR=$(GSL_HOME)
#assumes you have loaded cray-hdf5 module which automatically sets HDF5_DIR
HDF5_DIR=$(HDF5_ROOT)

CFLAGS = -march=native -mtune=native -std=gnu11 -O3 -flto -fopenmp -funroll-loops
$(info Using Delta settings: remember to prepend GSL lib location $(GSL_HOME)/lib to LD_LIBRARY_PATH for runtime)
15 changes: 11 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ HDF5_DIR =
GSL_DIR =
# System /lib equivalent (can be /usr/lib, /lib64, /usr/lib64)
# Can leave this blank if it's included automatically by GCC
SYSTEM_LIBDIR = /lib64
#SYSTEM_LIBDIR = /lib64
SYSTEM_LIBDIR =

# Try pointing this to h5pcc or h5cc on your machine, before hunting down libraries
CC=h5cc
Expand All @@ -27,10 +28,10 @@ ECHO=echo -e

# Overrides of the above for macOS
ifneq (,$(findstring Darwin,$(shell uname)))
export HDF5_CC = /usr/local/opt/llvm/bin/clang
export HDF5_CLINKER = /usr/local/opt/llvm/bin/clang
export HDF5_CC = /opt/homebrew/bin/gcc-13
export HDF5_CLINKER = /opt/homebrew/bin/gcc-13

GSL_DIR=/usr/local
GSL_DIR=/opt/homebrew/opt/gsl
SYSTEM_LIBDIR=

MD5=md5
Expand All @@ -47,6 +48,12 @@ endif
ifneq (,$(findstring frontera,$(HOST)))
-include $(MAKEFILE_PATH)/machines/frontera.make
endif
ifneq (,$(findstring delta,$(HOST)))
-include $(MAKEFILE_PATH)/machines/delta.make
endif
ifneq (,$(findstring callisto,$(HOST)))
-include $(MAKEFILE_PATH)/machines/callisto.make
endif
# Hack to check only whether host begins with bh*
ifneq (,$(findstring beginsbh,begins$(HOST)))
-include $(MAKEFILE_PATH)/machines/bh-cluster.make
Expand Down
4 changes: 4 additions & 0 deletions model/iharm/example.par
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ trace 0
trace_stride 1
# Trace file name
trace_outf trace.h5

# Histogram of origin of observed emissivity
histo 0
histo_outf histo.h5
68 changes: 64 additions & 4 deletions model/iharm/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static double mu_i, mu_e, mu_tot;

// MODEL PARAMETERS: PUBLIC
double DTd;
double sigma_cut = 1.0;
double sigma_cut = 1.;
double beta_crit = 1.0;
double sigma_cut_high = -1.0;

Expand All @@ -71,7 +71,8 @@ static double Ladv_dump;

static int reverse_field = 0;

double tf;
// Need to share this with main.c!
extern double tf;

// MAYBES
//static double t0;
Expand All @@ -85,7 +86,7 @@ double tf;
// TODO the way this is selected is horrid. Make it a parameter.
#define ELECTRONS_TFLUID (3)
static int RADIATION, ELECTRONS;
static double gam = 1.444444, game = 1.333333, gamp = 1.666667;
static double gam = 1.444444444444444, game = 1.333333333333333, gamp = 1.666666666666667;
static double Thetae_unit, Mdotedd;

// Ignore radiation interactions within one degree of polar axis
Expand All @@ -96,6 +97,10 @@ static int nloaded = 0;

static hdf5_blob fluid_header = { 0 };


// Debug KHARMA reader
#define DEBUG_READER (0)

struct of_data {
double t;
double ****p;
Expand Down Expand Up @@ -328,6 +333,59 @@ void init_model(double *tA, double *tB)
th_beg = 0.0174 * 2;
}
}

#if DEBUG_READER
/* Set filename */
char debug_fname[256];
snprintf(debug_fname, sizeof(debug_fname), "debug_reader_iharm.h5");

/* Create HDF5 file*/
hdf5_create(debug_fname);

/* Compute gcov, gcon */
size_t total_elements = NDIM * NDIM * (N2 + 2) * (N1 + 2);
double *gcov_global = malloc(total_elements * sizeof(double));
double *gcon_global = malloc(total_elements * sizeof(double));
// Use the arrays via indexing. For example, to access element [mu][nu][j][i]:
#define IDX(mu, nu, j, i) (((mu) * NDIM * (N2+2) * (N1+2)) + ((nu) * (N2+2) * (N1+2)) + ((j) * (N1+2)) + (i))

#pragma omp parallel for collapse(2)
for (int i = 0; i < N1+2; i++) {
for (int j = 0; j < N2+2; j++) {

double X[NDIM] = {0.};
ijktoX(i, j, 0, X);
double gcov[NDIM][NDIM], gcon[NDIM][NDIM];
gcov_func(X, gcov);
gcon_func(gcov, gcon);

for (int mu = 0; mu < NDIM; mu++) {
for (int nu = 0; nu < NDIM; nu++) {
gcov_global[IDX(mu, nu, j, i)] = gcov[mu][nu];
gcon_global[IDX(mu, nu, j, i)] = gcon[mu][nu];
}
}

}
}

/* Write gcov, gcon to file */
hsize_t dims_grid[4] = { NDIM, NDIM, N2+2, N1+2 };
hdf5_write_full_array(gcov_global, "gcov", 4, dims_grid, H5T_NATIVE_DOUBLE);
hdf5_write_full_array(gcon_global, "gcon", 4, dims_grid, H5T_NATIVE_DOUBLE);

/* Write physical quantities */
hsize_t dims_phys[3] = { N1+2, N2+2, N3+2 };
hdf5_write_full_array(data[0]->ne[0][0], "ne", 3, dims_phys, H5T_NATIVE_DOUBLE);
hdf5_write_full_array(data[0]->thetae[0][0], "thetae", 3, dims_phys, H5T_NATIVE_DOUBLE);
hdf5_write_full_array(data[0]->b[0][0], "b", 3, dims_phys, H5T_NATIVE_DOUBLE);
hdf5_write_full_array(data[0]->sigma[0][0], "sigma", 3, dims_phys, H5T_NATIVE_DOUBLE);
hdf5_write_full_array(data[0]->beta[0][0], "beta", 3, dims_phys, H5T_NATIVE_DOUBLE);

/* Close HDF5 file */
hdf5_close();

#endif // DEBUG_READER
}

/*
Expand Down Expand Up @@ -566,6 +624,8 @@ void init_physical_quantities(int n, double rescale_factor)

data[n]->b[i][j][k] *= rescale_factor;

// here b is in gauss; this takes it back to code units to
// calculate beta and sigma
double bsq = data[n]->b[i][j][k] / B_unit;
bsq = bsq*bsq;

Expand Down Expand Up @@ -862,7 +922,7 @@ void init_iharm_grid(char *fnam, int dumpidx)
hdf5_read_single_val(&N3, "n3", H5T_STD_I32LE);
hdf5_read_single_val(&gam, "gam", H5T_IEEE_F64LE);

if (hdf5_exists("gam_e")) {
if (hdf5_exists("gam_e")) { /* pyharm-converted files save gam_e, gam_p even when electrons are not run. Which overwrites the default values*/
fprintf(stderr, "custom electron model loaded from dump file...\n");
hdf5_read_single_val(&game, "gam_e", H5T_IEEE_F64LE);
hdf5_read_single_val(&gamp, "gam_p", H5T_IEEE_F64LE);
Expand Down
83 changes: 83 additions & 0 deletions model/kharma/example.par
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# example.par -- ipole example parameter file for iharm problem

# Common
dump tests/test-resources/sample_dump_SANE_a+0.94_MKS_0900.h5
outfile image.h5
nx 160
ny 160

# Emission 1=Pandya, 4=Dexter, others are debug/custom
emission_type 4

# M87 parameters
MBH 6.2e9
dsource 16.9e6
freqcgs 230.e9
# M_unit scales the accretion rate to match a known object flux
# These are example values
# SANE:
M_unit 3e26
# MAD:
#M_unit 6e24

# e- Temperature, via the Rhigh model described
trat_small 1
trat_large 20
# Constant e- temperature ratio
#tp_over_te 3

# Adaptive res
# enable by setting a minimum "base" image size
#nx_min 40
#ny_min 40
refine_abs = 2e-2
refine_rel = 1e-2
refine_cut = 0

# Camera
rcam 1000
# Values in degrees
thetacam 17
phicam 0
rotcam 0

# FOV from Earth
fovx_dsource 160
fovy_dsource 160

# Geodesic accuracy parameters
#eps 0.01
#maxnstep 50000

# Options
# Convention for EVPA defining stokes Q,U:
# 0 is measured East of North, 1 is North of West
qu_conv 0
# Don't produce an output file
quench_output 0
# Add a .ppm image of the unpolarized flux
add_ppm 0
# Only calculate the unpolarized image
only_unpolarized 0
# 1 to emit only for th>PI/2, 2 for other hemisphere
# 0 emits everywhere
counterjet 0
# Offset for each geodesic in pixels, used to prevent
# overtraining ML models to pixel locations
xoff 0
yoff 0

# Path trace -- save emissivities & local state
# for every step along a geodesic, or several
trace 0
# Pixel to trace i,j (rightward from left, upward from bottom)
#trace_i 40
#trace_j 40
# Or trace every N pixels in each direction
trace_stride 1
# Trace file name
trace_outf trace.h5

# Histogram of origin of observed emissivity
histo 0
histo_outf histo.h5
Loading