Exemple #1
0
    def RH_to_mol_frac(self,
                       T: float,
                       p: float = atm(),
                       RH: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            RH: 
                relative humidity [/]

        Returns:
            Water mole fraction [mol water/mol humid air]
            OR
            None if parameters out of range

        Note:
            Water mole fraction equals the volumetric fraction if ideal gas
        """
        try:
            return cp.CoolProp.HAPropsSI('psi_w', 'T', T, 'P', p, 'RH', RH)
        except:
            return None
Exemple #2
0
 def _M(self,
        T: float = C2K(20),
        p: float = atm(),
        x: float = 0.) -> Optional[float]:
     try:
         return cp.CoolProp.PropsSI('molemass', self.identifier)
     except:
         return None
Exemple #3
0
 def _beta(self,
           T: float,
           p: float = atm(),
           x: float = 0.) -> Optional[float]:
     try:
         return 1. / T
     except:
         return None
Exemple #4
0
 def __init__(self,
              identifier: str = 'R32',
              latex: Optional[str] = None,
              comment: Optional[str] = None):
     super().__init__(identifier=identifier, latex=latex, comment=comment)
     #
     self.D_in_air.calc = lambda T, p=atm(), x=0: 1.5e-5 * (T / C2K(20)
                                                            )**1.75
Exemple #5
0
 def _c_p(self,
          T: float,
          p: float = atm(),
          x: float = 0.) -> Optional[float]:
     try:
         return cp.CoolProp.PropsSI('C', 'T', T, 'P', p, self.identifier)
     except:
         return None
Exemple #6
0
    def __init__(self,
                 identifier: str = 'Air',
                 latex: Optional[str] = None,
                 comment: Optional[str] = None) -> None:
        """
        Args:
            identifier:
                identifier of matter

            latex:
                Latex-version of identifier. 
                If None, latex is identical with identifier

            comment:
                comment on matter
        """
        super().__init__(identifier=identifier, latex=latex, comment=comment)
        self.version = '111220_dww'
        self.comment = 'Composition: N2: 78%, O2: 21%, Ar+CO2: 1%'

        # reference point and operational range
        self.T._ranges['operational'] = Range(C2K(0.), C2K(100.))
        self.p._ranges['operational'] = Range(0. + atm(), 10e5 + atm())
        self.T.ref = C2K(15.)
        self.T.val = self.T.ref
        self.p.ref = atm()
        self.p.val = self.p.ref

        # constants
        self.E = 2.2e9
        self.h_melt = 334e3
        self.h_vap = 2270e3
        self.M.calc = lambda T=0., p=0., x=0.: 29e-3
        self.T_liq = C2K(0.)
        self.T_boil = 83.

        # functions of temperature, pressure and spare parameter 'x'
        self.beta.calc = self._beta
        self.c_p.calc = self._c_p
        self.c_sound.calc = self._c_sound
        self.k.calc = self._k
        self.nu.calc = self._nu
        self.rho.calc = self._rho
Exemple #7
0
    def __init__(self, identifier: str='water',
                 latex: Optional[str]='$H_2O$',
                 comment: Optional[str]=None) -> None:
        """
        Args:
            identifier:
                identifier of matter

            latex:
                Latex-version of identifier. 
                If None, latex is identical with identifier

            comment:
                comment on matter
        """
        super().__init__(identifier=identifier, latex=latex, comment=comment)
        self.version = '301017_dww'

        # reference point and operational range
        self.T.operational = Range(C2K(0), C2K(100))
        self.T.ref = C2K(15)
        self.T.val = self.T.ref
        self.p.operational = Range(0. + atm(), 100e5 + atm())
        self.p.ref = atm()
        self.p.val = self.p.ref

        # constants
        self.hMelt = 334.0e3
        self.hVap = 2270.0e3
        self.T_liq = C2K(0.0)
        self.T_boil = C2K(99.9839)
        self.composition['H2O'] = 100.

        # functions of temperature, pressure and spare parameter 'x'
        self.rho.calc     = self._rho
        self.nu.calc      = self._nu
        self.mu.calc      = self._mu
        self.c_p.calc     = self._c_p
        self.k.calc = self._k
        self.c_sound.calc = self._c_sound
        self.E.calc       = self._E
Exemple #8
0
    def __init__(self, identifier: str='hydraulic_oil',
                 latex: Optional[str]=None,
                 comment: Optional[str]=None) -> None:
        super().__init__(identifier=identifier)
        """
        Args:
            identifier:
                identifier of matter

            latex:
                Latex-version of identifier. 
                If None, latex is identical with identifier

            comment:
                comment on matter
        """
        super().__init__(identifier=identifier, latex=latex, comment=comment)
        self.version = '160118_dww'

        # reference point and operational range
        self.T.operational = Range(C2K(0), C2K(100))
        self.T.ref = C2K(15)
        self.T.val = self.T.ref
        self.p.operational = Range(0. + atm(), 100e5 + atm())
        self.p.ref = atm()
        self.p.val = self.p.ref

        # constants
#        self.hMelt =
#        self.hVap =
#        self.T_liq = C2K(  )
#        self.T_boil = C2K(   )
        self.composition['C12H24'] = 100  # TODO

        # functions of temperature, pressure and spare parameter 'x'
        self.rho.calc = self._rho
        self.nu.calc = self._nu
        self.mu.calc = self._mu
        self.c_p.calc = self._c_p
        self.k.calc = self._k
Exemple #9
0
 def _Pr(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = [
         100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
         750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
         1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 3000
     ]
     Up = [
         0.786, 0.758, 0.737, 0.720, 0.707, 0.700, 0.690, 0.686, 0.684,
         0.683, 0.685, 0.690, 0.695, 0.702, 0.709, 0.716, 0.720, 0.723,
         0.726, 0.728, 0.728, 0.719, 0.703, 0.685, 0.688, 0.685, 0.683,
         0.677, 0.672, 0.667, 0.655, 0.647, 0.630, 0.613, 0.536
     ]
     return np.interp(T, Tp, Up)
Exemple #10
0
    def __init__(self,
                 identifier: str = 'Ar',
                 latex: Optional[str] = None,
                 comment: Optional[str] = None) -> None:
        """
        Args:
            identifier:
                identifier of matter

            latex:
                Latex-version of identifier. 
                If None, latex is identical with identifier

            comment:
                comment on matter
        """
        super().__init__(identifier=identifier, latex=latex, comment=comment)
        self.version = '160118_dww'

        # reference point and operational range
        self.T._ranges['operational'] = Range(C2K(0), C2K(100))
        self.T.ref = C2K(15)
        self.T.val = self.T.ref
        self.p._ranges['operational'] = Range(0. + atm(), 100e5 + atm())
        self.p.ref = atm()
        self.p.val = self.p.ref

        # constants
        self.composition['Ar'] = 100.
        self.M.calc = lambda T=0., p=0., x=0.: 39.948e-3
        self.Z = 0.9994

        # functions of temperature, pressure and spare parameter 'x'
        self.rho.calc = self._rho
        self.nu.calc = self._nu
        self.mu.calc = self._mu
        self.c_p.calc = self._c_p
        self.k.calc = self._k
Exemple #11
0
 def _rho(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = [
         100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
         750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
         1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 3000
     ]
     Up = [
         3.5562, 2.3364, 1.7458, 1.3947, 1.1614, 0.9950, 0.8711, 0.7740,
         0.6964, 0.6329, 0.5804, 0.5356, 0.4975, 0.4643, 0.4354, 0.4097,
         0.3868, 0.3666, 0.3482, 0.3166, 0.2902, 0.2679, 0.2488, 0.2322,
         0.2177, 0.2049, 0.1935, 0.1833, 0.1741, 0.1658, 0.1582, 0.1513,
         0.1448, 0.1389, 0.1135
     ]
     return np.interp(T, Tp, Up)
Exemple #12
0
 def _k(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = [
         100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
         750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
         1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 3000
     ]
     Up = [
         9.34e-3, 13.8e-3, 18.1e-3, 22.3e-3, 26.3e-3, 30.0e-3, 33.8e-3,
         37.3e-3, 40.7e-3, 43.9e-3, 46.9e-3, 49.7e-3, 52.4e-3, 54.9e-3,
         57.3e-3, 59.6e-3, 62e-3, 64.3e-3, 66.7e-3, 71.5e-3, 76.3e-3, 82e-3,
         91e-3, 100e-3, 106e-3, 113e-3, 120e-3, 128e-3, 137e-3, 147e-3,
         160e-3, 175e-3, 196e-3, 222e-3, 486e-3
     ]
     return np.interp(T, Tp, Up)
Exemple #13
0
 def _c_p(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = [
         100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
         750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
         1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 3000
     ]
     Up = [
         1.032e3, 1.012e3, 1.007e3, 1.006e3, 1.007e3, 1.009e3, 1.014e3,
         1.021e3, 1.030e3, 1.040e3, 1.051e3, 1.063e3, 1.075e3, 1.087e3,
         1.099e3, 1.110e3, 1.121e3, 1.131e3, 1.141e3, 1.159e3, 1.175e3,
         1.189e3, 1.207e3, 1.230e3, 1.248e3, 1.267e3, 1.286e3, 1.307e3,
         1.337e3, 1.372e3, 1.417e3, 1.478e3, 1.558e3, 1.665e3, 2.726e3
     ]
     return np.interp(T, Tp, Up)
Exemple #14
0
 def _nu(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = [
         100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700,
         750, 800, 850, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
         1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 3000
     ]
     Up = [
         2e-6, 4.426e-6, 7.59e-6, 11.44e-6, 15.89e-6, 20.92e-6, 26.41e-6,
         32.39e-6, 38.79e-6, 45.57e-6, 52.69e-6, 60.21e-6, 68.10e-6,
         76.37e-6, 84.93e-6, 93.8e-6, 102.9e-6, 112.2e-6, 121.9e-6,
         141.8e-6, 162.9e-6, 185.1e-6, 213.0e-6, 240.0e-6, 268.0e-6,
         298.0e-6, 329.0e-6, 362.0e-6, 396.0e-6, 431.0e-6, 468.0e-6,
         506.0e-6, 547.0e-6, 589.0e-6, 841.0e-6
     ]
     return np.interp(T, Tp, Up)
Exemple #15
0
    def __init__(self,
                 identifier: str = '_Generic',
                 latex: Optional[str] = None,
                 comment: Optional[str] = None) -> None:
        """
        Args:
            identifier:
                identifier of matter

            latex:
                Latex-version of identifier. 
                If None, latex is identical with identifier

            comment:
                comment on matter                
        """
        super().__init__(identifier=identifier, latex=latex, comment=comment)
        self.version = '151220_dww'

        # reference point and operational range
        self.T._ranges['operational'] = Range(C2K(0.01), C2K(300))
        self.T.ref = C2K(20)
        self.T.val = self.T.ref
        self.p._ranges['operational'] = Range(atm(), atm() + 100e5)
        self.p.ref = atm()
        self.p.val = self.p.ref

        # constants
        self.composition[self.identifier] = 100.

        # functions of temperature, pressure and spare parameter 'x'
        self.c_p.calc = self._c_p
        self.k.calc = self._k
        self.M.calc = self._M
        self.mu.calc = self._mu
        self.rho.calc = self._rho
Exemple #16
0
    def _k(self, T: float, p: float = atm(), x: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            x: 
                relative humidity [/]

        Returns:
            thermal conductivity [W/m/K]
        """
        try:
            return cp.CoolProp.HAPropsSI('k', 'T', T, 'P', p, 'RH', x)
        except:
            return None
Exemple #17
0
    def _c_p(self,
             T: float,
             p: float = atm(),
             x: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            x: 
                relative humidity [/]

        Returns:
            Specific heat capacity [J/kg/K]
        """
        try:
            return cp.CoolProp.HAPropsSI('cp_ha', 'T', T, 'P', p, 'RH', x)
        except:
            return None
Exemple #18
0
    def _mu(self,
            T: float,
            p: float = atm(),
            x: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            x: 
                relative humidity [/]

        Returns:
            dynamic viscosity [Pa s]
        """
        try:
            return cp.CoolProp.HAPropsSI('mu', 'T', T, 'P', p, 'RH', x)
        except:
            return None
Exemple #19
0
    def SH_to_RH(self,
                 T: float,
                 p: float = atm(),
                 SH: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]

            SH:
                specific humidity [kg water/kg dry air]

        Returns:
            relative humidity [/]
            OR
            None if parameters out of range
        """
        return self.relative_humidity(T, p, hum_ratio=SH)
Exemple #20
0
    def _M(self, T: float, p: float = atm(), x: float = 0.) -> float:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            x:
                relative humidity [0..1]
        """
        try:
            psi_wat = self.RH_to_mol_frac(T, p, x)  # [mol water/mol humid air]
        except:
            return None

        if psi_wat is None:
            psi_wat = 0.
        M_air = cp.CoolProp.PropsSI('molemass', 'air')
        M_h2o = (2 * 1 + 16) * 1e-3  # cp.CoolProp.PropsSI('molemass', 'H2O')

        return psi_wat * M_h2o + (1. - psi_wat) * M_air
Exemple #21
0
 def RH_to_AH(self,
              T: float,
              p: float = atm(),
              RH: float = 0.) -> Optional[float]:
     """
     Calculates vapor mass per unit VOLUME of dry air
     
     Args:
         T:
             temperature [K]
         p:
             pressure [Pa]
         RH:
             relative humidity [/]
             
     Returns:
         absolute humidity [kg water/m3 dry air]
         OR
         None if parameters out of range
     """
     return self.RH_to_SH(T, p, RH) * self.rho(T, p, RH)
Exemple #22
0
    def RH_to_SH(self,
                 T: float,
                 p: float = atm(),
                 RH: float = 0.) -> Optional[float]:
        """
        Calculates vapor mass per unit MASS of dry air (specific humidity) 
        from relative humdity

            T:
                temperature [K]
            p:
                pressure [Pa]
            RH:
                relative humidity [/]
        
        Returns:
            specific humidity SH (humidity ratio) [kg water/kg dry air]
            OR
            None if parameters out of range
        """
        return self.humidity_ratio(T, p, RH)
Exemple #23
0
    def _rho(self,
             T: float,
             p: float = atm(),
             x: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]
            x: 
                relative humidity [/]

        Returns:
            density [kg/m3]
            
        Note:
            CoolProp's Vha-function returns mixture volume per unit humid 
            air in [m3/kg] -> density is inverse value	
        """
        try:
            return 1. / cp.CoolProp.HAPropsSI('Vha', 'T', T, 'P', p, 'RH', x)
        except:
            return None
Exemple #24
0
    def relative_humidity(self,
                          T: float,
                          p: float = atm(),
                          hum_ratio: float = 0.) -> Optional[float]:
        """
        Args:
            T:
                temperature [K]
            p:
                pressure [Pa]

            hum_ratio:
                humidity ratio [kg water/kg dry air]

        Returns:
            relative humidity [/]
            OR
            None if parameters out of range
        """
        try:
            return cp.CoolProp.HAPropsSI('RH', 'T', T, 'P', p, 'HumRat',
                                         hum_ratio)
        except:
            return None
Exemple #25
0
    def humidity_ratio(self,
                       T: float,
                       p: float = atm(),
                       RH: float = 0.) -> Optional[float]:
        """
        Calculates vapor mass per unit MASS of dry air (specific humidity)
        from relative humdity

            T:
                temperature [K]
            p:
                pressure [Pa]
            RH:
                relative humidity [/]
        
        Returns:
            specific humidity (humidity ratio) [kg water/kg dry air]
            OR
            None if parameters out of range
        """
        try:
            return cp.CoolProp.HAPropsSI('HumRat', 'T', T, 'P', p, 'RH', RH)
        except:
            return None
Exemple #26
0
 def _mu(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = C2K([0, 100, 200, 300, 400, 500, 600])
     Up = np.array([21.2, 27.1, 32.1, 36.7, 41.0, 45.22, 48.7]) * 1e-6
     return np.interp(T, Tp, Up)
Exemple #27
0
 def _c_sound(self, T: float, p: float = atm(), x: float = 0.) -> float:
     return 331.3 * np.sqrt(1 + K2C(T) / 273.15)
Exemple #28
0
 def _k(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = C2K([0, 100, 200, 300, 400, 500, 600])
     Up = np.array([16.51, 21.17, 25.59, 29.89, 33.96, 37.91, 39.43]) * 1e-3
     return np.interp(T, Tp, Up)
Exemple #29
0
 def _c_p(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = C2K([0, 100, 200, 300, 400, 500, 600, 700, 800])
     Up = [0.522, 0.521, 0.521, 0.521, 0.521, 0.520, 0.520, 0.520, 0.520]
     return np.interp(T, Tp, Up)
Exemple #30
0
 def _rho(self, T: float, p: float = atm(), x: float = 0.) -> float:
     Tp = C2K([20, 20])
     Up = [1.6339, 1.6339]
     return np.interp(T, Tp, Up)