@@ -38,6 +38,10 @@ def test_record_freezing_temperature_on_time_dependent_freeze(
3838 pytest .skip ("TODO #1495" )
3939
4040 # arrange
41+ attr_names = (
42+ "temperature of last freezing" ,
43+ "supersaturation of last freezing" ,
44+ )
4145 formulae = Formulae (
4246 particle_shape_and_density = "MixedPhaseSpheres" ,
4347 heterogeneous_ice_nucleation_rate = "Constant" ,
@@ -52,15 +56,18 @@ def test_record_freezing_temperature_on_time_dependent_freeze(
5256 backend = backend_class (formulae = formulae ),
5357 environment = Box (dt = 1 * si .s , dv = 1 * si .m ** 3 ),
5458 dynamics = (
55- Freezing (
56- immersion_freezing = freezing_mode ["immersion_freezing" ],
57- homogeneous_freezing = freezing_mode ["homogeneous_freezing" ],
58- thaw = "instantaneous" ,
59- ),
59+ [
60+ Freezing (
61+ immersion_freezing = freezing_mode ["immersion_freezing" ],
62+ homogeneous_freezing = freezing_mode ["homogeneous_freezing" ],
63+ thaw = "instantaneous" ,
64+ )
65+ ]
6066 ),
6167 )
6268 if record_freezing_temperature :
63- builder .request_attribute ("temperature of last freezing" )
69+ for attr_name in attr_names :
70+ builder .request_attribute (attr_name )
6471 particulator = builder .build (
6572 attributes = {
6673 "multiplicity" : np .asarray ([1 ]),
@@ -69,46 +76,59 @@ def test_record_freezing_temperature_on_time_dependent_freeze(
6976 }
7077 )
7178
72- temp_1 = 200 * si .K
73- temp_2 = 250 * si .K
74- temp_3 = 220 * si .K
79+ temp_list = np .asarray ([200 * si .K , 300 * si .K , 220 * si .K ])
80+ rh_list = np .asarray ([0.9 , 1.0 , 1.1 ])
7581 particulator .environment ["a_w_ice" ] = np .nan
76- particulator .environment ["T" ] = temp_2
82+ particulator .environment ["T" ] = temp_list [1 ]
83+ particulator .environment ["RH_ice" ] = rh_list [0 ]
7784
7885 # act & assert
79- attr_name = "temperature of last freezing"
8086 if not record_freezing_temperature :
81- assert attr_name not in particulator .attributes
87+ for attr_name in attr_names :
88+ assert attr_name not in particulator .attributes
8289 else :
8390 # never frozen yet
84- np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
91+ for attr_name in attr_names :
92+ np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
8593
8694 # still not frozen since RH not greater than 100%
87- particulator .environment ["RH" ] = 1.0
88- particulator .environment ["RH_ice" ] = 1.0
95+ particulator .environment ["RH" ] = rh_list [ 1 ]
96+ particulator .environment ["RH_ice" ] = rh_list [ 1 ]
8997 particulator .run (steps = 1 )
90- np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
98+ for attr_name in attr_names :
99+ np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
91100 assert all (particulator .attributes ["signed water mass" ].to_ndarray () > 0 )
92101
93102 # should freeze and record T1
94- particulator .environment ["RH" ] += EPSILON_RH
95- particulator .environment ["RH_ice" ] += EPSILON_RH
96- particulator .environment ["T" ] = temp_1
103+ particulator .environment ["RH" ] = rh_list [ 2 ]
104+ particulator .environment ["RH_ice" ] = rh_list [ 2 ]
105+ particulator .environment ["T" ] = temp_list [ 0 ]
97106 particulator .run (steps = 1 )
98107 assert all (particulator .attributes ["signed water mass" ].to_ndarray () < 0 )
99- assert all (particulator .attributes [attr_name ].to_ndarray () == temp_1 )
108+ assert all (
109+ particulator .attributes [attr_names [0 ]].to_ndarray () == temp_list [0 ]
110+ )
111+ assert all (
112+ particulator .attributes [attr_names [1 ]].to_ndarray () == rh_list [2 ]
113+ )
100114
101115 # should thaw
102- particulator .environment ["T" ] = 300 * si . K
116+ particulator .environment ["T" ] = temp_list [ 1 ]
103117 particulator .run (steps = 1 )
104118 assert all (particulator .attributes ["signed water mass" ].to_ndarray () > 0 )
105- np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
119+ for attr_name in attr_names :
120+ np .isnan (particulator .attributes [attr_name ].to_ndarray ()).all ()
106121
107122 # should re-freeze and record T2
108- particulator .environment ["T" ] = temp_3
123+ particulator .environment ["T" ] = temp_list [ 2 ]
109124 particulator .run (steps = 1 )
110125 assert all (particulator .attributes ["signed water mass" ].to_ndarray () < 0 )
111- assert all (particulator .attributes [attr_name ].to_ndarray () == temp_3 )
126+ assert all (
127+ particulator .attributes [attr_names [0 ]].to_ndarray () == temp_list [2 ]
128+ )
129+ assert all (
130+ particulator .attributes [attr_names [1 ]].to_ndarray () == rh_list [2 ]
131+ )
112132
113133 # TODO #599
114134 def test_no_subsaturated_freezing (self ):
0 commit comments