Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions TxyNotebook.ipynb

Large diffs are not rendered by default.

58 changes: 35 additions & 23 deletions antoine.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
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)

if len(b)==1:
Ps = 10**(a[0]-a[1] / (a[2] + T) )
Ps = np.round(Ps,3)
else:
Ps = 10.0**(a[:,0]-a[:,1] / ( a[:,2] + T ) )
Ps = np.round(Ps,3)

return Ps
8 changes: 4 additions & 4 deletions raoult_law_kvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def raoult_law_kvalue( T, P, a, *gamma):
# Modified by Tyler R. Josephson

ns,nc = a.shape
# makes np array of zeros
K = np.zeros(ns)
Ps = antoine(a, T)
K = Ps/P
# removed the array of zeros as it should directly work, efficiency wise
Ps = antoine(a, T) # pulls the constant values and Temperature in Celcius into antiones eqn to find sat pressure
K = Ps/P
if gamma:

K *= gamma

return K
Expand Down