Globe valve class

Globe valves are also children of the Valve parent, as shown in the following code:

# valve.py (part 9)
1 class Globe(Valve): 2 """Throttling valve.""" 3 4 def read_position(self): 5 """Identify the position of the valve.""" 6 return "{name} is {position}% open.".format(name=self.name, position=self.position) 7 8 def turn_handle(self, new_position): 9 """Change the status of the valve.""" 10 if new_position == 100: 11 self.open() 12 elif new_position == 0: 13 self.close() 14 else: 15 self.position = new_position 16 self.flow_out = self.flow_in * self.position / 100 17 self.press_drop(self.flow_out) 18 self.get_press_out(self.press_in)

Globe valves can be any position from fully open to fully closed, so the Globe subclass is similar to the Gate subclass. The primary difference is in turn_handle(), which accepts any value from 0 to 100. If the valve isn't fully open or closed, then the pressure and flow parameters of the valve are automatically adjusted.