diff -Nru iapws-1.3/debian/changelog iapws-1.4/debian/changelog --- iapws-1.3/debian/changelog 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/changelog 2019-06-15 06:32:45.000000000 +0000 @@ -1,3 +1,12 @@ +iapws (1.4-1) unstable; urgency=medium + + * New upstream release + * Drop python2 support. + * Move to debhelper >= 12 + * Now use pybuild build system + + -- Alastair McKinstry Sat, 15 Jun 2019 07:32:45 +0100 + iapws (1.3-2) unstable; urgency=medium * Standards-Version: 4.3.0 diff -Nru iapws-1.3/debian/compat iapws-1.4/debian/compat --- iapws-1.3/debian/compat 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/compat 2019-06-15 06:32:45.000000000 +0000 @@ -1 +1 @@ -10 +12 diff -Nru iapws-1.3/debian/control iapws-1.4/debian/control --- iapws-1.3/debian/control 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/control 2019-06-15 06:32:45.000000000 +0000 @@ -2,12 +2,9 @@ Section: python Priority: optional Maintainer: Alastair McKinstry -Build-Depends: debhelper (>= 10), - python-all, +Build-Depends: debhelper (>= 12), python3-all, - python-setuptools, python3-setuptools, - python-scipy, python3-scipy, dh-python Standards-Version: 4.3.0 @@ -15,15 +12,6 @@ Vcs-Browser: https://salsa.debian.org:/science-team/iapws.git Vcs-Git: https://salsa.debian.org:/science-team/iapws.git -Package: python-iapws -Architecture: all -Depends: ${misc:Depends}, ${python:Depends}, python-scipy -Provides: ${python:Provides} -Description: Python implementation of the international APWS-IF97 steam tables - This is a Python class to model a state for liquid water or steam - with the Industrial Formulation IAPWS-IF97. - . - Further information on the standard is available at http://www.iapws.org Package: python3-iapws Architecture: all diff -Nru iapws-1.3/debian/python3-iapws.install iapws-1.4/debian/python3-iapws.install --- iapws-1.3/debian/python3-iapws.install 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/python3-iapws.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -/usr/lib/python3* diff -Nru iapws-1.3/debian/python-iapws.install iapws-1.4/debian/python-iapws.install --- iapws-1.3/debian/python-iapws.install 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/python-iapws.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -/usr/lib/python2* diff -Nru iapws-1.3/debian/rules iapws-1.4/debian/rules --- iapws-1.3/debian/rules 2019-01-20 15:03:28.000000000 +0000 +++ iapws-1.4/debian/rules 2019-06-15 06:32:45.000000000 +0000 @@ -3,26 +3,10 @@ # Uncomment this to turn on verbose mode. # export DH_VERBOSE=1 -PYTHON2=$(shell pyversions -vr) -PYTHON3=$(shell py3versions -vr) - # magic debhelper rule %: - dh $@ --with python2,python3 - -build-python%: - python$* setup.py build - -override_dh_auto_build: $(PYTHON3:%=build-python%) - dh_auto_build - -install-python%: - python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb - -override_dh_auto_install: $(PYTHON3:%=install-python%) - dh_auto_install + dh $@ --buildsystem=pybuild override_dh_auto_clean: dh_auto_clean - rm -rf build rm -rf *.egg-info diff -Nru iapws-1.3/iapws/ammonia.py iapws-1.4/iapws/ammonia.py --- iapws-1.3/iapws/ammonia.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/ammonia.py 2019-06-15 06:32:57.000000000 +0000 @@ -1,8 +1,12 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -Guideline on the IAPWS Formulation 2001 for the Thermodynamic Properties of -Ammonia-Water Mistures +Module with Ammonia-water mixture properties and related properties. The module +include: + + * :class:`NH3`: Multiparameter equation of state for ammonia + * :class:`H2ONH3`: Thermodynamic properties of ammonia-water mixtures + * :class:`Ttr`: Triple point of ammonia-water mixtures """ @@ -11,11 +15,21 @@ import warnings from scipy.constants import Boltzmann as kb -from .iapws95 import MEoS, IAPWS95 +from .iapws95 import MEoS, IAPWS95, mainClassDoc +@mainClassDoc() class NH3(MEoS): - """Multiparameter equation of state for ammonia""" + """Multiparameter equation of state for ammonia + for internal procedures, see MEoS base class + + References + ---------- + Baehr, H.D., Tillner-Roth, R.; Thermodynamic Properties of Environmentally + Acceptable Refrigerants: Equations of State and Tables for Ammonia, R22, + R134a, R152a, and R123. Springer-Verlag, Berlin, 1994. + http://doi.org/10.1007/978-3-642-79400-1 + """ name = "ammonia" CASNumber = "7664-41-7" formula = "NH3" @@ -131,9 +145,9 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] fase: dict phase properties @@ -207,19 +221,21 @@ Returns ------- - prop : dictionary with thermodynamic properties of humid air - M: Mixture molecular mass [g/mol] - P: Pressure [MPa] - u: Specific internal energy [kJ/kg] - s: Specific entropy [kJ/kgK] - h: Specific enthalpy [kJ/kg] - a: Specific Helmholtz energy [kJ/kg] - g: Specific gibbs energy [kJ/kg] - cv: Specific isochoric heat capacity [kJ/kgK] - cp: Specific isobaric heat capacity [kJ/kgK] - w: Speed of sound [m/s] - fugH2O: Fugacity of water [-] - fugNH3: Fugacity of ammonia [-] + prop : dict + Dictionary with thermodynamic properties of ammonia-water mixtures: + + * M: Mixture molecular mass, [g/mol] + * P: Pressure, [MPa] + * u: Specific internal energy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * h: Specific enthalpy, [kJ/kg] + * a: Specific Helmholtz energy, [kJ/kg] + * g: Specific gibbs energy, [kJ/kg] + * cv: Specific isochoric heat capacity, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * fugH2O: Fugacity of water, [-] + * fugNH3: Fugacity of ammonia, [-] References ---------- @@ -275,23 +291,26 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] x : float - Mole fraction of ammonia in mixture [mol/mol] + Mole fraction of ammonia in mixture, [mol/mol] Returns ------- - prop : dictionary with ideal adimensional helmholtz energy and deriv - tau: the adimensional temperature variable [-] - delta: the adimensional density variable [-] - fio [-] - fiot: [∂fio/∂τ]δ [-] - fiod: [∂fio/∂δ]τ [-] - fiott: [∂²fio/∂τ²]δ [-] - fiodt: [∂²fio/∂τ∂δ] [-] - fiodd: [∂²fio/∂δ²]τ [-] + prop : dict + Dictionary with ideal adimensional helmholtz energy and + derivatives: + + * tau: the adimensional temperature variable, [-] + * delta: the adimensional density variable, [-] + * fio,[-] + * fiot: [∂fio/∂τ]δ [-] + * fiod: [∂fio/∂δ]τ [-] + * fiott: [∂²fio/∂τ²]δ [-] + * fiodt: [∂²fio/∂τ∂δ] [-] + * fiodd: [∂²fio/∂δ²]τ [-] References ---------- @@ -366,25 +385,28 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] x : float - Mole fraction of ammonia in mixture [mol/mol] + Mole fraction of ammonia in mixture, [mol/mol] Returns ------- - prop : dictionary with residual adimensional helmholtz energy and deriv - tau: the adimensional temperature variable [-] - delta: the adimensional density variable [-] - fir [-] - firt: [∂fir/∂τ]δ,x [-] - fird: [∂fir/∂δ]τ,x [-] - firtt: [∂²fir/∂τ²]δ,x [-] - firdt: [∂²fir/∂τ∂δ]x [-] - firdd: [∂²fir/∂δ²]τ,x [-] - firx: [∂fir/∂x]τ,δ [-] - F: Function for fugacity calculation [-] + prop : dict + dictionary with residual adimensional helmholtz energy and + derivatives: + + * tau: the adimensional temperature variable, [-] + * delta: the adimensional density variable, [-] + * fir, [-] + * firt: [∂fir/∂τ]δ,x [-] + * fird: [∂fir/∂δ]τ,x [-] + * firtt: [∂²fir/∂τ²]δ,x [-] + * firdt: [∂²fir/∂τ∂δ]x [-] + * firdd: [∂²fir/∂δ²]τ,x [-] + * firx: [∂fir/∂x]τ,δ [-] + * F: Function for fugacity calculation, [-] References ---------- @@ -441,23 +463,25 @@ Parameters ---------- tau : float - Adimensional temperature [-] + Adimensional temperature, [-] delta : float - Adimensional density [-] + Adimensional density, [-] x : float - Mole fraction of ammonia in mixture [mol/mol] + Mole fraction of ammonia in mixture, [mol/mol] Returns ------- - prop : dictionary with departure contribution to the residual - adimensional helmholtz energy and deriv - fir [-] - firt: [∂Δfir/∂τ]δ,x [-] - fird: [∂Δfir/∂δ]τ,x [-] - firtt: [∂²Δfir/∂τ²]δ,x [-] - firdt: [∂²Δfir/∂τ∂δ]x [-] - firdd: [∂²Δfir/∂δ²]τ,x [-] - firx: [∂Δfir/∂x]τ,δ [-] + prop : dict + Dictionary with departure contribution to the residual adimensional + helmholtz energy and derivatives: + + * fir [-] + * firt: [∂Δfir/∂τ]δ,x [-] + * fird: [∂Δfir/∂δ]τ,x [-] + * firtt: [∂²Δfir/∂τ²]δ,x [-] + * firdt: [∂²Δfir/∂τ∂δ]x [-] + * firdd: [∂²Δfir/∂δ²]τ,x [-] + * firx: [∂Δfir/∂x]τ,δ [-] References ---------- @@ -545,16 +569,17 @@ Parameters ---------- x : float - Mole fraction of ammonia in mixture [mol/mol] + Mole fraction of ammonia in mixture, [mol/mol] Returns ------- Ttr : float - Triple point temperature [K] + Triple point temperature, [K] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 0 ≤ x ≤ 1 References diff -Nru iapws-1.3/iapws/humidAir.py iapws-1.4/iapws/humidAir.py --- iapws-1.3/iapws/humidAir.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/humidAir.py 2019-06-15 06:32:57.000000000 +0000 @@ -1,8 +1,15 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -Guideline on the IAPWS Formulation 2001 for the Thermodynamic Properties of -Ammonia-Water Mistures +Module with Air-water mixture properties and related properties. The module +include: + + * :func:`_virial`: Virial equations for humid air + * :func:`_fugacity`: Fugacity equation for humid air + * :class:`MEoSBlend`: Special MEoS subclass to implement pseudocomponent + blend with ancillary dew and bubble point + * :class:`Air`: Multiparameter equation of state for Air as pseudocomponent + * :class:`HumidAir`: Humid air mixture with complete functionality """ @@ -15,7 +22,7 @@ from ._iapws import M as Mw from ._iapws import _Ice from ._utils import deriv_G -from .iapws95 import MEoS, IAPWS95 +from .iapws95 import MEoS, IAPWS95, mainClassDoc Ma = 28.96546 # g/mol @@ -32,25 +39,27 @@ Returns ------- - prop : float - dictionary with critical coefficient - Baa: Second virial coefficient of dry air [m³/mol] - Baw: Second air-water cross virial coefficient [m³/mol] - Bww: Second virial coefficient of water [m³/mol] - Caaa: Third virial coefficient of dry air [m⁶/mol] - Caaw: Third air-water cross virial coefficient [m⁶/mol] - Caww: Third air-water cross virial coefficient [m⁶/mol] - Cwww: Third virial coefficient of dry air [m⁶/mol] - Bawt: dBaw/dT [m³/molK] - Bawtt: d²Baw/dT² [m³/molK²] - Caawt: dCaaw/dT [m⁶/molK] - Caawtt: d²Caaw/dT² [m⁶/molK²] - Cawwt: dCaww/dT [m⁶/molK] - Cawwtt: d²Caww/dT² [m⁶/molK²] + prop : dict + Dictionary with critical coefficient: + + * Baa: Second virial coefficient of dry air, [m³/mol] + * Baw: Second air-water cross virial coefficient, [m³/mol] + * Bww: Second virial coefficient of water, [m³/mol] + * Caaa: Third virial coefficient of dry air, [m⁶/mol] + * Caaw: Third air-water cross virial coefficient, [m⁶/mol] + * Caww: Third air-water cross virial coefficient, [m⁶/mol] + * Cwww: Third virial coefficient of dry air, [m⁶/mol] + * Bawt: dBaw/dT, [m³/molK] + * Bawtt: d²Baw/dT², [m³/molK²] + * Caawt: dCaaw/dT, [m⁶/molK] + * Caawtt: d²Caaw/dT², [m⁶/molK²] + * Cawwt: dCaww/dT, [m⁶/molK] + * Cawwtt: d²Caww/dT², [m⁶/molK²] - Raises + Notes ------ - Warning : If T isn't in range of validity + Raise :class:`Warning` if T isn't in range of validity: + * Baa: 60 ≤ T ≤ 2000 * Baw: 130 ≤ T ≤ 2000 * Bww: 130 ≤ T ≤ 1273 @@ -68,6 +77,7 @@ ---------- IAPWS, Guideline on a Virial Equation for the Fugacity of H2O in Humid Air, http://www.iapws.org/relguide/VirialFugacity.html + IAPWS, Guideline on an Equation of State for Humid Air in Contact with Seawater and Ice, Consistent with the IAPWS Formulation 2008 for the Thermodynamic Properties of Seawater, Table 10, @@ -194,24 +204,26 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] x : float - Mole fraction of water-vapor [-] + Mole fraction of water-vapor, [-] Returns ------- fv : float - fugacity coefficient [MPa] + fugacity coefficient, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in range of validity + Raise :class:`NotImplementedError` if input isn't in range of validity: + * 193 ≤ T ≤ 473 * 0 ≤ P ≤ 5 * 0 ≤ x ≤ 1 - Really the xmax is the xsaturation but isn't implemented + + Really the xmax is the xsaturation but isn't implemented Examples -------- @@ -247,7 +259,7 @@ class MEoSBlend(MEoS): - """Special meos class to im:plement pseudocomponent blend and defining its + """Special meos class to implement pseudocomponent blend and defining its ancillary dew and bubble point""" @classmethod def _dewP(cls, T): @@ -278,8 +290,18 @@ return P +@mainClassDoc() class Air(MEoSBlend): - """Multiparameter equation of state for Air as pseudocomponent""" + """Multiparameter equation of state for Air as pseudocomponent + for internal procedures, see MEoS base class + + References + ---------- + Lemmon, E.W., Jacobsen, R.T, Penoncello, S.G., Friend, D.G.; Thermodynamic + Properties of Air and Mixtures of Nitrogen, Argon, and Oxygen From 60 to + 2000 K at Pressures to 2000 MPa. J. Phys. Chem. Ref. Data 29, 331 (2000). + http://dx.doi.org/10.1063/1.1285884 + """ name = "air" CASNumber = "1" formula = "N2+Ar+O2" @@ -378,20 +400,20 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- - mu : float - Viscosity [Pa·s] + μ : float + Viscosity, [Pa·s] References ---------- - Lemmon, E.W. and Jacobsen, R.T., Viscosity and Thermal Conductivity - Equations for Nitrogen, Oxygen, Argon, and Air, Int. J. Thermophys., - 25:21-69, 2004. doi:10.1023/B:IJOT.0000022327.04529.f3 + Lemmon, E.W., Jacobsen, R.T. Viscosity and Thermal Conductivity + Equations for Nitrogen, Oxygen, Argon, and Air. Int. J. Thermophys. 25 + (1) (2004) 21-69. http://dx.doi.org/10.1023/B:IJOT.0000022327.04529.f3 """ ek = 103.3 sigma = 0.36 @@ -431,22 +453,22 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] fase: dict phase properties Returns ------- k : float - Thermal conductivity [W/mK] + Thermal conductivity, [W/mK] References ---------- - Lemmon, E.W. and Jacobsen, R.T., Viscosity and Thermal Conductivity - Equations for Nitrogen, Oxygen, Argon, and Air, Int. J. Thermophys., - 25:21-69, 2004. doi:10.1023/B:IJOT.0000022327.04529.f3 + Lemmon, E.W., Jacobsen, R.T. Viscosity and Thermal Conductivity + Equations for Nitrogen, Oxygen, Argon, and Air. Int. J. Thermophys. 25 + (1) (2004) 21-69. http://dx.doi.org/10.1023/B:IJOT.0000022327.04529.f3 """ ek = 103.3 sigma = 0.36 @@ -529,21 +551,21 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] rho : float - Density [kg/m³] + Density, [kg/m³] v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] A : float - Mass fraction of dry air in humid air [kg/kg] + Mass fraction of dry air in humid air, [kg/kg] xa : float - Mole fraction of dry air in humid air [-] + Mole fraction of dry air in humid air, [-] W : float - Mass fraction of water in humid air [kg/kg] + Mass fraction of water in humid air, [kg/kg] xw : float - Mole fraction of water in humid air [-] + Mole fraction of water in humid air, [-] Notes ----- @@ -551,38 +573,35 @@ * v as a alternate input parameter to rho * For composition need one of A, xa, W, xw. - Returns - ------- The calculated instance has the following properties: - * P: Pressure [MPa] - * T: Temperature [K] - * g: Specific Gibbs free energy [kJ/kg] - * a: Specific Helmholtz free energy [kJ/kg] - * v: Specific volume [m³/kg] - * rho: Density [kg/m³] - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * s: Specific entropy [kJ/kg·K] - * cp: Specific isobaric heat capacity [kJ/kg·K] - * w: Speed of sound [m/s] - - * alfav: Isobaric cubic expansion coefficient [1/K] - * betas: Isoentropic temperature-pressure coefficient [-] - * xkappa: Isothermal Expansion Coefficient [-] - * ks: Adiabatic Compressibility [1/MPa] - - * A: Mass fraction of dry air in humid air [kg/kg] - * xa: Mole fraction of dry air in humid air [-] - * W: Mass fraction of water in humid air [kg/kg] - * xw: Mole fraction of water in humid air [-] - * mu: Relative chemical potential [kJ/kg] - * muw: Chemical potential of water [kJ/kg] - * M: Molar mass of humid air [g/mol] - * HR: Humidity ratio [-] - * xa: Mole fraction of dry air [-] - * xw: Mole fraction of water [-] - * xa_sat: Mole fraction of dry air at saturation state [-] - * RH: Relative humidity + + * P: Pressure, [MPa] + * T: Temperature, [K] + * g: Specific Gibbs free energy, [kJ/kg] + * a: Specific Helmholtz free energy, [kJ/kg] + * v: Specific volume, [m³/kg] + * rho: Density, [kg/m³] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * s: Specific entropy, [kJ/kg·K] + * cp: Specific isobaric heat capacity, [kJ/kg·K] + * w: Speed of sound, [m/s] + + * alfav: Isobaric cubic expansion coefficient, [1/K] + * betas: Isoentropic temperature-pressure coefficient, [-] + * xkappa: Isothermal Expansion Coefficient, [-] + * ks: Adiabatic Compressibility, [1/MPa] + + * A: Mass fraction of dry air in humid air, [kg/kg] + * W: Mass fraction of water in humid air, [kg/kg] + * xa: Mole fraction of dry air, [-] + * xw: Mole fraction of water, [-] + * xa_sat: Mole fraction of dry air at saturation state, [-] + * mu: Relative chemical potential, [kJ/kg] + * muw: Chemical potential of water, [kJ/kg] + * M: Molar mass of humid air, [g/mol] + * HR: Humidity ratio, [-] + * RH: Relative humidity, [-] """ kwargs = {"T": 0.0, "P": 0.0, @@ -725,17 +744,20 @@ if T <= 273.16: ice = _Ice(T, P) gw = ice["g"] - rho = ice["rho"] else: water = IAPWS95(T=T, P=P) gw = water.g - rho = water.rho - def f(a): + def f(parr): + rho, a = parr + if a > 1: + a = 1 fa = self._fav(T, rho, a) muw = fa["fir"]+rho*fa["fird"]-a*fa["fira"] - return gw-muw - Asat = fsolve(f, 0.9)[0] + return gw-muw, rho**2*fa["fird"]/1000-P + + rinput = fsolve(f, [1, 0.95], full_output=True) + Asat = rinput[0][1] return Asat def _prop(self, T, rho, fav): @@ -744,25 +766,27 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] rho : float - Density [kg/m³] + Density, [kg/m³] fav : dict dictionary with helmholtz energy and derivatives Returns ------- - prop : dictionary with thermodynamic properties of humid air - P: Pressure [MPa] - s: Specific entropy [kJ/kgK] - cp: Specific isobaric heat capacity [kJ/kgK] - h: Specific enthalpy [kJ/kg] - g: Specific gibbs energy [kJ/kg] - alfav: Thermal expansion coefficient [1/K] - betas: Isentropic T-P coefficient [K/MPa] - xkappa: Isothermal compressibility [1/MPa] - ks: Isentropic compressibility [1/MPa] - w: Speed of sound [m/s] + prop : dict + Dictionary with thermodynamic properties of humid air: + + * P: Pressure, [MPa] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * h: Specific enthalpy, [kJ/kg] + * g: Specific gibbs energy, [kJ/kg] + * alfav: Thermal expansion coefficient, [1/K] + * betas: Isentropic T-P coefficient, [K/MPa] + * xkappa: Isothermal compressibility, [1/MPa] + * ks: Isentropic compressibility, [1/MPa] + * w: Speed of sound, [m/s] References ---------- @@ -794,21 +818,23 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] A : float - Mass fraction of dry air in humid air [kg/kg] + Mass fraction of dry air in humid air, [kg/kg] fav : dict dictionary with helmholtz energy and derivatives Returns ------- - prop : dictionary with calculated properties - mu: Relative chemical potential [kJ/kg] - muw: Chemical potential of water [kJ/kg] - M: Molar mass of humid air [g/mol] - HR: Humidity ratio [-] - xa: Mole fraction of dry air [-] - xw: Mole fraction of water [-] + prop : dict + Dictionary with calculated properties: + + * mu: Relative chemical potential, [kJ/kg] + * muw: Chemical potential of water, [kJ/kg] + * M: Molar mass of humid air, [g/mol] + * HR: Humidity ratio, [-] + * xa: Mole fraction of dry air, [-] + * xw: Mole fraction of water, [-] References ---------- @@ -827,30 +853,32 @@ return prop def _fav(self, T, rho, A): - """Specific Helmholtz energy of humid air and derivatives + r"""Specific Helmholtz energy of humid air and derivatives Parameters ---------- T : float - Temperature [K] + Temperature, [K] rho : float - Density [kg/m³] + Density, [kg/m³] A : float - Mass fraction of dry air in humid air [kg/kg] + Mass fraction of dry air in humid air, [kg/kg] Returns ------- - prop : dictionary with helmholtz energy and derivatives - fir [kJ/kg] - fira: [∂fav/∂A]T,ρ [kJ/kg] - firt: [∂fav/∂T]A,ρ [kJ/kgK] - fird: [∂fav/∂ρ]A,T [kJ/m³kg²] - firaa: [∂²fav/∂A²]T,ρ [kJ/kg] - firat: [∂²fav/∂A∂T]ρ [kJ/kgK] - firad: [∂²fav/∂A∂ρ]T [kJ/m³kg²] - firtt: [∂²fav/∂T²]A,ρ [kJ/kgK²] - firdt: [∂²fav/∂T∂ρ]A [kJ/m³kg²K] - firdd: [∂²fav/∂ρ²]A,T [kJ/m⁶kg³] + prop : dict + Dictionary with helmholtz energy and derivatives: + + * fir, [kJ/kg] + * fira: :math:`\left.\frac{\partial f_{av}}{\partial A}\right|_{T,\rho}`, [kJ/kg] + * firt: :math:`\left.\frac{\partial f_{av}}{\partial T}\right|_{A,\rho}`, [kJ/kgK] + * fird: :math:`\left.\frac{\partial f_{av}}{\partial \rho}\right|_{A,T}`, [kJ/m³kg²] + * firaa: :math:`\left.\frac{\partial^2 f_{av}}{\partial A^2}\right|_{T, \rho}`, [kJ/kg] + * firat: :math:`\left.\frac{\partial^2 f_{av}}{\partial A \partial T}\right|_{\rho}`, [kJ/kgK] + * firad: :math:`\left.\frac{\partial^2 f_{av}}{\partial A \partial \rho}\right|_T`, [kJ/m³kg²] + * firtt: :math:`\left.\frac{\partial^2 f_{av}}{\partial T^2}\right|_{A, \rho}`, [kJ/kgK²] + * firdt: :math:`\left.\frac{\partial^2 f_{av}}{\partial \rho \partial T}\right|_A`, [kJ/m³kg²K] + * firdd: :math:`\left.\frac{\partial^2 f_{av}}{\partial \rho^2}\right|_{A, T}`, [kJ/m⁶kg³] References ---------- @@ -897,30 +925,32 @@ return prop def _fmix(self, T, rho, A): - """Specific Helmholtz energy of air-water interaction + r"""Specific Helmholtz energy of air-water interaction Parameters ---------- T : float - Temperature [K] + Temperature, [K] rho : float - Density [kg/m³] + Density, [kg/m³] A : float - Mass fraction of dry air in humid air [kg/kg] + Mass fraction of dry air in humid air, [kg/kg] Returns ------- - prop : dictionary with helmholtz energy and derivatives - fir - fira: [∂fmix/∂A]T,ρ - firt: [∂fmix/∂T]A,ρ - fird: [∂fmix/∂ρ]A,T - firaa: [∂²fmix/∂A²]T,ρ - firat: [∂²fmix/∂A∂T]ρ - firad: [∂²fmix/∂A∂ρ]T - firtt: [∂²fmix/∂T²]A,ρ - firdt: [∂²fmix/∂T∂ρ]A - firdd: [∂²fmix/∂ρ²]A,T + prop : dict + Dictionary with helmholtz energy and derivatives: + + * fir, [kJ/kg] + * fira: :math:`\left.\frac{\partial f_{mix}}{\partial A}\right|_{T,\rho}`, [kJ/kg] + * firt: :math:`\left.\frac{\partial f_{mix}}{\partial T}\right|_{A,\rho}`, [kJ/kgK] + * fird: :math:`\left.\frac{\partial f_{mix}}{\partial \rho}\right|_{A,T}`, [kJ/m³kg²] + * firaa: :math:`\left.\frac{\partial^2 f_{mix}}{\partial A^2}\right|_{T, \rho}`, [kJ/kg] + * firat: :math:`\left.\frac{\partial^2 f_{mix}}{\partial A \partial T}\right|_{\rho}`, [kJ/kgK] + * firad: :math:`\left.\frac{\partial^2 f_{mix}}{\partial A \partial \rho}\right|_T`, [kJ/m³kg²] + * firtt: :math:`\left.\frac{\partial^2 f_{mix}}{\partial T^2}\right|_{A, \rho}`, [kJ/kgK²] + * firdt: :math:`\left.\frac{\partial^2 f_{mix}}{\partial \rho \partial T}\right|_A`, [kJ/m³kg²K] + * firdd: :math:`\left.\frac{\partial^2 f_{mix}}{\partial \rho^2}\right|_{A, T}`, [kJ/m⁶kg³] References ---------- diff -Nru iapws-1.3/iapws/iapws08.py iapws-1.4/iapws/iapws08.py --- iapws-1.3/iapws/iapws08.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/iapws08.py 2019-06-15 06:32:57.000000000 +0000 @@ -1,7 +1,20 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -IAPWS standard for Seawater IAPWS08 +IAPWS standard for Seawater IAPWS08 and related functionality. The module +include: + +:class:`SeaWater`: Global module class with all the functionality integrated + +Other functionality: + * :func:`_Tb`: Boiling temperature of seawater + * :func:`_Tf`: Freezing temperature of seawater + * :func:`_Triple`: Triple point properties of seawater + * :func:`_OsmoticPressure`: Osmotic pressure of seawater + * :func:`_ThCond_SeaWater`: Thermal conductivity of seawater + * :func:`_solNa2SO4`: Solubility of sodium sulfate in aqueous mixtures of + sodium chloride and sulfuric acid + * :func:`_critNaCl`: Critical locus of aqueous solutions of sodium chloride """ from __future__ import division @@ -34,78 +47,79 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] S : float - Salinity [kg/kg] + Salinity, [kg/kg] - fast : Boolean, default False + fast : bool, default False Use the Supplementary release SR7-09 to speed up the calculation - IF97 : Boolean, default False + IF97 : bool, default False Use the Advisory Note No. 5 with industrial formulation Returns ------- rho : float - Density [kg/m³] + Density, [kg/m³] v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kg·K] + Specific entropy, [kJ/kg·K] u : float - Specific internal energy [kJ/kg] + Specific internal energy, [kJ/kg] g : float - Specific Gibbs free energy [kJ/kg] + Specific Gibbs free energy, [kJ/kg] a : float - Specific Helmholtz free energy [kJ/kg] + Specific Helmholtz free energy, [kJ/kg] cp : float - Specific isobaric heat capacity [kJ/kg·K] + Specific isobaric heat capacity, [kJ/kg·K] cv : float - Specific isochoric heat capacity [kJ/kg·K] + Specific isochoric heat capacity, [kJ/kg·K] gt : float - Derivative Gibbs energy with temperature [kJ/kg·K] + Derivative Gibbs energy with temperature, [kJ/kg·K] gp : float - Derivative Gibbs energy with pressure [m³/kg] + Derivative Gibbs energy with pressure, [m³/kg] gtt : float - Derivative Gibbs energy with temperature square [kJ/kg·K²] + Derivative Gibbs energy with temperature square, [kJ/kg·K²] gtp : float - Derivative Gibbs energy with pressure and temperature [m³/kg·K] + Derivative Gibbs energy with pressure and temperature, [m³/kg·K] gpp : float - Derivative Gibbs energy with temperature square [m³/kg·MPa] + Derivative Gibbs energy with temperature square, [m³/kg·MPa] gs : float - Derivative Gibbs energy with salinity [kJ/kg] + Derivative Gibbs energy with salinity, [kJ/kg] gsp : float - Derivative Gibbs energy with salinity and pressure [m³/kg] + Derivative Gibbs energy with salinity and pressure, [m³/kg] alfav : float - Thermal expansion coefficient [1/K] + Thermal expansion coefficient, [1/K] betas : float - Isentropic temperature-pressure coefficient [K/MPa] + Isentropic temperature-pressure coefficient, [K/MPa] xkappa : float - Isothermal compressibility [1/MPa] + Isothermal compressibility, [1/MPa] ks : float - Isentropic compressibility [1/MPa] + Isentropic compressibility, [1/MPa] w : float - Sound Speed [m/s] + Sound Speed, [m/s] m : float - Molality of seawater [mol/kg] + Molality of seawater, [mol/kg] mu : float - Relative chemical potential [kJ/kg] + Relative chemical potential, [kJ/kg] muw : float - Chemical potential of H2O [kJ/kg] + Chemical potential of H2O, [kJ/kg] mus : float - Chemical potential of sea salt [kJ/kg] + Chemical potential of sea salt, [kJ/kg] osm : float Osmotic coefficient, [-] haline : float - Haline contraction coefficient [kg/kg] + Haline contraction coefficient, [kg/kg] - Raises + Notes ------ - Warning : If input isn't in limit + :class:`Warning` if input isn't in limit: + * 261 ≤ T ≤ 353 * 0 < P ≤ 100 * 0 ≤ S ≤ 0.12 @@ -397,14 +411,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] S : float - Salinity [kg/kg] + Salinity, [kg/kg] Returns ------- Tb : float - Boiling temperature [K] + Boiling temperature, [K] References ---------- @@ -431,14 +445,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] S : float - Salinity [kg/kg] + Salinity, [kg/kg] Returns ------- Tf : float - Freezing temperature [K] + Freezing temperature, [K] References ---------- @@ -466,14 +480,15 @@ Parameters ---------- S : float - Salinity [kg/kg] + Salinity, [kg/kg] Returns ------- - Tt : float - Triple point temperature [K] - Pt: float - Triple point pressure [MPa] + prop : dict + Dictionary with the triple point properties: + + * Tt: Triple point temperature, [K] + * Pt: Triple point pressure, [MPa] References ---------- @@ -507,16 +522,16 @@ Parameters ---------- T : float - Tmperature [K] + Tmperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] S : float - Salinity [kg/kg] + Salinity, [kg/kg] Returns ------- Posm : float - Osmotic pressure [MPa] + Osmotic pressure, [MPa] References ---------- @@ -542,20 +557,21 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] S : float - Salinity [kg/kg] + Salinity, [kg/kg] Returns ------- k : float - Thermal conductivity excess relative to that of the pure water [W/mK] + Thermal conductivity excess relative to that of the pure water, [W/mK] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 273.15 ≤ T ≤ 523.15 * 0 ≤ P ≤ 140 * 0 ≤ S ≤ 0.17 @@ -597,20 +613,21 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] mH2SO4 : float - Molality of sufuric acid [mol/kg(water)] + Molality of sufuric acid, [mol/kg(water)] mNaCl : float - Molality of sodium chloride [mol/kg(water)] + Molality of sodium chloride, [mol/kg(water)] Returns ------- S : float - Molal solutility of sodium sulfate [mol/kg(water)] + Molal solutility of sodium sulfate, [mol/kg(water)] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 523.15 ≤ T ≤ 623.15 * 0 ≤ mH2SO4 ≤ 0.75 * 0 ≤ mNaCl ≤ 2.25 @@ -652,17 +669,21 @@ Parameters ---------- x : float - Mole fraction of NaCl [-] + Mole fraction of NaCl, [-] Returns ------- - Tc: critical temperature [K] - Pc: critical pressure [MPa] - rhoc: critical density [kg/m³] + prop : dict + A dictionary withe the properties: - Raises + * Tc: critical temperature, [K] + * Pc: critical pressure, [MPa] + * rhoc: critical density, [kg/m³] + + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 0 ≤ x ≤ 0.12 Examples diff -Nru iapws-1.3/iapws/iapws95.py iapws-1.4/iapws/iapws95.py --- iapws-1.3/iapws/iapws95.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/iapws95.py 2019-06-15 06:32:57.000000000 +0000 @@ -2,14 +2,17 @@ # -*- coding: utf-8 -*- """ -Implemented multiparameter equation of state as a Helmholtz free energy - * IAPWS-95 implementation - * Heavy water formulation 2017 +Implemented multiparameter equation of state as a Helmholtz free energy: + + * :class:`MEoS`: Base class of multiparameter equation of state + * :class:`IAPWS95`: 2016 revision of 1995 formulation for ordinaty water + * :class:`D2O`: 2017 formulation for heavy water. """ from __future__ import division -from itertools import product +import os +import platform import warnings from scipy import exp, log, ndarray @@ -22,36 +25,263 @@ from ._utils import _fase, getphase, deriv_H -class MEoS(_fase): +def _phir(tau, delta, coef): + """Residual contribution to the adimensional free Helmholtz energy + + Parameters + ---------- + tau : float + Inverse reduced temperature Tc/T, [-] + delta : float + Reduced density rho/rhoc, [-] + coef : dict + Dictionary with equation of state parameters + + Returns + ------- + fir : float + Adimensional free Helmholtz energy + + References + ---------- + IAPWS, Revised Release on the IAPWS Formulation 1995 for the + Thermodynamic Properties of Ordinary Water Substance for General and + Scientific Use, September 2016, Table 5 + http://www.iapws.org/relguide/IAPWS-95.html """ + fir = 0 + + # Polinomial terms + nr1 = coef.get("nr1", []) + d1 = coef.get("d1", []) + t1 = coef.get("t1", []) + for n, d, t in zip(nr1, d1, t1): + fir += n*delta**d*tau**t + + # Exponential terms + nr2 = coef.get("nr2", []) + d2 = coef.get("d2", []) + g2 = coef.get("gamma2", []) + t2 = coef.get("t2", []) + c2 = coef.get("c2", []) + for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): + fir += n*delta**d*tau**t*exp(-g*delta**c) + + # Gaussian terms + nr3 = coef.get("nr3", []) + d3 = coef.get("d3", []) + t3 = coef.get("t3", []) + a3 = coef.get("alfa3", []) + e3 = coef.get("epsilon3", []) + b3 = coef.get("beta3", []) + g3 = coef.get("gamma3", []) + for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): + fir += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2) + + # Non analitic terms + nr4 = coef.get("nr4", []) + a4 = coef.get("a4", []) + b4 = coef.get("b4", []) + Ai = coef.get("A", []) + Bi = coef.get("B", []) + Ci = coef.get("C", []) + Di = coef.get("D", []) + bt4 = coef.get("beta4", []) + for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): + Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) + F = exp(-C*(delta-1)**2-D*(tau-1)**2) + Delta = Tita**2+B*((delta-1)**2)**a + fir += n*Delta**b*delta*F + + return fir + + +def _phird(tau, delta, coef): + r"""Residual contribution to the adimensional free Helmholtz energy, delta + derivative + + Parameters + ---------- + tau : float + Inverse reduced temperature Tc/T, [-] + delta : float + Reduced density rho/rhoc, [-] + coef : dict + Dictionary with equation of state parameters + + Returns + ------- + fird : float + .. math:: + \left.\frac{\partial \phi^r_{\delta}}{\partial \delta}\right|_{\tau} + + References + ---------- + IAPWS, Revised Release on the IAPWS Formulation 1995 for the + Thermodynamic Properties of Ordinary Water Substance for General and + Scientific Use, September 2016, Table 5 + http://www.iapws.org/relguide/IAPWS-95.html + """ + fird = 0 + + # Polinomial terms + nr1 = coef.get("nr1", []) + d1 = coef.get("d1", []) + t1 = coef.get("t1", []) + for n, d, t in zip(nr1, d1, t1): + fird += n*d*delta**(d-1)*tau**t + + # Exponential terms + nr2 = coef.get("nr2", []) + d2 = coef.get("d2", []) + g2 = coef.get("gamma2", []) + t2 = coef.get("t2", []) + c2 = coef.get("c2", []) + for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): + fird += n*exp(-g*delta**c)*delta**(d-1)*tau**t*(d-g*c*delta**c) + + # Gaussian terms + nr3 = coef.get("nr3", []) + d3 = coef.get("d3", []) + t3 = coef.get("t3", []) + a3 = coef.get("alfa3", []) + e3 = coef.get("epsilon3", []) + b3 = coef.get("beta3", []) + g3 = coef.get("gamma3", []) + for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): + fird += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( + d/delta-2*a*(delta-e)) + + # Non analitic terms + nr4 = coef.get("nr4", []) + a4 = coef.get("a4", []) + b4 = coef.get("b4", []) + Ai = coef.get("A", []) + Bi = coef.get("B", []) + Ci = coef.get("C", []) + Di = coef.get("D", []) + bt4 = coef.get("beta4", []) + for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): + Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) + F = exp(-C*(delta-1)**2-D*(tau-1)**2) + Fd = -2*C*F*(delta-1) + + Delta = Tita**2+B*((delta-1)**2)**a + Deltad = (delta-1)*(A*Tita*2/bt*((delta-1)**2)**(0.5/bt-1) + + 2*B*a*((delta-1)**2)**(a-1)) + DeltaBd = b*Delta**(b-1)*Deltad + + fird += n*(Delta**b*(F+delta*Fd)+DeltaBd*delta*F) + + return fird + + +def _phirt(tau, delta, coef): + r"""Residual contribution to the adimensional free Helmholtz energy, tau + derivative + + Parameters + ---------- + tau : float + Inverse reduced temperature Tc/T, [-] + delta : float + Reduced density rho/rhoc, [-] + coef : dict + Dictionary with equation of state parameters + + Returns + ------- + firt : float + .. math:: + \left.\frac{\partial \phi^r_{\tau}}{\partial \tau}\right|_{\delta} + + References + ---------- + IAPWS, Revised Release on the IAPWS Formulation 1995 for the + Thermodynamic Properties of Ordinary Water Substance for General and + Scientific Use, September 2016, Table 5 + http://www.iapws.org/relguide/IAPWS-95.html + """ + firt = 0 + + # Polinomial terms + nr1 = coef.get("nr1", []) + d1 = coef.get("d1", []) + t1 = coef.get("t1", []) + for n, d, t in zip(nr1, d1, t1): + firt += n*t*delta**d*tau**(t-1) + + # Exponential terms + nr2 = coef.get("nr2", []) + d2 = coef.get("d2", []) + g2 = coef.get("gamma2", []) + t2 = coef.get("t2", []) + c2 = coef.get("c2", []) + for n, d, g, t, c in zip(nr2, d2, g2, t2, c2): + firt += n*t*delta**d*tau**(t-1)*exp(-g*delta**c) + + # Gaussian terms + nr3 = coef.get("nr3", []) + d3 = coef.get("d3", []) + t3 = coef.get("t3", []) + a3 = coef.get("alfa3", []) + e3 = coef.get("epsilon3", []) + b3 = coef.get("beta3", []) + g3 = coef.get("gamma3", []) + for n, d, t, a, e, b, g in zip(nr3, d3, t3, a3, e3, b3, g3): + firt += n*delta**d*tau**t*exp(-a*(delta-e)**2-b*(tau-g)**2)*( + t/tau-2*b*(tau-g)) + + # Non analitic terms + nr4 = coef.get("nr4", []) + a4 = coef.get("a4", []) + b4 = coef.get("b4", []) + Ai = coef.get("A", []) + Bi = coef.get("B", []) + Ci = coef.get("C", []) + Di = coef.get("D", []) + bt4 = coef.get("beta4", []) + for n, a, b, A, B, C, D, bt in zip(nr4, a4, b4, Ai, Bi, Ci, Di, bt4): + Tita = (1-tau)+A*((delta-1)**2)**(0.5/bt) + F = exp(-C*(delta-1)**2-D*(tau-1)**2) + Ft = -2*D*F*(tau-1) + Delta = Tita**2+B*((delta-1)**2)**a + DeltaBt = -2*Tita*b*Delta**(b-1) + firt += n*delta*(DeltaBt*F+Delta**b*Ft) + + return firt + + +class MEoS(_fase): + r""" General implementation of multiparameter equation of state. From this derived all child class specified per individual compounds Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] rho : float - Density [kg/m³] + Density, [kg/m³] v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] u : float - Specific internal energy [kJ/kg] + Specific internal energy, [kJ/kg] x : float - Vapor quality [-] + Vapor quality, [-] l : float, optional - Wavelength of light, for refractive index [nm] + Wavelength of light, for refractive index, [nm] rho0 : float, optional - Initial value of density, to improve iteration [kg/m³] + Initial value of density, to improve iteration, [kg/m³] T0 : float, optional - Initial value of temperature, to improve iteration [K] + Initial value of temperature, to improve iteration, [K] x0 : Initial value of vapor quality, necessary in bad input pair definition where there are two valid solution (T-h, T-s) @@ -61,83 +291,82 @@ * v as a alternate input parameter to rho * T-x, P-x, preferred input pair to specified a point in two phases region - Returns - ------- The calculated instance has the following properties: - * P: Pressure [MPa] - * T: Temperature [K] - * x: Vapor quality [-] - * g: Specific Gibbs free energy [kJ/kg] - * a: Specific Helmholtz free energy [kJ/kg] - * v: Specific volume [m³/kg] - * r: Density [kg/m³] - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * s: Specific entropy [kJ/kg·K] - * cp: Specific isobaric heat capacity [kJ/kg·K] - * cv: Specific isochoric heat capacity [kJ/kg·K] + + * P: Pressure, [MPa] + * T: Temperature, [K] + * x: Vapor quality, [-] + * g: Specific Gibbs free energy, [kJ/kg] + * a: Specific Helmholtz free energy, [kJ/kg] + * v: Specific volume, [m³/kg] + * r: Density, [kg/m³] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * s: Specific entropy, [kJ/kg·K] + * cp: Specific isobaric heat capacity, [kJ/kg·K] + * cv: Specific isochoric heat capacity, [kJ/kg·K] * cp_cv: Heat capacity ratio, [-] - * Z: Compression factor [-] - * fi: Fugacity coefficient [-] - * f: Fugacity [MPa] - * gamma: Isoentropic exponent [-] - - * alfav: Isobaric cubic expansion coefficient [1/K] - * kappa: Isothermal compressibility [1/MPa] - * kappas: Adiabatic compresibility [1/MPa] - * alfap: Relative pressure coefficient [1/K] - * betap: Isothermal stress coefficient [kg/m³] - * joule: Joule-Thomson coefficient [K/MPa] - - * betas: Isoentropic temperature-pressure coefficient [-] - * Gruneisen: Gruneisen parameter [-] - * virialB: Second virial coefficient [m³/kg] - * virialC: Third virial coefficient [m⁶/kg²] - * dpdT_rho: Derivatives, dp/dT at constant rho [MPa/K] - * dpdrho_T: Derivatives, dp/drho at constant T [MPa·m³/kg] - * drhodT_P: Derivatives, drho/dT at constant P [kg/m³·K] - * drhodP_T: Derivatives, drho/dP at constant T [kg/m³·MPa] - * dhdT_rho: Derivatives, dh/dT at constant rho [kJ/kg·K] - * dhdP_T: Isothermal throttling coefficient [kJ/kg·MPa] - * dhdT_P: Derivatives, dh/dT at constant P [kJ/kg·K] - * dhdrho_T: Derivatives, dh/drho at constant T [kJ·m³/kg²] - * dhdrho_P: Derivatives, dh/drho at constant P [kJ·m³/kg²] - * dhdP_rho: Derivatives, dh/dP at constant rho [kJ/kg·MPa] - * kt: Isothermal Expansion Coefficient [-] - * ks: Adiabatic Compressibility [1/MPa] - * Ks: Adiabatic bulk modulus [MPa] - * Kt: Isothermal bulk modulus [MPa] - - * v0: Ideal specific volume [m³/kg] - * rho0: Ideal gas density [kg/m³] - * u0: Ideal specific internal energy [kJ/kg] - * h0: Ideal specific enthalpy [kJ/kg] - * s0: Ideal specific entropy [kJ/kg·K] - * a0: Ideal specific Helmholtz free energy [kJ/kg] - * g0: Ideal specific Gibbs free energy [kJ/kg] - * cp0: Ideal specific isobaric heat capacity [kJ/kg·K] - * cv0: Ideal specific isochoric heat capacity [kJ/kg·K] - * w0: Ideal speed of sound [m/s] - * gamma0: Ideal isoentropic exponent [-] - - * w: Speed of sound [m/s] - * mu: Dynamic viscosity [Pa·s] - * nu: Kinematic viscosity [m²/s] - * k: Thermal conductivity [W/m·K] - * alfa: Thermal diffusivity [m²/s] - * sigma: Surface tension [N/m] - * epsilon: Dielectric constant [-] - * n: Refractive index [-] - * Prandt: Prandtl number [-] - * Pr: Reduced Pressure [-] - * Tr: Reduced Temperature [-] - * Hvap: Vaporization heat [kJ/kg] - * Svap: Vaporization entropy [kJ/kg·K] - - * Z_rho: (Z-1) over the density [m³/kg] - * IntP: Internal pressure [MPa] - * invT: Negative reciprocal temperature [1/K] - * hInput: Specific heat input [kJ/kg] + * Z: Compression factor, [-] + * fi: Fugacity coefficient, [-] + * f: Fugacity, [MPa] + * gamma: Isoentropic exponent, [-] + + * alfav: Isobaric cubic expansion coefficient, [1/K] + * kappa: Isothermal compressibility, [1/MPa] + * kappas: Adiabatic compresibility, [1/MPa] + * alfap: Relative pressure coefficient, [1/K] + * betap: Isothermal stress coefficient, [kg/m³] + * joule: Joule-Thomson coefficient, [K/MPa] + + * betas: Isoentropic temperature-pressure coefficient, [-] + * Gruneisen: Gruneisen parameter, [-] + * virialB: Second virial coefficient, [m³/kg] + * virialC: Third virial coefficient, [m⁶/kg²] + * dpdT_rho: Derivatives, dp/dT at constant rho, [MPa/K] + * dpdrho_T: Derivatives, dp/drho at constant T, [MPa·m³/kg] + * drhodT_P: Derivatives, drho/dT at constant P, [kg/m³·K] + * drhodP_T: Derivatives, drho/dP at constant T, [kg/m³·MPa] + * dhdT_rho: Derivatives, dh/dT at constant rho, [kJ/kg·K] + * dhdP_T: Isothermal throttling coefficient, [kJ/kg·MPa] + * dhdT_P: Derivatives, dh/dT at constant P, [kJ/kg·K] + * dhdrho_T: Derivatives, dh/drho at constant T, [kJ·m³/kg²] + * dhdrho_P: Derivatives, dh/drho at constant P, [kJ·m³/kg²] + * dhdP_rho: Derivatives, dh/dP at constant rho, [kJ/kg·MPa] + * kt: Isothermal Expansion Coefficient, [-] + * ks: Adiabatic Compressibility, [1/MPa] + * Ks: Adiabatic bulk modulus, [MPa] + * Kt: Isothermal bulk modulus, [MPa] + + * v0: Ideal specific volume, [m³/kg] + * rho0: Ideal gas density, [kg/m³] + * u0: Ideal specific internal energy, [kJ/kg] + * h0: Ideal specific enthalpy, [kJ/kg] + * s0: Ideal specific entropy, [kJ/kg·K] + * a0: Ideal specific Helmholtz free energy, [kJ/kg] + * g0: Ideal specific Gibbs free energy, [kJ/kg] + * cp0: Ideal specific isobaric heat capacity, [kJ/kg·K] + * cv0: Ideal specific isochoric heat capacity, [kJ/kg·K] + * w0: Ideal speed of sound, [m/s] + * gamma0: Ideal isoentropic exponent, [-] + + * w: Speed of sound, [m/s] + * mu: Dynamic viscosity, [Pa·s] + * nu: Kinematic viscosity, [m²/s] + * k: Thermal conductivity, [W/m·K] + * alfa: Thermal diffusivity, [m²/s] + * sigma: Surface tension, [N/m] + * epsilon: Dielectric constant, [-] + * n: Refractive index, [-] + * Prandt: Prandtl number, [-] + * Pr: Reduced Pressure, [-] + * Tr: Reduced Temperature, [-] + * Hvap: Vaporization heat, [kJ/kg] + * Svap: Vaporization entropy, [kJ/kg·K] + + * Z_rho: :math:`(Z-1)/\rho`, [m³/kg] + * IntP: Internal pressure, [MPa] + * invT: Negative reciprocal temperature, [1/K] + * hInput: Specific heat input, [kJ/kg] """ CP = None _Pv = None @@ -276,10 +505,12 @@ rhoo = 900 self.R = self._constants["R"]/self._constants.get("M", self.M) + rhoc = self._constants.get("rhoref", self.rhoc) + Tc = self._constants.get("Tref", self.Tc) propiedades = None - if x is None: + if self._mode not in ("Tx", "Px"): # Method with iteration necessary to get x if self._mode == "TP": try: @@ -299,12 +530,42 @@ rhoo = self.rhoc*3 except ValueError: rhoo = 1e-3 - rho = fsolve( - lambda rho: self._Helmholtz(rho, T)["P"]-P*1000, rhoo)[0] + + def f(rho): + delta = rho/rhoc + tau = Tc/T + + fird = _phird(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + return Po-P*1000 + + rho = fsolve(f, rhoo)[0] + + # Calculate quality + if T > self.Tc: + x = 1 + else: + Ps = self._Vapor_Pressure(T) + if Ps*0.95 < P < Ps*1.05: + rhol, rhov, Ps = self._saturation(T) + Ps *= 1e-3 + + if Ps > P: + x = 1 + else: + x = 0 elif self._mode == "Th": + tau = Tc/T + ideal = self._phi0(tau, 1) + fiot = ideal["fiot"] + def f(rho): - return self._Helmholtz(rho, T)["h"]-h + delta = rho/rhoc + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + return ho-h if T >= self.Tc: rhoo = self.rhoc @@ -313,8 +574,15 @@ x0 = self.kwargs["x0"] rhov = self._Vapor_Density(T) rhol = self._Liquid_Density(T) - hl = self._Helmholtz(rhol, T)["h"] - hv = self._Helmholtz(rhov, T)["h"] + deltaL = rhol/rhoc + deltaG = rhov/rhoc + + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hl = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + hv = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) if x0 not in (0, 1) and hl <= h <= hv: rhol, rhov, Ps = self._saturation(T) vapor = self._Helmholtz(rhov, T) @@ -332,10 +600,20 @@ rho = fsolve(f, rhoo)[0] elif self._mode == "Ts": + tau = Tc/T + def f(rho): if rho < 0: rho = 1e-20 - return self._Helmholtz(rho, T)["s"]-s + delta = rho/rhoc + + ideal = self._phi0(tau, delta) + fio = ideal["fio"] + fiot = ideal["fiot"] + fir = _phir(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + so = self.R*(tau*(fiot+firt)-fio-fir) + return so-s if T >= self.Tc: rhoo = self.rhoc @@ -343,8 +621,21 @@ else: rhov = self._Vapor_Density(T) rhol = self._Liquid_Density(T) - sl = self._Helmholtz(rhol, T)["s"] - sv = self._Helmholtz(rhov, T)["s"] + deltaL = rhol/rhoc + deltaG = rhov/rhoc + + idealL = self._phi0(tau, deltaL) + idealG = self._phi0(tau, deltaG) + fioL = idealL["fio"] + fioG = idealG["fio"] + fiot = idealL["fiot"] + firL = _phir(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + sl = self.R*(tau*(fiot+firtL)-fioL-firL) + firG = _phir(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + sv = self.R*(tau*(fiot+firtG)-fioG-firG) + if sl <= s <= sv: rhol, rhov, Ps = self._saturation(T) vapor = self._Helmholtz(rhov, T) @@ -362,9 +653,19 @@ rho = fsolve(f, rhoo)[0] elif self._mode == "Tu": + tau = Tc/T + ideal = self._phi0(tau, 1) + fiot = ideal["fiot"] + def f(rho): - prop = self._Helmholtz(rho, T) - return prop["h"]-prop["P"]/rho-u + delta = rho/rhoc + + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + + return ho-Po/rho-u if T >= self.Tc: rhoo = self.rhoc @@ -372,10 +673,20 @@ else: rhov = self._Vapor_Density(T) rhol = self._Liquid_Density(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - uv = vapor["h"]-vapor["P"]/rhov - ul = liquido["h"]-liquido["P"]/rhol + deltaL = rhol/rhoc + deltaG = rhov/rhoc + + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + PoL = (1+deltaL*firdL)*self.R*T*rhol + PoG = (1+deltaG*firdG)*self.R*T*rhov + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + uv = hoG-PoG/rhov + ul = hoL-PoL/rhol if ul <= u <= uv: rhol, rhov, Ps = self._saturation(T) vapor = self._Helmholtz(rhov, T) @@ -393,23 +704,35 @@ rho = fsolve(f, rhoo)[0] elif self._mode == "Prho": - T = fsolve( - lambda T: self._Helmholtz(rho, T)["P"]-P*1000, To)[0] + delta = rho/rhoc + + def f(T): + tau = Tc/T + + fird = _phird(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + return Po-P*1000 + + T = fsolve(f, To)[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if T == To or rhov <= rho <= rhol: def f(parr): T, rhol, rhog = parr + tau = Tc/T deltaL = rhol/self.rhoc deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) - Jl = rhol*(1+deltaL*liquido["fird"]) - Jv = rhog*(1+deltaG*vapor["fird"]) - K = liquido["fir"]-vapor["fir"] - Ps = self.R*T*rhol*rhog/(rhol-rhog)*( - liquido["fir"]-vapor["fir"]+log(rhol/rhog)) + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) return (Jl-Jv, Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, Ps - P*1000) @@ -434,26 +757,67 @@ elif self._mode == "Ph": def funcion(parr): - par = self._Helmholtz(parr[0], parr[1]) - return par["P"]-P*1000, par["h"]-h + rho, T = parr + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + return Po-P*1000, ho-h + rho, T = fsolve(funcion, [rhoo, To]) rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if rho == rhoo or rhov <= rho <= rhol: - def funcion(parr): - rho, T = parr - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - x = (1./rho-1/rhol)/(1/rhov-1/rhol) - return Ps-P*1000, vapor["h"]*x+liquido["h"]*(1-x)-h - rho, T = fsolve(funcion, [2., 500.]) - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - hv = vapor["h"] - hl = liquido["h"] - x = (h-hl)/(hv-hl) + + def f(parr): + T, rhol, rhog, x = parr + tau = Tc/T + deltaL = rhol/self.rhoc + deltaG = rhog/self.rhoc + + ideal = self._phi0(tau, deltaL) + fiot = ideal["fiot"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) + + return (Jl-Jv, + Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, + hoL*(1-x)+hoG*x - h, + Ps - P*1000) + + for to in [To, 300, 400, 500, 600]: + rLo = self._Liquid_Density(to) + rGo = self._Vapor_Density(to) + sol = fsolve(f, [to, rLo, rGo, 0.5], full_output=True) + T, rhoL, rhoG, x = sol[0] + if sol[2] == 1 and 0 <= x <= 1 and \ + sum(abs(sol[1]["fvec"])) < 1e-5: + break + + if sum(abs(sol[1]["fvec"])) > 1e-5: + raise(RuntimeError(sol[3])) + + liquido = self._Helmholtz(rhoL, T) + vapor = self._Helmholtz(rhoG, T) + P = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( + liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "Ps": try: @@ -462,10 +826,22 @@ x0 = None if x0 is None or x0 == 0 or x0 == 1: - def funcion(parr): - par = self._Helmholtz(parr[0], parr[1]) - return par["P"]-P*1000, par["s"]-s - rho, T = fsolve(funcion, [rhoo, To]) + def f(parr): + rho, T = parr + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fio = ideal["fio"] + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + fir = _phir(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + so = self.R*(tau*(fiot+firt)-fio-fir) + return Po-P*1000, so-s + + rho, T = fsolve(f, [rhoo, To]) else: def funcion(parr): @@ -484,50 +860,112 @@ x = (s-sl)/(sv-sl) elif self._mode == "Pu": - def funcion(parr): + def f(parr): rho, T = parr - par = self._Helmholtz(rho, T) - return par["h"]-par["P"]/rho-u, par["P"]-P*1000 - sol = fsolve(funcion, [rhoo, To], full_output=True) + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + return ho-Po/rho-u, Po-P*1000 + + sol = fsolve(f, [rhoo, To], full_output=True) rho, T = sol[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if rho == rhoo or sol[2] != 1: - def funcion(parr): - rho, T = parr - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - vu = vapor["h"]-Ps/rhov - lu = liquido["h"]-Ps/rhol - x = (1./rho-1/rhol)/(1/rhov-1/rhol) - return Ps-P*1000, vu*x+lu*(1-x)-u - rho, T = fsolve(funcion, [2., 500.]) - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - uv = vapor["h"]-Ps/rhov - ul = liquido["h"]-Ps/rhol - x = (u-ul)/(uv-ul) + + def f(parr): + T, rhol, rhog, x = parr + tau = Tc/T + deltaL = rhol/self.rhoc + deltaG = rhog/self.rhoc + + ideal = self._phi0(tau, deltaL) + fiot = ideal["fiot"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) + vu = hoG-Ps/rhog + lu = hoL-Ps/rhol + return (Jl-Jv, + Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, + lu*(1-x)+vu*x - u, + Ps - P*1000) + + for to in [To, 300, 400, 500, 600]: + rLo = self._Liquid_Density(to) + rGo = self._Vapor_Density(to) + sol = fsolve(f, [to, rLo, rGo, 0.5], full_output=True) + T, rhoL, rhoG, x = sol[0] + if sol[2] == 1 and 0 <= x <= 1 and \ + sum(abs(sol[1]["fvec"])) < 1e-5: + break + + if sum(abs(sol[1]["fvec"])) > 1e-5: + raise(RuntimeError(sol[3])) + + liquido = self._Helmholtz(rhoL, T) + vapor = self._Helmholtz(rhoG, T) + P = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( + liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "rhoh": - T = fsolve(lambda T: self._Helmholtz(rho, T)["h"]-h, To)[0] + delta = rho/rhoc + + def f(T): + tau = Tc/T + + ideal = self._phi0(tau, delta) + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + return ho-h + + T = fsolve(f, To)[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if T == To or rhov <= rho <= rhol: def f(parr): T, rhol, rhog = parr + tau = Tc/T deltaL = rhol/self.rhoc deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) - Jl = rhol*(1+deltaL*liquido["fird"]) - Jv = rhog*(1+deltaG*vapor["fird"]) - K = liquido["fir"]-vapor["fir"] + + ideal = self._phi0(tau, deltaL) + fiot = ideal["fiot"] + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG x = (1./rho-1/rhol)/(1/rhog-1/rhol) return (Jl-Jv, Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, - liquido["h"]*(1-x)+vapor["h"]*x - h) + hoL*(1-x)+hoG*x - h) for to in [To, 300, 400, 500, 600]: rhoLo = self._Liquid_Density(to) @@ -548,23 +986,51 @@ liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "rhos": - T = fsolve(lambda T: self._Helmholtz(rho, T)["s"]-s, To)[0] + delta = rho/rhoc + + def f(T): + tau = Tc/T + ideal = self._phi0(tau, delta) + fio = ideal["fio"] + fiot = ideal["fiot"] + fir = _phir(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + so = self.R*(tau*(fiot+firt)-fio-fir) + return so-s + + T = fsolve(f, To)[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if T == To or rhov <= rho <= rhol: + def f(parr): T, rhol, rhog = parr + tau = Tc/T deltaL = rhol/self.rhoc deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) - Jl = rhol*(1+deltaL*liquido["fird"]) - Jv = rhog*(1+deltaG*vapor["fird"]) - K = liquido["fir"]-vapor["fir"] + + idealL = self._phi0(tau, deltaL) + fioL = idealL["fio"] + fiot = idealL["fiot"] + idealG = self._phi0(tau, deltaG) + fioG = idealG["fio"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + soL = self.R*(tau*(fiot+firtL)-fioL-firL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + soG = self.R*(tau*(fiot+firtG)-fioG-firG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG x = (1./rho-1/rhol)/(1/rhog-1/rhol) return (Jl-Jv, Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, - liquido["s"]*(1-x)+vapor["s"]*x - s) + soL*(1-x)+soG*x - s) for to in [To, 300, 400, 500, 600]: rhoLo = self._Liquid_Density(to) @@ -585,27 +1051,47 @@ liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "rhou": - def funcion(T): - par = self._Helmholtz(rho, T) - return par["h"]-par["P"]/rho-u - T = fsolve(funcion, To)[0] + delta = rho/rhoc + + def f(T): + tau = Tc/T + + ideal = self._phi0(tau, delta) + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + return ho-Po/rho-u + + T = fsolve(f, To)[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if T == To or rhov <= rho <= rhol: def f(parr): T, rhol, rhog = parr + tau = Tc/T deltaL = rhol/self.rhoc deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) - Jl = rhol*(1+deltaL*liquido["fird"]) - Jv = rhog*(1+deltaG*vapor["fird"]) - K = liquido["fir"]-vapor["fir"] + + ideal = self._phi0(tau, deltaL) + fiot = ideal["fiot"] + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG x = (1./rho-1/rhol)/(1/rhog-1/rhol) - Ps = self.R*T*rhol*rhog/(rhol-rhog)*( - liquido["fir"]-vapor["fir"]+log(rhol/rhog)) - vu = vapor["h"]-Ps/rhog - lu = liquido["h"]-Ps/rhol + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) + vu = hoG-Ps/rhog + lu = hoL-Ps/rhol return (Jl-Jv, Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, lu*(1-x)+vu*x - u) @@ -629,123 +1115,218 @@ liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "hs": - def funcion(parr): - par = self._Helmholtz(parr[0], parr[1]) - return par["h"]-h, par["s"]-s - rho, T = fsolve(funcion, [rhoo, To]) + def f(parr): + rho, T = parr + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fio = ideal["fio"] + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + fir = _phir(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + so = self.R*(tau*(fiot+firt)-fio-fir) + return ho-h, so-s + + rho, T = fsolve(f, [rhoo, To]) rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if rhov <= rho <= rhol: - def funcion(parr): - rho, T = parr - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - x = (1./rho-1/rhol)/(1/rhov-1/rhol) - return (vapor["h"]*x+liquido["h"]*(1-x)-h, - vapor["s"]*x+liquido["s"]*(1-x)-s) - rho, T = fsolve(funcion, [0.5, 400.]) - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - sv = vapor["s"] - sl = liquido["s"] - x = (s-sl)/(sv-sl) - P = Ps/1000 + + def f(parr): + T, rhol, rhog, x = parr + tau = Tc/T + deltaL = rhol/self.rhoc + deltaG = rhog/self.rhoc + + idealL = self._phi0(tau, deltaL) + fiot = idealL["fiot"] + fioL = idealL["fio"] + idealG = self._phi0(tau, deltaG) + fioG = idealG["fio"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + soL = self.R*(tau*(fiot+firtL)-fioL-firL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + soG = self.R*(tau*(fiot+firtG)-fioG-firG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + return (Jl-Jv, + Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, + hoL*(1-x)+hoG*x - h, + soL*(1-x)+soG*x - s) + + for to in [To, 300, 400, 500, 600]: + rLo = self._Liquid_Density(to) + rGo = self._Vapor_Density(to) + sol = fsolve(f, [to, rLo, rGo, 0.5], full_output=True) + T, rhoL, rhoG, x = sol[0] + if sol[2] == 1 and 0 <= x <= 1 and \ + sum(abs(sol[1]["fvec"])) < 1e-5: + break + + if sum(abs(sol[1]["fvec"])) > 1e-5: + raise(RuntimeError(sol[3])) + + liquido = self._Helmholtz(rhoL, T) + vapor = self._Helmholtz(rhoG, T) + P = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( + liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "hu": - def funcion(parr): + def f(parr): rho, T = parr - par = self._Helmholtz(rho, T) - return par["h"]-par["P"]/rho-u, par["h"]-h - sol = fsolve(funcion, [rhoo, To], full_output=True) + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + Po = (1+delta*fird)*self.R*T*rho + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + + return ho-Po/rho-u, ho-h + + sol = fsolve(f, [rhoo, To], full_output=True) rho, T = sol[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if sol[2] != 1 or rhov <= rho <= rhol: - def funcion(parr): - rho, T = parr - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - vu = vapor["h"]-Ps/rhov - lu = liquido["h"]-Ps/rhol - x = (1./rho-1/rhol)/(1/rhov-1/rhol) - return (vapor["h"]*x+liquido["h"]*(1-x)-h, - vu*x+lu*(1-x)-u) - To = [500, 700, 300, 900] - if self.kwargs["T0"]: - To.insert(0, self.kwargs["T0"]) - rhov = self._Vapor_Density(self.Tt) - rhol = self._Liquid_Density(self.Tt) - ro = [1, 1e-3, rhov, rhol] - if self.kwargs["rho0"]: - ro.insert(0, self.kwargs["rho0"]) - - for r, t in product(ro, To): - sol = fsolve(funcion, [r, t], full_output=True) - rho, T = sol[0] - if sol[2] == 1 and sum(abs(sol[1]["fvec"])) < 1e-5: + def f(parr): + T, rhol, rhog, x = parr + tau = Tc/T + deltaL = rhol/self.rhoc + deltaG = rhog/self.rhoc + + ideal = self._phi0(tau, deltaL) + fiot = ideal["fiot"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) + vu = hoG-Ps/rhog + lu = hoL-Ps/rhol + + return (Jl-Jv, + Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, + hoL*(1-x)+hoG*x - h, + lu*(1-x)+vu*x - u) + + for to in [To, 300, 400, 500, 600]: + rLo = self._Liquid_Density(to) + rGo = self._Vapor_Density(to) + sol = fsolve(f, [to, rLo, rGo, 0.5], full_output=True) + T, rhoL, rhoG, x = sol[0] + if sol[2] == 1 and 0 <= x <= 1 and \ + sum(abs(sol[1]["fvec"])) < 1e-5: break if sum(abs(sol[1]["fvec"])) > 1e-5: raise(RuntimeError(sol[3])) - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - hv = vapor["h"] - hl = liquido["h"] - x = (h-hl)/(hv-hl) - P = Ps/1000 + liquido = self._Helmholtz(rhoL, T) + vapor = self._Helmholtz(rhoG, T) + P = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( + liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "su": - def funcion(parr): + def f(parr): rho, T = parr - par = self._Helmholtz(rho, T) - return par["h"]-par["P"]/rho-u, par["s"]-s - sol = fsolve(funcion, [rhoo, To], full_output=True) + delta = rho/rhoc + tau = Tc/T + + ideal = self._phi0(tau, delta) + fio = ideal["fio"] + fiot = ideal["fiot"] + fird = _phird(tau, delta, self._constants) + fir = _phir(tau, delta, self._constants) + firt = _phirt(tau, delta, self._constants) + ho = self.R*T*(1+tau*(fiot+firt)+delta*fird) + so = self.R*(tau*(fiot+firt)-fio-fir) + Po = (1+delta*fird)*self.R*T*rho + return ho-Po/rho-u, so-s + + sol = fsolve(f, [rhoo, To], full_output=True) rho, T = sol[0] rhol = self._Liquid_Density(T) rhov = self._Vapor_Density(T) if sol[2] != 1 or rhov <= rho <= rhol: - def funcion(parr): - rho, T = parr - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - vu = vapor["h"]-Ps/rhov - lu = liquido["h"]-Ps/rhol - x = (1./rho-1/rhol)/(1/rhov-1/rhol) - return (vapor["s"]*x+liquido["s"]*(1-x)-s, - vu*x+lu*(1-x)-u) - To = [500, 700, 300, 900] - if self.kwargs["T0"]: - To.insert(0, self.kwargs["T0"]) - rhov = self._Vapor_Density(self.Tt) - rhol = self._Liquid_Density(self.Tt) - ro = [1, 1e-3, rhov, rhol] - if self.kwargs["rho0"]: - ro.insert(0, self.kwargs["rho0"]) - - for r, t in product(ro, To): - sol = fsolve(funcion, [r, t], full_output=True) - rho, T = sol[0] - if sol[2] == 1 and sum(abs(sol[1]["fvec"])) < 1e-5: + def f(parr): + T, rhol, rhog, x = parr + tau = Tc/T + deltaL = rhol/self.rhoc + deltaG = rhog/self.rhoc + + idealL = self._phi0(tau, deltaL) + fiot = idealL["fiot"] + fioL = idealL["fio"] + idealG = self._phi0(tau, deltaG) + fioG = idealG["fio"] + + firL = _phir(tau, deltaL, self._constants) + firdL = _phird(tau, deltaL, self._constants) + firtL = _phirt(tau, deltaL, self._constants) + hoL = self.R*T*(1+tau*(fiot+firtL)+deltaL*firdL) + soL = self.R*(tau*(fiot+firtL)-fioL-firL) + firG = _phir(tau, deltaG, self._constants) + firdG = _phird(tau, deltaG, self._constants) + firtG = _phirt(tau, deltaG, self._constants) + hoG = self.R*T*(1+tau*(fiot+firtG)+deltaG*firdG) + soG = self.R*(tau*(fiot+firtG)-fioG-firG) + + Jl = rhol*(1+deltaL*firdL) + Jv = rhog*(1+deltaG*firdG) + K = firL-firG + + Ps = self.R*T*rhol*rhog/(rhol-rhog)*(K+log(rhol/rhog)) + vu = hoG-Ps/rhog + lu = hoL-Ps/rhol + + return (Jl-Jv, + Jl*(1/rhog-1/rhol)-log(rhol/rhog)-K, + soL*(1-x)+soG*x - s, + lu*(1-x)+vu*x - u) + + for to in [To, 300, 400, 500, 600]: + rLo = self._Liquid_Density(to) + rGo = self._Vapor_Density(to) + sol = fsolve(f, [to, rLo, rGo, 0.5], full_output=True) + T, rhoL, rhoG, x = sol[0] + if sol[2] == 1 and 0 <= x <= 1 and \ + sum(abs(sol[1]["fvec"])) < 1e-5: break if sum(abs(sol[1]["fvec"])) > 1e-5: raise(RuntimeError(sol[3])) - rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - sv = vapor["s"] - sl = liquido["s"] - x = (s-sl)/(sv-sl) - P = Ps/1000 + liquido = self._Helmholtz(rhoL, T) + vapor = self._Helmholtz(rhoG, T) + P = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( + liquido["fir"]-vapor["fir"]+log(rhoL/rhoG))/1000 elif self._mode == "Trho": if T < self.Tc: @@ -753,11 +1334,11 @@ rhol = self._Liquid_Density(T) if rhol > rho > rhov: rhol, rhov, Ps = self._saturation(T) - vapor = self._Helmholtz(rhov, T) - liquido = self._Helmholtz(rhol, T) - x = (1/rho-1/rhol)/(1/rhov-1/rhol) - rho = 1/(x/rhov-(1-x)/rhol) - P = Ps/1000 + if rhol > rho > rhov: + vapor = self._Helmholtz(rhov, T) + liquido = self._Helmholtz(rhol, T) + x = (1/rho-1/rhol)/(1/rhov-1/rhol) + P = Ps/1000 rho = float(rho) T = float(T) @@ -791,16 +1372,19 @@ raise NotImplementedError("Incoming out of bound") # Iterate over saturation routine to get T - def funcion(T): + def f(T): rhol = self._Liquid_Density(T) rhog = self._Vapor_Density(T) deltaL = rhol/self.rhoc deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) + + tau = Tc/T + + firL = _phir(tau, deltaL, self._constants) + firG = _phir(tau, deltaG, self._constants) Ps = self.R*T*rhol*rhog/(rhol-rhog)*( - liquido["fir"]-vapor["fir"]+log(deltaL/deltaG)) + firL-firG+log(deltaL/deltaG)) return Ps/1000-P if T0: @@ -809,7 +1393,7 @@ To = _TSat_P(P) else: To = (self.Tc+self.Tt)/2 - T = fsolve(funcion, To)[0] + T = fsolve(f, To)[0] rhol, rhov, Ps = self._saturation(T) vapor = self._Helmholtz(rhov, T) liquido = self._Helmholtz(rhol, T) @@ -977,34 +1561,40 @@ def _saturation(self, T): """Saturation calculation for two phase search""" - if T > self.Tc: - T = self.Tc + rhoc = self._constants.get("rhoref", self.rhoc) + Tc = self._constants.get("Tref", self.Tc) + + if T > Tc: + T = Tc + tau = Tc/T + rhoLo = self._Liquid_Density(T) rhoGo = self._Vapor_Density(T) def f(parr): rhol, rhog = parr - deltaL = rhol/self.rhoc - deltaG = rhog/self.rhoc - liquido = self._Helmholtz(rhol, T) - vapor = self._Helmholtz(rhog, T) - Jl = deltaL*(1+deltaL*liquido["fird"]) - Jv = deltaG*(1+deltaG*vapor["fird"]) - Kl = deltaL*liquido["fird"]+liquido["fir"]+log(deltaL) - Kv = deltaG*vapor["fird"]+vapor["fir"]+log(deltaG) + deltaL = rhol/rhoc + deltaG = rhog/rhoc + phirL = _phir(tau, deltaL, self._constants) + phirG = _phir(tau, deltaG, self._constants) + phirdL = _phird(tau, deltaL, self._constants) + phirdG = _phird(tau, deltaG, self._constants) + Jl = deltaL*(1+deltaL*phirdL) + Jv = deltaG*(1+deltaG*phirdG) + Kl = deltaL*phirdL+phirL+log(deltaL) + Kv = deltaG*phirdG+phirG+log(deltaG) return Kv-Kl, Jv-Jl rhoL, rhoG = fsolve(f, [rhoLo, rhoGo]) if rhoL == rhoG: Ps = self.Pc else: - liquido = self._Helmholtz(rhoL, T) - vapor = self._Helmholtz(rhoG, T) deltaL = rhoL/self.rhoc deltaG = rhoG/self.rhoc + firL = _phir(tau, deltaL, self._constants) + firG = _phir(tau, deltaG, self._constants) - Ps = self.R*T*rhoL*rhoG/(rhoL-rhoG)*( - liquido["fir"]-vapor["fir"]+log(deltaL/deltaG)) + Ps = self.R*T*rhoL*rhoG/(rhoL-rhoG)*(firL-firG+log(deltaL/deltaG)) return rhoL, rhoG, Ps def _Helmholtz(self, rho, T): @@ -1013,23 +1603,24 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- - prop : dictionary with calculated properties - fir: [-] - fird: [∂fir/∂δ]τ [-] - firdd: [∂²fir/∂δ²]τ [-] - delta: Reducen density, rho/rhoc [-] - P: Pressure [kPa] - h: Enthalpy [kJ/kg] - s: Entropy [kJ/kgK] - cv: Isochoric specific heat [kJ/kgK] - alfav: Thermal expansion coefficient [1/K] - betap: Isothermal compressibility [1/kPa] + prop : dict + Dictionary with calculated properties: + * fir: [-] + * fird: ∂fir/∂δ|τ + * firdd: ∂²fir/∂δ²|τ + * delta: Reducen density rho/rhoc, [-] + * P: Pressure, [kPa] + * h: Enthalpy, [kJ/kg] + * s: Entropy, [kJ/kgK] + * cv: Isochoric specific heat, [kJ/kgK] + * alfav: Thermal expansion coefficient, [1/K] + * betap: Isothermal compressibility, [1/kPa] References ---------- @@ -1105,19 +1696,19 @@ Parameters ---------- tau : float - Inverse reduced temperature, Tc/T [-] + Inverse reduced temperature Tc/T, [-] delta : float - Reduced density, rho/rhoc [-] + Reduced density rho/rhoc, [-] Returns ------- prop : dictionary with ideal adimensional helmholtz energy and deriv - fio [-] - fiot: [∂fio/∂τ]δ [-] - fiod: [∂fio/∂δ]τ [-] - fiott: [∂²fio/∂τ²]δ [-] - fiodt: [∂²fio/∂τ∂δ] [-] - fiodd: [∂²fio/∂δ²]τ [-] + fio, [-] + fiot: ∂fio/∂τ|δ + fiod: ∂fio/∂δ|τ + fiott: ∂²fio/∂τ²|δ + fiodt: ∂²fio/∂τ∂δ + fiodd: ∂²fio/∂δ²|τ References ---------- @@ -1170,19 +1761,20 @@ Parameters ---------- tau : float - Inverse reduced temperature, Tc/T [-] + Inverse reduced temperature Tc/T, [-] delta : float - Reduced density, rho/rhoc [-] + Reduced density rho/rhoc, [-] Returns ------- - prop : dictionary with residual adimensional helmholtz energy and deriv - fir [-] - firt: [∂fir/∂τ]δ,x [-] - fird: [∂fir/∂δ]τ,x [-] - firtt: [∂²fir/∂τ²]δ,x [-] - firdt: [∂²fir/∂τ∂δ]x [-] - firdd: [∂²fir/∂δ²]τ,x [-] + prop : dict + Dictionary with residual adimensional helmholtz energy and deriv: + * fir + * firt: ∂fir/∂τ|δ,x + * fird: ∂fir/∂δ|τ,x + * firtt: ∂²fir/∂τ²|δ,x + * firdt: ∂²fir/∂τ∂δ|x + * firdd: ∂²fir/∂δ²|τ,x References ---------- @@ -1307,9 +1899,10 @@ Returns ------- - prop : dictionary with residual adimensional helmholtz energy and deriv - B: [∂fir/∂δ]δ->0 [-] - C: [∂²fir/∂δ²]δ->0 [-] + prop : dict + Dictionary with residual adimensional helmholtz energy: + * B: ∂fir/∂δ|δ->0 + * C: ∂²fir/∂δ²|δ->0 """ Tc = self._constants.get("Tref", self.Tc) tau = Tc/T @@ -1390,19 +1983,21 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- - prop : dictionary with residual helmholtz energy and derivatives - fir [kJ/kg] - firt: [∂fir/∂T]ρ [kJ/kgK] - fird: [∂fir/∂ρ]T [kJ/m³kg²] - firtt: [∂²fir/∂T²]ρ [kJ/kgK²] - firdt: [∂²fir/∂T∂ρ] [kJ/m³kg²K] - firdd: [∂²fir/∂ρ²]T [kJ/m⁶kg] + prop : dict + Dictionary with residual helmholtz energy and derivatives: + + * fir, [kJ/kg] + * firt: ∂fir/∂T|ρ, [kJ/kgK] + * fird: ∂fir/∂ρ|T, [kJ/m³kg²] + * firtt: ∂²fir/∂T²|ρ, [kJ/kgK²] + * firdt: ∂²fir/∂T∂ρ, [kJ/m³kg²K] + * firdd: ∂²fir/∂ρ²|T, [kJ/m⁶kg] References ---------- @@ -1457,12 +2052,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- - sigma : float - Surface tension [N/m] + σ : float + Surface tension, [N/m] Notes ----- @@ -1483,12 +2078,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- Pv : float - Vapour pressure [Pa] + Vapour pressure, [Pa] References ---------- @@ -1511,12 +2106,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- rho : float - Saturated liquid density [kg/m³] + Saturated liquid density, [kg/m³] References ---------- @@ -1542,12 +2137,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- rho : float - Saturated vapor density [kg/m³] + Saturated vapor density, [kg/m³] References ---------- @@ -1573,12 +2168,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- dPdT : float - dPdT [MPa/K] + dPdT, [MPa/K] References ---------- @@ -1597,9 +2192,35 @@ return dPdT +def mainClassDoc(): + """Function decorator used to automatic adiction of base class MEoS in + subclass __doc__""" + def decorator(f): + # __doc__ is only writable in python3. + # The doc build must be done with python3 so this snnippet do the work + py_version = platform.python_version() + if py_version[0] == "3": + doc = f.__doc__.split(os.linesep) + try: + ind = doc.index("") + except ValueError: + ind = 1 + + doc1 = os.linesep.join(doc[:ind]) + doc3 = os.linesep.join(doc[ind:]) + doc2 = os.linesep.join(MEoS.__doc__.split(os.linesep)[3:]) + + f.__doc__ = doc1 + os.linesep + os.linesep + \ + doc2 + os.linesep + os.linesep + doc3 + return f + + return decorator + + +@mainClassDoc() class IAPWS95(MEoS): """Implementation of IAPWS Formulation 1995 for ordinary water substance, - (revised release of 2016), see MEoS __doc__ + (revised release of 2016), for internal procedures, see MEoS base class Examples -------- @@ -1696,10 +2317,13 @@ IAPWS, Revised Release on the IAPWS Formulation 1995 for the Thermodynamic Properties of Ordinary Water Substance for General and Scientific Use, September 2016, http://www.iapws.org/relguide/IAPWS-95.html + IAPWS, Revised Supplementary Release on Saturation Properties of Ordinary Water Substance September 1992, http://www.iapws.org/relguide/Supp-sat.html + IAPWS, Guideline on a Low-Temperature Extension of the IAPWS-95 Formulation for Water Vapor, http://www.iapws.org/relguide/LowT.html + IAPWS, Revised Advisory Note No. 3: Thermodynamic Derivatives from IAPWS Formulations, http://www.iapws.org/relguide/Advise3.pdf """ @@ -1821,12 +2445,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- alfa : float - alfa coefficient [kJ/kg] + alfa coefficient, [kJ/kg] References ---------- @@ -1851,12 +2475,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- phi : float - phi coefficient [kJ/kgK] + phi coefficient, [kJ/kgK] References ---------- @@ -1884,12 +2508,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- h : float - Saturated liquid enthalpy [kJ/kg] + Saturated liquid enthalpy, [kJ/kg] References ---------- @@ -1910,12 +2534,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- h : float - Saturated vapor enthalpy [kJ/kg] + Saturated vapor enthalpy, [kJ/kg] References ---------- @@ -1936,12 +2560,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- s : float - Saturated liquid entropy [kJ/kgK] + Saturated liquid entropy, [kJ/kgK] References ---------- @@ -1962,12 +2586,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- s : float - Saturated liquid entropy [kJ/kgK] + Saturated liquid entropy, [kJ/kgK] References ---------- @@ -2030,9 +2654,10 @@ IAPWS95.__init__(self, T=T, x=x) +@mainClassDoc() class D2O(MEoS): """Implementation of IAPWS Formulation for heavy water substance, - see MEoS __doc__ + for internal procedures, see MEoS base class Examples -------- @@ -2046,10 +2671,6 @@ Properties of Heavy Water, http://www.iapws.org/relguide/Heavy-2017.pdf IAPWS, Revised Advisory Note No. 3: Thermodynamic Derivatives from IAPWS Formulations, http://www.iapws.org/relguide/Advise3.pdf - - Notes - ----- - This correlation replace the old 2005 formulation. """ name = "heavy water" CASNumber = "7789-20-0" @@ -2066,7 +2687,7 @@ Fi0 = {"ao_log": [1, 3], "pow": [0, 1], - "ao_pow": [-8.6785029980521, 6.9636373404376], + "ao_pow": [-8.670994022646, 6.96033578458778], "ao_exp": [0.010633, 0.99787, 2.1483, 0.3549], "titao": [308/Tc, 1695/Tc, 3949/Tc, 10317/Tc], "ao_hyp": [], "hyp": []} @@ -2074,31 +2695,32 @@ _constants = { "R": 8.3144598, - "nr1": [0.0118675032, 2.9662988968, -3.7869557999, 0.9405186104, - -0.91798012, -0.0136265695], + "nr1": [0.122082060e-1, 0.296956870e1, -0.379004540e1, 0.941089600, + -0.922466250, -0.139604190e-1], "d1": [4, 1, 1, 2, 2, 3], - "t1": [1, 0.66, 0.9431, 0.542, 0.677, 1.067], + "t1": [1.0000, 0.6555, 0.9369, 0.5610, 0.7017, 1.0672], - "nr2": [-0.1649561953, -5.5624457002, -4.9497345162, -0.0526711496, - -9.3602294045, -0.6355718773], + "nr2": [-0.125203570, -0.555391500e1, -0.493009740e1, -0.359470240e-1, + -0.936172870e1, -0.691835150], "c2": [1, 2, 2, 1, 2, 2], "d2": [1, 1, 3, 2, 2, 1], - "t2": [3.77, 4.55, 5.121, 0.22, 5.434, 2.24], + "t2": [3.9515, 4.6000, 5.1590, 0.2000, 5.4644, 2.3660], "gamma2": [1]*6, - "nr3": [-0.0397982189, -2.2454381046, 8.6094866025, -2.4724812971, - 16.3908849971, 2.85881805220, 15.2772603367, -1.8389093973, - 2.2813734134, 5.2237649193, 0.4219197316, -0.38833488], - "t3": [3.36, 1.31, 1.52, 3.38, 3.76, 4.8, 1, 1.676, 3.8, 2.6, 1, 4], + "nr3": [-0.456110600e-1, -0.224513300e1, 0.860006070e1, -0.248410420e1, + 0.164476900e2, 0.270393360e1, 0.375637470e2, -0.177607760e1, + 0.220924640e1, 0.519652000e1, 0.421097400, -0.391921100], + "t3": [3.4553, 1.4150, 1.5745, 3.4540, 3.8106, 4.8950, 1.4300, 1.5870, + 3.7900, 2.6200, 1.9000, 4.3200], "d3": [1, 3, 1, 3, 1, 1, 2, 2, 2, 1, 1, 1], - "alfa3": [0.639, 1.4536, 1.5326, 2.4443, 1.3063, 1.362, 3.5532, 1.2923, - 2.58, 1.226, 19.18, 19.093], - "beta3": [0.4064, 2.4085, 1.29, 8.516, 0.3661, 0.9485, 7.195, 3.34, - 6.7977, 0.952, 1176, 1160], - "epsilon3": [2.0155, 0.29, 0.5821, 0.2313, 0.6825, 0.961, 1.2565, - 0.1533, 0.4198, 0.9661, 0.9402, 0.94], - "gamma3": [1.523, 1.3642, 1.74, 1.297, 2.7218, 3.54, 2.466, 0.8115, - 1.3637, 2.5616, 1.0491, 1.0486]} + "alfa3": [0.6014, 1.4723, 1.5305, 2.4297, 1.3086, 1.3528, 3.4456, + 1.2645, 2.5547, 1.2148, 18.738, 18.677], + "beta3": [0.4200, 2.4318, 1.2888, 8.2710, 0.3673, 0.9504, 7.8318, + 3.3281, 7.1753, 0.9465, 1177.0, 1167.0], + "epsilon3": [1.8663, 0.2895, 0.5803, 0.2236, 0.6815, 0.9495, 1.1158, + 0.1607, 0.4144, 0.9683, 0.9488, 0.9487], + "gamma3": [1.5414, 1.3794, 1.7385, 1.3045, 2.7242, 3.5321, 2.4552, + 0.8319, 1.3500, 2.5617, 1.0491, 1.0486]} _Pv = { "ao": [-0.80236e1, 0.23957e1, -0.42639e2, 0.99569e2, -0.62135e2], diff -Nru iapws-1.3/iapws/iapws97.py iapws-1.4/iapws/iapws97.py --- iapws-1.3/iapws/iapws97.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/iapws97.py 2019-06-15 06:32:57.000000000 +0000 @@ -8,7 +8,7 @@ The module implement the fundamental equation for the five regions (rectangular boxes) and the backward equation (marked in grey). -:func:`IAPWS97`: Global module class with all the functionality integrated +:class:`IAPWS97`: Global module class with all the functionality integrated Fundamental equations: * :func:`_Region1` @@ -109,16 +109,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * s(100MPa,623.15K) ≤ s ≤ s'(623.15K) References @@ -159,12 +160,12 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -187,12 +188,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -215,18 +216,19 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 5.048096828 ≤ s ≤ 5.260578707 * 2.563592004e3 ≤ h ≤ 2.812942061e3 @@ -279,16 +281,17 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 273.15 ≤ T ≤ 647.096 References @@ -323,16 +326,17 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 0.00061121 ≤ P ≤ 22.064 References @@ -368,16 +372,17 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * h'(623.15K) ≤ h ≤ h''(623.15K) References @@ -421,16 +426,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * s'(623.15K) ≤ s ≤ s''(623.15K) References @@ -473,16 +479,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * s'(273.15K) ≤ s ≤ s'(623.15K) References @@ -531,16 +538,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * s'(623.15K) ≤ s ≤ sc References @@ -585,16 +593,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 5.85 ≤ s ≤ s"(273.15K) References @@ -645,16 +654,17 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * sc ≤ s ≤ 5.85 References @@ -699,23 +709,23 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isocoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s] - * alfav: Cubic expansion coefficient [1/K] - * kt: Isothermal compressibility [1/MPa] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isocoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * alfav: Cubic expansion coefficient, [1/K] + * kt: Isothermal compressibility, [1/MPa] References ---------- @@ -744,6 +754,9 @@ >>> _Region1(500,3)["kt"] 0.00112892188 """ + if P < 0: + P = Pmin + I = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32] J = [-2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, @@ -794,14 +807,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -840,14 +853,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -886,14 +899,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -936,23 +949,23 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isocoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s] - * alfav: Cubic expansion coefficient [1/K] - * kt: Isothermal compressibility [1/MPa] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isocoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * alfav: Cubic expansion coefficient, [1/K] + * kt: Isothermal compressibility, [1/MPa] References ---------- @@ -981,6 +994,9 @@ >>> _Region2(300,0.0035)["kt"] 286.239651 """ + if P < 0: + P = Pmin + Tr = 540/T Pr = P/1 @@ -1043,9 +1059,9 @@ Parameters ---------- Tr : float - Reduced temperature [-] + Reduced temperature, [-] Pr : float - Reduced pressure [-] + Reduced pressure, [-] Returns ------- @@ -1053,11 +1069,11 @@ Array with ideal Gibbs energy partial derivatives: * g: Ideal Specific Gibbs energy [kJ/kg] - * gp: [∂g/∂P]T - * gpp: [∂²g/∂P²]T - * gt: [∂g/∂T]P - * gtt: [∂²g/∂T²]P - * gpt: [∂²g/∂T∂P] + * gp: ∂g/∂P|T + * gpp: ∂²g/∂P²|T + * gt: ∂g/∂T|P + * gtt: ∂²g/∂T²|P + * gpt: ∂²g/∂T∂P References ---------- @@ -1087,12 +1103,12 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -1114,12 +1130,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] References ---------- @@ -1141,12 +1157,12 @@ Parameters ---------- s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] References ---------- @@ -1178,14 +1194,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1231,14 +1247,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1285,14 +1301,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1334,14 +1350,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] """ if P <= 4: T = _Backward2a_T_Ph(P, h) @@ -1366,14 +1382,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1426,14 +1442,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1483,14 +1499,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1534,14 +1550,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] """ if P <= 4: T = _Backward2a_T_Ps(P, s) @@ -1562,14 +1578,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -1616,14 +1632,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -1671,14 +1687,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -1726,14 +1742,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] """ sfbc = 5.85 hamin = _hab_s(s) @@ -1753,23 +1769,23 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isocoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s] - * alfav: Cubic expansion coefficient [1/K] - * kt: Isothermal compressibility [1/MPa] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isocoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * alfav: Cubic expansion coefficient, [1/K] + * kt: Isothermal compressibility, [1/MPa] References ---------- @@ -1855,12 +1871,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Examples -------- @@ -1877,12 +1893,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1913,12 +1929,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1949,12 +1965,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -1985,12 +2001,12 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2013,14 +2029,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] xy: string Subregions options: cd, gh, ij, jk, mn, qu, rx, uv Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2080,9 +2096,9 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] References ---------- @@ -2094,7 +2110,7 @@ Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] Examples -------- @@ -2133,14 +2149,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] References ---------- @@ -2185,14 +2201,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] """ hf = _h_3ab(P) if h <= hf: @@ -2207,14 +2223,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2260,14 +2276,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2313,14 +2329,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- T : float - Temperature [K] + Temperature, [K] """ hf = _h_3ab(P) if h <= hf: @@ -2336,14 +2352,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] References ---------- @@ -2388,14 +2404,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] References ---------- @@ -2441,14 +2457,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] """ if s <= sc: return _Backward3a_v_Ps(P, s) @@ -2462,14 +2478,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2515,14 +2531,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -2567,14 +2583,14 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] """ sc = 4.41202148223476 if s <= sc: @@ -2590,14 +2606,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -2646,14 +2662,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] References ---------- @@ -2704,14 +2720,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- P : float - Pressure [MPa] + Pressure, [MPa] """ sc = 4.41202148223476 if s <= sc: @@ -2726,16 +2742,16 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] x : integer - Vapor quality [-] + Vapor quality, [-] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] Notes ----- @@ -2769,14 +2785,14 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] References ---------- @@ -2951,16 +2967,16 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] x : char Region 3 subregion code Returns ------- v : float - Specific volume [m³/kg] + Specific volume, [m³/kg] References ---------- @@ -3560,21 +3576,21 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] x : float - Vapor quality [-] + Vapor quality, [-] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * T: Saturated temperature [K] - * P: Saturated pressure [MPa] - * x: Vapor quality [-] - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] + * T: Saturated temperature, [K] + * P: Saturated pressure, [MPa] + * x: Vapor quality, [-] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] """ T = _TSat_P(P) if T > 623.15: @@ -3608,14 +3624,14 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- T : float - Temperature [K] + Temperature, [K] References ---------- @@ -3666,23 +3682,23 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isocoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s] - * alfav: Cubic expansion coefficient [1/K] - * kt: Isothermal compressibility [1/MPa] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isocoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * alfav: Cubic expansion coefficient, [1/K] + * kt: Isothermal compressibility, [1/MPa] References ---------- @@ -3711,6 +3727,9 @@ >>> _Region5(2000,30)["kt"] 0.0329193892 """ + if P < 0: + P = Pmin + Tr = 1000/T Pr = P/1 @@ -3753,16 +3772,16 @@ Parameters ---------- Tr : float - Reduced temperature [-] + Reduced temperature, [-] Pr : float - Reduced pressure [-] + Reduced pressure, [-] Returns ------- prop : array Array with ideal Gibbs energy partial derivatives: - * g: Ideal Specific Gibbs energy [kJ/kg] + * g: Ideal Specific Gibbs energy, [kJ/kg] * gp: [∂g/∂P]T * gpp: [∂²g/∂P²]T * gt: [∂g/∂T]P @@ -3797,9 +3816,9 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- @@ -3838,9 +3857,9 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] Returns ------- @@ -3912,9 +3931,9 @@ Parameters ---------- P : float - Pressure [MPa] + Pressure, [MPa] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- @@ -3986,9 +4005,9 @@ Parameters ---------- h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] Returns ------- @@ -4145,7 +4164,7 @@ def funcion(par): return (_Region5(par[0], par[1])["h"]-h, _Region5(par[0], par[1])["s"]-s) - T, P = fsolve(funcion, [1400, 0.001]) + T, P = fsolve(funcion, [1400, 1]) if 1073.15 < T <= 2273.15 and Pmin <= P <= 50: region = 5 @@ -4158,23 +4177,23 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties. The available properties are: - * v: Specific volume [m³/kg] - * h: Specific enthalpy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isocoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s] - * alfav: Cubic expansion coefficient [1/K] - * kt: Isothermal compressibility [1/MPa] + * v: Specific volume, [m³/kg] + * h: Specific enthalpy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isocoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s] + * alfav: Cubic expansion coefficient, [1/K] + * kt: Isothermal compressibility, [1/MPa] """ if T <= 1073.15: Tr = 540/T @@ -4190,7 +4209,7 @@ prop0["h"] = Tr*got*R*T prop0["s"] = R*(Tr*got-go) prop0["cp"] = -R*Tr**2*gott - prop0["cv"] = R*(-Tr**2*gott+(gop-Tr*gopt)**2/gopp) + prop0["cv"] = R*(-Tr**2*gott-1) prop0["w"] = (R*T*1000/(1+1/Tr**2/gott))**0.5 prop0["alfav"] = 1/T @@ -4204,21 +4223,22 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] h : float - Specific enthalpy [kJ/kg] + Specific enthalpy, [kJ/kg] s : float - Specific entropy [kJ/kgK] + Specific entropy, [kJ/kgK] x : float - Vapor quality [-] + Vapor quality, [-] l : float, optional - Wavelength of light, for refractive index [nm] + Wavelength of light, for refractive index, [nm] Notes ----- Definitions options: + * T, P: Not valid for two-phases region * P, h * P, s @@ -4228,66 +4248,70 @@ Returns ------- - The calculated instance has the following properties: - * P: Pressure [MPa] - * T: Temperature [K] - * g: Specific Gibbs free energy [kJ/kg] - * a: Specific Helmholtz free energy [kJ/kg] - * v: Specific volume [m³/kg] - * r: Density [kg/m³] - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * s: Specific entropy [kJ/kg·K] - * cp: Specific isobaric heat capacity [kJ/kg·K] - * cv: Specific isochoric heat capacity [kJ/kg·K] - * Z: Compression factor [-] - * fi: Fugacity coefficient [-] - * f: Fugacity [MPa] - - * gamma: Isoentropic exponent [-] - * alfav: Isobaric cubic expansion coefficient [1/K] - * xkappa: Isothermal compressibility [1/MPa] - * kappas: Adiabatic compresibility [1/MPa] - * alfap: Relative pressure coefficient [1/K] - * betap: Isothermal stress coefficient [kg/m³] - * joule: Joule-Thomson coefficient [K/MPa] - * deltat: Isothermal throttling coefficient [kJ/kg·MPa] - * region: Region - - * v0: Ideal specific volume [m³/kg] - * u0: Ideal specific internal energy [kJ/kg] - * h0: Ideal specific enthalpy [kJ/kg] - * s0: Ideal specific entropy [kJ/kg·K] - * a0: Ideal specific Helmholtz free energy [kJ/kg] - * g0: Ideal specific Gibbs free energy [kJ/kg] - * cp0: Ideal specific isobaric heat capacity [kJ/kg·K] - * cv0: Ideal specific isochoric heat capacity [kJ/kg·K] - * w0: Ideal speed of sound [m/s] - * gamma0: Ideal isoentropic exponent [-] - - * w: Speed of sound [m/s] - * mu: Dynamic viscosity [Pa·s] - * nu: Kinematic viscosity [m²/s] - * k: Thermal conductivity [W/m·K] - * alfa: Thermal diffusivity [m²/s] - * sigma: Surface tension [N/m] - * epsilon: Dielectric constant [-] - * n: Refractive index [-] - * Prandt: Prandtl number [-] - * Pr: Reduced Pressure [-] - * Tr: Reduced Temperature [-] - * Hvap: Vaporization heat [kJ/kg] - * Svap: Vaporization entropy [kJ/kg·K] + prop : dict + The calculated instance has the following properties: + + * P: Pressure, [MPa] + * T: Temperature, [K] + * g: Specific Gibbs free energy, [kJ/kg] + * a: Specific Helmholtz free energy, [kJ/kg] + * v: Specific volume, [m³/kg] + * rho: Density, [kg/m³] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * s: Specific entropy, [kJ/kg·K] + * cp: Specific isobaric heat capacity, [kJ/kg·K] + * cv: Specific isochoric heat capacity, [kJ/kg·K] + * Z: Compression factor, [-] + * fi: Fugacity coefficient, [-] + * f: Fugacity, [MPa] + + * gamma: Isoentropic exponent, [-] + * alfav: Isobaric cubic expansion coefficient, [1/K] + * xkappa: Isothermal compressibility, [1/MPa] + * kappas: Adiabatic compresibility, [1/MPa] + * alfap: Relative pressure coefficient, [1/K] + * betap: Isothermal stress coefficient, [kg/m³] + * joule: Joule-Thomson coefficient, [K/MPa] + * deltat: Isothermal throttling coefficient, [kJ/kg·MPa] + * region: Region + + * v0: Ideal specific volume, [m³/kg] + * u0: Ideal specific internal energy, [kJ/kg] + * h0: Ideal specific enthalpy, [kJ/kg] + * s0: Ideal specific entropy, [kJ/kg·K] + * a0: Ideal specific Helmholtz free energy, [kJ/kg] + * g0: Ideal specific Gibbs free energy, [kJ/kg] + * cp0: Ideal specific isobaric heat capacity, [kJ/kg·K] + * cv0: Ideal specific isochoric heat capacity [kJ/kg·K] + * w0: Ideal speed of sound, [m/s] + * gamma0: Ideal isoentropic exponent, [-] + + * w: Speed of sound, [m/s] + * mu: Dynamic viscosity, [Pa·s] + * nu: Kinematic viscosity, [m²/s] + * k: Thermal conductivity, [W/m·K] + * alfa: Thermal diffusivity, [m²/s] + * sigma: Surface tension, [N/m] + * epsilon: Dielectric constant, [-] + * n: Refractive index, [-] + * Prandt: Prandtl number, [-] + * Pr: Reduced Pressure, [-] + * Tr: Reduced Temperature, [-] + * Hvap: Vaporization heat, [kJ/kg] + * Svap: Vaporization entropy, [kJ/kg·K] Examples -------- - >>> water=IAPWS97(T=170+273.15,x=0.5) + >>> water=IAPWS97(T=170+273.15, x=0.5) >>> water.Liquid.cp, water.Vapor.cp, water.Liquid.w, water.Vapor.w 4.3695 2.5985 1418.3 498.78 - >>> water=IAPWS97(T=325+273.15,x=0.5) + + >>> water=IAPWS97(T=325+273.15, x=0.5) >>> water.P, water.Liquid.v, water.Vapor.v, water.Liquid.h, water.Vapor.h 12.0505 0.00152830 0.0141887 1493.37 2684.48 - >>> water=IAPWS97(T=50+273.15,P=0.0006112127) + + >>> water=IAPWS97(T=50+273.15, P=0.0006112127) >>> water.cp0, water.cv0, water.h0, water.s0, water.w0 1.8714 1.4098 2594.66 9.471 444.93 """ @@ -4650,8 +4674,7 @@ fase.joule = self.derivative("T", "P", "h", fase) fase.deltat = self.derivative("h", "P", "T", fase) - fase.gamma = -fase.cp_cv*fase.v/self.P*self.derivative( - "P", "v", "T", fase) + fase.gamma = -fase.v/self.P*self.derivative("P", "v", "s", fase) fase.alfap = fase.alfav/self.P/fase.xkappa fase.betap = -1/self.P*self.derivative("P", "v", "T", fase) @@ -4667,7 +4690,10 @@ fase.nu = fase.mu/fase.rho fase.alfa = fase.k/1000/fase.rho/fase.cp - fase.epsilon = _Dielectric(fase.rho, self.T) + try: + fase.epsilon = _Dielectric(fase.rho, self.T) + except NotImplementedError: + fase.epsilon = None fase.Prandt = fase.mu*fase.cp*1000/fase.k try: fase.n = _Refractive(fase.rho, self.T, self.kwargs["l"]) diff -Nru iapws-1.3/iapws/_iapws.py iapws-1.4/iapws/_iapws.py --- iapws-1.3/iapws/_iapws.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/_iapws.py 2019-06-15 06:32:57.000000000 +0000 @@ -1,7 +1,29 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -Miscelaneous IAPWS standards +Miscelaneous IAPWS standards. This module include: + + * :func:`_Ice`: Ice Ih state equation + * :func:`_Liquid`: Properties of liquid water at 0.1 MPa + * :func:`_Supercooled`: Thermodynamic properties of supercooled water + * :func:`_Sublimation_Pressure`: Sublimation pressure correlation + * :func:`_Melting_Pressure`: Melting pressure correlation + * :func:`_Viscosity`: Viscosity correlation + * :func:`_ThCond`: Themal conductivity correlation + * :func:`_Tension`: Surface tension correlation + * :func:`_Dielectric`: Dielectric constant correlation + * :func:`_Refractive`: Refractive index correlation + * :func:`_Kw`: Ionization constant correlation for ordinary water + * :func:`_Conductivity`: Electrolytic conductivity correlation + * :func:`_D2O_Viscosity`: Viscosity correlation for heavy water + * :func:`_D2O_ThCond`: Thermal conductivity correlation for heavy water + * :func:`_D2O_Tension`: Surface tension correlation for heavy water + * :func:`_D2O_Sublimation_Pressure`: Sublimation Pressure correlation for + heavy water + * :func:`_D2O_Melting_Pressure`: Melting Pressure correlation for heavy + water + * :func:`_Henry`: Henry constant for liquid-gas equilibrium + * :func:`_Kvalue`: Vapor-liquid distribution constant """ from __future__ import division @@ -12,8 +34,6 @@ from scipy.optimize import minimize -from ._utils import deriv_H - # Constants M = 18.015268 # g/mol @@ -45,35 +65,36 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties of ice. The available properties are: - * rho: Density [kg/m³] - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * a: Specific Helmholtz energy [kJ/kg] - * g: Specific Gibbs energy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * alfav: Cubic expansion coefficient [1/K] - * beta: Pressure coefficient [MPa/K] - * xkappa: Isothermal compressibility [1/MPa] - * ks: Isentropic compressibility [1/MPa] + * rho: Density, [kg/m³] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * a: Specific Helmholtz energy, [kJ/kg] + * g: Specific Gibbs energy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * alfav: Cubic expansion coefficient, [1/K] + * beta: Pressure coefficient, [MPa/K] + * xkappa: Isothermal compressibility, [1/MPa] + * ks: Isentropic compressibility, [1/MPa] * gt: [∂g/∂T]P * gtt: [∂²g/∂T²]P * gp: [∂g/∂P]T * gpp: [∂²g/∂P²]T * gtp: [∂²g/∂T∂P] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * T ≤ 273.16 * P ≤ 208.566 * State below the melting and sublimation lines @@ -83,9 +104,11 @@ >>> st1 = _Ice(100, 100) >>> st1["rho"], st1["h"], st1["s"] 941.678203297 -483.491635676 -2.61195122589 + >>> st2 = _Ice(273.152519,0.101325) >>> st2["a"], st2["u"], st2["cp"] -0.00918701567 -333.465403393 2.09671391024 + >>> st3 = _Ice(273.16,611.657e-6) >>> st3["alfav"], st3["beta"], st3["xkappa"], st3["ks"] 0.000159863102566 1.35714764659 1.17793449348e-04 1.14161597779e-04 @@ -190,41 +213,42 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] - optional, although this relation is for P=0.1MPa, can be extrapoled at - pressure 0.3MPa + Pressure, [MPa] + Although this relation is for P=0.1MPa, can be extrapoled at pressure + 0.3 MPa Returns ------- prop : dict Dict with calculated properties of water. The available properties are: - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * a: Specific Helmholtz energy [kJ/kg] - * g: Specific Gibbs energy [kJ/kg] - * s: Specific entropy [kJ/kgK] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isochoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s²] - * rho: Density [kg/m³] - * v: Specific volume [m³/kg] - * vt: [∂v/∂T]P [m³/kgK] - * vtt: [∂²v/∂T²]P [m³/kgK²] - * vp: [∂v/∂P]T [m³/kg/MPa] - * vtp: [∂²v/∂T∂P] [m³/kg/MPa] - * alfav: Cubic expansion coefficient [1/K] - * xkappa : Isothermal compressibility [1/MPa] - * ks: Isentropic compressibility [1/MPa] - * mu: Viscosity [mPas] - * k: Thermal conductivity [W/mK] - * epsilon: Dielectric constant [-] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * a: Specific Helmholtz energy, [kJ/kg] + * g: Specific Gibbs energy, [kJ/kg] + * s: Specific entropy, [kJ/kgK] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isochoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s²] + * rho: Density, [kg/m³] + * v: Specific volume, [m³/kg] + * vt: [∂v/∂T]P, [m³/kgK] + * vtt: [∂²v/∂T²]P, [m³/kgK²] + * vp: [∂v/∂P]T, [m³/kg/MPa] + * vtp: [∂²v/∂T∂P], [m³/kg/MPa] + * alfav: Cubic expansion coefficient, [1/K] + * xkappa : Isothermal compressibility, [1/MPa] + * ks: Isentropic compressibility, [1/MPa] + * mu: Viscosity, [mPas] + * k: Thermal conductivity, [W/mK] + * epsilon: Dielectric constant, [-] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 253.15 ≤ T ≤ 383.15 * 0.1 ≤ P ≤ 0.3 @@ -368,32 +392,33 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] Returns ------- prop : dict Dict with calculated properties of water. The available properties are: - * L: Ordering field [-] - * x: Mole fraction of low-density structure [-] - * rho: Density [kg/m³] - * s: Specific entropy [kJ/kgK] - * h: Specific enthalpy [kJ/kg] - * u: Specific internal energy [kJ/kg] - * a: Specific Helmholtz energy [kJ/kg] - * g: Specific Gibbs energy [kJ/kg] - * alfap: Thermal expansion coefficient [1/K] - * xkappa : Isothermal compressibility [1/MPa] - * cp: Specific isobaric heat capacity [kJ/kgK] - * cv: Specific isochoric heat capacity [kJ/kgK] - * w: Speed of sound [m/s²] + * L: Ordering field, [-] + * x: Mole fraction of low-density structure, [-] + * rho: Density, [kg/m³] + * s: Specific entropy, [kJ/kgK] + * h: Specific enthalpy, [kJ/kg] + * u: Specific internal energy, [kJ/kg] + * a: Specific Helmholtz energy, [kJ/kg] + * g: Specific Gibbs energy, [kJ/kg] + * alfap: Thermal expansion coefficient, [1/K] + * xkappa : Isothermal compressibility, [1/MPa] + * cp: Specific isobaric heat capacity, [kJ/kgK] + * cv: Specific isochoric heat capacity, [kJ/kgK] + * w: Speed of sound, [m/s²] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * Tm ≤ T ≤ 300 * 0 < P ≤ 1000 @@ -542,16 +567,17 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- P : float - Pressure at sublimation line [MPa] + Pressure at sublimation line, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 50 ≤ T ≤ 273.16 Examples @@ -582,7 +608,7 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] ice: string Type of ice: Ih, III, V, VI, VII. Below 273.15 is a mandatory input, the ice Ih is the default value. @@ -591,11 +617,12 @@ Returns ------- P : float - Pressure at sublimation line [MPa] + Pressure at sublimation line, [MPa] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 251.165 ≤ T ≤ 715 Examples @@ -658,19 +685,18 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] - fase: dict + Temperature, [K] + fase: dict, optional for calculate critical enhancement phase properties - drho: float + drho: float, optional for calculate critical enhancement [∂ρ/∂P]T at reference state, - optional for calculate critical enhancement Returns ------- - mu : float - Viscosity [Pa·s] + μ : float + Viscosity, [Pa·s] Examples -------- @@ -698,7 +724,7 @@ 0.188797e1, 0.126613e1, 0.120573, -0.281378, -0.906851, -0.772479, -0.489837, -0.257040, 0.161913, 0.257399, -0.325372e-1, 0.698452e-1, 0.872102e-2, -0.435673e-2, -0.593264e-3] - mu1 = exp(Dr*sum([(1/Tr-1)**i*H*(Dr-1)**j for i, j, H in zip(I, J, Hij)])) + mu1 = exp(Dr*sum([(1/Tr-1)**i*h*(Dr-1)**j for i, j, h in zip(I, J, Hij)])) # Critical enhancement if fase and drho: @@ -748,19 +774,18 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] - fase: dict + Temperature, [K] + fase: dict, optional for calculate critical enhancement phase properties - drho: float + drho: float, optional for calculate critical enhancement [∂ρ/∂P]T at reference state, - optional for calculate critical enhancement Returns ------- k : float - Thermal conductivity [W/mK] + Thermal conductivity, [W/mK] Examples -------- @@ -850,16 +875,17 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- - sigma : float - Surface tension [N/m] + σ : float + Surface tension, [N/m] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 248.15 ≤ T ≤ 647 * Estrapolate to -25ºC in supercooled liquid metastable state @@ -888,18 +914,19 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- epsilon : float - Dielectric constant [-] + Dielectric constant, [-] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 238 ≤ T ≤ 1200 Examples @@ -949,20 +976,21 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] l : float, optional - Light Wavelength [μm] + Light Wavelength, [μm] Returns ------- n : float - Refractive index [-] + Refractive index, [-] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 0 ≤ ρ ≤ 1060 * 261.15 ≤ T ≤ 773.15 * 0.2 ≤ λ ≤ 1.1 @@ -1002,18 +1030,19 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- pKw : float - Ionization constant in -log10(kw) [-] + Ionization constant in -log10(kw), [-] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 0 ≤ ρ ≤ 1250 * 273.15 ≤ T ≤ 1073.15 @@ -1055,18 +1084,19 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- K : float - Electrolytic conductivity [S/m] + Electrolytic conductivity, [S/m] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 600 ≤ ρ ≤ 1200 * 273.15 ≤ T ≤ 1073.15 @@ -1107,14 +1137,14 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- - mu : float - Viscosity [Pa·s] + μ : float + Viscosity, [Pa·s] Examples -------- @@ -1156,14 +1186,14 @@ Parameters ---------- rho : float - Density [kg/m³] + Density, [kg/m³] T : float - Temperature [K] + Temperature, [K] Returns ------- k : float - Thermal conductivity [W/mK] + Thermal conductivity, [W/mK] Examples -------- @@ -1205,16 +1235,17 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] Returns ------- - sigma : float - Surface tension [N/m] + σ : float + Surface tension, [N/m] - Raises + Notes ------ - NotImplementedError : If input isn't in limit + Raise :class:`NotImplementedError` if input isn't in limit: + * 269.65 ≤ T ≤ 643.847 Examples @@ -1236,13 +1267,115 @@ raise NotImplementedError("Incoming out of bound") +def _D2O_Sublimation_Pressure(T): + """Sublimation Pressure correlation for heavy water + + Parameters + ---------- + T : float + Temperature, [K] + + Returns + ------- + P : float + Pressure at sublimation line, [MPa] + + Notes + ------ + Raise :class:`NotImplementedError` if input isn't in limit: + + * 210 ≤ T ≤ 276.969 + + Examples + -------- + >>> _Sublimation_Pressure(245) + 3.27390934e-5 + + References + ---------- + IAPWS, Revised Release on the IAPWS Formulation 2017 for the Thermodynamic + Properties of Heavy Water, http://www.iapws.org/relguide/Heavy.html. + """ + if 210 <= T <= 276.969: + Tita = T/276.969 + suma = 0 + ai = [-0.1314226e2, 0.3212969e2] + ti = [-1.73, -1.42] + for a, t in zip(ai, ti): + suma += a*(1-Tita**t) + return exp(suma)*0.00066159 + else: + raise NotImplementedError("Incoming out of bound") + + +def _D2O_Melting_Pressure(T, ice="Ih"): + """Melting Pressure correlation for heavy water + + Parameters + ---------- + T : float + Temperature, [K] + ice: string + Type of ice: Ih, III, V, VI, VII. + Below 276.969 is a mandatory input, the ice Ih is the default value. + Above 276.969, the ice type is unnecesary. + + Returns + ------- + P : float + Pressure at melting line, [MPa] + + Notes + ------ + Raise :class:`NotImplementedError` if input isn't in limit: + + * 254.415 ≤ T ≤ 315 + + Examples + -------- + >>> _D2O__Melting_Pressure(260) + 8.947352740189152e-06 + >>> _D2O__Melting_Pressure(254, "III") + 268.6846466336108 + + References + ---------- + IAPWS, Revised Release on the Pressure along the Melting and Sublimation + Curves of Ordinary Water Substance, http://iapws.org/relguide/MeltSub.html. + """ + if ice == "Ih" and 254.415 <= T <= 276.969: + # Ice Ih, Eq 9 + Tita = T/276.969 + ai = [-0.30153e5, 0.692503e6] + ti = [5.5, 8.2] + suma = 1 + for a, t in zip(ai, ti): + suma += a*(1-Tita**t) + P = suma*0.00066159 + elif ice == "III" and 254.415 < T <= 258.661: + # Ice III, Eq 10 + Tita = T/254.415 + P = 222.41*(1-0.802871*(1-Tita**33)) + elif ice == "V" and 258.661 < T <= 275.748: + # Ice V, Eq 11 + Tita = T/258.661 + P = 352.19*(1-1.280388*(1-Tita**7.6)) + elif (ice == "VI" and 275.748 < T <= 276.969) or 276.969 < T <= 315: + # Ice VI + Tita = T/275.748 + P = 634.53*(1-1.276026*(1-Tita**4)) + else: + raise NotImplementedError("Incoming out of bound") + return P + + def _Henry(T, gas, liquid="H2O"): """Equation for the calculation of Henry's constant Parameters ---------- T : float - Temperature [K] + Temperature, [K] gas : string Name of gas to calculate solubility liquid : string @@ -1251,14 +1384,15 @@ Returns ------- kw : float - Henry's constant [MPa] + Henry's constant, [MPa] Notes ----- - The gas availables for H2O solvent are: - He, Ne, Ar, Kr, Xe, H2, N2, O2, CO, CO2, H2S, CH4, C2H6, SF6 - For D2O as solvent: - He, Ne, Ar, Kr, Xe, D2, CH4 + The gas availables for H2O solvent are He, Ne, Ar, Kr, Xe, H2, N2, O2, CO, + CO2, H2S, CH4, C2H6, SF6 + For D2O as solvent He, Ne, Ar, Kr, Xe, D2, CH4 + + Raise :class:`NotImplementedError` if input gas or liquid are unsupported Examples -------- @@ -1365,7 +1499,7 @@ Parameters ---------- T : float - Temperature [K] + Temperature, [K] gas : string Name of gas to calculate solubility liquid : string @@ -1374,14 +1508,16 @@ Returns ------- kd : float - Vapor-liquid distribution constant [-] + Vapor-liquid distribution constant, [-] Notes ----- - The gas availables for H2O solvent are: - He, Ne, Ar, Kr, Xe, H2, N2, O2, CO, CO2, H2S, CH4, C2H6, SF6 - For D2O as solvent: - He, Ne, Ar, Kr, Xe, D2, CH4 + The gas availables for H2O solvent are He, Ne, Ar, Kr, Xe, H2, N2, O2, CO, + CO2, H2S, CH4, C2H6, SF6 + + For D2O as solvent He, Ne, Ar, Kr, Xe, D2, CH4 + + Raise :class:`NotImplementedError` if input gas or liquid are unsupported Examples -------- diff -Nru iapws-1.3/iapws/__init__.py iapws-1.4/iapws/__init__.py --- iapws-1.3/iapws/__init__.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/__init__.py 2019-06-15 06:32:57.000000000 +0000 @@ -10,4 +10,233 @@ from .humidAir import HumidAir # noqa from .ammonia import H2ONH3 # noqa -__version__ = "1.3" +__version__ = "1.4" + + +__doi__ = { + "R1-76": + {"autor": "IAPWS", + "title": "Revised Release on the Surface Tension of Ordynary Water " + "Substance", + "ref": "2014", + "doi": ""}, + "R2-83": + {"autor": "IAPWS", + "title": "Release on the Values of Temperature, Pressure and Density " + "of Ordynary and Heavy Water Substances at their Respectives" + " Critical Points", + "ref": "1992", + "doi": ""}, + "R4-84": + {"autor": "IAPWS", + "title": "Revised Release on Viscosity and Thermal Conductivity of " + "Heavy Water Substance", + "ref": "2007", + "doi": ""}, + "R5-85": + {"autor": "IAPWS", + "title": "Release on Surface Tension of Heavy Water Substance", + "ref": "1994", + "doi": ""}, + "R6-95": + {"autor": "IAPWS", + "title": "Revised Release on the IAPWS Formulation 1995 for the " + "Thermodynamic Properties of Ordinary Water Substance for " + "General and Scientific Use", + "ref": "2006", + "doi": ""}, + "R7-97": + {"autor": "IAPWS", + "title": "Revised Release on the IAPWS Industrial Formulation 1997 " + "for the Thermodynamic Properties of Water and Steam", + "ref": "2012", + "doi": ""}, + "R8-97": + {"autor": "IAPWS", + "title": "Release on the Static Dielectric Constant of Ordinary Water" + "Substance for Temperatures from 238 K to 873 K and " + "Pressures up to 1000 MPa", + "ref": "1997", + "doi": ""}, + "R9-97": + {"autor": "IAPWS", + "title": "Release on the Refractive Index of Ordinary Water Substance" + " as a Function of Wavelength, Temperature and Pressure", + "ref": "1997", + "doi": ""}, + "R10-06": + {"autor": "IAPWS", + "title": "Revised Release on the Equation of State 2006 for H2O Ice " + "Ih", + "ref": "2009", + "doi": ""}, + "R11-07": + {"autor": "IAPWS", + "title": "Release on the Ionization Constant of H2O", + "ref": "2007", + "doi": ""}, + "R12-08": + {"autor": "IAPWS", + "title": "Release on the IAPWS Formulation 2008 for the Viscosity of " + "Ordinary Water Substance", + "ref": "2008", + "doi": ""}, + "R13-08": + {"autor": "IAPWS", + "title": "Release on the IAPWS Formulation 2008 for the Thermodynamic" + " Properties of Seawater", + "ref": "2008", + "doi": ""}, + "R14-08": + {"autor": "IAPWS", + "title": "Revised Release on the Pressure along the Melting and " + "Sublimation Curves of Ordinary Water Substance", + "ref": "2011", + "doi": ""}, + "R15-11": + {"autor": "IAPWS", + "title": "Release on the IAPWS Formulation 2011 for the Thermal " + "Conductivity of Ordinary Water Substance", + "ref": "2011", + "doi": ""}, + "R16-17": + {"autor": "IAPWS", + "title": "Release on the IAPWS Formulation 2017 for the Thermodynamic" + " Properties of Heavy Water", + "ref": "2017", + "doi": ""}, + "SR1-86": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Saturation Properties of " + "Ordinary Water Substance", + "ref": "1992", + "doi": ""}, + "SR2-01": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Backward Equations for " + "Pressure as a Function of Enthalpy and Entropy p(h,s) for " + "Regions 1 and 2 of the IAPWS Industrial Formulation 1997 " + "for the Thermodynamic Properties of Water and Steam", + "ref": "2014", + "doi": ""}, + "SR3-03": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Backward Equations for " + "the Functions T(p,h), v(p,h), and T(p,s), v(p,s) for " + "Region 3 of the IAPWS Industrial Formulation 1997 for the " + "Thermodynamic Properties of Water and Steam", + "ref": "2014", + "doi": ""}, + "SR4-04": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Backward Equations p(h,s) " + "for Region 3, Equations as a Function of h and s for the " + "Region Boundaries, and an Equation Tsat(h,s) for Region 4 " + "of the IAPWS Industrial Formulation 1997 for the " + "Thermodynamic Properties of Water and Steam", + "ref": "2014", + "doi": ""}, + "SR5-05": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Backward Equations for " + "Specific Volume as a Function of Pressure and Temperature " + "v(p,T) for Region 3 of the IAPWS Industrial Formulation " + "1997 for the Thermodynamic Properties of Water and Steam", + "ref": "2016", + "doi": ""}, + "SR6-08": + {"autor": "IAPWS", + "title": "Revised Supplementary Release on Properties of Liquid " + "Water at 0.1 MPa", + "ref": "2011", + "doi": ""}, + + "SR7-09": + {"autor": "IAPWS", + "title": "Supplementary Release on a Computationally Efficient " + "Thermodynamic Formulation for Liquid Water for " + "Oceanographic Use", + "ref": "2009", + "doi": ""}, + "G1-90": + {"autor": "IAPWS", + "title": "Electrolytic Conductivity (Specific Conductance) of Liquid " + "and Dense Supercritical Water from 0°C to 800°C and " + "Pressures up to 1000 MPa", + "ref": "1990", + "doi": ""}, + "G2-90": + {"autor": "IAPWS", + "title": "Solubility of Sodium Sulfate in Aqueous Mixtures of Sodium " + "Chloride and Sulfuric Acid from Water to Concentrated " + "Solutions, from 250 °C to 350 °C", + "ref": "1994", + "doi": ""}, + "G3-00": + {"autor": "IAPWS", + "title": "Revised Guideline on the Critical Locus of Aqueous " + "Solutions of Sodium Chloride", + "ref": "2012", + "doi": ""}, + "G4-01": + {"autor": "IAPWS", + "title": "Guideline on the IAPWS Formulation 2001 for the " + "Thermodynamic Properties of Ammonia-Water Mixtures", + "ref": "2001", + "doi": ""}, + "G5-01": + {"autor": "IAPWS", + "title": "Guideline on the Use of Fundamental Physical Constants and " + "Basic Constants of Water", + "ref": "2016", + "doi": ""}, + "G7-04": + {"autor": "IAPWS", + "title": "Guideline on the Henry's Constant and Vapor-Liquid " + "Distribution Constant for Gases in H2O and D2O at High " + "Temperatures", + "ref": "2004", + "doi": ""}, + + "G8-10": + {"autor": "IAPWS", + "title": "Guideline on an Equation of State for Humid Air in Contact " + "with Seawater and Ice, Consistent with the IAPWS " + "Formulation 2008 for the Thermodynamic Properties of " + "Seawater", + "ref": "2010", + "doi": ""}, + "G9-12": + {"autor": "IAPWS", + "title": "Guideline on a Low-Temperature Extension of the IAPWS-95 " + "Formulation for Water Vapor", + "ref": "2012", + "doi": ""}, + "G10-15": + {"autor": "IAPWS", + "title": "Guideline on the Thermal Conductivity of Seawater", + "ref": "2015", + "doi": ""}, + "G11-15": + {"autor": "IAPWS", + "title": "Guideline on a Virial Equation for the Fugacity of H2O in " + "Humid Air", + "ref": "2015", + "doi": ""}, + "G12-15": + {"autor": "IAPWS", + "title": "Guideline on Thermodynamic Properties of Supercooled Water", + "ref": "2015", + "doi": ""}, + "AN3-07": + {"autor": "IAPWS", + "title": "Thermodynamic Derivatives from IAPWS Formulations", + "ref": "2014", + "doi": ""}, + "AN5-13": + {"autor": "IAPWS", + "title": "Industrial Calculation of the Thermodynamic Properties of " + "Seawater", + "ref": "2016", + "doi": ""}, + } diff -Nru iapws-1.3/iapws/_utils.py iapws-1.4/iapws/_utils.py --- iapws-1.3/iapws/_utils.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws/_utils.py 2019-06-15 06:32:57.000000000 +0000 @@ -1,7 +1,14 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ -Miscelaneous utilities +Miscelaneous internal utilities. This module include: + + * :func:`getphase`: Get phase string of state + * :class:`_fase`: Base class to define a phase state + * :func:`deriv_H`: Calculate generic partial derivative with a fundamental + Helmholtz free energy equation of state + * :func:`deriv_G`: Calculate generic partial derivative with a fundamental + Gibbs free energy equation of state """ from __future__ import division @@ -13,21 +20,21 @@ Parameters ---------- Tc : float - Critical temperature [K] + Critical temperature, [K] Pc : float - Critical pressure [MPa] + Critical pressure, [MPa] T : float - Temperature [K] + Temperature, [K] P : float - Pressure [MPa] + Pressure, [MPa] x : float - Quality [-] - region: integer - Region number, specific to IAPWS97 region definition + Quality, [-] + region: int + Region number, used only for IAPWS97 region definition Returns ------- - phase : string + phase : str Phase name """ # Avoid round problem @@ -110,17 +117,36 @@ def deriv_H(state, z, x, y, fase): - """Calculate generic partial derivative: (∂z/∂x)y from a fundamental + r"""Calculate generic partial derivative + :math:`\left.\frac{\partial z}{\partial x}\right|_{y}` from a fundamental helmholtz free energy equation of state Parameters ---------- state : any python object - Only need define P and T properties - x, y, z : string - Name of variables of derivate, can be: P, T, v, rho, u, h, s, g, a + Only need to define P and T properties, non phase specific properties + z : str + Name of variables in numerator term of derivatives + x : str + Name of variables in denominator term of derivatives + y : str + Name of constant variable in partial derivaritive fase : any python object - Define other phase properties v, cv, alfap, s, betap + Define phase specific properties (v, cv, alfap, s, betap) + + Notes + ----- + x, y and z can be the following values: + + * P: Pressure + * T: Temperature + * v: Specific volume + * rho: Density + * u: Internal Energy + * h: Enthalpy + * s: Entropy + * g: Gibbs free energy + * a: Helmholtz free energy Returns ------- @@ -166,17 +192,36 @@ def deriv_G(state, z, x, y, fase): - """Calculate generic partial derivative: (∂z/∂x)y from a fundamental + r"""Calculate generic partial derivative + :math:`\left.\frac{\partial z}{\partial x}\right|_{y}` from a fundamental Gibbs free energy equation of state Parameters ---------- state : any python object - Only need define P and T properties - x, y, z : string - Name of variables of derivate, can be: P, T, v, rho, u, h, s, g, a + Only need to define P and T properties, non phase specific properties + z : str + Name of variables in numerator term of derivatives + x : str + Name of variables in denominator term of derivatives + y : str + Name of constant variable in partial derivaritive fase : any python object - Define other phase properties v, cp, alfav, s, xkappa + Define phase specific properties (v, cp, alfav, s, xkappa) + + Notes + ----- + x, y and z can be the following values: + + * P: Pressure + * T: Temperature + * v: Specific volume + * rho: Density + * u: Internal Energy + * h: Enthalpy + * s: Entropy + * g: Gibbs free energy + * a: Helmholtz free energy Returns ------- diff -Nru iapws-1.3/iapws.egg-info/PKG-INFO iapws-1.4/iapws.egg-info/PKG-INFO --- iapws-1.3/iapws.egg-info/PKG-INFO 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/iapws.egg-info/PKG-INFO 2019-06-15 06:32:57.000000000 +0000 @@ -1,12 +1,12 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: iapws -Version: 1.3 +Version: 1.4 Summary: Python implementation of standards from The InternationalAssociation for the Properties of Water and Steam Home-page: https://github.com/jjgomera/iapws Author: jjgomera Author-email: jjgomera@gmail.com License: gpl v3 -Download-URL: https://github.com/jjgomera/iapws/tarball/v1.3 +Download-URL: https://github.com/jjgomera/iapws/tarball/v1.4 Description: .. image:: https://api.travis-ci.org/jjgomera/iapws.svg?branch=master :target: https://travis-ci.org/jjgomera/iapws :alt: Build Status @@ -47,7 +47,11 @@ dependences -------------------- - * python 2x, 3x, compatible with both versions + * Support for both python branch:: + + * python 2.7 + * python 3.4 or later + * Numpy-scipy: library with mathematic and scientific tools @@ -75,7 +79,7 @@ For a rapid usage demostration, see this examples - IAPWS-IF97 + IAPWS-IF97 (`see full documentation `__) .. code:: python @@ -86,7 +90,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies - IAPWS-95 + IAPWS-95 (`see full documentation `__) .. code:: python @@ -97,7 +101,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies - IAPWS-05 for Heavy water + IAPWS-17 for Heavy water (`see full documentation `__) .. code:: python @@ -106,7 +110,7 @@ print(sat_liquid.h) #calculated enthalpy - IAPWS-06 for Ice Ih + IAPWS-06 for Ice Ih (`see full documentation `__) .. code:: python @@ -115,7 +119,7 @@ print(ice["rho"]) #Calculated density - IAPWS-08 for seawater + IAPWS-08 for seawater (`see full documentation `__) .. code:: python @@ -152,3 +156,4 @@ Classifier: Topic :: Scientific/Engineering :: Chemistry Classifier: Topic :: Scientific/Engineering :: Physics Classifier: Topic :: Software Development :: Libraries :: Python Modules +Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.* diff -Nru iapws-1.3/PKG-INFO iapws-1.4/PKG-INFO --- iapws-1.3/PKG-INFO 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/PKG-INFO 2019-06-15 06:32:57.000000000 +0000 @@ -1,12 +1,12 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: iapws -Version: 1.3 +Version: 1.4 Summary: Python implementation of standards from The InternationalAssociation for the Properties of Water and Steam Home-page: https://github.com/jjgomera/iapws Author: jjgomera Author-email: jjgomera@gmail.com License: gpl v3 -Download-URL: https://github.com/jjgomera/iapws/tarball/v1.3 +Download-URL: https://github.com/jjgomera/iapws/tarball/v1.4 Description: .. image:: https://api.travis-ci.org/jjgomera/iapws.svg?branch=master :target: https://travis-ci.org/jjgomera/iapws :alt: Build Status @@ -47,7 +47,11 @@ dependences -------------------- - * python 2x, 3x, compatible with both versions + * Support for both python branch:: + + * python 2.7 + * python 3.4 or later + * Numpy-scipy: library with mathematic and scientific tools @@ -75,7 +79,7 @@ For a rapid usage demostration, see this examples - IAPWS-IF97 + IAPWS-IF97 (`see full documentation `__) .. code:: python @@ -86,7 +90,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies - IAPWS-95 + IAPWS-95 (`see full documentation `__) .. code:: python @@ -97,7 +101,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies - IAPWS-05 for Heavy water + IAPWS-17 for Heavy water (`see full documentation `__) .. code:: python @@ -106,7 +110,7 @@ print(sat_liquid.h) #calculated enthalpy - IAPWS-06 for Ice Ih + IAPWS-06 for Ice Ih (`see full documentation `__) .. code:: python @@ -115,7 +119,7 @@ print(ice["rho"]) #Calculated density - IAPWS-08 for seawater + IAPWS-08 for seawater (`see full documentation `__) .. code:: python @@ -152,3 +156,4 @@ Classifier: Topic :: Scientific/Engineering :: Chemistry Classifier: Topic :: Scientific/Engineering :: Physics Classifier: Topic :: Software Development :: Libraries :: Python Modules +Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.* diff -Nru iapws-1.3/README.rst iapws-1.4/README.rst --- iapws-1.3/README.rst 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/README.rst 2019-06-15 06:32:57.000000000 +0000 @@ -38,7 +38,11 @@ dependences -------------------- -* python 2x, 3x, compatible with both versions +* Support for both python branch:: + + * python 2.7 + * python 3.4 or later + * Numpy-scipy: library with mathematic and scientific tools @@ -66,7 +70,7 @@ For a rapid usage demostration, see this examples -IAPWS-IF97 +IAPWS-IF97 (`see full documentation `__) .. code:: python @@ -77,7 +81,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies -IAPWS-95 +IAPWS-95 (`see full documentation `__) .. code:: python @@ -88,7 +92,7 @@ print(sat_steam.h, sat_liquid.h, steam.h) #calculated enthalpies -IAPWS-05 for Heavy water +IAPWS-17 for Heavy water (`see full documentation `__) .. code:: python @@ -97,7 +101,7 @@ print(sat_liquid.h) #calculated enthalpy -IAPWS-06 for Ice Ih +IAPWS-06 for Ice Ih (`see full documentation `__) .. code:: python @@ -106,7 +110,7 @@ print(ice["rho"]) #Calculated density -IAPWS-08 for seawater +IAPWS-08 for seawater (`see full documentation `__) .. code:: python diff -Nru iapws-1.3/setup.py iapws-1.4/setup.py --- iapws-1.3/setup.py 2018-04-04 05:26:21.000000000 +0000 +++ iapws-1.4/setup.py 2019-06-15 06:32:57.000000000 +0000 @@ -21,6 +21,7 @@ 'Association for the Properties of Water and Steam', long_description=long_description, license="gpl v3", + python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', install_requires=["scipy"], classifiers=[ "Development Status :: 5 - Production/Stable",