From b2dae3523f205ad08672a20e97664f428160bccf Mon Sep 17 00:00:00 2001 From: Caleb Bell Date: Fri, 16 Dec 2016 22:38:22 -0400 Subject: [PATCH] Removed documentation for pr; changed VolumeGas to use EOS --- docs/thermo.pr.rst | 7 ------ docs/thermo.rst | 1 - tests/test_eos.py | 8 ++----- tests/test_utils.py | 16 ++++++------- tests/test_volume.py | 6 +++-- thermo/chemical.py | 34 +++++++++++++++++++--------- thermo/eos.py | 26 ++++++++++++++++++++- thermo/pr.py | 4 ++++ thermo/utils.py | 2 +- thermo/vapor_pressure.py | 10 +++++--- thermo/volume.py | 49 +++++++++++++++++++++++++++++----------- 11 files changed, 109 insertions(+), 54 deletions(-) delete mode 100644 docs/thermo.pr.rst diff --git a/docs/thermo.pr.rst b/docs/thermo.pr.rst deleted file mode 100644 index 248462ca..00000000 --- a/docs/thermo.pr.rst +++ /dev/null @@ -1,7 +0,0 @@ -thermo.pr module -================ - -.. automodule:: thermo.pr - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/thermo.rst b/docs/thermo.rst index 7695e166..31392a5f 100644 --- a/docs/thermo.rst +++ b/docs/thermo.rst @@ -27,7 +27,6 @@ Submodules thermo.miscdata thermo.permittivity thermo.phase_change - thermo.pr thermo.reaction thermo.refractivity thermo.safety diff --git a/tests/test_eos.py b/tests/test_eos.py index 5a00fc50..3bc4ece0 100644 --- a/tests/test_eos.py +++ b/tests/test_eos.py @@ -814,9 +814,7 @@ def dV_dT(T, P, eos, order=0, phase=True, Tc=507.6, Pc=3025000., omega=0.2975): continue x.append(numer) y.append(ana) - ans = allclose_variable(x, y, limits=[.009, .05, .65, .93],rtols=[1E-5, 1E-6, 1E-9, 1E-10]) - if not ans: - raise Exception('dVdT numerical derivative failing!') + assert allclose_variable(x, y, limits=[.009, .05, .65, .93],rtols=[1E-5, 1E-6, 1E-9, 1E-10]) @pytest.mark.slow @@ -850,8 +848,6 @@ def dV_dP(P, T, eos, order=0, phase=True, Tc=507.6, Pc=3025000., omega=0.2975): continue x.append(numer) y.append(ana) - ans = allclose_variable(x, y, limits=[.02, .04, .04, .05, .15, .45, .95], + assert allclose_variable(x, y, limits=[.02, .04, .04, .05, .15, .45, .95], rtols=[1E-2, 1E-3, 1E-4, 1E-5, 1E-6, 1E-7, 1E-9]) - if not ans: - raise Exception('Error') diff --git a/tests/test_utils.py b/tests/test_utils.py index 636dbba8..7fde0028 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -445,14 +445,10 @@ def test_allclose_variable(): x = [2.7244322249597719e-08, 3.0105683900110473e-10, 2.7244124924802327e-08, 3.0105259397637556e-10, 2.7243929226310193e-08, 3.0104990272770901e-10, 2.7243666849384451e-08, 3.0104101821236015e-10, 2.7243433745917367e-08, 3.0103707421519949e-10] y = [2.7244328304561904e-08, 3.0105753470546008e-10, 2.724412872417824e-08, 3.0105303055834564e-10, 2.7243914341030203e-08, 3.0104819238021998e-10, 2.7243684057561379e-08, 3.0104299541023674e-10, 2.7243436694839306e-08, 3.010374130526363e-10] - ans = allclose_variable(x, y, limits=[.0, .5], rtols=[1E-5, 1E-6]) - if not ans: - raise Exception('Failure') + assert allclose_variable(x, y, limits=[.0, .5], rtols=[1E-5, 1E-6]) with pytest.raises(Exception): - ans = allclose_variable(x, y, limits=[.0, .1], rtols=[1E-5, 1E-6]) - if not ans: - raise Exception('Failure') + assert allclose_variable(x, y, limits=[.0, .1], rtols=[1E-5, 1E-6]) with pytest.raises(Exception): allclose_variable(x, y[1:], limits=[.0, .5], rtols=[1E-5, 1E-6]) @@ -463,6 +459,8 @@ def test_allclose_variable(): x = [1,1,1,1,1,1,1,1,1] y = [.9,.9,.9,.9,.9,.9,.9,.9, .9] - ans = allclose_variable(x, y, limits=[.0], atols=[.1]) - if ans is False: - raise Exception('Failure on a unit test') + assert allclose_variable(x, y, limits=[.0], atols=[.1]) + + +def test_horner(): + assert horner([1,2,3], 3) == 18 \ No newline at end of file diff --git a/tests/test_volume.py b/tests/test_volume.py index b753cf1e..7b8a8f94 100644 --- a/tests/test_volume.py +++ b/tests/test_volume.py @@ -25,6 +25,7 @@ import pytest import pandas as pd from thermo.volume import * +from thermo.eos import * from thermo.utils import Vm_to_rho from thermo.identifiers import checkCAS @@ -270,9 +271,10 @@ def test_ideal_gas(): @pytest.mark.meta_T_dept def test_VolumeGas(): - SO2 = VolumeGas(CASRN='7446-09-5', MW=64.0638, Tc=430.8, Pc=7884098.25, omega=0.251, dipole=1.63) + eos = [PR(T=300, P=1E5, Tc=430.8, Pc=7884098.25, omega=0.251)] + SO2 = VolumeGas(CASRN='7446-09-5', MW=64.0638, Tc=430.8, Pc=7884098.25, omega=0.251, dipole=1.63, eos=eos) Vm_calcs = [(SO2.set_user_methods_P(i, forced_P=True), SO2.TP_dependent_property(305, 1E5))[1] for i in SO2.all_methods_P] - Vm_exp = [0.025024421772080314, 0.02499978619699621, 0.02499586901117375, 0.02499627309459868, 0.02499978619699621, 0.024971467450477493, 0.02535910239] + Vm_exp = [0.025024302563892417, 0.02499978619699621, 0.02499586901117375, 0.02499627309459868, 0.02499978619699621, 0.024971467450477493, 0.02535910239] assert_allclose(sorted(Vm_calcs), sorted(Vm_exp)) # Test that methods return None diff --git a/thermo/chemical.py b/thermo/chemical.py index d35afe79..d15fcffa 100644 --- a/thermo/chemical.py +++ b/thermo/chemical.py @@ -321,33 +321,39 @@ def set_eos(self, T, P, eos=PR): self.eos = eos(T=T, P=P, Tc=self.Tc, Pc=self.Pc, omega=self.omega) else: self.eos = GCEOS_DUMMY(T=T, P=P) + @property + def eos(self): + return self.eos_in_a_box[0] + @eos.setter + def eos(self, eos): if self.eos_in_a_box: self.eos_in_a_box.pop() # Pass this mutable list to objects so if it is changed, it gets # changed in the property method too - self.eos_in_a_box.append(self.eos) + self.eos_in_a_box.append(eos) + def set_TP_sources(self): # Tempearture and Pressure Denepdence # Get and choose initial methods - self.VaporPressure = VaporPressure(Tb=self.Tb, Tc=self.Tc, Pc=self.Pc, omega=self.omega, CASRN=self.CAS, eos=self.eos_in_a_box) + self.VaporPressure = VaporPressure(Tb=self.Tb, Tc=self.Tc, Pc=self.Pc, + omega=self.omega, CASRN=self.CAS, + eos=self.eos_in_a_box) self.Psat_298 = self.VaporPressure.T_dependent_property(298.15) - self.VolumeLiquid = VolumeLiquid(MW=self.MW, Tb=self.Tb, Tc=self.Tc, Pc=self.Pc, Vc=self.Vc, Zc=self.Zc, omega=self.omega, - dipole=self.dipole, Psat=self.VaporPressure.T_dependent_property, CASRN=self.CAS) + dipole=self.dipole, + Psat=self.VaporPressure.T_dependent_property, + eos=self.eos_in_a_box, CASRN=self.CAS) self.Vml_Tb = self.VolumeLiquid.T_dependent_property(self.Tb) if self.Tb else None self.Vml_Tm = self.VolumeLiquid.T_dependent_property(self.Tm) if self.Tm else None self.Vml_STP = self.VolumeLiquid.T_dependent_property(298.15) - # set molecular_diameter; depends on Vml_Tb, Vml_Tm - self.molecular_diameter_sources = molecular_diameter(Tc=self.Tc, Pc=self.Pc, Vc=self.Vc, Zc=self.Zc, omega=self.omega, Vm=self.Vml_Tm, Vb=self.Vml_Tb, AvailableMethods=True, CASRN=self.CAS) - self.molecular_diameter_source = self.molecular_diameter_sources[0] - self.molecular_diameter = molecular_diameter(Tc=self.Tc, Pc=self.Pc, Vc=self.Vc, Zc=self.Zc, omega=self.omega, Vm=self.Vml_Tm, Vb=self.Vml_Tb, Method=self.molecular_diameter_source, CASRN=self.CAS) - - self.VolumeGas = VolumeGas(MW=self.MW, Tc=self.Tc, Pc=self.Pc, omega=self.omega, dipole=self.dipole, CASRN=self.CAS) + self.VolumeGas = VolumeGas(MW=self.MW, Tc=self.Tc, Pc=self.Pc, + omega=self.omega, dipole=self.dipole, + eos=self.eos_in_a_box, CASRN=self.CAS) self.VolumeSolid = VolumeSolid(CASRN=self.CAS, MW=self.MW, Tt=self.Tt) @@ -383,8 +389,14 @@ def set_TP_sources(self): self.phase_STP = identify_phase(T=298.15, P=101325., Tm=self.Tm, Tb=self.Tb, Tc=self.Tc, Psat=self.Psat_298) + # set molecular_diameter; depends on Vml_Tb, Vml_Tm + self.molecular_diameter_sources = molecular_diameter(Tc=self.Tc, Pc=self.Pc, Vc=self.Vc, Zc=self.Zc, omega=self.omega, Vm=self.Vml_Tm, Vb=self.Vml_Tb, AvailableMethods=True, CASRN=self.CAS) + self.molecular_diameter_source = self.molecular_diameter_sources[0] + self.molecular_diameter = molecular_diameter(Tc=self.Tc, Pc=self.Pc, Vc=self.Vc, Zc=self.Zc, omega=self.omega, Vm=self.Vml_Tm, Vb=self.Vml_Tb, Method=self.molecular_diameter_source, CASRN=self.CAS) + def set_TP(self): - self.eos.to_TP(T=self.T, P=self.P) + self.eos = self.eos.to_TP(T=self.T, P=self.P) + self.eos_in_a_box[0] = self.eos self.Psat = self.VaporPressure.T_dependent_property(T=self.T) self.Vms = self.VolumeSolid.T_dependent_property(T=self.T) diff --git a/thermo/eos.py b/thermo/eos.py index 5e64128f..7c20c3df 100644 --- a/thermo/eos.py +++ b/thermo/eos.py @@ -92,6 +92,7 @@ class GCEOS(object): the liquid or gas phase with the convention of adding on `_l` or `_g` to the variable names. ''' + kwargs = {} def check_sufficient_inputs(self): '''Method to an exception if none of the pairs (T, P), (T, V), or (P, V) are given. ''' @@ -643,6 +644,23 @@ def Psat(self, T, polish=False): ------- Psat : float Vapor pressure, [Pa] + + Notes + ----- + Equations of state derived from another but using the same form and + `a` and `b` values work with the former's coefficients. + + All coefficients were derived with numpy's polyfit. The intersection + between the polynomials is continuous, but there is a step change + in its derivative. + + Form for the regression is inspired from [1]_. + + References + ---------- + .. [1] Soave, G. "Direct Calculation of Pure-Compound Vapour Pressures + through Cubic Equations of State." Fluid Phase Equilibria 31, no. 2 + (January 1, 1986): 203-7. doi:10.1016/0378-3812(86)90013-0. ''' alpha = self.a_alpha_and_derivatives(T, full=False)/self.a Tr = T/self.Tc @@ -664,7 +682,10 @@ def to_solve(P): def to_TP(self, T, P): if T != self.T or P != self.P: - self.__init__(T=T, P=P, Tc=self.Tc, Pc=self.Pc, omega=self.omega) + return self.__class__(T=T, P=P, Tc=self.Tc, Pc=self.Pc, omega=self.omega, **self.kwargs) + else: + return self + class GCEOS_DUMMY(GCEOS): def __init__(self, T=None, P=None, **kwargs): @@ -1694,6 +1715,7 @@ def __init__(self, Tc, Pc, omega, T=None, P=None, V=None, kappa1=0): self.T = T self.P = P self.V = V + self.kwargs = {'kappa1': kappa1} self.a = self.c1*R*R*Tc*Tc/Pc self.b = self.c2*R*Tc/Pc @@ -1890,6 +1912,7 @@ def __init__(self, Tc, Pc, omega, T=None, P=None, V=None, kappa1=0, kappa2=0, ka self.P = P self.V = V self.check_sufficient_inputs() + self.kwargs = {'kappa1': kappa1, 'kappa2': kappa2, 'kappa3': kappa3} self.a = self.c1*R*R*Tc*Tc/Pc self.b = self.c2*R*Tc/Pc @@ -2576,6 +2599,7 @@ def __init__(self, Tc, Pc, omega=None, T=None, P=None, V=None, S1=None, S2=0): self.T = T self.P = P self.V = V + self.kwargs = {'S1': S1, 'S2': S2} self.check_sufficient_inputs() if S1 is None and omega is None: diff --git a/thermo/pr.py b/thermo/pr.py index 5bc7adbb..be109df8 100644 --- a/thermo/pr.py +++ b/thermo/pr.py @@ -27,6 +27,10 @@ from scipy.optimize import fsolve from numpy import roots from thermo.utils import log, exp +''' +THIS FILE IS EXTREMELY DEPRECATED! CURRENTLY ONLY USED FOR THE CASE OF GAS +MIXTURE VOLUMES. +''' R = 8.3145 diff --git a/thermo/utils.py b/thermo/utils.py index ef994537..467f679a 100644 --- a/thermo/utils.py +++ b/thermo/utils.py @@ -32,7 +32,7 @@ 'Z_from_virial_pressure_form', 'zs_to_ws', 'ws_to_zs', 'zs_to_Vfs', 'Vfs_to_zs', 'none_and_length_check', 'normalize', 'mixing_simple', 'mixing_logarithmic', 'phase_set_property', 'TDependentProperty', -'TPDependentProperty', 'allclose_variable'] +'TPDependentProperty', 'allclose_variable', 'horner'] from cmath import sqrt as csqrt import numpy as np diff --git a/thermo/vapor_pressure.py b/thermo/vapor_pressure.py index 5e46ec9f..7bc12655 100644 --- a/thermo/vapor_pressure.py +++ b/thermo/vapor_pressure.py @@ -180,7 +180,7 @@ def TRC_Antoine_extended(T, Tc, to, A, B, C, n, E, F): vapor_pressure_methods = [WAGNER_MCGARRY, WAGNER_POLING, ANTOINE_EXTENDED_POLING, COOLPROP, ANTOINE_POLING, VDI_TABULAR, AMBROSE_WALTON, - LEE_KESLER_PSAT, BOILING_CRITICAL, SANJARI] + LEE_KESLER_PSAT, EOS, BOILING_CRITICAL, SANJARI] '''Holds all methods available for the VaporPressure class, for use in iterating over them.''' @@ -292,7 +292,7 @@ class VaporPressure(TDependentProperty): ranked_methods = [WAGNER_MCGARRY, WAGNER_POLING, ANTOINE_EXTENDED_POLING, COOLPROP, ANTOINE_POLING, VDI_TABULAR, AMBROSE_WALTON, - LEE_KESLER_PSAT, BOILING_CRITICAL, SANJARI] + LEE_KESLER_PSAT, BOILING_CRITICAL, EOS, SANJARI] '''Default rankings of the available methods.''' def __init__(self, Tb=None, Tc=None, Pc=None, omega=None, CASRN='', @@ -393,6 +393,8 @@ def load_all_methods(self): methods.append(LEE_KESLER_PSAT) methods.append(AMBROSE_WALTON) methods.append(SANJARI) + if self.eos: + methods.append(EOS) Tmins.append(0.01); Tmaxs.append(self.Tc) self.all_methods = set(methods) if Tmins and Tmaxs: @@ -440,6 +442,8 @@ def calculate(self, T, method): Psat = Ambrose_Walton(T, self.Tc, self.Pc, self.omega) elif method == SANJARI: Psat = Sanjari(T, self.Tc, self.Pc, self.omega) + elif method == EOS: + Psat = self.eos[0].Psat(T) elif method in self.tabular_data: Psat = self.interpolate(T, method) return Psat @@ -482,7 +486,7 @@ def test_method_validity(self, T, method): elif method == COOLPROP: if T < self.CP_f.Tmin or T < self.CP_f.Tt or T > self.CP_f.Tmax or T > self.CP_f.Tc: return False - elif method in [BOILING_CRITICAL, LEE_KESLER_PSAT, AMBROSE_WALTON, SANJARI]: + elif method in [BOILING_CRITICAL, LEE_KESLER_PSAT, AMBROSE_WALTON, SANJARI, EOS]: if T > self.Tc or T < 0: return False # No lower limit diff --git a/thermo/volume.py b/thermo/volume.py index ad23474e..7f7ebf2b 100644 --- a/thermo/volume.py +++ b/thermo/volume.py @@ -655,7 +655,7 @@ def CRC_inorganic(T, rho0, k, Tm): COOLPROP = 'COOLPROP' -PERRYDIPPR = "PERRYDIPPR" +PERRYDIPPR = 'PERRYDIPPR' MMSNM0 = 'MMSNM0' MMSNM0FIT = 'MMSNM0FIT' VDI_TABULAR = 'VDI_TABULAR' @@ -669,6 +669,7 @@ def CRC_inorganic(T, rho0, k, Tm): BHIRUD_NORMAL = 'BHIRUD_NORMAL' TOWNSEND_HALES = 'TOWNSEND_HALES' CAMPBELL_THODOS = 'CAMPBELL_THODOS' +EOS = 'EOS' CRC_INORG_L = 'CRC_INORG_L' @@ -682,7 +683,7 @@ def CRC_inorganic(T, rho0, k, Tm): '''Holds all low-pressure methods available for the VolumeLiquid class, for use in iterating over them.''' -volume_liquid_methods_P = [COOLPROP, COSTALD_COMPRESSED] +volume_liquid_methods_P = [COOLPROP, COSTALD_COMPRESSED, EOS] '''Holds all high-pressure methods available for the VolumeLiquid class, for use in iterating over them.''' @@ -722,6 +723,8 @@ class VolumeLiquid(TPDependentProperty): Dipole, [debye] Psat : float or callable, optional Vapor pressure at a given temperature, or callable for the same [Pa] + eos : object, optional + Equation of State object after :obj:`thermo.eos.GCEOS` Notes ----- @@ -790,6 +793,8 @@ class VolumeLiquid(TPDependentProperty): Range is limited to that of the equations of state it uses, as described in [5]_. Very slow, but unparalled in accuracy for pressure dependence. + **EOS**: + Equation of state provided by user. See Also -------- @@ -847,15 +852,15 @@ class VolumeLiquid(TPDependentProperty): HTCOSTALDFIT, RACKETTFIT, CRC_INORG_L, CRC_INORG_L_CONST, MMSNM0, HTCOSTALD, YEN_WOODS_SAT, RACKETT, YAMADA_GUNN, - BHIRUD_NORMAL, TOWNSEND_HALES, CAMPBELL_THODOS] + BHIRUD_NORMAL, TOWNSEND_HALES, CAMPBELL_THODOS, EOS] '''Default rankings of the low-pressure methods.''' - ranked_methods_P = [COOLPROP, COSTALD_COMPRESSED] + ranked_methods_P = [COOLPROP, COSTALD_COMPRESSED, EOS] '''Default rankings of the high-pressure methods.''' def __init__(self, MW=None, Tb=None, Tc=None, Pc=None, Vc=None, Zc=None, - omega=None, dipole=None, Psat=None, CASRN=''): + omega=None, dipole=None, Psat=None, CASRN='', eos=None): self.CASRN = CASRN self.MW = MW self.Tb = Tb @@ -866,6 +871,7 @@ def __init__(self, MW=None, Tb=None, Tc=None, Pc=None, Vc=None, Zc=None, self.omega = omega self.dipole = dipole self.Psat = Psat + self.eos = eos self.Tmin = None '''Minimum temperature at which no method can calculate the @@ -989,6 +995,8 @@ def load_all_methods(self): Tmins.append(0); Tmaxs.append(self.Tc) if all((self.Tc, self.Pc, self.omega)): methods_P.append(COSTALD_COMPRESSED) + if self.eos: + methods_P.append(EOS) if Tmins and Tmaxs: self.Tmin, self.Tmax = min(Tmins), max(Tmaxs) @@ -1078,6 +1086,9 @@ def calculate_P(self, T, P, method): Vm = COSTALD_compressed(T, P, Psat, self.Tc, self.Pc, self.omega, Vm) elif method == COOLPROP: Vm = 1./PropsSI('DMOLAR', 'T', T, 'P', P, self.CASRN) + elif method == EOS: + self.eos[0] = self.eos[0].to_TP(T=T, P=P) + Vm = self.eos[0].V_l elif method in self.tabular_data: Vm = self.interpolate_P(T, P, method) return Vm @@ -1174,6 +1185,9 @@ def test_method_validity_P(self, T, P, method): pass elif method == COOLPROP: validity = PhaseSI('T', T, 'P', P, self.CASRN) == 'liquid' + elif method == EOS: + self.eos[0] = self.eos[0].to_TP(T=T, P=P) + validity = hasattr(self.eos[0], 'V_l') elif method in self.tabular_data: if not self.tabular_extrapolation_permitted: Ts, Ps, properties = self.tabular_data[method] @@ -1562,7 +1576,7 @@ def ideal_gas(T, P): return R*T/P -PR = 'PR' +#PR = 'PR' CRC_VIRIAL = 'CRC_VIRIAL' TSONOPOULOS_EXTENDED = 'TSONOPOULOS_EXTENDED' TSONOPOULOS = 'TSONOPOULOS' @@ -1570,7 +1584,7 @@ def ideal_gas(T, P): PITZER_CURL = 'PITZER_CURL' IDEAL = 'IDEAL' NONE = 'NONE' -volume_gas_methods = [PR, CRC_VIRIAL, TSONOPOULOS_EXTENDED, TSONOPOULOS, +volume_gas_methods = [COOLPROP, EOS, CRC_VIRIAL, TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, PITZER_CURL, IDEAL] '''Holds all methods available for the VolumeGas class, for use in iterating over them.''' @@ -1679,13 +1693,13 @@ class VolumeGas(TPDependentProperty): under.''' ranked_methods = [] '''Default rankings of the low-pressure methods.''' - ranked_methods_P = [COOLPROP, PR, TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, + ranked_methods_P = [COOLPROP, EOS, TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, PITZER_CURL, CRC_VIRIAL, IDEAL] '''Default rankings of the pressure-dependent methods.''' def __init__(self, CASRN='', MW=None, Tc=None, Pc=None, omega=None, - dipole=None): + dipole=None, eos=None): # Only use TPDependentPropoerty functions here self.CASRN = CASRN self.MW = MW @@ -1693,6 +1707,7 @@ def __init__(self, CASRN='', MW=None, Tc=None, Pc=None, omega=None, self.Pc = Pc self.omega = omega self.dipole = dipole + self.eos = eos self.Tmin = 0 '''Minimum temperature at which no method can calculate the @@ -1753,8 +1768,10 @@ def load_all_methods(self): methods_P = [IDEAL] # no point in getting Tmin, Tmax if all((self.Tc, self.Pc, self.omega)): - methods_P.extend([PR, TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, + methods_P.extend([TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, PITZER_CURL]) + if self.eos: + methods_P.append(EOS) if self.CASRN in CRC_virial_data.index: methods_P.append(CRC_VIRIAL) self.CRC_VIRIAL_coeffs = _CRC_virial_data_values[CRC_virial_data.index.get_loc(self.CASRN)].tolist()[1:] @@ -1784,8 +1801,11 @@ def calculate_P(self, T, P, method): Vm : float Molar volume of the gas at T and P, [m^3/mol] ''' - if method == PR: - Vm = PR_Vm(T, P, self.Tc, self.Pc, self.omega, phase='g') + if method == EOS: + self.eos[0] = self.eos[0].to_TP(T=T, P=P) + Vm = self.eos[0].V_g +# if method == PR: +# Vm = PR_Vm(T, P, self.Tc, self.Pc, self.omega, phase='g') elif method == TSONOPOULOS_EXTENDED: B = BVirial_Tsonopoulos_extended(T, self.Tc, self.Pc, self.omega, dipole=self.dipole) Vm = ideal_gas(T, P) + B @@ -1848,10 +1868,13 @@ def test_method_validity_P(self, T, P, method): validity = True if T < 0 or P < 0: validity = False - elif method in [PR, TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, + elif method in [TSONOPOULOS_EXTENDED, TSONOPOULOS, ABBOTT, PITZER_CURL, CRC_VIRIAL, IDEAL]: pass # Would be nice to have a limit on CRC_VIRIAL + elif method == EOS: + self.eos[0] = self.eos[0].to_TP(T=T, P=P) + validity = hasattr(self.eos[0], 'V_g') elif method == COOLPROP: validity = PhaseSI('T', T, 'P', P, self.CASRN) in ['gas', 'supercritical_gas', 'supercritical', 'supercritical_liquid'] elif method in self.tabular_data: