Skip to content

Commit

Permalink
Fix some EMHD stuff
Browse files Browse the repository at this point in the history
Not all flag names were updated "EMHD"->"EMHDVar", I suspect a merge
somewhere regressed that.
Also fix some more scripts
  • Loading branch information
Ben Prather committed Oct 5, 2023
1 parent 802bdb2 commit 26cf7f1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
10 changes: 6 additions & 4 deletions kharma/emhd/emhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ std::shared_ptr<KHARMAPackage> Initialize(ParameterInput *pin, std::shared_ptr<P
// EMHD is supported only with imex driver and implicit evolution,
// synchronizing primitive variables
Metadata::AddUserFlag("EMHDVar"); // "EMHD" name now taken by Parthenon for general flag, we want this one specific
std::vector<MetadataFlag> emhd_flags = {Metadata::Cell, Metadata::GetUserFlag("Implicit"), Metadata::GetUserFlag("EMHD")};
std::vector<MetadataFlag> emhd_flags = {Metadata::Cell, Metadata::GetUserFlag("Implicit"), Metadata::GetUserFlag("EMHDVar")};

auto flags_prim = packages->Get("Driver")->Param<std::vector<MetadataFlag>>("prim_flags");
flags_prim.insert(flags_prim.end(), emhd_flags.begin(), emhd_flags.end());
Expand Down Expand Up @@ -185,8 +185,9 @@ void BlockUtoP(MeshBlockData<Real> *rc, IndexDomain domain, bool coarse)
{
auto pmb = rc->GetBlockPointer();

// Get only relevant cons, but all prims as we need the Lorentz factor
PackIndexMap prims_map, cons_map;
auto U_E = rc->PackVariables(std::vector<MetadataFlag>{Metadata::GetUserFlag("EMHD"), Metadata::Conserved}, cons_map);
auto U_E = rc->PackVariables(std::vector<MetadataFlag>{Metadata::GetUserFlag("EMHDVar"), Metadata::Conserved}, cons_map);
auto P = rc->PackVariables(std::vector<MetadataFlag>{Metadata::GetUserFlag("Primitive")}, prims_map);
const VarMap m_p(prims_map, false), m_u(cons_map, true);

Expand Down Expand Up @@ -217,9 +218,10 @@ void BlockPtoU(MeshBlockData<Real> *rc, IndexDomain domain, bool coarse)
{
auto pmb = rc->GetBlockPointer();

// Get only relevant cons, but all prims as we need the Lorentz factor
PackIndexMap prims_map, cons_map;
auto U_E = rc->PackVariables(std::vector<MetadataFlag>{Metadata::GetUserFlag("EMHDVar"), Metadata::Conserved}, cons_map);
auto P = rc->PackVariables(std::vector<MetadataFlag>{Metadata::GetUserFlag("Primitive")}, prims_map);
auto U_E = rc->PackVariables({Metadata::GetUserFlag("EMHDVar"), Metadata::Conserved}, cons_map);
auto P = rc->PackVariables({Metadata::GetUserFlag("Primitive")}, prims_map);
const VarMap m_p(prims_map, false), m_u(cons_map, true);

const auto& G = pmb->coords;
Expand Down
6 changes: 3 additions & 3 deletions tests/bz_monopole/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ BASE=../..
exit_code=0

# Full run to test stability to completion
$BASE/run.sh -i $BASE/pars/bz_monopole.par debug/verbose=1 parthenon/output0/single_precision_output=false >log_bz_monopole_full.txt 2>&1 #|| exit_code=$?
$BASE/run.sh -i $BASE/pars/tests/bz_monopole.par debug/verbose=1 parthenon/output0/single_precision_output=false >log_bz_monopole_full.txt 2>&1 || exit_code=$?

# At *least* check divB
pyharm-check-basics bz_monopole.out0.final.phdf || exit_code=$?

# Take 1 step to look for early signs of non-fatal instabilities
$BASE/run.sh -i $BASE/pars/bz_monopole.par parthenon/time/nlim=1 parthenon/output0/dt=0.0 parthenon/output0/single_precision_output=false >log_bz_monopole_step.txt 2>&1 #|| exit_code=$?
$BASE/run.sh -i $BASE/pars/tests/bz_monopole.par parthenon/time/nlim=1 parthenon/output0/dt=0.0 parthenon/output0/single_precision_output=false >log_bz_monopole_step.txt 2>&1 #|| exit_code=$?

# Check is for plots only!
# This just makes plots, it doesn't check anything
python ./check.py
4 changes: 2 additions & 2 deletions tests/conducting_atmosphere/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ conv_2d() {
for res in "${RES_LIST[@]}"
do
cp conducting_atmosphere_${res}_default/atmosphere_soln_*.txt .
$BASE/run.sh -n 1 -i $BASE/pars/conducting_atmosphere.par debug/verbose=1 \
$BASE/run.sh -n 1 -i ./conducting_atmosphere.par debug/verbose=1 \
parthenon/time/tlim=200 parthenon/output0/dt=1000000 \
parthenon/mesh/nx1=$res parthenon/mesh/nx2=$res parthenon/mesh/nx3=1 \
parthenon/meshblock/nx1=$res parthenon/meshblock/nx2=$res parthenon/meshblock/nx3=1 \
Expand All @@ -35,4 +35,4 @@ conv_2d() {
}

ALL_RES="64,128,256,512"
conv_2d emhd2d_weno GRMHD/reconstruction=weno5 "in 2D, WENO5"
conv_2d emhd2d_weno driver/reconstruction=weno5 "in 2D, WENO5"
14 changes: 7 additions & 7 deletions tests/emhdshock/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if __name__=='__main__':
outputdir = './'
kharmadir = '/home/vdhruv2/kharma'
kharmadir = '../../'
RES = [int(r) for r in sys.argv[1].split(",")]

CONDUCTION = 1
Expand All @@ -25,13 +25,13 @@
for r, res in enumerate(RES):

# load analytic result
rho_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_rho.txt'))
u_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_u.txt'))
u1_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_u1.txt'))
rho_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_rho.txt'))
u_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_u.txt'))
u1_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_u1.txt'))
if CONDUCTION:
q_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_q.txt'))
dP_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_dP.txt'))
x_analytic = np.loadtxt(os.path.join(kharmadir, 'kharma/prob/emhd/', 'shock_soln_{}_default'.format(res), 'shock_soln_xCoords.txt'))
q_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_q.txt'))
dP_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_dP.txt'))
x_analytic = np.loadtxt(os.path.join(outputdir, 'shock_soln_{}_default'.format(res), 'shock_soln_xCoords.txt'))

# load code data
dfile = h5py.File('emhd_1d_{}_end.h5'.format(res), 'r')
Expand Down
7 changes: 1 addition & 6 deletions tests/emhdshock/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

# Run checks against analytic result for specified tests

. /home/vdhruv2/anaconda3/etc/profile.d/conda.sh
conda activate pyharm

# Very small amplitude by default, preserve double precision
~/pyHARM/scripts/pyharm-convert --double *.phdf
pyharm convert --double *.phdf

RES1D="256,512,1024,2048"

conda activate base

fail=0

python3 check.py $RES1D "EMHD shock" emhd1d || fail=1
Expand Down

0 comments on commit 26cf7f1

Please sign in to comment.