Skip to content

Commit 9e153ee

Browse files
authored
freezing tests volume-to-mass refactor. closes #1262 (#1358)
1 parent f44d88b commit 9e153ee

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/unit_tests/backends/test_freezing_methods.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from PySDM import Builder, Formulae
77
from PySDM.dynamics import Freezing
88
from PySDM.environments import Box
9-
from PySDM.physics import constants_defaults as const
109
from PySDM.physics import si
1110
from PySDM.products import IceWaterContent
1211

@@ -68,7 +67,7 @@ def test_freeze_singular(backend_class):
6867
dt = 1 * si.s
6968
dv = 1 * si.m**3
7069
T_fz = 250 * si.K
71-
vol = 1 * si.um**3
70+
water_mass = 1 * si.mg
7271
multiplicity = 1e10
7372
steps = 1
7473

@@ -81,7 +80,7 @@ def test_freeze_singular(backend_class):
8180
attributes = {
8281
"multiplicity": np.full(n_sd, multiplicity),
8382
"freezing temperature": np.full(n_sd, T_fz),
84-
"volume": np.full(n_sd, vol),
83+
"water mass": np.full(n_sd, water_mass),
8584
}
8685
products = (IceWaterContent(name="qi"),)
8786
particulator = builder.build(attributes=attributes, products=products)
@@ -92,9 +91,10 @@ def test_freeze_singular(backend_class):
9291
particulator.run(steps=steps)
9392

9493
# assert
95-
np.testing.assert_almost_equal(
96-
np.asarray(particulator.products["qi"].get()),
97-
[n_sd * multiplicity * vol * const.rho_w / dv],
94+
np.testing.assert_approx_equal(
95+
actual=np.asarray(particulator.products["qi"].get()),
96+
desired=n_sd * multiplicity * water_mass / dv,
97+
significant=7,
9898
)
9999

100100
@staticmethod
@@ -123,7 +123,7 @@ def test_freeze_time_dependent(backend_class, double_precision, plot=False):
123123
)
124124

125125
# dummy (but must-be-set) values
126-
vol = (
126+
initial_water_mass = (
127127
44 # for sign flip (ice water has negative volumes), value does not matter
128128
)
129129
d_v = 666 # products use conc., dividing there, multiplying here, value does not matter
@@ -165,7 +165,7 @@ def low(t):
165165
attributes = {
166166
"multiplicity": np.full(n_sd, int(case["N"])),
167167
"immersed surface area": np.full(n_sd, immersed_surface_area),
168-
"volume": np.full(n_sd, vol),
168+
"water mass": np.full(n_sd, initial_water_mass),
169169
}
170170
particulator = builder.build(attributes=attributes, products=products)
171171
env["RH"] = 1.0001
@@ -178,7 +178,7 @@ def low(t):
178178

179179
ice_mass_per_volume = particulator.products["qi"].get()[cell_id]
180180
ice_mass = ice_mass_per_volume * d_v
181-
ice_number = ice_mass / (const.rho_w * vol)
181+
ice_number = ice_mass / initial_water_mass
182182
unfrozen_fraction = 1 - ice_number / number_of_real_droplets
183183
output[key]["unfrozen_fraction"].append(unfrozen_fraction)
184184

0 commit comments

Comments
 (0)