From 7b217a1b71d3204759a4e6156f8fd92ed4815d5a Mon Sep 17 00:00:00 2001 From: "David E. Bernal Neira" Date: Wed, 5 Aug 2026 15:44:45 -0400 Subject: [PATCH] Name the ice vapor-pressure coefficients and reuse Vapor_pressure The two coefficients of the ice vapor-pressure correlation appeared as bare literals in three places: Vapor_pressure, the inverted form in Tbot_max_eq_cap, and an inline re-derivation in Eq_Constraints. A correction to either coefficient had to be found in all three, and the inverted form is easy to miss because the numbers appear rearranged. Name them as module constants with their units, use them in both the forward and inverted forms, and have Eq_Constraints call Vapor_pressure instead of re-deriving it. The C1 rewrite is bitwise identical over the primary drying range (max abs diff 0.0 across -45 to 5 degC). Refs #12. Full test suite: 144 passed, 1 skipped. --- lyopronto/functions.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lyopronto/functions.py b/lyopronto/functions.py index e13570a7..14b43b46 100644 --- a/lyopronto/functions.py +++ b/lyopronto/functions.py @@ -22,6 +22,12 @@ import numpy as np from . import constant +# Antoine-form coefficients for the vapor pressure of ice over the primary +# drying range, in Torr and K. Used by Vapor_pressure and by its inverse in +# Tbot_max_eq_cap. +VAPOR_PRESSURE_PREEXPONENTIAL = 2.698e10 +VAPOR_PRESSURE_TEMPERATURE_COEFFICIENT = 6144.96 + ####################### Functions ####################### ## @@ -32,7 +38,7 @@ def Vapor_pressure(T_sub): temperature [degC] """ - p = 2.698e10*np.exp(-6144.96/(273.15+T_sub)) # Vapor pressure at the sublimation temperature [Torr] + p = VAPOR_PRESSURE_PREEXPONENTIAL*np.exp(-VAPOR_PRESSURE_TEMPERATURE_COEFFICIENT/(273.15+T_sub)) # Vapor pressure at the sublimation temperature [Torr] return p @@ -202,7 +208,7 @@ def Tbot_max_eq_cap(Pch,dm_dt,Lpr0,Lck,Rp,Ap): """ P_sub = dm_dt/Ap*Rp + Pch # Sublimation front pressure [Torr] - T_sub = -6144.96/np.log(P_sub/2.698e10) - 273.15 # Sublimation front temperature [degC] + T_sub = -VAPOR_PRESSURE_TEMPERATURE_COEFFICIENT/np.log(P_sub/VAPOR_PRESSURE_PREEXPONENTIAL) - 273.15 # Sublimation front temperature [degC] Tbot = T_sub + (Lpr0-Lck)*(P_sub-Pch)*constant.dHs/Rp/constant.hr_To_s/constant.k_ice # Vial bottom temperature [degC] Tbot_max = np.max(Tbot) # Maximum vial bottom temperature [degC] @@ -234,7 +240,7 @@ def Eq_Constraints(Pch,dmdt,Tbot,Tsh,Psub,Tsub,Kv,Lpr0,Lck,Av,Ap,Rp): vial area [cm^2], product area [cm^2], and product resistance [cm^2-Torr-hr/g] """ - C1 = Psub - 2.698e10*np.exp(-6144.96/(273.15+Tsub)) # Vapor pressure at the sublimation temperature [Torr] + C1 = Psub - Vapor_pressure(Tsub) # Vapor pressure at the sublimation temperature [Torr] C2 = dmdt - Ap/Rp/constant.kg_To_g*(Psub-Pch) # Sublimation rate [kg/hr]