From 75e826c1d5df2ed9b962b25b942dc6af2ce3feb3 Mon Sep 17 00:00:00 2001 From: Philipp Grete Date: Mon, 8 May 2023 13:44:11 +0200 Subject: [PATCH] Bump Parthenon to include Ascent bug and fix output component labels (#60) --- external/parthenon | 2 +- src/hydro/hydro.cpp | 40 ++++++------ .../test_suites/cluster_hse/cluster_hse.py | 14 +++-- .../cluster_tabular_cooling.py | 62 +++++++------------ 4 files changed, 53 insertions(+), 65 deletions(-) diff --git a/external/parthenon b/external/parthenon index ad23761c..7da5c6a2 160000 --- a/external/parthenon +++ b/external/parthenon @@ -1 +1 @@ -Subproject commit ad23761c10528b86a7c2ed914c6798ad14607110 +Subproject commit 7da5c6a29792b47cff2411390d91ef2c8f386304 diff --git a/src/hydro/hydro.cpp b/src/hydro/hydro.cpp index 106a6ce3..6b6c5ee0 100644 --- a/src/hydro/hydro.cpp +++ b/src/hydro/hydro.cpp @@ -509,34 +509,34 @@ std::shared_ptr Initialize(ParameterInput *pin) { pkg->AddParam("nscalars", nscalars); std::vector cons_labels(nhydro); - cons_labels[IDN] = "Density"; - cons_labels[IM1] = "MomentumDensity1"; - cons_labels[IM2] = "MomentumDensity2"; - cons_labels[IM3] = "MomentumDensity3"; - cons_labels[IEN] = "TotalEnergyDensity"; + cons_labels[IDN] = "density"; + cons_labels[IM1] = "momentum_density_1"; + cons_labels[IM2] = "momentum_density_2"; + cons_labels[IM3] = "momentum_density_3"; + cons_labels[IEN] = "total_energy_density"; if (fluid == Fluid::glmmhd) { - cons_labels[IB1] = "MagneticField1"; - cons_labels[IB2] = "MagneticField2"; - cons_labels[IB3] = "MagneticField3"; - cons_labels[IPS] = "MagneticPhi"; + cons_labels[IB1] = "magnetic_field_1"; + cons_labels[IB2] = "magnetic_field_2"; + cons_labels[IB3] = "magnetic_field_3"; + cons_labels[IPS] = "magnetic_psi"; } // TODO(pgrete) check if this could be "one-copy" for two stage SSP integrators std::vector prim_labels(nhydro); - prim_labels[IDN] = "Density"; - prim_labels[IV1] = "Velocity1"; - prim_labels[IV2] = "Velocity2"; - prim_labels[IV3] = "Velocity3"; - prim_labels[IPR] = "Pressure"; + prim_labels[IDN] = "density"; + prim_labels[IV1] = "velocity_1"; + prim_labels[IV2] = "velocity_2"; + prim_labels[IV3] = "velocity_3"; + prim_labels[IPR] = "pressure"; if (fluid == Fluid::glmmhd) { - prim_labels[IB1] = "MagneticField1"; - prim_labels[IB2] = "MagneticField2"; - prim_labels[IB3] = "MagneticField3"; - prim_labels[IPS] = "MagneticPhi"; + prim_labels[IB1] = "magnetic_field_1"; + prim_labels[IB2] = "magnetic_field_2"; + prim_labels[IB3] = "magnetic_field_3"; + prim_labels[IPS] = "magnetic_psi"; } for (auto i = 0; i < nscalars; i++) { - cons_labels.emplace_back("Scalar_" + std::to_string(i)); - prim_labels.emplace_back("Scalar_" + std::to_string(i)); + cons_labels.emplace_back("scalar_density_" + std::to_string(i)); + prim_labels.emplace_back("scalar_" + std::to_string(i)); } Metadata m( diff --git a/tst/regression/test_suites/cluster_hse/cluster_hse.py b/tst/regression/test_suites/cluster_hse/cluster_hse.py index b86f858a..bc90b5f8 100644 --- a/tst/regression/test_suites/cluster_hse/cluster_hse.py +++ b/tst/regression/test_suites/cluster_hse/cluster_hse.py @@ -361,10 +361,10 @@ def rk4(f, y0, T): return False profile_comparison_vars = ( - (analytic_P, he_sphere_P, "Pressure"), - (analytic_K, he_sphere_K, "Entropy"), - (analytic_rho, he_sphere_rho, "Density"), - (analytic_g, he_sphere_g, "Gravity"), + (analytic_P, he_sphere_P, "pressure"), + (analytic_K, he_sphere_K, "entropy"), + (analytic_rho, he_sphere_rho, "density"), + (analytic_g, he_sphere_g, "gravity"), ) fig, axes = plt.subplots(2, 2) @@ -442,8 +442,10 @@ def analytic_gold(Z, Y, X, analytic_var): return analytic_interp analytic_components = { - "Pressure": lambda Z, Y, X, time: analytic_gold(Z, Y, X, analytic_P).v, - "Density": lambda Z, Y, X, time: analytic_gold(Z, Y, X, analytic_rho).v, + "prim_pressure": lambda Z, Y, X, time: analytic_gold(Z, Y, X, analytic_P).v, + "prim_density": lambda Z, Y, X, time: analytic_gold( + Z, Y, X, analytic_rho + ).v, } # Use a very loose tolerance, linf relative error diff --git a/tst/regression/test_suites/cluster_tabular_cooling/cluster_tabular_cooling.py b/tst/regression/test_suites/cluster_tabular_cooling/cluster_tabular_cooling.py index 7c8d78b3..c9eaa4f8 100644 --- a/tst/regression/test_suites/cluster_tabular_cooling/cluster_tabular_cooling.py +++ b/tst/regression/test_suites/cluster_tabular_cooling/cluster_tabular_cooling.py @@ -259,19 +259,29 @@ def Analyse(self, parameters): return False analytic_uniform_gas_components = { - "Density": lambda Z, Y, X, time: (np.ones_like(X) * self.uniform_gas_rho) + "prim_density": lambda Z, Y, X, time: ( + np.ones_like(X) * self.uniform_gas_rho + ) .in_units("code_mass*code_length**-3") .v, - "Velocity1": lambda Z, Y, X, time: (np.ones_like(X) * self.uniform_gas_ux) + "prim_velocity_1": lambda Z, Y, X, time: ( + np.ones_like(X) * self.uniform_gas_ux + ) .in_units("code_length*code_time**-1") .v, - "Velocity2": lambda Z, Y, X, time: (np.ones_like(X) * self.uniform_gas_uy) + "prim_velocity_2": lambda Z, Y, X, time: ( + np.ones_like(X) * self.uniform_gas_uy + ) .in_units("code_length*code_time**-1") .v, - "Velocity3": lambda Z, Y, X, time: (np.ones_like(X) * self.uniform_gas_uz) + "prim_velocity_3": lambda Z, Y, X, time: ( + np.ones_like(X) * self.uniform_gas_uz + ) .in_units("code_length*code_time**-1") .v, - "Pressure": lambda Z, Y, X, time: (np.ones_like(X) * self.uniform_gas_pres) + "prim_pressure": lambda Z, Y, X, time: ( + np.ones_like(X) * self.uniform_gas_pres + ) .in_units("code_mass*code_length**-1*code_time**-2") .v, } @@ -307,27 +317,15 @@ def zero_corrected_linf_err(gold, test): # FIXME: TODO(forrestglines) For now this is hard coded - a component mapping should be done by phdf prim_col_dict = { - "Density": 0, - "Velocity1": 1, - "Velocity2": 2, - "Velocity3": 3, - "Pressure": 4, + "density": 0, + "pressure": 4, } rho = unyt.unyt_array( - prim[:, prim_col_dict["Density"]], "code_mass*code_length**-3" - ) - ux = unyt.unyt_array( - prim[:, prim_col_dict["Velocity1"]], "code_length*code_time**-1" - ) - uy = unyt.unyt_array( - prim[:, prim_col_dict["Velocity2"]], "code_length*code_time**-1" - ) - uz = unyt.unyt_array( - prim[:, prim_col_dict["Velocity3"]], "code_length*code_time**-1" + prim[:, prim_col_dict["density"]], "code_mass*code_length**-3" ) pres = unyt.unyt_array( - prim[:, prim_col_dict["Pressure"]], + prim[:, prim_col_dict["pressure"]], "code_mass*code_length**-1*code_time**-2", ) @@ -356,7 +354,7 @@ def zero_corrected_linf_err(gold, test): { k: v for k, v in analytic_uniform_gas_components.items() - if k != "Pressure" + if k != "prim_pressure" }, err_func=zero_corrected_linf_err, tol=self.machine_epsilon, @@ -373,27 +371,15 @@ def zero_corrected_linf_err(gold, test): # FIXME: TODO(forrestglines) For now this is hard coded - a component mapping should be done by phdf prim_col_dict = { - "Density": 0, - "Velocity1": 1, - "Velocity2": 2, - "Velocity3": 3, - "Pressure": 4, + "density": 0, + "pressure": 4, } rho = unyt.unyt_array( - prim[prim_col_dict["Density"]], "code_mass*code_length**-3" - ) - ux = unyt.unyt_array( - prim[prim_col_dict["Velocity1"]], "code_length*code_time**-1" - ) - uy = unyt.unyt_array( - prim[prim_col_dict["Velocity2"]], "code_length*code_time**-1" - ) - uz = unyt.unyt_array( - prim[prim_col_dict["Velocity3"]], "code_length*code_time**-1" + prim[prim_col_dict["density"]], "code_mass*code_length**-3" ) pres = unyt.unyt_array( - prim[prim_col_dict["Pressure"]], + prim[prim_col_dict["pressure"]], "code_mass*code_length**-1*code_time**-2", )