From 7dea8c592db829bdc4cb3d1b45a985ecc0b215f1 Mon Sep 17 00:00:00 2001 From: Adel Qalieh Date: Sat, 17 Sep 2022 08:39:54 -0400 Subject: [PATCH 1/6] Revert units back to kJ consistently --- thermochem/janaf.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/thermochem/janaf.py b/thermochem/janaf.py index f3b675f..c022538 100644 --- a/thermochem/janaf.py +++ b/thermochem/janaf.py @@ -56,10 +56,10 @@ class JanafPhase(object): [ 57.077 59.704 115.753] >>> print(p.hef([500, 550, 1800])) # H-H(Tr) in kJ/mol [ 12.562 15.9955 110.022 ] - >>> print(p.DeltaH([500, 550, 1800])) # Enthalpy in kJ/mol - [-943670. -943229.5 -936679. ] + >>> print(p.DeltaH([500, 550, 1800])) # Standard enthalpy of formation in kJ/mol + [-943.670 -943.2295 -936.679 ] >>> print(p.DeltaG([500, 550, 1800])) # Gibbs free enegy in kJ/mol - [-852157. -843046.5 -621013. ] + [-852.157 -843.0465 -621.013 ] >>> p.logKf([500, 550, 1800]).astype(int).tolist() # Equilibrium constant of formation. [89, 80, 18] >>> print(p.cp(1000)) # Heat capacity in J/mol/K @@ -102,10 +102,6 @@ def __init__(self, rawdata_text): # Convert to floats. data[c] = pd.to_numeric(data[c], errors='coerce') - # Convert all units to Joules. - data['Delta_fH'] *= 1000 - data['Delta_fG'] *= 1000 - # Handle NaNs for the phase transition points. This only affects # Delta_fG, Delta_fH, and log(Kf) good_indices = np.where(np.isfinite(data['Delta_fH'])) @@ -130,8 +126,8 @@ def __str__(self): rep += "\n S(%0.2f) = %0.3f J/mol/K" % (Tr, self.S(Tr)) rep += "\n [G-H(%0.2f)]/%0.2f = %0.3f J/mol/K" % (Tr, Tr, self.gef(Tr)) rep += "\n H-H(%0.2f) = %0.3f J/mol/K" % (Tr, self.hef(Tr)) - rep += "\n Delta_fH(%0.2f) = %0.0f J/mol" % (Tr, self.DeltaH(Tr)) - rep += "\n Delta_fG(%0.2f) = %0.0f J/mol" % (Tr, self.DeltaG(Tr)) + rep += "\n Delta_fH(%0.2f) = %0.3f kJ/mol" % (Tr, self.DeltaH(Tr)) + rep += "\n Delta_fG(%0.2f) = %0.3f kJ/mol" % (Tr, self.DeltaG(Tr)) rep += "\n log(Kf((%0.2f)) = %0.3f" % (Tr, self.logKf(Tr)) return rep @@ -272,8 +268,8 @@ def getphasedata(self, S(298.15) = 60.752 J/mol/K [G-H(298.15)]/298.15 = 60.752 J/mol/K H-H(298.15) = 0.000 J/mol/K - Delta_fH(298.15) = -272044 J/mol - Delta_fG(298.15) = -251429 J/mol + Delta_fH(298.15) = -272.044 kJ/mol + Delta_fG(298.15) = -251.429 kJ/mol log(Kf((298.15)) = 44.049 """ From eeb21de03e3e147ed6fcda944a979ddc2e4047bb Mon Sep 17 00:00:00 2001 From: Adel Qalieh Date: Sat, 17 Sep 2022 08:49:40 -0400 Subject: [PATCH 2/6] Add TODOs for deprecation warnings --- thermochem/burcat.py | 1 + thermochem/janaf.py | 1 + 2 files changed, 2 insertions(+) diff --git a/thermochem/burcat.py b/thermochem/burcat.py index 680d2b9..84608f9 100644 --- a/thermochem/burcat.py +++ b/thermochem/burcat.py @@ -60,6 +60,7 @@ def cpo(self, T): # I know perfectly that the most efficient way of evaluating # polynomials is recursively but I want the implementation to # be as explicit as possible + # TODO: Setting array element with sequence will be deprecated in Numpy Ta = np.array([1, T, T ** 2, T ** 3, T ** 4], 'd') if T > 200 and T <= 1000: return np.dot(self.Tmin_[:5], Ta) * R diff --git a/thermochem/janaf.py b/thermochem/janaf.py index c022538..2746d20 100644 --- a/thermochem/janaf.py +++ b/thermochem/janaf.py @@ -77,6 +77,7 @@ def __init__(self, rawdata_text): self.description = self.rawdata_text.splitlines()[0] # Read the text file into a DataFrame. + # TODO: adjust usecols length to be within bounds, Pandas deprecation data = pd.read_csv( StringIO(self.rawdata_text), skiprows=2, From ba60ec8c716c2b1fe5d37a49cf9ccb1a850c0477 Mon Sep 17 00:00:00 2001 From: Dan J Bower Date: Tue, 27 Feb 2024 21:50:22 +0100 Subject: [PATCH 3/6] add l,g as a valid phase type --- thermochem/janaf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thermochem/janaf.py b/thermochem/janaf.py index 2746d20..c169987 100644 --- a/thermochem/janaf.py +++ b/thermochem/janaf.py @@ -146,7 +146,7 @@ class Janafdb(object): To load thermodynamic constants for TiO2, rutile. """ VALIDPHASETYPES = ['cr', 'l', 'cr,l', 'g', 'ref', 'cd', 'fl', 'am', 'vit', - 'mon', 'pol', 'sln', 'aq', 'sat'] + 'mon', 'pol', 'sln', 'aq', 'sat', 'l,g'] JANAF_URL = "https://janaf.nist.gov/tables/%s.txt" def __init__(self): From 978495d1f2a1db6638931480cae6bc8b6fed0ebf Mon Sep 17 00:00:00 2001 From: Dan J Bower Date: Fri, 22 Mar 2024 21:59:27 +0100 Subject: [PATCH 4/6] Raise ParserWarning not ParserError for Pandas > 1.3.5 Raise a ParserWarning to avoid the ParserError `pandas.errors.ParserError: Defining usecols with out-of-bounds indices is not allowed.` when using Pandas>1.3.5. Now a warning is output for the problematic lines (which relate to comments in the JANAF data). Tested on an example txt file: https://janaf.nist.gov/tables/H-066.txt --- thermochem/janaf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/thermochem/janaf.py b/thermochem/janaf.py index c169987..59ba4c6 100644 --- a/thermochem/janaf.py +++ b/thermochem/janaf.py @@ -77,7 +77,6 @@ def __init__(self, rawdata_text): self.description = self.rawdata_text.splitlines()[0] # Read the text file into a DataFrame. - # TODO: adjust usecols length to be within bounds, Pandas deprecation data = pd.read_csv( StringIO(self.rawdata_text), skiprows=2, @@ -85,7 +84,7 @@ def __init__(self, rawdata_text): delimiter=r'[\t\s]+', engine='python', names=['T', 'Cp', 'S', '[G-H(Tr)]/T', 'H-H(Tr)', 'Delta_fH', 'Delta_fG', 'log(Kf)'], - usecols=range(8) # Ignore extra columns -- those are caused by comments in the text file + on_bad_lines='warn' ) self.rawdata = data From f35dc37211441a9feb6d425de65b0f4c2179b1e6 Mon Sep 17 00:00:00 2001 From: Dan J Bower Date: Fri, 22 Mar 2024 22:18:12 +0100 Subject: [PATCH 5/6] Update Pandas version This is related to pull request #30, which requires at least Pandas 1.3.0 for the `on_bad_lines` keyword argument to be available. See https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index a990203..dff7809 100644 --- a/README.rst +++ b/README.rst @@ -55,7 +55,7 @@ automatically with any of the installation instructions provided. - SciPy >= 0.6.0 -- pandas >= 0.17.0 +- pandas >= 1.3.0 Development ----------- From 579d3c4a80d627893350f3b50df73aab3ae16570 Mon Sep 17 00:00:00 2001 From: Dan J Bower Date: Mon, 8 Apr 2024 17:32:55 +0200 Subject: [PATCH 6/6] Update dependency versions (#31) * Update dependency versions Minimum requirements for pandas 1.3.0. * Update setup.py Update dependencies --- README.rst | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index dff7809..81a6523 100644 --- a/README.rst +++ b/README.rst @@ -51,9 +51,9 @@ Dependencies This packages depends on the following modules to run. These should be installed automatically with any of the installation instructions provided. -- NumPy >= 1.2.1 +- NumPy >= 1.17.3 -- SciPy >= 0.6.0 +- SciPy >= 1.12.0 - pandas >= 1.3.0 diff --git a/setup.py b/setup.py index 7010588..2c24767 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ license="BSD", packages=find_packages(), include_package_data=True, - install_requires=['scipy>=0.6.0', 'numpy>=1.2.1', 'pandas>=0.17.0'], + install_requires=['scipy>=1.12.0', 'numpy>=1.17.3', 'pandas>=1.3.0'], zip_safe=False, keywords='thermo chemistry physics', classifiers=[