@@ -18,22 +18,37 @@ def __init__(self):
18
18
BackendMethods .__init__ (self )
19
19
const = self .formulae .constants
20
20
unfrozen_and_saturated = self .formulae .trivia .unfrozen_and_saturated
21
+ frozen_and_above_freezing_point = (
22
+ self .formulae .trivia .frozen_and_above_freezing_point
23
+ )
21
24
22
25
@numba .njit (
23
26
** {** conf .JIT_FLAGS , "fastmath" : self .formulae .fastmath , "parallel" : False }
24
27
)
25
28
def _freeze (volume , i ):
26
29
volume [i ] = - 1 * volume [i ] * const .rho_w / const .rho_i
27
30
# TODO #599: change thd (latent heat)!
28
- # TODO #599: handle the negative volume in tests, attributes, products, dynamics, ...
31
+
32
+ @numba .njit (
33
+ ** {** conf .JIT_FLAGS , "fastmath" : self .formulae .fastmath , "parallel" : False }
34
+ )
35
+ def _thaw (volume , i ):
36
+ volume [i ] = - 1 * volume [i ] * const .rho_i / const .rho_w
37
+ # TODO #599: change thd (latent heat)!
29
38
30
39
@numba .njit (** {** conf .JIT_FLAGS , "fastmath" : self .formulae .fastmath })
31
- def freeze_singular_body (attributes , temperature , relative_humidity , cell ):
40
+ def freeze_singular_body (
41
+ attributes , temperature , relative_humidity , cell , thaw
42
+ ):
32
43
n_sd = len (attributes .freezing_temperature )
33
44
for i in numba .prange (n_sd ): # pylint: disable=not-an-iterable
34
45
if attributes .freezing_temperature [i ] == 0 :
35
46
continue
36
- if (
47
+ if thaw and frozen_and_above_freezing_point (
48
+ attributes .wet_volume [i ], temperature [cell [i ]]
49
+ ):
50
+ _thaw (attributes .wet_volume , i )
51
+ elif (
37
52
unfrozen_and_saturated (
38
53
attributes .wet_volume [i ], relative_humidity [cell [i ]]
39
54
)
@@ -56,13 +71,18 @@ def freeze_time_dependent_body( # pylint: disable=unused-argument,too-many-argu
56
71
relative_humidity ,
57
72
record_freezing_temperature ,
58
73
freezing_temperature ,
74
+ thaw ,
59
75
):
60
76
n_sd = len (attributes .wet_volume )
61
77
for i in numba .prange (n_sd ): # pylint: disable=not-an-iterable
62
78
if attributes .immersed_surface_area [i ] == 0 :
63
79
continue
64
80
cell_id = cell [i ]
65
- if unfrozen_and_saturated (
81
+ if thaw and frozen_and_above_freezing_point (
82
+ attributes .wet_volume [i ], temperature [cell_id ]
83
+ ):
84
+ _thaw (attributes .wet_volume , i )
85
+ elif unfrozen_and_saturated (
66
86
attributes .wet_volume [i ], relative_humidity [cell_id ]
67
87
):
68
88
rate = j_het (a_w_ice [cell_id ])
@@ -77,7 +97,9 @@ def freeze_time_dependent_body( # pylint: disable=unused-argument,too-many-argu
77
97
78
98
self .freeze_time_dependent_body = freeze_time_dependent_body
79
99
80
- def freeze_singular (self , * , attributes , temperature , relative_humidity , cell ):
100
+ def freeze_singular (
101
+ self , * , attributes , temperature , relative_humidity , cell , thaw : bool
102
+ ):
81
103
self .freeze_singular_body (
82
104
SingularAttributes (
83
105
freezing_temperature = attributes .freezing_temperature .data ,
@@ -86,6 +108,7 @@ def freeze_singular(self, *, attributes, temperature, relative_humidity, cell):
86
108
temperature .data ,
87
109
relative_humidity .data ,
88
110
cell .data ,
111
+ thaw = thaw ,
89
112
)
90
113
91
114
def freeze_time_dependent (
@@ -99,7 +122,8 @@ def freeze_time_dependent(
99
122
temperature ,
100
123
relative_humidity ,
101
124
record_freezing_temperature ,
102
- freezing_temperature
125
+ freezing_temperature ,
126
+ thaw : bool
103
127
):
104
128
self .freeze_time_dependent_body (
105
129
rand .data ,
@@ -110,10 +134,11 @@ def freeze_time_dependent(
110
134
timestep ,
111
135
cell .data ,
112
136
a_w_ice .data ,
113
- temperature .data if record_freezing_temperature else None ,
137
+ temperature .data ,
114
138
relative_humidity .data ,
115
139
record_freezing_temperature = record_freezing_temperature ,
116
- freezing_temperature = freezing_temperature .data
117
- if record_freezing_temperature
118
- else None ,
140
+ freezing_temperature = (
141
+ freezing_temperature .data if record_freezing_temperature else None
142
+ ),
143
+ thaw = thaw ,
119
144
)
0 commit comments