コード例 #1
0
        def f():
            rho = 1000
            nu = 1e-6
            D = 50e-3
            L = 1
            eps_rough = 10e-6
            v = 1
            Re = v * D / nu

            k = resistance_pipe(v=v, D=D, L=L, nu=nu, eps_rough=eps_rough)
            dp = pressure_drop(k=k, v=v, rho=rho)

            maxKey = max(map(len, locals()))
            for key, val in locals().items():
                if key != 'maxKey':
                    s = '{:>' + str(maxKey + 4) + '}: {}'
                    print(s.format(key, val))
コード例 #2
0
    def test7(self):
        # dp(nu)  for a v-sequence
        for k in self.k_functions:
            print('\n\n***', k.__name__)

            nu_seq = [x * 1e-7 for x in range(1, int(1e5))]
            dp1 = [pressure_drop(k(v1=v1, D1=D1, D2=D2, nu=nu,
                                  eps_rough=eps_rough), v1, rho)
                   for nu in nu_seq]
            x = [x * 1e6 for x in nu_seq]
            y = [y * 1e-3 for y in dp1]
            plt.title('v: '+str(v1))
            plt.xlabel(r'$\nu$ [mm$^2$/s]')
            plt.ylabel('$p$ [kPa]')
            plt.plot(x, y)
            plt.show()

        self.assertTrue(True)
コード例 #3
0
    def test8(self):
        # dp(nu)  for a v-sequence
        for k in self.k_functions:
            plt.xlabel('$v$ [m/s]')
            plt.ylabel('$p$ [kPa]')
            v_seq = np.linspace(0.1, 10., 50)
            nu_seq = [1e-7, 1e-6, 1e-5, 1e-4, 1e-3]
            for nu in nu_seq:
                dp2 = [pressure_drop(k(v1=v1, D1=D1, D2=D2, nu=nu,
                                       eps_rough=eps_rough), v1, rho)
                       for v1 in v_seq]
                y = [y * 1e-3 for y in dp2]
                plt.plot(v_seq, y,
                         label='nu:'+str(round(nu*1e6, 1))+'e-6')
            plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')
            plt.show()

        self.assertTrue(True)
コード例 #4
0
    def test9(self):
        # dp(v)  for a v-sequence
        for k in self.k_functions:
            plt.xlabel(r'$Re \cdot 10^{-3}$ [/]')
            plt.ylabel('$p$ [kPa]')
            v1_seq = np.array([.1, .2, .4, .6, .8, 1, 2, 3, 4, 5, 6, 7, 8,
                               9, 10])
            nu_seq = np.array([1e-7, 1e-6, 1e-5, 1e-4, 1e-3])
            for nu in nu_seq:
                Re_seq = v1_seq * D1 / nu
                dp_seq = [pressure_drop(k(v1=v1, D1=D1, D2=D2, nu=nu,
                          eps_rough=eps_rough), v1, rho) for v1 in v1_seq]
                dp_kPa = 1e-3 * np.array(dp_seq)
                plt.plot(Re_seq * 1e-3, dp_kPa,
                         label='nu:'+str(round(nu*1e6, 1))+'e-6')
            plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left')
            plt.show()

        self.assertTrue(True)
コード例 #5
0
    def test6(self):
        # plot dp(v, nu)  for v-sequence
        for v in [0.05, 0.1, 0.2, 1, 10]:
            plt.xlabel(r'$\nu$ [mm$^2$/s]')
            plt.ylabel('$p$ [kPa]')
            nu_seq = np.linspace(1e-7, 1e-3, 1000)
            for k in self.k_functions:
                print('\n\n***', k.__name__)
                if str(k).find('Expansion') == -1:
                    v1 = v
                else:
                    v1 = v * (D1/D2)**2
                dp1 = np.array([pressure_drop(k(v1=v1, D1=D1, D2=D2, nu=nu,
                                              eps_rough=eps_rough), v1, rho)
                                for nu in nu_seq])
                s = str(k).split(sep=' ')[1][10:]
                plt.title('v_low: '+str(v)+', D1: '+str(D1)+', D2: '+str(D2) +
                          ', eps: '+str(eps_rough)+' v1_expan=v2_reduc')
                plt.plot(nu_seq*1e6, dp1*1e-3, label=s)
            plt.show()

        self.assertTrue(True)