6
6
from PySDM import Builder , Formulae
7
7
from PySDM .dynamics import Freezing
8
8
from PySDM .environments import Box
9
- from PySDM .physics import constants_defaults as const
10
9
from PySDM .physics import si
11
10
from PySDM .products import IceWaterContent
12
11
@@ -68,7 +67,7 @@ def test_freeze_singular(backend_class):
68
67
dt = 1 * si .s
69
68
dv = 1 * si .m ** 3
70
69
T_fz = 250 * si .K
71
- vol = 1 * si .um ** 3
70
+ water_mass = 1 * si .mg
72
71
multiplicity = 1e10
73
72
steps = 1
74
73
@@ -81,7 +80,7 @@ def test_freeze_singular(backend_class):
81
80
attributes = {
82
81
"multiplicity" : np .full (n_sd , multiplicity ),
83
82
"freezing temperature" : np .full (n_sd , T_fz ),
84
- "volume " : np .full (n_sd , vol ),
83
+ "water mass " : np .full (n_sd , water_mass ),
85
84
}
86
85
products = (IceWaterContent (name = "qi" ),)
87
86
particulator = builder .build (attributes = attributes , products = products )
@@ -92,9 +91,10 @@ def test_freeze_singular(backend_class):
92
91
particulator .run (steps = steps )
93
92
94
93
# 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 ,
98
98
)
99
99
100
100
@staticmethod
@@ -123,7 +123,7 @@ def test_freeze_time_dependent(backend_class, double_precision, plot=False):
123
123
)
124
124
125
125
# dummy (but must-be-set) values
126
- vol = (
126
+ initial_water_mass = (
127
127
44 # for sign flip (ice water has negative volumes), value does not matter
128
128
)
129
129
d_v = 666 # products use conc., dividing there, multiplying here, value does not matter
@@ -165,7 +165,7 @@ def low(t):
165
165
attributes = {
166
166
"multiplicity" : np .full (n_sd , int (case ["N" ])),
167
167
"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 ),
169
169
}
170
170
particulator = builder .build (attributes = attributes , products = products )
171
171
env ["RH" ] = 1.0001
@@ -178,7 +178,7 @@ def low(t):
178
178
179
179
ice_mass_per_volume = particulator .products ["qi" ].get ()[cell_id ]
180
180
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
182
182
unfrozen_fraction = 1 - ice_number / number_of_real_droplets
183
183
output [key ]["unfrozen_fraction" ].append (unfrozen_fraction )
184
184
0 commit comments