def test_Weinaug_Katz(): # sample test case sigma = Weinaug_Katz([5.1e-5, 7.2e-5], Vml=0.000125, Vmg=0.02011, xs=[.4, .6], ys=[.6, .4]) assert_close(sigma, 0.06547479150776776) # pure component check it checks out Vml = rho_to_Vm(800.8088185536124, 100.15888) Vmg = rho_to_Vm(4.97865317223119, 100.15888) sigma = Weinaug_Katz([5.088443542210164e-05], Vml, Vmg, [1.0], [1.0]) assert_close(sigma, 0.026721669606560042, rtol=1e-13)
def __init__(self, T=None, P=None, zs=None): self.T = T self.P = P self._rho_mass = iapws.iapws97_rho(T, P) self._V = rho_to_Vm(rho=self._rho_mass, MW=self._MW) self.region = region = iapws.iapws97_identify_region_TP(T, P) if region == 1: self.pi = P * 6.049606775559589e-08 #1/16.53E6 self.tau = 1386.0 / T self.Pref = 16.53E6 self.Tref = 1386.0 elif region == 2: self.pi = P * 1e-6 self.tau = 540.0 / T self.Pref = 1e6 self.Tref = 540.0 elif region == 3: self.tau = self.Tc / T self.Tref = self.Tc self.delta = self._rho_mass * 0.003105590062111801 # 1/322.0 self.rhoref = 322.0 elif region == 5: self.pi = P * 1e-6 self.tau = 1000.0 / T self.Tref = 1000.0 self.Pref = 1e6
def to(self, zs, T=None, P=None, V=None): new = self.__class__.__new__(self.__class__) new.zs = zs if T is not None and P is not None: new.T = T new._rho_mass = rho_mass = iapws.iapws95_rho(T, P) new._V = rho_to_Vm(rho=rho_mass, MW=self._MW) new.P = P elif T is not None and V is not None: new.T = T new._rho_mass = rho_mass = 1e-3 * self._MW / V P = iapws.iapws95_P(T, rho_mass) new._V = V new.P = P elif P is not None and V is not None: new._rho_mass = rho_mass = Vm_to_rho(V, MW=self._MW) T = new.T = iapws.iapws95_T(P, rho_mass) new._V = V new.P = P else: raise ValueError("Two of T, P, or V are needed") new.P = P new.T = T new.tau = tau = new.Tc / T new.delta = delta = rho_mass * new.rhoc_mass_inv new.A0, new.dA0_dtau, new.d2A0_dtau2, new.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta) return new
def __init__(self, T=None, P=None, zs=None): self.T = T self.P = P self._rho_mass = rho_mass = iapws.iapws95_rho(T, P) self._V = rho_to_Vm(rho=rho_mass, MW=self._MW) self.tau = tau = self.Tc / T self.delta = delta = rho_mass * self.rhoc_mass_inv self.A0, self.dA0_dtau, self.d2A0_dtau2, self.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta)
def to_TP_zs(self, T, P, zs): new = self.__class__.__new__(self.__class__) new.zs = zs new.T = T new.P = P new._rho_mass = rho_mass = iapws.iapws95_rho(T, P) new._V = rho_to_Vm(rho=rho_mass, MW=self._MW) new.tau = tau = new.Tc / T new.delta = delta = rho_mass * new.rhoc_mass_inv new.A0, new.dA0_dtau, new.d2A0_dtau2, new.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta) return new
def to(self, zs, T=None, P=None, V=None): new = self.__class__.__new__(self.__class__) new.zs = zs if T is not None: new.T = T if P is not None: new._rho_mass = rho_mass = iapws.iapws97_rho(T, P) new._V = rho_to_Vm(rho=rho_mass, MW=self._MW) new.P = P elif V is not None: new._rho_mass = rho_mass = Vm_to_rho(V, MW=self._MW) P = iapws.iapws97_P(T, rho_mass) new.V = V new.P = P elif P is not None and V is not None: new._rho_mass = rho_mass = Vm_to_rho(V, MW=self._MW) T = new.T = iapws.iapws97_T(P, rho_mass) new.V = V new.P = P else: raise ValueError("Two of T, P, or V are needed") new.region = region = iapws.iapws97_identify_region_TP(new.T, new.P) if region == 1: new.pi = P * 6.049606775559589e-08 #1/16.53E6 new.tau = 1386.0 / T new.Pref = 16.53E6 new.Tref = 1386.0 elif region == 2: new.pi = P * 1e-6 new.tau = 540.0 / T new.Pref = 1e6 new.Tref = 540.0 elif region == 3: new.tau = new.Tc / T new.Tref = new.Tc new.delta = new._rho_mass * 0.003105590062111801 # 1/322.0 new.rhoref = 322.0 elif region == 5: new.pi = P * 1e-6 new.tau = 1000.0 / T new.Tref = 1000.0 new.Pref = 1e6 new.P = P new.T = T return new
def to_TP_zs(self, T, P, zs, other_eos=None): new = self.__class__.__new__(self.__class__) new.T = T new.P = P new.zs = zs self._rho_mass = iapws.iapws97_rho(T, P) self._V = rho_to_Vm(rho=self._rho_mass, MW=self._MW) self.region = region = iapws.iapws97_identify_region_TP(T, P) if region == 1: self.pi = P * 6.049606775559589e-08 #1/16.53E6 self.tau = 1386.0 / T elif region == 2: self.pi = P * 1e-6 self.tau = 540.0 / T elif region == 3: self.tau = self.Tc / T self.delta = self._rho_mass * 0.003105590062111801 # 1/322.0 elif region == 5: self.pi = P * 1e-6 self.tau = 1000.0 / T
class IAPWS95(HelmholtzEOS): model_name = 'iapws95' _MW = iapws.iapws95_MW Tc = iapws.iapws95_Tc Pc = iapws.iapws95_Pc rhoc_mass = iapws.iapws95_rhoc rhoc_mass_inv = 1.0 / rhoc_mass rhoc_inv = rho_to_Vm(rhoc_mass, _MW) rhoc = 1.0 / rhoc_inv rho_red = rhoc rho_red_inv = rhoc_inv T_red = Tc T_fixed_transport = 1.5 * T_red _MW_kg = _MW * 1e-3 R = _MW_kg * iapws.iapws95_R # This is just the gas constant 8.314... but matching iapws to their decimals R_inv = 1.0 / R R2 = R * R #R = property_mass_to_molar(iapws95_R, iapws95_MW) zs = [1.0] cmps = [0] # HeatCapacityGases = iapws_correlations.HeatCapacityGases T_MAX_FIXED = 5000.0 T_MIN_FIXED = 243.0 # PU has flash failures at < 242 ish K _d4Ar_ddelta2dtau2_func = staticmethod(iapws.iapws95_d4Ar_ddelta2dtau2) _d3Ar_ddeltadtau2_func = staticmethod(iapws.iapws95_d3Ar_ddeltadtau2) _d3Ar_ddelta2dtau_func = staticmethod(iapws.iapws95_d3Ar_ddelta2dtau) _d2Ar_ddeltadtau_func = staticmethod(iapws.iapws95_d2Ar_ddeltadtau) _d2Ar_dtau2_func = staticmethod(iapws.iapws95_d2Ar_dtau2) _dAr_dtau_func = staticmethod(iapws.iapws95_dAr_dtau) _d3Ar_ddelta3_func = staticmethod(iapws.iapws95_d3Ar_ddelta3) _d2Ar_ddelta2_func = staticmethod(iapws.iapws95_d2Ar_ddelta2) _dAr_ddelta_func = staticmethod(iapws.iapws95_dAr_ddelta) _Ar_func = staticmethod(iapws.iapws95_Ar) def __init__(self, T=None, P=None, zs=None): self.T = T self.P = P self._rho_mass = rho_mass = iapws.iapws95_rho(T, P) self._V = rho_to_Vm(rho=rho_mass, MW=self._MW) self.tau = tau = self.Tc / T self.delta = delta = rho_mass * self.rhoc_mass_inv self.A0, self.dA0_dtau, self.d2A0_dtau2, self.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta) def to_TP_zs(self, T, P, zs): new = self.__class__.__new__(self.__class__) new.zs = zs new.T = T new.P = P new._rho_mass = rho_mass = iapws.iapws95_rho(T, P) new._V = rho_to_Vm(rho=rho_mass, MW=self._MW) new.tau = tau = new.Tc / T new.delta = delta = rho_mass * new.rhoc_mass_inv new.A0, new.dA0_dtau, new.d2A0_dtau2, new.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta) return new def to(self, zs, T=None, P=None, V=None): new = self.__class__.__new__(self.__class__) new.zs = zs if T is not None and P is not None: new.T = T new._rho_mass = rho_mass = iapws.iapws95_rho(T, P) new._V = rho_to_Vm(rho=rho_mass, MW=self._MW) new.P = P elif T is not None and V is not None: new.T = T new._rho_mass = rho_mass = 1e-3 * self._MW / V P = iapws.iapws95_P(T, rho_mass) new._V = V new.P = P elif P is not None and V is not None: new._rho_mass = rho_mass = Vm_to_rho(V, MW=self._MW) T = new.T = iapws.iapws95_T(P, rho_mass) new._V = V new.P = P else: raise ValueError("Two of T, P, or V are needed") new.P = P new.T = T new.tau = tau = new.Tc / T new.delta = delta = rho_mass * new.rhoc_mass_inv new.A0, new.dA0_dtau, new.d2A0_dtau2, new.d3A0_dtau3 = iapws.iapws95_A0_tau_derivatives( tau, delta) return new def mu(self): r'''Calculate and return the viscosity of water according to the IAPWS. For details, see :obj:`chemicals.viscosity.mu_IAPWS`. Returns ------- mu : float Viscosity of water, [Pa*s] ''' try: return self._mu except: pass self.__mu_k() return self._mu def k(self): r'''Calculate and return the thermal conductivity of water according to the IAPWS. For details, see :obj:`chemicals.thermal_conductivity.k_IAPWS`. Returns ------- k : float Thermal conductivity of water, [W/m/K] ''' try: return self._k except: pass self.__mu_k() return self._k def __mu_k(self): drho_mass_dP = self.drho_mass_dP() # TODO: curve fit drho_dP_Tr better than IAPWS did (mpmath) drho_dP_Tr = self.to(T=self.T_fixed_transport, V=self._V, zs=self.zs).drho_mass_dP() self._mu = mu_IAPWS(T=self.T, rho=self._rho_mass, drho_dP=drho_mass_dP, drho_dP_Tr=drho_dP_Tr) self._k = k_IAPWS(T=self.T, rho=self._rho_mass, Cp=self.Cp_mass(), Cv=self.Cv_mass(), mu=self._mu, drho_dP=drho_mass_dP, drho_dP_Tr=drho_dP_Tr)