[docs]classPumpCstEff(BaseComponent):""" **Component**: Pump **Model**: Constant efficiency **Descritpion**: This model determines the exhaust specific enthalpy and the exhaust temperature of a pump. This model can be used for on-design models of systems. **Assumptions**: - Steady-state operation. - Efficiency stays constant for all the conditions. **Connectors**: su (MassConnector): Mass connector for the suction side. ex (MassConnector): Mass connector for the exhaust side. W (WorkConnector): Work connector for the pump power consumption. **Parameters**: eta_is: Isentropic efficiency. [-] **Inputs**: P_su: Suction side pressure. [Pa] T_su: Suction side temperature. [K] m_dot : Suction side flowrate [kg/s] P_ex: Exhaust side pressure. [Pa] fluid: Suction side fluid. [-] **Ouputs**: h_ex: Exhaust side specific enthalpy. [J/kg] T_ex: Exhaust side temperature. [K] """def__init__(self):super().__init__()self.su=MassConnector()self.ex=MassConnector()self.W=WorkConnector()defget_required_inputs(self):# Return a list of required inputsreturn['P_su','T_su','P_ex','fluid']defget_required_parameters(self):return['eta_is']defsolve(self):# Perform checks to ensure the model can be calculated and has parametersself.check_calculable()self.check_parametrized()ifnot(self.calculableandself.parametrized):print("Pump model is either not calculable or not parametrized.")self.solved=Falsereturntry:self.AS=CP.AbstractState('HEOS',self.su.fluid)"""PUMP MODEL"""# Calculate the outlet enthalpy based on isentropic efficiencyself.AS.update(CP.PSmass_INPUTS,self.ex.p,self.su.s)h_ex_is=self.AS.hmass()h_ex=self.su.h+(h_ex_is-self.su.h)/self.params['eta_is']w_pp=h_ex-self.su.hW_dot_pp=self.su.m_dot*w_pp"""Update connectors after the calculations"""self.update_connectors(h_ex,w_pp,W_dot_pp)# Mark the model as solved if successfulself.solved=TrueexceptExceptionase:# Handle any errors that occur during solvingself.solved=Falseprint(f"Convergence problem in pump model: {e}")defupdate_connectors(self,h_ex,w_pp,W_dot_pp):"""Update the connectors with the calculated values."""self.ex.set_h(h_ex)self.ex.set_fluid(self.su.fluid)self.ex.set_m_dot(self.su.m_dot)self.W.set_w(w_pp)self.W.set_W_dot(W_dot_pp)defprint_results(self):print("=== Pump Results ===")print(f" - h_ex: {self.ex.h} [J/kg]")print(f" - T_ex: {self.ex.T} [K]")print(f" - W_dot_pp: {self.W.W_dot} [W]")print("=========================")defprint_states_connectors(self):print("=== Pump States ===")print("Mass connectors:")print(f" - su: fluid={self.su.fluid}, T={self.su.T} [K], p={self.su.p} [Pa], h={self.su.h} [J/kg], s={self.su.s} [J/K.kg], m_dot={self.su.m_dot} [kg/s]")print(f" - ex: fluid={self.ex.fluid}, T={self.ex.T} [K], p={self.ex.p} [Pa], h={self.ex.h} [J/kg], s={self.ex.s} [J/K.kg], m_dot={self.ex.m_dot} [kg/s]")print("=========================")print("Work connector:")print(f" - W_dot_pp: {self.W.W_dot} [W]")print("=========================")