コード例 #1
0
ファイル: test_piping.py プロジェクト: oemof/tespy
    def test_Valve(self):
        """Test component properties of valves."""
        instance = Valve('valve')
        self.setup_piping_network(instance)

        # parameter specification
        self.c1.set_attr(fluid={'CH4': 1}, m=10, p=10, T=120)
        self.c2.set_attr(p=1)

        # test variable pressure ration
        instance.set_attr(pr='var')
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        pr = round(self.c2.p.val_SI / self.c1.p.val_SI, 2)
        msg = ('Value of pressure ratio must be ' + str(pr) + ', is ' +
               str(round(instance.pr.val, 2)) + '.')
        assert pr == round(instance.pr.val, 2), msg

        # test variable zeta value
        zeta = round(instance.zeta.val, 0)
        instance.set_attr(zeta='var', pr=None)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        msg = ('Value of dimension independent zeta value must be ' +
               str(zeta) + ', is ' + str(round(instance.zeta.val, 0)) + '.')
        assert zeta == round(instance.zeta.val, 0), msg

        # dp char
        x = np.array([8, 9, 10, 11, 12])
        y = np.array([5, 8, 9, 9.5, 9.6]) * 1e5
        dp_char = CharLine(x, y)
        instance.set_attr(zeta=None,
                          dp_char={
                              'char_func': dp_char,
                              'is_set': True
                          })
        m = 11
        self.c1.set_attr(m=m)
        self.c2.set_attr(p=np.nan)
        self.nw.solve('design')
        convergence_check(self.nw.lin_dep)
        self.nw.print_results()
        dp = round(-dp_char.evaluate(m), 0)
        dp_act = round(self.c2.p.val_SI - self.c1.p.val_SI)
        msg = ('The pressure drop at the valve should be ' + str(dp) + ' but '
               'is ' + str(dp_act) + '.')
        assert dp == dp_act, msg
コード例 #2
0
ファイル: ccet_040.py プロジェクト: maltefritz/SWSH
cond.set_attr(pr1=0.99,
              pr2=0.98,
              ttd_u=5,
              design=['ttd_u', 'pr2'],
              offdesign=['zeta2', 'kA_char'])

pump1.set_attr(eta_s=0.8,
               eta_s_char=eta_s_p1,
               design=['eta_s'],
               offdesign=['eta_s_char'])
pump2.set_attr(eta_s=0.8,
               eta_s_char=eta_s_p2,
               design=['eta_s'],
               offdesign=['eta_s_char'])

mp_valve.set_attr(pr=1, design=['pr'])

# %% connection parameters

# gas turbine
c_in.set_attr(T=20,
              p=1,
              fluid={
                  'Ar': 0.0129,
                  'N2': 0.7553,
                  'H2O': 0,
                  'CH4': 0,
                  'CO2': 0.0004,
                  'O2': 0.2314
              })
# gt_in.set_attr(T=1315)