示例#1
0
 def test_get_speed(self):
     p = PositiveDisplacement()
     p.adjust_speed(0)
     assert p.get_speed_str() == "The pump is stopped."
     p1 = PositiveDisplacement(pump_speed=75, displacement=0.05)
     p1.adjust_speed(75)
     assert p1.get_speed_str() == "The pump is running at 75 rpm."
示例#2
0
 def test_adjust_speed_neg(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     with pytest.raises(ValueError) as excinfo:
         p.speed = -10
     exception_msg = excinfo.value.args[0]
     assert exception_msg == "Speed must be 0 or greater."
示例#3
0
 def test_adjust_speed_expected(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     p.adjust_speed(25)
     assert p.flow == 1.25
     assert p.power == 0.005776719563607849
     assert p.speed == 25
示例#4
0
 def test_adjust_speed_zero(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     p.adjust_speed(0)
     assert p.flow == 0.0
     assert p.power == 0.0
     assert p.speed == 0
示例#5
0
# Pump 1 group (centrifugal)
centrif_pump1 = CentrifPump("Centrifugal Pump", pump_head_in=20)
out_valve1 = Gate("Centrifugal Pump outlet",
                  flow_coeff=90,
                  sys_flow_in=centrif_pump1.get_flow)
throttle1 = Globe("Centrifugal Pump throttle",
                  flow_coeff=30,
                  sys_flow_in=centrif_pump1.get_flow)
in_valve2 = Gate("Gear Pump inlet",
                 flow_coeff=270,
                 sys_flow_in=centrif_pump1.get_flow)

# Pump 2 group (gear)
gear_pump1 = PositiveDisplacement("Gear Pump",
                                  displacement=0.096,
                                  pump_head_in=throttle1.press_out,
                                  press_out=10)
out_valve2 = Gate("Gear Pump outlet",
                  flow_coeff=270,
                  sys_flow_in=gear_pump1.get_flow)
recirc1 = Globe("Gear Pump throttle",
                flow_coeff=30,
                sys_flow_in=gear_pump1.get_flow)
relief1 = Relief("Gear Pump relief",
                 flow_coeff=0.71,
                 open_press=150,
                 close_press=125,
                 sys_flow_in=gear_pump1.get_flow)
in_valve1 = Gate("Centrifugal Pump inlet",
                 flow_coeff=90,
                 sys_flow_in=48,
示例#6
0
 def test_speed_control_non_int(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     with pytest.raises(TypeError):
         p.speed = "a"
示例#7
0
 def test_get_power(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     p.adjust_speed(p.speed)
     assert p.get_power_str() == "The power usage for the pump is 0.02 kW."
示例#8
0
 def test_get_pressure(self):
     p = PositiveDisplacement(press_out=24.5,
                              pump_speed=75,
                              displacement=0.05)
     p.adjust_speed(p.speed)
     assert p.get_press_str() == "The pump pressure is 24.50 psi."
示例#9
0
 def test_get_flowrate(self):
     p = PositiveDisplacement(pump_speed=75, displacement=0.05)
     p.adjust_speed(p.speed)
     assert p.get_flow_str() == "The pump outlet flow rate is 3.75 gpm."
示例#10
0
# Gate Valve 2
valve2 = Gate("Valve 2", position=100, flow_coeff=200, press_in=throttle1.press_out, sys_flow_in=throttle1.flow_out)
valve2.flow_out = valve2.flow_in
valve2.press_drop(valve2.flow_out)
valve2.valve_flow_out(valve2.Cv, valve2.deltaP)
valve2.get_press_out(valve2.press_in)

# Gate Valve 3
valve3 = Gate("Valve 3", position=100, flow_coeff=200, press_in=valve2.press_out, sys_flow_in=valve2.flow_out)
valve3.flow_out = valve3.flow_in
valve3.press_drop(valve3.flow_out)
valve3.valve_flow_out(valve3.Cv, valve3.deltaP)
valve3.get_press_out(valve3.press_in)

# Gear Pump
pump2 = PositiveDisplacement("Gear Pump", displacement=0.096, press_out=30,
                             pump_head_in=utility_formulas.press_to_head(valve3.press_out))
pump2.adjust_speed(300)

# Relief Valve 1
relief1 = Relief("Relief 1", open_press=60, close_press=55, press_in=pump2.outlet_pressure)

# Globe Valve 2
recirc1 = Globe("Throttle 2", position=100, flow_coeff=21, press_in=pump2.outlet_pressure,
                sys_flow_in=pump2.flow)
recirc1.flow_out = recirc1.flow_in
recirc1.press_drop(recirc1.flow_out)
recirc1.valve_flow_out(recirc1.Cv, recirc1.deltaP)
recirc1.get_press_out(recirc1.press_in)

# Gate Valve 4
valve4 = Gate("Valve 4", position=100, flow_coeff=200, press_in=recirc1.press_out, sys_flow_in=recirc1.flow_out)
示例#11
0
"""Assumes valves in series, with the first supplied by a tank 10 feet above the valve with a pipe length of 6 feet.
Water level is 4 feet above tank bottom; total water head = 14 feet.
"""

import utility_formulas

from PipingSystems.pump.pump import CentrifPump, PositiveDisplacement
from PipingSystems.valve.valve import Gate, Globe, Relief

valve1 = Gate("Valve 1",  position=100, flow_coeff=200, sys_flow_in=utility_formulas.gravity_flow_rate(2, 1.67),
              press_in=utility_formulas.static_press(14))
pump1 = CentrifPump("Pump 1")
throttle1 = Globe("Throttle 1", position=100, flow_coeff=21)
valve2 = Gate("Valve 2",  position=100, flow_coeff=200)
valve3 = Gate("Valve 3",  position=100, flow_coeff=200)
pump2 = PositiveDisplacement("Gear Pump", displacement=0.096, press_out=30)
relief1 = Relief("Relief 1",  position=0, open_press=60, close_press=55)
recirc1 = Globe("Throttle 2", position=100, flow_coeff=21)
valve4 = Gate("Valve 4",  position=100, flow_coeff=200)


# Utility functions
def test_grav_flow():
    flow_rate = utility_formulas.gravity_flow_rate(2, 1.67)
    assert flow_rate == 319.28008077388426


def test_static_press():
    press = utility_formulas.static_press(14)
    assert press == 6.068373888888889