1414 SingularAttributes ,
1515 TimeDependentAttributes ,
1616 TimeDependentHomogeneousAttributes ,
17+ < << << << HEAD
1718 ThresholdHomogeneousAndThawAttributes ,
19+ == == == =
20+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
1821)
1922
2023
@@ -38,6 +41,7 @@ def body(signed_water_mass, i):
3841 return body
3942
4043 @cached_property
44+ < << << << HEAD
4145 def _thaw_instantaneous_body (self ):
4246 _thaw = self ._thaw
4347 frozen_and_above_freezing_point = (
@@ -67,6 +71,18 @@ def body(
6771 relative_humidity ,
6872 cell ,
6973 ):
74+ == == == =
75+ def _freeze_singular_body (self ):
76+ _thaw = self ._thaw
77+ _freeze = self ._freeze
78+ frozen_and_above_freezing_point = (
79+ self .formulae .trivia .frozen_and_above_freezing_point
80+ )
81+ unfrozen_and_saturated = self .formulae .trivia .unfrozen_and_saturated
82+
83+ @numba .njit (** self .default_jit_flags )
84+ def body (attributes , temperature , relative_humidity , cell , thaw ):
85+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
7086 n_sd = len (attributes .freezing_temperature )
7187 for i in numba .prange (n_sd ): # pylint: disable=not-an-iterable
7288 if attributes .freezing_temperature [i ] == 0 :
@@ -82,8 +98,17 @@ def body(
8298 return body
8399
84100 @cached_property
101+ << << < << HEAD
85102 def _immersion_freezing_time_dependent_body (self ):
86103 _freeze = self ._freeze
104+ == == == =
105+ def _freeze_time_dependent_body (self ):
106+ _thaw = self ._thaw
107+ _freeze = self ._freeze
108+ frozen_and_above_freezing_point = (
109+ self .formulae .trivia .frozen_and_above_freezing_point
110+ )
111+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
87112 unfrozen_and_saturated = self .formulae .trivia .unfrozen_and_saturated
88113 j_het = self .formulae .heterogeneous_ice_nucleation_rate .j_het
89114 prob_zero_events = self .formulae .trivia .poissonian_avoidance_function
@@ -115,6 +140,66 @@ def body( # pylint: disable=too-many-arguments
115140 _freeze (attributes .signed_water_mass , i )
116141
117142 return body
143+ < << << << HEAD
144+ == == == =
145+
146+ @cached_property
147+ def _freeze_time_dependent_homogeneous_body (self ):
148+ _thaw = self ._thaw
149+ _freeze = self ._freeze
150+ frozen_and_above_freezing_point = (
151+ self .formulae .trivia .frozen_and_above_freezing_point
152+ )
153+ unfrozen_and_ice_saturated = self .formulae .trivia .unfrozen_and_ice_saturated
154+ j_hom = self .formulae .homogeneous_ice_nucleation_rate .j_hom
155+ prob_zero_events = self .formulae .trivia .poissonian_avoidance_function
156+ d_a_w_ice_within_range = (
157+ self .formulae .homogeneous_ice_nucleation_rate .d_a_w_ice_within_range
158+ )
159+ d_a_w_ice_maximum = (
160+ self .formulae .homogeneous_ice_nucleation_rate .d_a_w_ice_maximum
161+ )
162+
163+ @numba .njit (** self .default_jit_flags )
164+ def body ( # pylint: disable=unused-argument,too-many-arguments
165+ rand ,
166+ attributes ,
167+ timestep ,
168+ cell ,
169+ a_w_ice ,
170+ temperature ,
171+ relative_humidity_ice ,
172+ thaw ,
173+ ):
174+
175+ n_sd = len (attributes .signed_water_mass )
176+ for i in numba .prange (n_sd ): # pylint: disable=not-an-iterable
177+ cell_id = cell [i ]
178+ if thaw and frozen_and_above_freezing_point (
179+ attributes .signed_water_mass [i ], temperature [cell_id ]
180+ ):
181+ _thaw (attributes .signed_water_mass , i )
182+ elif unfrozen_and_ice_saturated (
183+ attributes .signed_water_mass [i ], relative_humidity_ice [cell_id ]
184+ ):
185+ d_a_w_ice = (relative_humidity_ice [cell_id ] - 1.0 ) * a_w_ice [
186+ cell_id
187+ ]
188+
189+ if d_a_w_ice_within_range (d_a_w_ice ):
190+ d_a_w_ice = d_a_w_ice_maximum (d_a_w_ice )
191+ rate_assuming_constant_temperature_within_dt = (
192+ j_hom (temperature [cell_id ], d_a_w_ice )
193+ * attributes .volume [i ]
194+ )
195+ prob = 1 - prob_zero_events (
196+ r = rate_assuming_constant_temperature_within_dt , dt = timestep
197+ )
198+ if rand [i ] < prob :
199+ _freeze (attributes .signed_water_mass , i )
200+
201+ return body
202+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
118203
119204 @cached_property
120205 def _homogeneous_freezing_time_dependent_body (self ):
@@ -190,6 +275,7 @@ def thaw_instantaneous(
190275 cell ,
191276 temperature ,
192277 ):
278+ < << << << HEAD
193279 self ._thaw_instantaneous_body (
194280 ThresholdHomogeneousAndThawAttributes (
195281 signed_water_mass = attributes .signed_water_mass .data ,
@@ -202,6 +288,9 @@ def immersion_freezing_singular(
202288 self , * , attributes , temperature , relative_humidity , cell
203289 ):
204290 self ._immersion_freezing_singular_body (
291+ == == == =
292+ self ._freeze_singular_body (
293+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
205294 SingularAttributes (
206295 freezing_temperature = attributes .freezing_temperature .data ,
207296 signed_water_mass = attributes .signed_water_mass .data ,
@@ -221,7 +310,11 @@ def immersion_freezing_time_dependent(
221310 a_w_ice ,
222311 relative_humidity ,
223312 ):
313+ < << << << HEAD
224314 self ._immersion_freezing_time_dependent_body (
315+ == == == =
316+ self ._freeze_time_dependent_body (
317+ >> >> >> > 561 d4927 (Homogeneous freezing (as a new option in `Freezing` dynamic , disabled by default + new physics formulae for hom . nucl . rate ); new example : `Spichtinger_et_al_2023` (#1488))
225318 rand .data ,
226319 TimeDependentAttributes (
227320 immersed_surface_area = attributes .immersed_surface_area .data ,
@@ -274,6 +367,32 @@ def homogeneous_freezing_time_dependent(
274367 relative_humidity_ice .data ,
275368 )
276369
370+ def freeze_time_dependent_homogeneous (
371+ self ,
372+ * ,
373+ rand ,
374+ attributes ,
375+ timestep ,
376+ cell ,
377+ a_w_ice ,
378+ temperature ,
379+ relative_humidity_ice ,
380+ thaw : bool ,
381+ ):
382+ self ._freeze_time_dependent_homogeneous_body (
383+ rand .data ,
384+ TimeDependentHomogeneousAttributes (
385+ volume = attributes .volume .data ,
386+ signed_water_mass = attributes .signed_water_mass .data ,
387+ ),
388+ timestep ,
389+ cell .data ,
390+ a_w_ice .data ,
391+ temperature .data ,
392+ relative_humidity_ice .data ,
393+ thaw = thaw ,
394+ )
395+
277396 @cached_property
278397 def _record_freezing_temperatures_body (self ):
279398 ff = self .formulae_flattened
0 commit comments