From 7642f4c22d459ec32d355a70136a8ed6f4bc1c1f Mon Sep 17 00:00:00 2001 From: Caleb Bell Date: Fri, 13 Dec 2024 09:53:09 -0700 Subject: [PATCH] Code cleanup --- tests/Data/joback_log_good_sorted.txt | 1 - tests/test_chemical.py | 2 +- tests/test_heat_capacity.py | 11 +++++++++++ thermo/electrochem.py | 4 +--- thermo/utils/t_dependent_property.py | 3 +++ 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/Data/joback_log_good_sorted.txt b/tests/Data/joback_log_good_sorted.txt index dc7650b3..e564f14c 100644 --- a/tests/Data/joback_log_good_sorted.txt +++ b/tests/Data/joback_log_good_sorted.txt @@ -2321,7 +2321,6 @@ Did not match all atoms present 110690-43-2 CCOCN1C=C(C(=O)N(C1=O)C(=O)C2=CC(=CC Did not match all atoms present 1107-00-2 C1=CC2=C(C=C1C(C3=CC4=C(C=C3)C(=O)OC4=O)(C(F)(F)F)C(F)(F)F)C(=O)OC2=O {16: 6, 28: 4, 4: 3, 14: 6} Did not match all atoms present 1107-69-3 C/C(=N\NC1=C(C=C(C=C1)[N+](=O)[O-])[N+](=O)[O-])/C=N/NC2=C(C=C(C=C2)[N+](=O)[O-])[N+](=O)[O-] {1: 1, 34: 2, 38: 4, 6: 1, 7: 1, 14: 6, 31: 2} Did not match all atoms present 110720-66-6 [C@@H]([C@H](C(=O)[O-])O)(C(=O)[O-])O.[Ca+2] {24: 2, 3: 2, 20: 2} -Did not match all atoms present 11073-85-1 [Ge].[Te] {} Did not match all atoms present 110735-99-4 C(COC(=O)CC(C(=O)OCCC(C(C(C(C(C(F)(F)F)(F)F)(F)F)(F)F)(F)F)(F)F)S(=O)(=O)[O-])C(C(C(C(C(C(F)(F)F)(F)F)(F)F)(F)F)(F)F)(F)F.[Na+] {2: 5, 3: 1, 4: 12, 16: 26, 28: 2, 29: 3} Did not match all atoms present 110736-41-9 O.O.O.[Fe].[Fe] {} Did not match all atoms present 11075-28-8 C1=CC=C2C(=C1)C(=O)C3=C(C=CC(=C3C2=O)NCC(CCl)O)NCC(CCl)O {2: 4, 3: 2, 14: 6, 17: 2, 20: 2, 25: 2, 31: 2} diff --git a/tests/test_chemical.py b/tests/test_chemical.py index a6e01c54..90a3c8ac 100644 --- a/tests/test_chemical.py +++ b/tests/test_chemical.py @@ -292,7 +292,7 @@ def test_H_Chemical(): @pytest.mark.meta_Chemical @pytest.mark.deprecated def test_all_chemicals(): - for i in pubchem_db.CAS_index.values(): + for i in pubchem_db: c = Chemical(i.CASs) print(i.CASs) diff --git a/tests/test_heat_capacity.py b/tests/test_heat_capacity.py index 996a0f32..eab33fc4 100644 --- a/tests/test_heat_capacity.py +++ b/tests/test_heat_capacity.py @@ -874,6 +874,7 @@ def test_JANAF_fit_carbon_exists(): @pytest.mark.slow @pytest.mark.fuzz +@pytest.mark.meta_T_dept def test_locked_integral(): obj = HeatCapacityGas(load_data=False, CASRN="7732-18-5", similarity_variable=0.16652530518537598, MW=18.01528, extrapolation="linear", method="POLY_FIT", @@ -888,6 +889,7 @@ def test_locked_integral(): @pytest.mark.slow @pytest.mark.fuzz +@pytest.mark.meta_T_dept def test_locked_integral_over_T(): obj = HeatCapacityGas(load_data=False, CASRN="7732-18-5", similarity_variable=0.16652530518537598, MW=18.01528, extrapolation="linear", method="POLY_FIT", poly_fit=(50.0, 1000.0, [5.543665000518528e-22, -2.403756749600872e-18, 4.2166477594350336e-15, -3.7965208514613565e-12, 1.823547122838406e-09, -4.3747690853614695e-07, 5.437938301211039e-05, -0.003220061088723078, 33.32731489750759])) @@ -899,3 +901,12 @@ def to_int(T): quad_ans = quad(to_int, T1, T2)[0] analytical_ans = obj.T_dependent_property_integral_over_T(T1, T2) assert_close(quad_ans, analytical_ans, rtol=1e-5) + +@pytest.mark.meta_T_dept +def test_heat_capacity_interp1d_removed_extrapolation_method_compatibility(): + EtOH = HeatCapacityGas(CASRN='64-17-5', similarity_variable=0.1953615, MW=46.06844, extrapolation='interp1d', method='POLING_POLY') + assert_close(EtOH(EtOH.Tmin - 10), 37.421995400002054) + assert_close(EtOH(EtOH.Tmax + 10), 142.81153700770574) + EtOH = HeatCapacityGas(CASRN='64-17-5', similarity_variable=0.1953615, MW=46.06844, extrapolation='interp1d|interp1d', method='POLING_POLY') + assert_close(EtOH(EtOH.Tmin - 10), 37.421995400002054) + assert_close(EtOH(EtOH.Tmax + 10), 142.81153700770574) \ No newline at end of file diff --git a/thermo/electrochem.py b/thermo/electrochem.py index d03e716c..b38025a6 100644 --- a/thermo/electrochem.py +++ b/thermo/electrochem.py @@ -749,8 +749,6 @@ def Laliberte_heat_capacity_mix(T, ws, a1s, a2s, a3s, a4s, a5s, a6s): Temperature of fluid [K] ws : array Weight fractions of fluid components other than water - CASRNs : array - CAS numbers of the fluid components other than water Returns ------- @@ -798,7 +796,7 @@ def Laliberte_heat_capacity(T, ws, CASRNs): Temperature of fluid [K] ws : array Weight fractions of fluid components other than water - CASRNs : array + CASRNs : list[str] CAS numbers of the fluid components other than water Returns diff --git a/thermo/utils/t_dependent_property.py b/thermo/utils/t_dependent_property.py index 67d3af4f..ec6285ea 100644 --- a/thermo/utils/t_dependent_property.py +++ b/thermo/utils/t_dependent_property.py @@ -4264,6 +4264,9 @@ def extrapolation(self): @extrapolation.setter def extrapolation(self, extrapolation): + # backwards compatibility + if extrapolation is not None: + extrapolation = extrapolation.replace('interp1d', 'linear') self._extrapolation = extrapolation if extrapolation is None: self.extrapolation_split = False