@@ -104,15 +104,13 @@ def quantity(value: float, unit: str) -> PlainQuantity:
104
104
@lru_cache
105
105
def density_water_kg_per_m3 (
106
106
Twater_degC : float ,
107
- pressure : Optional [PlainQuantity ] = None ,
108
- enable_fallback_calculation = False ) -> float :
107
+ pressure : Optional [PlainQuantity ] = None ) -> float :
109
108
"""
110
109
Calculate the density of water as a function of temperature.
111
110
112
111
Args:
113
112
Twater_degC: The temperature of water in degrees C.
114
113
pressure: Pressure - should be provided
115
- enable_fallback_calculation: deprecation shim, do not use, see https://github.com/NREL/GEOPHIRES-X/issues/110
116
114
Returns:
117
115
The density of water in kg/m³.
118
116
Raises:
@@ -129,15 +127,8 @@ def density_water_kg_per_m3(
129
127
return CP .PropsSI ('D' , 'T' , celsius_to_kelvin (Twater_degC ), 'Q' , 0 , 'Water' )
130
128
131
129
except (NotImplementedError , ValueError ) as e :
132
- if enable_fallback_calculation :
133
- _logger .warning (f'density_water: Fallback calculation triggered for { Twater_degC } C' )
134
-
135
- Twater_K = celsius_to_kelvin (Twater_degC )
136
- # water density correlation as used in Geophires v1.2 [kg/m3]
137
- rho_water = (.7983223 + (1.50896E-3 - 2.9104E-6 * Twater_K ) * Twater_K ) * 1E3
138
- return rho_water
139
-
140
- raise ValueError (f'Input temperature { Twater_degC } is out of range or otherwise not implemented' ) from e
130
+ raise ValueError (f'Input temperature & pressure ({ Twater_degC } , { pressure } ) '
131
+ f'are out of range or otherwise could not be used to calculate' ) from e
141
132
142
133
143
134
def celsius_to_kelvin (celsius : float ) -> float :
@@ -161,12 +152,13 @@ def celsius_to_kelvin(celsius: float) -> float:
161
152
@lru_cache
162
153
def viscosity_water_Pa_sec (
163
154
Twater_degC : float ,
164
- pressure : Optional [PlainQuantity ] = None ,
165
- enable_fallback_calculation = False ) -> float :
155
+ pressure : Optional [PlainQuantity ] = None ) -> float :
166
156
"""
167
- The ViscosityWater function is used to calculate the dynamic viscosity of water as a function of temperature.
157
+ Calculate the dynamic viscosity of water as a function of temperature and pressure.
158
+
168
159
Args:
169
160
Twater_degC: the temperature of water in degrees C
161
+ pressure: Pressure - should be provided
170
162
Returns:
171
163
Viscosity of water in Pa·s (Ns/m2)
172
164
Raises:
@@ -181,29 +173,21 @@ def viscosity_water_Pa_sec(
181
173
return CP .PropsSI ('V' , 'T' , celsius_to_kelvin (Twater_degC ), 'Q' , 0 , 'Water' )
182
174
183
175
except (NotImplementedError , ValueError ) as e :
184
- if enable_fallback_calculation :
185
- _logger .warning (f'viscosity_water: Fallback calculation triggered for { Twater_degC } C' )
186
-
187
- # accurate to within 2.5% from 0 to 370 degrees C [Ns/m2]
188
- muwater = 2.414E-5 * np .power (10 , 247.8 / (Twater_degC + 273.15 - 140 ))
189
- return muwater
190
-
191
- raise ValueError (f'Input temperature { Twater_degC } is out of range or otherwise not implemented' ) from e
176
+ raise ValueError (f'Input temperature & pressure ({ Twater_degC } , { pressure } ) '
177
+ f'are out of range or otherwise could not be used to calculate' ) from e
192
178
193
179
194
180
@lru_cache
195
181
def heat_capacity_water_J_per_kg_per_K (
196
182
Twater_degC : float ,
197
183
pressure : Optional [PlainQuantity ] = None ,
198
- enable_fallback_calculation = False
199
184
) -> float :
200
185
"""
201
186
Calculate the isobaric specific heat capacity (c_p) of water as a function of temperature.
202
187
203
188
Args:
204
189
Twater_degC: The temperature of water in degrees C.
205
190
pressure: Pressure - should be provided
206
- enable_fallback_calculation: deprecation shim, do not use, see https://github.com/NREL/GEOPHIRES-X/issues/110
207
191
Returns:
208
192
The isobaric specific heat capacity of water as a function of temperature in J/(kg·K).
209
193
Raises:
@@ -224,21 +208,8 @@ def heat_capacity_water_J_per_kg_per_K(
224
208
return CP .PropsSI ('C' , 'T' , celsius_to_kelvin (Twater_degC ), 'Q' , 0 , 'Water' )
225
209
226
210
except (NotImplementedError , ValueError ) as e :
227
- if enable_fallback_calculation :
228
- _logger .warning (f'heat_capacity_water: Fallback calculation triggered for { Twater_degC } C' )
229
-
230
- Twater = (Twater_degC + 273.15 ) / 1000
231
- A = - 203.6060
232
- B = 1523.290
233
- C = - 3196.413
234
- D = 2474.455
235
- E = 3.855326
236
- # water specific heat capacity in J/(kg·K)
237
- cpwater = (A + B * Twater + C * Twater ** 2 + D * Twater ** 3 + E / (Twater ** 2 )) / 18.02 * 1000
238
-
239
- return cpwater
240
-
241
- raise ValueError (f'Input temperature { Twater_degC } is out of range or otherwise not implemented' ) from e
211
+ raise ValueError (f'Input temperature & pressure ({ Twater_degC } , { pressure } ) '
212
+ f'are out of range or otherwise could not be used to calculate' ) from e
242
213
243
214
244
215
@lru_cache
@@ -273,15 +244,15 @@ def RecoverableHeat(Twater_degC: float) -> float:
273
244
274
245
275
246
@lru_cache
276
- def vapor_pressure_water_kPa (Twater_degC : float , enable_fallback_calculation = False ) -> float :
247
+ def vapor_pressure_water_kPa (
248
+ Twater_degC : float ,
249
+ pressure : Optional [PlainQuantity ] = None ) -> float :
277
250
"""
278
251
Calculate the vapor pressure of water as a function of temperature.
279
252
280
- TODO accept pressure as parameter https://github.com/NREL/GEOPHIRES-X/issues/118
281
-
282
253
Args:
283
254
Twater_degC: the temperature of water in degrees C
284
- enable_fallback_calculation: deprecation shim, do not use, see https://github.com/NREL/GEOPHIRES-X/issues/110
255
+ pressure: Pressure - should be provided
285
256
Returns:
286
257
The vapor pressure of water as a function of temperature in kPa
287
258
Raises:
@@ -295,34 +266,19 @@ def vapor_pressure_water_kPa(Twater_degC: float, enable_fallback_calculation=Fal
295
266
raise ValueError (f'Twater_degC ({ Twater_degC } ) must be greater than or equal to 0' )
296
267
297
268
try :
298
- return (quantity (CP .PropsSI ('P' , 'T' , celsius_to_kelvin (Twater_degC ), 'Q' , 0 , 'Water' ), 'Pa' )
299
- .to ('kPa' ).magnitude )
300
- except (NotImplementedError , ValueError ) as e :
301
- if enable_fallback_calculation :
302
- _logger .warning (f'vapor_pressure_water: Fallback calculation triggered for { Twater_degC } C' )
303
- return _vapor_pressure_antoine_equation_kPa (Twater_degC )
269
+ if pressure is not None :
270
+ return (quantity (
271
+ CP .PropsSI ('P' , 'T' , celsius_to_kelvin (Twater_degC ), 'P' , pressure .to ('Pa' ).magnitude , 'Water' ), 'Pa' )
272
+ .to ('kPa' ).magnitude )
273
+ else :
274
+ _logger .warning (f'vapor_pressure_water: No pressure provided, using vapor quality=0 instead' )
275
+ return (quantity (CP .PropsSI ('P' , 'T' , celsius_to_kelvin (Twater_degC ), 'Q' , 0 , 'Water' ), 'Pa' )
276
+ .to ('kPa' ).magnitude )
304
277
305
278
279
+ except (NotImplementedError , ValueError ) as e :
306
280
raise ValueError (f'Input temperature { Twater_degC } is out of range or otherwise not implemented' ) from e
307
281
308
- def _vapor_pressure_antoine_equation_kPa (Twater_degC : float ) -> float :
309
- """
310
- water vapor pressure in kPa using Antione Equation
311
- Do not add additional consumers, use geophires_x.GeoPHIRESUtils.vapor_pressure_water_kPa instead.
312
- """
313
-
314
- if Twater_degC < 100 :
315
- A = 8.07131
316
- B = 1730.63
317
- C = 233.426
318
- else :
319
- A = 8.14019
320
- B = 1810.94
321
- C = 244.485
322
- vp = 133.322 * (
323
- 10 ** (A - B / (C + Twater_degC ))) / 1000
324
- return vp
325
-
326
282
327
283
@lru_cache
328
284
def entropy_water_kJ_per_kg_per_K (temperature_degC : float ) -> float :
0 commit comments