From 80043a8fdce5cc55d458bc37dc9e384669e9bc64 Mon Sep 17 00:00:00 2001 From: Boris Ivanov Date: Wed, 18 Sep 2024 00:08:39 +0100 Subject: [PATCH] refactor saturation vapour pressure formulae to avoid using temperatures in Celsius (#1388) Co-authored-by: Sylwester Arabas --- .pre-commit-config.yaml | 2 +- .../methods/condensation_methods.py | 4 +- .../impl_numba/methods/physics_methods.py | 6 +- .../scipy_ode_condensation_solver.py | 4 +- .../methods/condensation_methods.py | 4 +- .../methods/physics_methods.py | 4 +- .../august_roche_magnus.py | 10 +- .../saturation_vapour_pressure/bolton_1980.py | 12 +- .../flatau_walko_cotton.py | 38 +- .../saturation_vapour_pressure/lowe1977.py | 30 +- .../murphy_koop_2005.py | 24 +- .../saturation_vapour_pressure/wexler_1976.py | 20 +- .../Abdul_Razzak_Ghan_2000/run_ARG_parcel.py | 2 +- .../Alpert_and_Knopf_2016/simulation.py | 7 +- .../Arabas_and_Shima_2017/settings.py | 2 +- .../Arabas_et_al_2023/fig_2.ipynb | 2121 ++++++++++++++++- .../Arabas_et_al_2023/run_simulation.py | 3 +- .../Gedzelman_and_Arnold_1994/fig_2.ipynb | 2 +- .../Grabowski_and_Pawlowska_2023/settings.py | 4 +- .../Graf_et_al_2019/figure_4.ipynb | 1392 +++++++++-- .../Jensen_and_Nugent_2017/simulation.py | 4 +- .../Kreidenweis_et_al_2003/settings.py | 4 +- .../Lowe_et_al_2019/settings.py | 4 +- .../Miyake_et_al_1968/fig_19.ipynb | 2 +- .../Niedermeier_et_al_2014/settings.py | 3 +- examples/PySDM_examples/Pyrcel/settings.py | 7 +- .../Pyrcel/tutorial_settings.py | 7 +- .../figs_4_5_6.ipynb | 2 +- .../Yang_et_al_2018/simulation.py | 4 +- .../test_initialisation.py | 2 +- .../physics/test_dimensional_analysis.py | 6 +- tests/unit_tests/physics/test_formulae.py | 8 +- .../test_isotope_relaxation_timescale.py | 2 +- .../test_saturation_vapour_pressure.py | 20 +- 34 files changed, 3477 insertions(+), 289 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2eb269d3..e6ff7144a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,4 +18,4 @@ repos: hooks: - id: trailing-whitespace - id: end-of-file-fixer - - id: debug-statements + - id: debug-statements \ No newline at end of file diff --git a/PySDM/backends/impl_numba/methods/condensation_methods.py b/PySDM/backends/impl_numba/methods/condensation_methods.py index 5c7f71e94..1b8d33ce2 100644 --- a/PySDM/backends/impl_numba/methods/condensation_methods.py +++ b/PySDM/backends/impl_numba/methods/condensation_methods.py @@ -291,9 +291,7 @@ def step_impl( # pylint: disable=too-many-arguments,too-many-locals ) pv = formulae.state_variable_triplet__pv(p, water_vapour_mixing_ratio) lv = formulae.latent_heat__lv(T) - pvs = formulae.saturation_vapour_pressure__pvs_Celsius( - T - formulae.constants.T0 - ) + pvs = formulae.saturation_vapour_pressure__pvs_water(T) DTp = formulae.diffusion_thermics__D(T, p) RH = pv / pvs Sc = formulae.trivia__air_schmidt_number( diff --git a/PySDM/backends/impl_numba/methods/physics_methods.py b/PySDM/backends/impl_numba/methods/physics_methods.py index f83efa137..e99eac112 100644 --- a/PySDM/backends/impl_numba/methods/physics_methods.py +++ b/PySDM/backends/impl_numba/methods/physics_methods.py @@ -59,7 +59,7 @@ def body(*, rhod, thd, water_vapour_mixing_ratio, T, p, RH): ) RH[i] = ff.state_variable_triplet__pv( p[i], water_vapour_mixing_ratio[i] - ) / ff.saturation_vapour_pressure__pvs_Celsius(T[i] - ff.constants.T0) + ) / ff.saturation_vapour_pressure__pvs_water(T[i]) return body @@ -82,9 +82,7 @@ def _a_w_ice_body(self): @numba.njit(**self.default_jit_flags) def body(*, T_in, p_in, RH_in, water_vapour_mixing_ratio_in, a_w_ice_out): for i in prange(T_in.shape[0]): # pylint: disable=not-an-iterable - pvi = ff.saturation_vapour_pressure__ice_Celsius( - T_in[i] - ff.constants.T0 - ) + pvi = ff.saturation_vapour_pressure__pvs_ice(T_in[i]) pv = ff.state_variable_triplet__pv( p_in[i], water_vapour_mixing_ratio_in[i] ) diff --git a/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py b/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py index d4a170ab6..83011edf2 100644 --- a/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py +++ b/PySDM/backends/impl_numba/test_helpers/scipy_ode_condensation_solver.py @@ -18,7 +18,7 @@ _CellData, _Counters, ) -from PySDM.physics.constants_defaults import PI_4_3, T0 +from PySDM.physics.constants_defaults import PI_4_3 idx_thd = 0 idx_x = 1 @@ -205,7 +205,7 @@ def _odesys( # pylint: disable=too-many-arguments,too-many-locals T = jit_formulae.state_variable_triplet__T(rhod, thd) p = jit_formulae.state_variable_triplet__p(rhod, T, water_vapour_mixing_ratio) pv = jit_formulae.state_variable_triplet__pv(p, water_vapour_mixing_ratio) - pvs = jit_formulae.saturation_vapour_pressure__pvs_Celsius(T - T0) + pvs = jit_formulae.saturation_vapour_pressure__pvs_water(T) RH = pv / pvs dy_dt = np.empty_like(y) diff --git a/PySDM/backends/impl_thrust_rtc/methods/condensation_methods.py b/PySDM/backends/impl_thrust_rtc/methods/condensation_methods.py index 7bbe9efbb..7a75a0cb0 100644 --- a/PySDM/backends/impl_thrust_rtc/methods/condensation_methods.py +++ b/PySDM/backends/impl_thrust_rtc/methods/condensation_methods.py @@ -318,8 +318,8 @@ def __pre(self): p='p[i]', water_vapour_mixing_ratio='predicted_water_vapour_mixing_ratio[i]')}; lv[i] = {phys.latent_heat.lv.c_inline( T='T[i]')}; - pvs[i] = {phys.saturation_vapour_pressure.pvs_Celsius.c_inline( - T='T[i] - const.T0')}; + pvs[i] = {phys.saturation_vapour_pressure.pvs_water.c_inline( + T='T[i]')}; RH[i] = pv[i] / pvs[i]; RH_max[i] = max(RH_max[i], RH[i]); DTp[i] = {phys.diffusion_thermics.D.c_inline( diff --git a/PySDM/backends/impl_thrust_rtc/methods/physics_methods.py b/PySDM/backends/impl_thrust_rtc/methods/physics_methods.py index 3ad60fdba..cd56b986f 100644 --- a/PySDM/backends/impl_thrust_rtc/methods/physics_methods.py +++ b/PySDM/backends/impl_thrust_rtc/methods/physics_methods.py @@ -27,9 +27,7 @@ def _temperature_pressure_rh_body(self): )}; RH[i] = {self.formulae.state_variable_triplet.pv.c_inline( p="p[i]", water_vapour_mixing_ratio="water_vapour_mixing_ratio[i]" - )} / {self.formulae.saturation_vapour_pressure.pvs_Celsius.c_inline( - T="T[i] - const.T0" - )}; + )} / {self.formulae.saturation_vapour_pressure.pvs_water.c_inline(T="T[i]")}; """.replace( "real_type", self._get_c_type() ), diff --git a/PySDM/physics/saturation_vapour_pressure/august_roche_magnus.py b/PySDM/physics/saturation_vapour_pressure/august_roche_magnus.py index 605c07264..7a41c041f 100644 --- a/PySDM/physics/saturation_vapour_pressure/august_roche_magnus.py +++ b/PySDM/physics/saturation_vapour_pressure/august_roche_magnus.py @@ -12,10 +12,12 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): - return const.ARM_C1 * np.exp((const.ARM_C2 * T) / (T + const.ARM_C3)) + def pvs_water(const, T): + return const.ARM_C1 * np.exp( + (const.ARM_C2 * (T - const.T0)) / ((T - const.T0) + const.ARM_C3) + ) @staticmethod - def ice_Celsius(const, T): + def pvs_ice(const, T): """NaN with unit of pressure and correct dimension""" - return np.nan * T / const.ARM_C3 * const.ARM_C1 + return np.nan * (T - const.T0) / const.ARM_C3 * const.ARM_C1 diff --git a/PySDM/physics/saturation_vapour_pressure/bolton_1980.py b/PySDM/physics/saturation_vapour_pressure/bolton_1980.py index 2ef5934d0..cb65a853b 100644 --- a/PySDM/physics/saturation_vapour_pressure/bolton_1980.py +++ b/PySDM/physics/saturation_vapour_pressure/bolton_1980.py @@ -10,11 +10,13 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): - """valid for -30 <= T <= 35 C, eq (10)""" - return const.B80W_G0 * np.exp((const.B80W_G1 * T) / (T + const.B80W_G2)) + def pvs_water(const, T): + """valid for 243.15(-30) <= T <= 308.15(35) K(C), eq. (10)""" + return const.B80W_G0 * np.exp( + (const.B80W_G1 * (T - const.T0)) / ((T - const.T0) + const.B80W_G2) + ) @staticmethod - def ice_Celsius(const, T): + def pvs_ice(const, T): """NaN with unit of pressure and correct dimension""" - return np.nan * T / const.B80W_G2 * const.B80W_G0 + return np.nan * (T - const.T0) / const.B80W_G2 * const.B80W_G0 diff --git a/PySDM/physics/saturation_vapour_pressure/flatau_walko_cotton.py b/PySDM/physics/saturation_vapour_pressure/flatau_walko_cotton.py index 9e3ba266d..900ff356e 100644 --- a/PySDM/physics/saturation_vapour_pressure/flatau_walko_cotton.py +++ b/PySDM/physics/saturation_vapour_pressure/flatau_walko_cotton.py @@ -9,22 +9,27 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): - return const.FWC_C0 + T * ( + def pvs_water(const, T): + return const.FWC_C0 + (T - const.T0) * ( const.FWC_C1 - + T + + (T - const.T0) * ( const.FWC_C2 - + T + + (T - const.T0) * ( const.FWC_C3 - + T + + (T - const.T0) * ( const.FWC_C4 - + T + + (T - const.T0) * ( const.FWC_C5 - + T * (const.FWC_C6 + T * (const.FWC_C7 + T * const.FWC_C8)) + + (T - const.T0) + * ( + const.FWC_C6 + + (T - const.T0) + * (const.FWC_C7 + (T - const.T0) * const.FWC_C8) + ) ) ) ) @@ -32,22 +37,27 @@ def pvs_Celsius(const, T): ) @staticmethod - def ice_Celsius(const, T): - return const.FWC_I0 + T * ( + def pvs_ice(const, T): + return const.FWC_I0 + (T - const.T0) * ( const.FWC_I1 - + T + + (T - const.T0) * ( const.FWC_I2 - + T + + (T - const.T0) * ( const.FWC_I3 - + T + + (T - const.T0) * ( const.FWC_I4 - + T + + (T - const.T0) * ( const.FWC_I5 - + T * (const.FWC_I6 + T * (const.FWC_I7 + T * const.FWC_I8)) + + (T - const.T0) + * ( + const.FWC_I6 + + (T - const.T0) + * (const.FWC_I7 + (T - const.T0) * const.FWC_I8) + ) ) ) ) diff --git a/PySDM/physics/saturation_vapour_pressure/lowe1977.py b/PySDM/physics/saturation_vapour_pressure/lowe1977.py index 9c400ed13..7d92e50e8 100644 --- a/PySDM/physics/saturation_vapour_pressure/lowe1977.py +++ b/PySDM/physics/saturation_vapour_pressure/lowe1977.py @@ -9,31 +9,41 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): - return const.L77W_A0 + T * ( + def pvs_water(const, T): + return const.L77W_A0 + (T - const.T0) * ( const.L77W_A1 - + T + + (T - const.T0) * ( const.L77W_A2 - + T + + (T - const.T0) * ( const.L77W_A3 - + T * (const.L77W_A4 + T * (const.L77W_A5 + T * (const.L77W_A6))) + + (T - const.T0) + * ( + const.L77W_A4 + + (T - const.T0) + * (const.L77W_A5 + (T - const.T0) * (const.L77W_A6)) + ) ) ) ) @staticmethod - def ice_Celsius(const, T): - return const.L77I_A0 + T * ( + def pvs_ice(const, T): + return const.L77I_A0 + (T - const.T0) * ( const.L77I_A1 - + T + + (T - const.T0) * ( const.L77I_A2 - + T + + (T - const.T0) * ( const.L77I_A3 - + T * (const.L77I_A4 + T * (const.L77I_A5 + T * (const.L77I_A6))) + + (T - const.T0) + * ( + const.L77I_A4 + + (T - const.T0) + * (const.L77I_A5 + (T - const.T0) * (const.L77I_A6)) + ) ) ) ) diff --git a/PySDM/physics/saturation_vapour_pressure/murphy_koop_2005.py b/PySDM/physics/saturation_vapour_pressure/murphy_koop_2005.py index 54f774b2e..2515a2aec 100644 --- a/PySDM/physics/saturation_vapour_pressure/murphy_koop_2005.py +++ b/PySDM/physics/saturation_vapour_pressure/murphy_koop_2005.py @@ -10,28 +10,28 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): + def pvs_water(const, T): """valid for 123 < T < 332 K, eq (10)""" return const.MK05_LIQ_C1 * np.exp( const.MK05_LIQ_C2 - - const.MK05_LIQ_C3 / (T + const.T0) - - const.MK05_LIQ_C4 * np.log((T + const.T0) / const.MK05_LIQ_C5) - + const.MK05_LIQ_C6 * (T + const.T0) - + np.tanh(const.MK05_LIQ_C7 * (T + const.T0 - const.MK05_LIQ_C8)) + - const.MK05_LIQ_C3 / (T) + - const.MK05_LIQ_C4 * np.log(T / const.MK05_LIQ_C5) + + const.MK05_LIQ_C6 * (T) + + np.tanh(const.MK05_LIQ_C7 * (T - const.MK05_LIQ_C8)) * ( const.MK05_LIQ_C9 - - const.MK05_LIQ_C10 / (T + const.T0) - - const.MK05_LIQ_C11 * np.log((T + const.T0) / const.MK05_LIQ_C12) - + const.MK05_LIQ_C13 * (T + const.T0) + - const.MK05_LIQ_C10 / T + - const.MK05_LIQ_C11 * np.log(T / const.MK05_LIQ_C12) + + const.MK05_LIQ_C13 * T ) ) @staticmethod - def ice_Celsius(const, T): + def pvs_ice(const, T): """valid for T > 110 K, eq (7)""" return const.MK05_ICE_C1 * np.exp( const.MK05_ICE_C2 - - const.MK05_ICE_C3 / (T + const.T0) - + const.MK05_ICE_C4 * np.log((T + const.T0) / const.MK05_ICE_C5) - - const.MK05_ICE_C6 * (T + const.T0) + - const.MK05_ICE_C3 / T + + const.MK05_ICE_C4 * np.log(T / const.MK05_ICE_C5) + - const.MK05_ICE_C6 * T ) diff --git a/PySDM/physics/saturation_vapour_pressure/wexler_1976.py b/PySDM/physics/saturation_vapour_pressure/wexler_1976.py index 9d82366bd..e983fa716 100644 --- a/PySDM/physics/saturation_vapour_pressure/wexler_1976.py +++ b/PySDM/physics/saturation_vapour_pressure/wexler_1976.py @@ -10,22 +10,22 @@ def __init__(self, _): pass @staticmethod - def pvs_Celsius(const, T): + def pvs_water(const, T): return ( np.exp( - const.W76W_G0 / (T + const.T0) ** 2 - + const.W76W_G1 / (T + const.T0) + const.W76W_G0 / T**2 + + const.W76W_G1 / T + const.W76W_G2 - + const.W76W_G3 * (T + const.T0) - + const.W76W_G4 * (T + const.T0) ** 2 - + const.W76W_G5 * (T + const.T0) ** 3 - + const.W76W_G6 * (T + const.T0) ** 4 - + const.W76W_G7 * np.log((T + const.T0) / const.one_kelvin) + + const.W76W_G3 * T + + const.W76W_G4 * T**2 + + const.W76W_G5 * T**3 + + const.W76W_G6 * T**4 + + const.W76W_G7 * np.log(T / const.one_kelvin) ) * const.W76W_G8 ) @staticmethod - def ice_Celsius(const, T): + def pvs_ice(const, T): """NaN with unit of pressure and correct dimension""" - return np.nan * T / const.B80W_G2 * const.B80W_G0 + return np.nan * (T - const.T0) / const.B80W_G2 * const.B80W_G0 diff --git a/examples/PySDM_examples/Abdul_Razzak_Ghan_2000/run_ARG_parcel.py b/examples/PySDM_examples/Abdul_Razzak_Ghan_2000/run_ARG_parcel.py index d3f4dcb6b..e0cee0f4d 100644 --- a/examples/PySDM_examples/Abdul_Razzak_Ghan_2000/run_ARG_parcel.py +++ b/examples/PySDM_examples/Abdul_Razzak_Ghan_2000/run_ARG_parcel.py @@ -35,7 +35,7 @@ def run_parcel( formulae = Formulae(constants=CONSTANTS_ARG) const = formulae.constants - pv0 = RH0 * formulae.saturation_vapour_pressure.pvs_Celsius(T0 - const.T0) + pv0 = RH0 * formulae.saturation_vapour_pressure.pvs_water(T0) env = Parcel( dt=dt, diff --git a/examples/PySDM_examples/Alpert_and_Knopf_2016/simulation.py b/examples/PySDM_examples/Alpert_and_Knopf_2016/simulation.py index ad35faf62..1681dfeb6 100644 --- a/examples/PySDM_examples/Alpert_and_Knopf_2016/simulation.py +++ b/examples/PySDM_examples/Alpert_and_Knopf_2016/simulation.py @@ -11,7 +11,6 @@ from PySDM.environments import Box from PySDM.initialisation import discretise_multiplicities from PySDM.initialisation.sampling import spectral_sampling -from PySDM.physics import constants as const from PySDM.physics import si from PySDM.products import IceWaterContent, TotalUnfrozenImmersedSurfaceArea @@ -143,7 +142,7 @@ def plot_j_het(self, variant: str, abifm_params_case: str, ylim=None): svp = formulae.saturation_vapour_pressure plot_x = np.linspace(*self.temperature_range) * si.K plot_y = formulae.heterogeneous_ice_nucleation_rate.j_het( - svp.ice_Celsius(plot_x - const.T0) / svp.pvs_Celsius(plot_x - const.T0) + svp.pvs_ice(plot_x) / svp.pvs_water(plot_x) ) pyplot.grid() pyplot.plot(plot_x, plot_y / yunit, color="red", label="ABIFM $J_{het}$") @@ -252,9 +251,7 @@ def simulation( for i in range(int(total_time / time_step) + 1): if cooling_rate != 0: env["T"] -= np.full((1,), cooling_rate * time_step / 2) - env["a_w_ice"] = svp.ice_Celsius(env["T"][0] - const.T0) / svp.pvs_Celsius( - env["T"][0] - const.T0 - ) + env["a_w_ice"] = svp.pvs_ice(env["T"][0]) / svp.pvs_water(env["T"][0]) particulator.run(0 if i == 0 else 1) if cooling_rate != 0: env["T"] -= np.full((1,), cooling_rate * time_step / 2) diff --git a/examples/PySDM_examples/Arabas_and_Shima_2017/settings.py b/examples/PySDM_examples/Arabas_and_Shima_2017/settings.py index c57c8833f..241d7a6f1 100644 --- a/examples/PySDM_examples/Arabas_and_Shima_2017/settings.py +++ b/examples/PySDM_examples/Arabas_and_Shima_2017/settings.py @@ -27,7 +27,7 @@ def __init__( self.T0 = 300 * si.kelvin self.z_half = 150 * si.metres - pvs = self.formulae.saturation_vapour_pressure.pvs_Celsius(self.T0 - const.T0) + pvs = self.formulae.saturation_vapour_pressure.pvs_water(self.T0) self.initial_water_vapour_mixing_ratio = const.eps / ( self.p0 / self.RH0 / pvs - 1 ) diff --git a/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb b/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb index d2ebf7a97..f47678ff8 100644 --- a/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb +++ b/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb @@ -2,15 +2,15 @@ "cells": [ { "cell_type": "markdown", + "id": "556981ca9ffb9215", + "metadata": { + "collapsed": false + }, "source": [ "[![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb)\n", "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=lab/tree/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb)\n", "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Arabas_et_al_2023/fig_2.ipynb)" - ], - "metadata": { - "collapsed": false - }, - "id": "556981ca9ffb9215" + ] }, { "cell_type": "code", @@ -26,7 +26,6 @@ "source": [ "from matplotlib import pyplot\n", "from open_atmos_jupyter_utils import show_plot\n", - "from PySDM.physics import constants as const\n", "from PySDM import Formulae\n", "from PySDM_examples.Arabas_et_al_2023.curved_text import CurvedText\n", "from PySDM_examples.Arabas_et_al_2023.commons import FREEZING_CONSTANTS, COOLING_RATES, TEMP_RANGE\n", @@ -80,7 +79,7 @@ "def _T(TK):\n", " return (TK/si.K).to_base_units().magnitude\n", "\n", - "a_w_ice = svp.ice_Celsius(_T(T) - const.T0) / svp.pvs_Celsius(_T(T) - const.T0)" + "a_w_ice = svp.pvs_ice(_T(T)) / svp.pvs_water(_T(T))" ] }, { @@ -96,20 +95,2116 @@ "outputs": [ { "data": { - "text/plain": "
", - "image/svg+xml": "\n\n\n \n \n \n \n 2024-02-01T08:25:48.581901\n image/svg+xml\n \n \n Matplotlib v3.8.2, https://matplotlib.org/\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " 2024-02-01T08:25:48.581901\n", + " image/svg+xml\n", + " \n", + " \n", + " Matplotlib v3.8.2, https://matplotlib.org/\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "\n" + ], + "text/plain": [ + "
" + ] }, "metadata": {}, "output_type": "display_data" }, { "data": { - "text/plain": "HTML(value=\"./fig_theory.pdf
\")", "application/vnd.jupyter.widget-view+json": { + "model_id": "8ecfeccd1d0847fb9a89752e4dde4b7e", "version_major": 2, - "version_minor": 0, - "model_id": "8ecfeccd1d0847fb9a89752e4dde4b7e" - } + "version_minor": 0 + }, + "text/plain": [ + "HTML(value=\"./fig_theory.pdf
\")" + ] }, "metadata": {}, "output_type": "display_data" diff --git a/examples/PySDM_examples/Arabas_et_al_2023/run_simulation.py b/examples/PySDM_examples/Arabas_et_al_2023/run_simulation.py index 1cd7b106b..ce047c3be 100644 --- a/examples/PySDM_examples/Arabas_et_al_2023/run_simulation.py +++ b/examples/PySDM_examples/Arabas_et_al_2023/run_simulation.py @@ -4,10 +4,9 @@ def update_thermo(particulator, T): env = particulator.environment svp = particulator.formulae.saturation_vapour_pressure - const = particulator.formulae.constants env["T"] = T - env["a_w_ice"] = svp.ice_Celsius(T - const.T0) / svp.pvs_Celsius(T - const.T0) + env["a_w_ice"] = svp.pvs_ice(T) / svp.pvs_water(T) def run_simulation(particulator, temperature_profile, n_steps): diff --git a/examples/PySDM_examples/Gedzelman_and_Arnold_1994/fig_2.ipynb b/examples/PySDM_examples/Gedzelman_and_Arnold_1994/fig_2.ipynb index 78d1c478a..b83df568e 100644 --- a/examples/PySDM_examples/Gedzelman_and_Arnold_1994/fig_2.ipynb +++ b/examples/PySDM_examples/Gedzelman_and_Arnold_1994/fig_2.ipynb @@ -174,7 +174,7 @@ " )(kwargs['temperature'])\n", "\n", " missing_b_multiplier = (\n", - " kwargs['formulae'].saturation_vapour_pressure.pvs_Celsius(kwargs['temperature'] - T0)\n", + " kwargs['formulae'].saturation_vapour_pressure.pvs_water(kwargs['temperature'])\n", " / kwargs['temperature']\n", " / const.Rv\n", " )\n", diff --git a/examples/PySDM_examples/Grabowski_and_Pawlowska_2023/settings.py b/examples/PySDM_examples/Grabowski_and_Pawlowska_2023/settings.py index 4e3dc689e..1d45ea81d 100644 --- a/examples/PySDM_examples/Grabowski_and_Pawlowska_2023/settings.py +++ b/examples/PySDM_examples/Grabowski_and_Pawlowska_2023/settings.py @@ -61,9 +61,7 @@ def __init__( self.initial_temperature = initial_temperature pv0 = ( initial_relative_humidity - * self.formulae.saturation_vapour_pressure.pvs_Celsius( - initial_temperature - const.T0 - ) + * self.formulae.saturation_vapour_pressure.pvs_water(initial_temperature) ) self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) self.t_max = displacement / vertical_velocity diff --git a/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb b/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb index bbf406d91..c0f3c5508 100644 --- a/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb +++ b/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb @@ -2,28 +2,37 @@ "cells": [ { "cell_type": "markdown", + "id": "327f2a018faf3142", + "metadata": { + "collapsed": false + }, "source": [ "[![View notebook](https://img.shields.io/static/v1?label=render%20on&logo=github&color=87ce3e&message=GitHub)](https://github.com/open-atmos/PySDM/blob/main/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb)\n", "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb) \n", "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-atmos/PySDM/blob/main/examples/PySDM_examples/Graf_et_al_2019/figure_4.ipynb)" - ], - "metadata": { - "collapsed": false - }, - "id": "327f2a018faf3142" + ] }, { "cell_type": "markdown", - "source": [ - "based on [Graf et al. 2019](https://doi.org/10.5194/acp-19-747-2019)" - ], + "id": "aa160d9c48befc58", "metadata": { "collapsed": false }, - "id": "aa160d9c48befc58" + "source": [ + "based on [Graf et al. 2019](https://doi.org/10.5194/acp-19-747-2019)" + ] }, { "cell_type": "code", + "execution_count": 13, + "id": "2432d43d15e97625", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:43:41.429069Z", + "start_time": "2024-01-11T08:43:41.423952Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "import math\n", @@ -38,93 +47,93 @@ "from PySDM.initialisation.sampling import spectral_sampling\n", "from PySDM.initialisation import equilibrate_wet_radii, discretise_multiplicities\n", "from PySDM import products" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:43:41.429069Z", - "start_time": "2024-01-11T08:43:41.423952Z" - } - }, - "id": "2432d43d15e97625", - "execution_count": 13 + ] }, { "cell_type": "code", + "execution_count": 2, + "id": "81d815991be0cc9", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:35.791569Z", + "start_time": "2024-01-11T08:42:35.352112Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "formulae = Formulae()\n", "const = formulae.constants\n", - "pvs_Celsius = formulae.saturation_vapour_pressure.pvs_Celsius\n", + "pvs_water = formulae.saturation_vapour_pressure.pvs_water\n", "\n", "RH0 = .75\n", "p0 = 950 * si.hPa\n", - "T0_C = 12 * si.K\n", + "T0 = const.T0 + 12 * si.K\n", "alt_initial = 500 * si.m \n", "alt_final = 3500 * si.m\n", "\n", "total_displacement = alt_final - alt_initial\n", - "initial_water_vapour_mixing_ratio = const.eps / (p0 / RH0 / pvs_Celsius(T0_C) - 1)\n", + "initial_water_vapour_mixing_ratio = const.eps / (p0 / RH0 / pvs_water(T0) - 1)\n", "\n", "n_sd = 1\n", "dt = 10 * si.s\n", "vertical_velocity = 2.5 * si.m / si.s" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:35.791569Z", - "start_time": "2024-01-11T08:42:35.352112Z" - } - }, - "id": "81d815991be0cc9", - "execution_count": 2 + ] }, { "cell_type": "code", + "execution_count": 3, + "id": "dada2ae5b4083f0e", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:35.796706Z", + "start_time": "2024-01-11T08:42:35.793581Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "env = Parcel(\n", " # given in the paper\n", " p0=p0,\n", - " T0=T0_C + const.T0,\n", + " T0=T0,\n", " initial_water_vapour_mixing_ratio=initial_water_vapour_mixing_ratio,\n", " # arbitrary choices\n", " w=vertical_velocity,\n", " dt=dt,\n", " mass_of_dry_air=1e3 * si.kg,\n", ")" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:35.796706Z", - "start_time": "2024-01-11T08:42:35.793581Z" - } - }, - "id": "dada2ae5b4083f0e", - "execution_count": 3 + ] }, { "cell_type": "code", - "outputs": [], - "source": [ - "builder = Builder(backend=CPU(formulae=formulae), n_sd=n_sd, environment=env)\n", - "builder.add_dynamic(AmbientThermodynamics())\n", - "builder.add_dynamic(Condensation())" - ], + "execution_count": 4, + "id": "47f3f883e4e67ed", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:36.874577Z", "start_time": "2024-01-11T08:42:35.804074Z" - } + }, + "collapsed": false }, - "id": "47f3f883e4e67ed", - "execution_count": 4 + "outputs": [], + "source": [ + "builder = Builder(backend=CPU(formulae=formulae), n_sd=n_sd, environment=env)\n", + "builder.add_dynamic(AmbientThermodynamics())\n", + "builder.add_dynamic(Condensation())" + ] }, { "cell_type": "code", + "execution_count": 5, + "id": "f98070a3d550d65", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:36.878312Z", + "start_time": "2024-01-11T08:42:36.876718Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "spectrum = Lognormal(norm_factor=1e4 / si.mg, m_mode=50 * si.nm, s_geom=1.5)\n", @@ -132,67 +141,67 @@ "cloud_range = (.5 * si.um, 25 * si.um)\n", "output_interval = 4\n", "output_points = 40" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:36.878312Z", - "start_time": "2024-01-11T08:42:36.876718Z" - } - }, - "id": "f98070a3d550d65", - "execution_count": 5 + ] }, { "cell_type": "code", - "outputs": [], - "source": [ - "r_dry, specific_concentration = spectral_sampling.Logarithmic(spectrum).sample(n_sd)" - ], + "execution_count": 6, + "id": "5ec5eabc3c1d3872", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:36.883Z", "start_time": "2024-01-11T08:42:36.880940Z" - } + }, + "collapsed": false }, - "id": "5ec5eabc3c1d3872", - "execution_count": 6 + "outputs": [], + "source": [ + "r_dry, specific_concentration = spectral_sampling.Logarithmic(spectrum).sample(n_sd)" + ] }, { "cell_type": "code", - "outputs": [], - "source": [ - "v_dry = formulae.trivia.volume(radius=r_dry)" - ], + "execution_count": 7, + "id": "ce639f01f48ff348", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:37.072808Z", "start_time": "2024-01-11T08:42:36.886365Z" - } + }, + "collapsed": false }, - "id": "ce639f01f48ff348", - "execution_count": 7 + "outputs": [], + "source": [ + "v_dry = formulae.trivia.volume(radius=r_dry)" + ] }, { "cell_type": "code", - "outputs": [], - "source": [ - "r_wet = equilibrate_wet_radii(r_dry=r_dry, environment=builder.particulator.environment, kappa_times_dry_volume=kappa * v_dry)" - ], + "execution_count": 8, + "id": "28897f499330f699", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:38.909344Z", "start_time": "2024-01-11T08:42:37.088206Z" - } + }, + "collapsed": false }, - "id": "28897f499330f699", - "execution_count": 8 + "outputs": [], + "source": [ + "r_wet = equilibrate_wet_radii(r_dry=r_dry, environment=builder.particulator.environment, kappa_times_dry_volume=kappa * v_dry)" + ] }, { "cell_type": "code", + "execution_count": 9, + "id": "8cf40dfb18e7e082", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:38.913147Z", + "start_time": "2024-01-11T08:42:38.909929Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "attributes = {\n", @@ -201,19 +210,19 @@ " 'kappa times dry volume': kappa * v_dry,\n", " 'volume': formulae.trivia.volume(radius=r_wet)\n", "}" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:38.913147Z", - "start_time": "2024-01-11T08:42:38.909929Z" - } - }, - "id": "8cf40dfb18e7e082", - "execution_count": 9 + ] }, { "cell_type": "code", + "execution_count": 10, + "id": "f36faa7368db791e", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:39.067069Z", + "start_time": "2024-01-11T08:42:38.920056Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "particulator = builder.build(\n", @@ -224,19 +233,19 @@ " products.AmbientTemperature(name=\"T\")\n", " )\n", ")" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:39.067069Z", - "start_time": "2024-01-11T08:42:38.920056Z" - } - }, - "id": "f36faa7368db791e", - "execution_count": 10 + ] }, { "cell_type": "code", + "execution_count": 11, + "id": "843a224f900fb94d", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:45.925004Z", + "start_time": "2024-01-11T08:42:39.077019Z" + }, + "collapsed": false + }, "outputs": [], "source": [ "n_steps = total_displacement / (dt * vertical_velocity)\n", @@ -260,36 +269,1126 @@ " \n", " if levels['0C'] is None and output[\"T\"][-1] < const.T0:\n", " levels['0C'] = .5 * (output['z'][-1] + output[\"z\"][-2])" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:45.925004Z", - "start_time": "2024-01-11T08:42:39.077019Z" - } - }, - "id": "843a224f900fb94d", - "execution_count": 11 + ] }, { "cell_type": "code", + "execution_count": 12, + "id": "a363f02a36a714d", + "metadata": { + "ExecuteTime": { + "end_time": "2024-01-11T08:42:46.314435Z", + "start_time": "2024-01-11T08:42:45.927080Z" + }, + "collapsed": false + }, "outputs": [ { "data": { - "text/plain": "
", - "image/svg+xml": "\n\n\n \n \n \n \n 2024-01-11T09:42:46.281407\n image/svg+xml\n \n \n Matplotlib v3.8.2, https://matplotlib.org/\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + "image/svg+xml": [ + "\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " 2024-01-11T09:42:46.281407\n", + " image/svg+xml\n", + " \n", + " \n", + " Matplotlib v3.8.2, https://matplotlib.org/\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "\n" + ], + "text/plain": [ + "
" + ] }, "metadata": {}, "output_type": "display_data" }, { "data": { - "text/plain": "HTML(value=\"./fig_4a.pdf
\")", "application/vnd.jupyter.widget-view+json": { + "model_id": "30b01b7b859146a7897eba2e25623cf6", "version_major": 2, - "version_minor": 0, - "model_id": "30b01b7b859146a7897eba2e25623cf6" - } + "version_minor": 0 + }, + "text/plain": [ + "HTML(value=\"./fig_4a.pdf
\")" + ] }, "metadata": {}, "output_type": "display_data" @@ -320,58 +1419,49 @@ "xy2.set_xlabel(\"T / C\")\n", "xy1.set_ylabel(\"z / m\")\n", "show_plot('fig_4a.pdf')" - ], - "metadata": { - "collapsed": false, - "ExecuteTime": { - "end_time": "2024-01-11T08:42:46.314435Z", - "start_time": "2024-01-11T08:42:45.927080Z" - } - }, - "id": "a363f02a36a714d", - "execution_count": 12 + ] }, { "cell_type": "code", - "outputs": [], - "source": [], + "execution_count": 12, + "id": "5acab115cd92fd9b", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:46.317574Z", "start_time": "2024-01-11T08:42:46.313381Z" - } + }, + "collapsed": false }, - "id": "5acab115cd92fd9b", - "execution_count": 12 + "outputs": [], + "source": [] }, { "cell_type": "code", - "outputs": [], - "source": [], + "execution_count": 12, + "id": "d0173c4dbd123f7b", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:46.323642Z", "start_time": "2024-01-11T08:42:46.319974Z" - } + }, + "collapsed": false }, - "id": "d0173c4dbd123f7b", - "execution_count": 12 + "outputs": [], + "source": [] }, { "cell_type": "code", - "outputs": [], - "source": [], + "execution_count": 12, + "id": "430e8a3643291372", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-01-11T08:42:46.326817Z", "start_time": "2024-01-11T08:42:46.322560Z" - } + }, + "collapsed": false }, - "id": "430e8a3643291372", - "execution_count": 12 + "outputs": [], + "source": [] } ], "metadata": { diff --git a/examples/PySDM_examples/Jensen_and_Nugent_2017/simulation.py b/examples/PySDM_examples/Jensen_and_Nugent_2017/simulation.py index ab6135624..465d06139 100644 --- a/examples/PySDM_examples/Jensen_and_Nugent_2017/simulation.py +++ b/examples/PySDM_examples/Jensen_and_Nugent_2017/simulation.py @@ -29,9 +29,9 @@ def __init__( gravitational_coalsecence: bool = False, ): const = settings.formulae.constants - pvs_Celsius = settings.formulae.saturation_vapour_pressure.pvs_Celsius + pvs_water = settings.formulae.saturation_vapour_pressure.pvs_water initial_water_vapour_mixing_ratio = const.eps / ( - settings.p0 / settings.RH0 / pvs_Celsius(settings.T0 - const.T0) - 1 + settings.p0 / settings.RH0 / pvs_water(settings.T0) - 1 ) n_gccn = np.count_nonzero(table_3.NA) if gccn else 0 diff --git a/examples/PySDM_examples/Kreidenweis_et_al_2003/settings.py b/examples/PySDM_examples/Kreidenweis_et_al_2003/settings.py index de7bd938a..eba95a612 100644 --- a/examples/PySDM_examples/Kreidenweis_et_al_2003/settings.py +++ b/examples/PySDM_examples/Kreidenweis_et_al_2003/settings.py @@ -7,7 +7,7 @@ from PySDM.initialisation import spectra from PySDM.initialisation.sampling import spectral_sampling as spec_sampling from PySDM.physics import si -from PySDM.physics.constants import PPB, PPM, T0 +from PySDM.physics.constants import PPB, PPM @strict @@ -40,7 +40,7 @@ def __init__( self.p0 = 950 * si.mbar self.T0 = 285.2 * si.K - pv0 = 0.95 * self.formulae.saturation_vapour_pressure.pvs_Celsius(self.T0 - T0) + pv0 = 0.95 * self.formulae.saturation_vapour_pressure.pvs_water(self.T0) self.initial_water_vapour_mixing_ratio = const.eps * pv0 / (self.p0 - pv0) self.kappa = 0.61 diff --git a/examples/PySDM_examples/Lowe_et_al_2019/settings.py b/examples/PySDM_examples/Lowe_et_al_2019/settings.py index 25c674984..dfbc7f54d 100644 --- a/examples/PySDM_examples/Lowe_et_al_2019/settings.py +++ b/examples/PySDM_examples/Lowe_et_al_2019/settings.py @@ -44,9 +44,7 @@ def __init__( self.p0 = 980 * si.mbar self.T0 = 280 * si.K - pv0 = 0.999 * self.formulae.saturation_vapour_pressure.pvs_Celsius( - self.T0 - const.T0 - ) + pv0 = 0.999 * self.formulae.saturation_vapour_pressure.pvs_water(self.T0) self.initial_water_vapour_mixing_ratio = const.eps * pv0 / (self.p0 - pv0) self.cloud_radius_range = (0.5 * si.micrometre, np.inf) diff --git a/examples/PySDM_examples/Miyake_et_al_1968/fig_19.ipynb b/examples/PySDM_examples/Miyake_et_al_1968/fig_19.ipynb index cf68eaf3d..d9fe16ae1 100644 --- a/examples/PySDM_examples/Miyake_et_al_1968/fig_19.ipynb +++ b/examples/PySDM_examples/Miyake_et_al_1968/fig_19.ipynb @@ -2805,7 +2805,7 @@ " CONST = FORMULAE.constants\n", " for temperature in (T0 + 20 * si.K, T0 + 10 * si.K):\n", " for color_i, iso in enumerate(('18O', '17O', '2H')):\n", - " e_s = FORMULAE.saturation_vapour_pressure.pvs_Celsius(temperature - T0)\n", + " e_s = FORMULAE.saturation_vapour_pressure.pvs_water(temperature)\n", " \n", " M_iso = getattr(CONST, f'M_{iso}') + CONST.M_1H + (CONST.M_1H if iso[-1] == 'O' else CONST.M_16O)\n", " \n", diff --git a/examples/PySDM_examples/Niedermeier_et_al_2014/settings.py b/examples/PySDM_examples/Niedermeier_et_al_2014/settings.py index 0dda9eda4..0a29a4ecf 100644 --- a/examples/PySDM_examples/Niedermeier_et_al_2014/settings.py +++ b/examples/PySDM_examples/Niedermeier_et_al_2014/settings.py @@ -3,7 +3,6 @@ from pystrict import strict from PySDM import Formulae -from PySDM.physics import constants as const from PySDM.physics import si @@ -40,7 +39,7 @@ def p0(self): @property def pv0(self): - pvs = self.formulae.saturation_vapour_pressure.pvs_Celsius(self.T0 - const.T0) + pvs = self.formulae.saturation_vapour_pressure.pvs_water(self.T0) return self.initial_relative_humidity * pvs @property diff --git a/examples/PySDM_examples/Pyrcel/settings.py b/examples/PySDM_examples/Pyrcel/settings.py index 6c09ce0b8..1a36a2bad 100644 --- a/examples/PySDM_examples/Pyrcel/settings.py +++ b/examples/PySDM_examples/Pyrcel/settings.py @@ -29,11 +29,8 @@ def __init__( self.vertical_velocity = vertical_velocity self.initial_pressure = initial_pressure self.initial_temperature = initial_temperature - pv0 = ( - initial_relative_humidity - * formulae.saturation_vapour_pressure.pvs_Celsius( - initial_temperature - const.T0 - ) + pv0 = initial_relative_humidity * formulae.saturation_vapour_pressure.pvs_water( + initial_temperature ) self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) self.t_max = displacement / vertical_velocity diff --git a/examples/PySDM_examples/Pyrcel/tutorial_settings.py b/examples/PySDM_examples/Pyrcel/tutorial_settings.py index 12838a2e3..fabee3f29 100644 --- a/examples/PySDM_examples/Pyrcel/tutorial_settings.py +++ b/examples/PySDM_examples/Pyrcel/tutorial_settings.py @@ -29,11 +29,8 @@ def __init__( self.vertical_velocity = vertical_velocity self.initial_pressure = initial_pressure self.initial_temperature = initial_temperature - pv0 = ( - initial_relative_humidity - * formulae.saturation_vapour_pressure.pvs_Celsius( - initial_temperature - const.T0 - ) + pv0 = initial_relative_humidity * formulae.saturation_vapour_pressure.pvs_water( + initial_temperature ) self.initial_vapour_mixing_ratio = const.eps * pv0 / (initial_pressure - pv0) self.t_max = displacement / vertical_velocity diff --git a/examples/PySDM_examples/Rozanski_and_Sonntag_1982/figs_4_5_6.ipynb b/examples/PySDM_examples/Rozanski_and_Sonntag_1982/figs_4_5_6.ipynb index abace7fc3..53187f5ed 100644 --- a/examples/PySDM_examples/Rozanski_and_Sonntag_1982/figs_4_5_6.ipynb +++ b/examples/PySDM_examples/Rozanski_and_Sonntag_1982/figs_4_5_6.ipynb @@ -109,7 +109,7 @@ " 'initial_water_vapour_mixing_ratio': const.eps / ( # TODO #1207: use a physics formula \n", " FIG4_CAPTION_PARAMS['P_init']\n", " / FIG4_CAPTION_PARAMS['RH_init']\n", - " / formulae.saturation_vapour_pressure.pvs_Celsius(FIG4_CAPTION_PARAMS['T_init'] - const.T0)\n", + " / formulae.saturation_vapour_pressure.pvs_water(FIG4_CAPTION_PARAMS['T_init'])\n", " - 1\n", " ),\n", " 'T0': FIG4_CAPTION_PARAMS['T_init'],\n", diff --git a/examples/PySDM_examples/Yang_et_al_2018/simulation.py b/examples/PySDM_examples/Yang_et_al_2018/simulation.py index 6d5ca09b6..7fa2ab525 100644 --- a/examples/PySDM_examples/Yang_et_al_2018/simulation.py +++ b/examples/PySDM_examples/Yang_et_al_2018/simulation.py @@ -30,9 +30,7 @@ def __init__(self, settings, backend=CPU): / ( settings.p0 / settings.RH0 - / self.formulae.saturation_vapour_pressure.pvs_Celsius( - settings.T0 - self.formulae.constants.T0 - ) + / self.formulae.saturation_vapour_pressure.pvs_water(settings.T0) - 1 ), T0=settings.T0, diff --git a/tests/smoke_tests/parcel_b/arabas_and_shima_2017/test_initialisation.py b/tests/smoke_tests/parcel_b/arabas_and_shima_2017/test_initialisation.py index 0c6993404..3137232d8 100644 --- a/tests/smoke_tests/parcel_b/arabas_and_shima_2017/test_initialisation.py +++ b/tests/smoke_tests/parcel_b/arabas_and_shima_2017/test_initialisation.py @@ -28,7 +28,7 @@ def test_T_initialisation(settings_idx): def test_RH_initialisation(settings_idx): setup = setups[settings_idx] pv0 = setup.p0 / (1 + CONST.eps / setup.initial_water_vapour_mixing_ratio) - pvs = setup.formulae.saturation_vapour_pressure.pvs_Celsius(setup.T0 - CONST.T0) + pvs = setup.formulae.saturation_vapour_pressure.pvs_water(setup.T0) TestInitialisation.simulation_test("RH", pv0 / pvs, setup) @staticmethod diff --git a/tests/unit_tests/physics/test_dimensional_analysis.py b/tests/unit_tests/physics/test_dimensional_analysis.py index e9543eebb..a0813a8cc 100644 --- a/tests/unit_tests/physics/test_dimensional_analysis.py +++ b/tests/unit_tests/physics/test_dimensional_analysis.py @@ -29,9 +29,9 @@ def test_fake_numba(): sut = DimensionalAnalysis() # Act & Assert - assert hasattr(Formulae().saturation_vapour_pressure.pvs_Celsius, "py_func") + assert hasattr(Formulae().saturation_vapour_pressure.pvs_water, "py_func") with sut: assert not hasattr( - Formulae().saturation_vapour_pressure.pvs_Celsius, "py_func" + Formulae().saturation_vapour_pressure.pvs_water, "py_func" ) - assert hasattr(Formulae().saturation_vapour_pressure.pvs_Celsius, "py_func") + assert hasattr(Formulae().saturation_vapour_pressure.pvs_water, "py_func") diff --git a/tests/unit_tests/physics/test_formulae.py b/tests/unit_tests/physics/test_formulae.py index 2e6a7a239..8036254ea 100644 --- a/tests/unit_tests/physics/test_formulae.py +++ b/tests/unit_tests/physics/test_formulae.py @@ -20,8 +20,8 @@ def test_pvs_liq(opt): # Arrange formulae = Formulae(saturation_vapour_pressure=opt) si = constants_defaults.si - sut = formulae.saturation_vapour_pressure.pvs_Celsius - T = 300 * si.kelvins + sut = formulae.saturation_vapour_pressure.pvs_water + T = 300 * si.kelvins + constants_defaults.T0 # Act pvs = sut(T) @@ -36,8 +36,8 @@ def test_pvs_ice(opt): # Arrange formulae = Formulae(saturation_vapour_pressure=opt) si = constants_defaults.si - sut = formulae.saturation_vapour_pressure.ice_Celsius - T = 250 * si.kelvins + sut = formulae.saturation_vapour_pressure.pvs_ice + T = 250 * si.kelvins + constants_defaults.T0 # Act pvs = sut(T) diff --git a/tests/unit_tests/physics/test_isotope_relaxation_timescale.py b/tests/unit_tests/physics/test_isotope_relaxation_timescale.py index 329b56876..1fdb61792 100644 --- a/tests/unit_tests/physics/test_isotope_relaxation_timescale.py +++ b/tests/unit_tests/physics/test_isotope_relaxation_timescale.py @@ -33,7 +33,7 @@ def test_unit_and_magnitude(paper, iso): alpha_iso = getattr( formulae.isotope_equilibrium_fractionation_factors, f"alpha_l_{iso}" )(temperature) - e_s = formulae.saturation_vapour_pressure.pvs_Celsius(temperature - const.T0) + e_s = formulae.saturation_vapour_pressure.pvs_water(temperature) radius = 0.1 * si.mm vent_coeff = 1.01 diff --git a/tests/unit_tests/physics/test_saturation_vapour_pressure.py b/tests/unit_tests/physics/test_saturation_vapour_pressure.py index 317984ab2..c4b1fd132 100644 --- a/tests/unit_tests/physics/test_saturation_vapour_pressure.py +++ b/tests/unit_tests/physics/test_saturation_vapour_pressure.py @@ -27,10 +27,12 @@ def test_saturation_vapour_pressure(plot=False): if name[:2] not in ("__", "a_"): if not ( key in ("AugustRocheMagnus", "Wexler1976", "Bolton1980") - and name == "ice_Celsius" + and name == "pvs_ice" ): pyplot.plot( - temperature, func(temperature), label=f"{key}::{name}" + temperature, + func(temperature + const.T0), + label=f"{key}::{name}", ) pyplot.grid() pyplot.legend() @@ -46,10 +48,10 @@ def test_saturation_vapour_pressure(plot=False): np.testing.assert_allclose( Formulae( saturation_vapour_pressure=choices_keys[0] - ).saturation_vapour_pressure.pvs_Celsius(temperature), + ).saturation_vapour_pressure.pvs_water(temperature + const.T0), Formulae( saturation_vapour_pressure=choice - ).saturation_vapour_pressure.pvs_Celsius(temperature), + ).saturation_vapour_pressure.pvs_water(temperature + const.T0), rtol=2e-2, ) @@ -59,19 +61,19 @@ def test_saturation_vapour_pressure(plot=False): np.testing.assert_array_less( Formulae( saturation_vapour_pressure="FlatauWalkoCotton" - ).saturation_vapour_pressure.ice_Celsius(temperature), + ).saturation_vapour_pressure.pvs_ice(temperature + const.T0), Formulae( saturation_vapour_pressure=choice - ).saturation_vapour_pressure.pvs_Celsius(temperature), + ).saturation_vapour_pressure.pvs_water(temperature + const.T0), ) temperature = np.linspace(1, 1, 100) np.testing.assert_array_less( Formulae( saturation_vapour_pressure="FlatauWalkoCotton" - ).saturation_vapour_pressure.pvs_Celsius(temperature), + ).saturation_vapour_pressure.pvs_water(temperature + const.T0), Formulae( saturation_vapour_pressure=choice - ).saturation_vapour_pressure.ice_Celsius(temperature), + ).saturation_vapour_pressure.pvs_ice(temperature + const.T0), ) @staticmethod @@ -91,7 +93,7 @@ def test_saturation_vapour_pressure(plot=False): ) def test_wexler_1976_table_1(T_C, expected_es_mb): formulae = Formulae(saturation_vapour_pressure="Wexler1976") - actual_es = formulae.saturation_vapour_pressure.pvs_Celsius(T_C) + actual_es = formulae.saturation_vapour_pressure.pvs_water(T_C + const.T0) np.testing.assert_approx_equal( actual=actual_es, desired=expected_es_mb * si.mbar, significant=4 )