Skip to content

Commit

Permalink
Fix component labels in agn tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed May 5, 2023
1 parent 15cc60d commit b38c4a6
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,69 +345,69 @@ def accretion_mask(Z, Y, X, inner_state, outer_state):
return False

initial_analytic_components = {
"Density": lambda Z, Y, X, time: np.ones_like(Z)
"cons_Density": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_rho.in_units("code_mass/code_length**3").v,
"MomentumDensity1": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity1": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_Mx.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"MomentumDensity2": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity2": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_My.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"MomentumDensity3": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity3": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_Mz.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"TotalEnergyDensity": lambda Z, Y, X, time: np.ones_like(Z)
"cons_TotalEnergyDensity": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_energy_density.in_units(
"code_mass*code_length**-1*code_time**-2"
).v,
"Velocity1": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity1": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_ux.in_units("code_length*code_time**-1").v,
"Velocity2": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity2": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_uy.in_units("code_length*code_time**-1").v,
"Velocity3": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity3": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_uz.in_units("code_length*code_time**-1").v,
"Pressure": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Pressure": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_pres.in_units(
"code_mass/(code_length*code_time**2)"
).v,
}

final_analytic_components = {
"Density": lambda Z, Y, X, time: accretion_mask(
"cons_Density": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_rho, self.uniform_gas_rho
)
.in_units("code_mass/code_length**3")
.v,
"MomentumDensity1": lambda Z, Y, X, time: accretion_mask(
"cons_MomentumDensity1": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_Mx, self.uniform_gas_Mx
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"MomentumDensity2": lambda Z, Y, X, time: accretion_mask(
"cons_MomentumDensity2": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_My, self.uniform_gas_My
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"MomentumDensity3": lambda Z, Y, X, time: accretion_mask(
"cons_MomentumDensity3": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_Mz, self.uniform_gas_Mz
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"TotalEnergyDensity": lambda Z, Y, X, time: accretion_mask(
"cons_TotalEnergyDensity": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_energy_density, self.uniform_gas_energy_density
)
.in_units("code_mass*code_length**-1*code_time**-2")
.v,
"Velocity1": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity1": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_ux.in_units("code_length*code_time**-1").v,
"Velocity2": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity2": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_uy.in_units("code_length*code_time**-1").v,
"Velocity3": lambda Z, Y, X, time: np.ones_like(Z)
"prim_Velocity3": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_uz.in_units("code_length*code_time**-1").v,
"Pressure": lambda Z, Y, X, time: accretion_mask(
"prim_Pressure": lambda Z, Y, X, time: accretion_mask(
Z, Y, X, final_pres, self.uniform_gas_pres
)
.in_units("code_mass/(code_length*code_time**2)")
Expand Down
14 changes: 8 additions & 6 deletions tst/regression/test_suites/cluster_hse/cluster_hse.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,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)
Expand Down Expand Up @@ -441,8 +441,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,48 +420,48 @@ def agn_feedback(Z, Y, X, dt):
return False

initial_analytic_components = {
"Density": lambda Z, Y, X, time: np.ones_like(Z)
"cons_Density": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_rho.in_units("code_mass/code_length**3").v,
"MomentumDensity1": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity1": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_Mx.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"MomentumDensity2": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity2": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_My.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"MomentumDensity3": lambda Z, Y, X, time: np.ones_like(Z)
"cons_MomentumDensity3": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_Mz.in_units(
"code_mass*code_length**-2*code_time**-1"
).v,
"TotalEnergyDensity": lambda Z, Y, X, time: np.ones_like(Z)
"cons_TotalEnergyDensity": lambda Z, Y, X, time: np.ones_like(Z)
* self.uniform_gas_energy_density.in_units(
"code_mass*code_length**-1*code_time**-2"
).v,
}

final_analytic_components = {
"Density": lambda Z, Y, X, time: (
"cons_Density": lambda Z, Y, X, time: (
self.uniform_gas_rho + agn_feedback(Z, Y, X, time)[0]
)
.in_units("code_mass/code_length**3")
.v,
"MomentumDensity1": lambda Z, Y, X, time: (
"cons_MomentumDensity1": lambda Z, Y, X, time: (
self.uniform_gas_Mx + agn_feedback(Z, Y, X, time)[1]
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"MomentumDensity2": lambda Z, Y, X, time: (
"cons_MomentumDensity2": lambda Z, Y, X, time: (
self.uniform_gas_My + agn_feedback(Z, Y, X, time)[2]
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"MomentumDensity3": lambda Z, Y, X, time: (
"cons_MomentumDensity3": lambda Z, Y, X, time: (
self.uniform_gas_Mz + agn_feedback(Z, Y, X, time)[3]
)
.in_units("code_mass*code_length**-2*code_time**-1")
.v,
"TotalEnergyDensity": lambda Z, Y, X, time: (
"cons_TotalEnergyDensity": lambda Z, Y, X, time: (
self.uniform_gas_energy_density + agn_feedback(Z, Y, X, time)[4]
)
.in_units("code_mass*code_length**-1*code_time**-2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ def B_scaled_linf_err(gold, test, B0):
# Construct lambda functions for initial and final analytically
# expected density and total energy density
densities_analytic_components = {
"Density": lambda Z, Y, X, time: density_func(Z, Y, X, rho0)
"cons_Density": lambda Z, Y, X, time: density_func(Z, Y, X, rho0)
.in_units("code_mass*code_length**-3")
.v,
"TotalEnergyDensity": lambda Z, Y, X, time: (
"cons_TotalEnergyDensity": lambda Z, Y, X, time: (
internal_energy_density_func(Z, Y, X, rho0)
+ b_energy_func(Z, Y, X, B_field)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_Velocity1": 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_Velocity2": 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_Velocity3": 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,
}
Expand Down Expand Up @@ -356,7 +366,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,
Expand Down

0 comments on commit b38c4a6

Please sign in to comment.