Centrifugal pump class

Having written all of the code for any generic pump, we now write the code for centrifugal pumps, which are the most common type of variable displacement pumps. This code is shown here:

# pump.py (part 9)
1class CentrifPump(Pump): 2 """Defines a variable-displacement, centrifugal-style pump.""" 3 4 def get_speed_str(self): 5 """Get the current speed of the pump, in rpm.""" 6 if self.speed == 0: 7 return "The pump is stopped." 8 else: 9 return "The pump is running at {speed} rpm.".format(speed=self.speed) 10 11 def get_flow_str(self): 12 """Get the current flow rate of the pump.""" 13 return "The pump output flow rate is {flow} gpm.".format(flow=self.flow)

Line 1 subclasses the Pump base class to create the CentrifPump subclass. For this particular type of pump, we don't require any special parameters beyond the default, generic ones, so we don't have to provide a new __init__ method.

Lines 4-9 create a method that returns a string, indicating the speed of the pump or if it is not running. Lines 11-13 do the same thing for pump flow rate:

# pump.py (part 10)
1 def get_press_str(self): 2 """Get the current output pressure for the pump.""" 3 return "The pump pressure is {press:.2f} psi.".format(press=self.outlet_pressure) 4
5    def get_power_str(self): 
6        """Get the current power draw for the pump.""" 
7        return "The power usage for the pump is {pow:.2f} kW.".format(pow=self.power) 

Lines 1-3 provide a string output for pump outlet pressure, and lines 5-7 are for pump power:

# pump.py (part 11)
1 def adjust_speed(self, new_speed): 2 """Defines pump characteristics that are based on pump speed. 3 4 Only applies to variable displacement (centrifugal) pumps. Variable names match pump law equations. 5 """ 6 n2 = new_speed # Validate input 7 8 if self.speed == 0: # Pump initially stopped 9 n1 = 1 10 else: 11 n1 = self.speed 12 v1 = self.flow 13 hp1 = self.outlet_pressure 14 15 self.flow = v1 * (n2 / n1) # New flow rate 16 self.outlet_pressure = hp1 * math.pow((n2 / n1), 2) # New outlet pressure 17 self.speed = n2 # Replace old speed with new value 18 delta_p = self.diff_press_psi(self.head_in, utility_formulas.press_to_head(self.outlet_pressure)) 19 self.power = self.pump_power(self.flow, delta_p)

The method that is defined in the following code listing adjusts the speed of the pump, but requires some explanation. Centrifugal pump operating characteristics are defined by the following pump affinity laws:

  • Flow rate is proportional to pump speed (Q ∝ N)
  • Pressure (head) is proportional to the square of pump speed (H  )
  • Power is proportional to the cube of pump speed (P )

Hence, to double the flow rate from a centrifugal pump, the output pressure increases four-fold while the power required increases by a factor of eight.

The adjust_speed() method uses these pump laws to calculate the resulting changes as pump speed varies. It also attempts to account for a pump that is initially started, as the formulas assume a steady-state running condition:

# pump.py (part 12)
1 def start_pump(self, speed, flow, out_press=0.0, out_ft=0.0): 2 """System characteristics when a pump is initially started. 3 4 Assumes all valves fully open, i.e. maximum flow rate. 5 6 """ 7 self.speed = speed 8 self.flow = flow 9 if out_press > 0.0: 10 self.outlet_pressure = out_press 11 elif out_ft > 0.0: 12 self.outlet_pressure = utility_formulas.head_to_press(out_ft) 13 else: 14 return "Outlet pump pressure required." 15 delta_p = self.outlet_pressure - utility_formulas.head_to_press(self.head_in) 16 self.power = self.pump_power(self.flow, delta_p) 17 18 return self.speed, self.flow, self.outlet_pressure, self.power

The method in the preceding code listing initializes the pump's characteristics when it is initially started. This is only necessary when after a pump instance has been initially created and either the instance was set to a stopped condition or was shut off.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.105.215