From f2207c00610234761fee5ed850d1b0311817c8b8 Mon Sep 17 00:00:00 2001 From: 720suprem360 Date: Wed, 26 Feb 2025 12:52:31 -0500 Subject: [PATCH 1/2] Updated Antoine equation. Returns error if number of Antoine coefficients provided is not a multiple of three. Also able to compute saturation pressure for a single row of Antoine coefficients. --- antoine.py | 61 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/antoine.py b/antoine.py index 68068c4..9b02529 100644 --- a/antoine.py +++ b/antoine.py @@ -1,26 +1,41 @@ def antoine( a, T): - # Ps = antoine( a, T) - # - # Uses Antoine's equation to obtain the vapor pressure of a substance given - # the coefficients of the equation: - # Ps = a1 - a2/(a3+T) - # - # INPUTS: - # a - the antoine coefficients with coeffients in columns and species in - # rows. Coefficients from NIST expect units of bar and K. - # T - the temperature at which the vapor pressure is evaluated (K) - # tempUnit - OPTIONAL the unit of temperature used - # - # OUTPUT: - # Ps - row vector of species vapor pressures at the specified temperature, - # typically in bar. - # - # The units depend on the units used for the coefficients. The user is - # responsible for maintaining consistency with units. NIST uses bar and K. - # - # Code originally by: James C. Sutherland - # Modified by: Tyler R. Josephson - # Changed comment +"""Antoine's equation calculator + + This uses Antoine's equation to calculate the vapor pressure of a fluid + given the coefficients of the equation: Ps = a1 - a2/(a3 + T). - Ps = 10.0**( a[:,0] - a[:,1] / ( a[:,2] + T ) ) + Parameters + ---------- + a : the Antoine coefficients with coefficients in columns and species in rows. + T : the temperature to evaluate the vapor pressure at. + + Returns + ------- + Ps : row vector of vapor pressures for all species at the specified temperature + + The units depend on the units used for the coefficients. The user is + responsible for maintaining consistency with units. Customarily, + coefficients are supplied for pressure in mmHg and T in Celsius. + + The coefficient argument 'a' can be in typical Python list notation. + + Examples + -------- + >>> Ps = antoine(a, T) + + """ + import numpy as np + a = np.array(a) + b = np.shape(a) + c = np.size(a) + d = str(c/3) + e = np.char.endswith(d,'.0') + + if e == False: + Ps = 'Error! You are inputting either too many or too little Antoine coefficients. This function only accepts multiples of three.' + print(Ps) + if len(b)==1: + Ps = 10**(a[0]-a[1] / (a[2] + T) ) + else: + Ps = 10.0**(a[:,0]-a[:,1] / ( a[:,2] + T ) ) return Ps From a8296c9d8f379e9441b27ebc9e2ad88b0acb7771 Mon Sep 17 00:00:00 2001 From: 720suprem360 Date: Wed, 26 Feb 2025 14:00:49 -0500 Subject: [PATCH 2/2] Update antoine.py --- antoine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/antoine.py b/antoine.py index 9b02529..a714062 100644 --- a/antoine.py +++ b/antoine.py @@ -32,7 +32,7 @@ def antoine( a, T): e = np.char.endswith(d,'.0') if e == False: - Ps = 'Error! You are inputting either too many or too little Antoine coefficients. This function only accepts multiples of three.' + Ps = 'Error! This function only accepts a 3n count of Antoine coefficients.' print(Ps) if len(b)==1: Ps = 10**(a[0]-a[1] / (a[2] + T) )