Пример #1
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
Пример #2
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
Пример #3
0
    def test4(self):
        foo = FlowBase(fluid=HydraulicOil())

        foo.T.val = C2K(50)
        foo.v = 1.
        print(foo)
        print('*' * 60)

        self.assertTrue(True)
Пример #4
0
    def test3(self):
        foo = FlowBase(d_pipe=25e-3, fluid=Water())

        foo.T.val = C2K(50)
        foo.v = 1.
        print(foo)
        print('*' * 60)

        self.assertTrue(True)
Пример #5
0
    def test2(self):
        foo = FlowBase(w_h_pipe = (4e-3, 5e-3))

        foo.T.val = C2K(50)
        foo.v = 1.
        print(foo)
        print('*' * 60)

        self.assertTrue(True)
Пример #6
0
    def __init__(self, identifier: str = 'Flow', 
                 d_pipe: Optional[float] = None, 
                 w_h_pipe: Optional[Tuple[float, float]] = None,
                 v: float = 1.,
                 fluid: Optional[Fluid] = None) -> None:
        """
           ------              _---_      ^
        h |      |           _-     -_    |
          |      |           -_     _-    | d_pipe
           ------              -___-      v
             w           
        
        Args:
            identifier:
                indentifier of flow

            d_pipe:
                inner diameter if circular cross-section [m]

            w_h_pipe:
                width and height of rectangular cross-section [m, m]

            v:
                speed (mean velocity) [m/s]
                
            fluid:
                fluid object, default is Water

        Note:
            If both d_pipe and w_h_pipe are given, w_h_pipe is ignored
        """
        super().__init__(identifier=identifier)

        if fluid is None:
            self._fluid: Fluid = Water()
        else:
            self._fluid: Fluid = fluid 
            assert isinstance(self.fluid, Fluid)

        self.T.val: float = C2K(20)
        self.p.val: float = self.p.ref

        self._v: float = Parameter(identifier='v', unit='m/s', val=v)
        self._A: float = 0.
        self._m_dot: float = 0.
        self._V_dot: float = 0.

        self._d_pipe: Optional[float] = None
        self._w_h_pipe: Optional[Tuple[float, float]] = None

        if d_pipe is not None:
            self.d_pipe = d_pipe
        elif w_h_pipe is not None:
            self.w_h_pipe = w_h_pipe
        else:
            self.d_pipe = 1.
Пример #7
0
    def test2(self):
        s = 'Water'
        print('-' * len(s) + '\n' + s + '\n' + '-' * len(s))

        collection = Matters()
        print('Collection:', collection)
        mat = collection('Water')
        mat.plot('c_p')

        rho = mat.plot('rho')
        print('rho:', rho)
        lambda_ = mat.lambda_(T=C2K(100))
        print('lambda_:', lambda_)
        c_p = mat.c_p(T=C2K(20), p=mat.p.ref)
        print('c_p:', c_p)

        mat.plot('all')

        self.assertTrue(True)
Пример #8
0
    def test1(self):
        foo = FlowBase(fluid=Water())
        foo.T.val = C2K(50)
        foo.v = 2.0

        print('foo.T():', foo.T())
        print('foo.T.val:', foo.T.val)
        print('*' * 60)

        self.assertTrue(foo.T.val == foo.T())
Пример #9
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
Пример #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
Пример #11
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
Пример #12
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)
Пример #13
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)
Пример #14
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)
Пример #15
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)