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

Before August, KHARMA did not normalize face-centered field initialization #110

Closed
bprather opened this issue Aug 1, 2024 · 2 comments
Closed

Comments

@bprather
Copy link
Contributor

bprather commented Aug 1, 2024

When initializing B, KHARMA has an option beta_min, which sets the ratio of the maximum pressure to maximum magnetic pressure to a desired value by renormalizing the magnetic field.
When running with face-centered fields b_field/solver = face_ct, this fails to happen. The normalization is applied to the cell-centered magnetic field representation, which was subsequently replaced by the (non-normalized) averaged face-centered field.

This is fixed in a branch, PR today. Hopefully I can add a test comparing KHARMA's FM torus initialization to pyharm's independent implementation to avoid any similar errors in the future.

It remains to assess the extent of the damage. Happily, un-normalized aligned MAD simulations at gamma=5/3 (relevant for the very expensive INCITE runs) all have beta_min ~ 40, which is not unusable so long as we record this. SANEs fall around ~130-150. I have checked, and this does not affect Illinois v5 simulations -- it is limited to simulations using face_ct magnetic fields, all more recent than anything in what I'd call widespread "production" use.

If you have pyharm installed, you can use a short script to verify what your actual beta_min turned out to be:

#!/usr/bin/env python3

import sys
import numpy as np
import pyharm

dump = pyharm.load_dump(sys.argv[1])

Pg_max = np.max(dump['Pg'])
print("Gas pressure max: ", np.max(dump['Pg']))
Pb_max = np.max(dump['Pb'])
print("Mag. pressure max: ", np.max(dump['Pb']))
print("beta_min: ", Pg_max/Pb_max)

I now have tables of the common values at gamma=5/3 and with the usual MAD torus size of rin=20 r_g, rmax=41 r_g if these would be useful. The starting values for different runs with the same physical parameters agree to about 0.1% relative error, as one might hope.

@bprather
Copy link
Contributor Author

bprather commented Aug 1, 2024

The particular ratio of the un-normalized field is very dependent on torus size and adiabatic index, as one might suspect, but not too much on spin.

Indexes and sizes at spin 0.9375:

12/24 G5/3 7.328340434092419
20/41 G13/9 32.798673249803585
20/41 G1.65 45.97006872447211
20/41 G1.6 43.139474342430056
20/41 G4/3 24.149477307464718
20/41 G5/3 46.86564316290881
40/80 G5/3 499.7851368492688
40/80 G5/3 (lower res) 494.7122346366759

Spins at gamma=5/3 20/41:

MAD -0.125 42.20982131423358
MAD 0.125 43.166460300895956
MAD -0.25 41.70337498842309
MAD 0.25 43.62106378779599
MAD -0.5 40.662107072927505
MAD 0.5 44.48529252304539
MAD -0.75 39.58821345093395
MAD 0.75 45.29844988956158
MAD -0.9375 38.70490073540681
MAD 0.9375 45.841224343122306
MAD 0 42.696306777060705

@bprather bprather changed the title KHARMA does not normalize face-centered field initialization Before August, KHARMA did not normalize face-centered field initialization Aug 2, 2024
@bprather bprather pinned this issue Aug 2, 2024
@bprather
Copy link
Contributor Author

This is fixed in the "oldstable" 2024.5.1 and stable 2024.9, so I'm closing it. This needs to be kept in mind for simulations which began in July or earlier, though, notably for the Illinois library on Frontier.

@bprather bprather unpinned this issue Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant