Mass Connector

The MassConnector class links components by transferring mass flow and thermodynamic properties between them. If two thermodynamic properties are provided, the class automatically calculates the remaining properties.

The class has two key flags:

  • state_known: This boolean flag indicates whether all thermodynamic properties are known.

  • state_completely_known: This boolean flag indicates whether both the mass flow rate and all thermodynamic properties are known.

Connectors description.
class connector.mass_connector.MassConnector(fluid=None)[source]

MassConnector is a class that handle and calculate fluid properties based on given state variables.

Attributes:

fluidstr, optional

The name of the fluid.

m_dotfloat, optional

Mass flow rate in kg/s.

V_dotfloat, optional

Volume flow rate in m^3/s.

Tfloat, optional

Temperature in Kelvin.

pfloat, optional

Pressure in Pascal.

hfloat, optional

Specific enthalpy in J/kg.

sfloat, optional

Specific entropy in J/kg/K.

Dfloat, optional

Mass density in kg/m^3.

xfloat, optional

Quality in kg/kg.

cpfloat, optional

Specific heat capacity in J/kg/K.

SCfloat, optional

Subcooling in K.

SHfloat, optional

Superheating in K.

completely_knownbool

True if all properties and mass flow rate are known, otherwise False.

state_knownbool

True if all state properties are known, otherwise False.

variables_inputlist of lists

A list of the state variables used to define the fluid state. Each entry is a list of [variable_name, value].

Methods:

__init__(self, fluid=None):

Initializes the MassConnector object with optional fluid.

reset(self):

Resets all properties to None and flags to False.

check_completely_known(self):

Checks if all necessary properties and mass flow rate are known to determine if the state is completely known.

calculate_properties(self):

Calculates fluid properties using CoolProp based on known variables.

set_properties(self, kwargs):

Sets various properties of the fluid. Accepts named arguments for ‘fluid’, ‘m_dot’, ‘V_dot’, ‘T’, ‘P’, ‘H’, ‘S’, ‘D’, ‘x’, and ‘cp’.

set_fluid(self, value):

Sets the fluid type and checks if it’s valid.

set_m_dot(self, value):

Sets the mass flow rate and ensures volume flow rate is not set simultaneously.

set_V_dot(self, value):

Sets the volume flow rate and ensures mass flow rate is not set simultaneously.

set_T(self, value):

Sets the temperature and updates the list of known variables.

set_p(self, value):

Sets the pressure and updates the list of known variables.

set_h(self, value):

Sets the specific enthalpy and updates the list of known variables.

set_s(self, value):

Sets the specific entropy and updates the list of known variables.

set_D(self, value):

Sets the mass density and updates the list of known variables.

set_x(self, value):

Sets the quality and updates the list of known variables.

set_cp(self, value):

Sets the specific heat capacity without calculating other properties.

set_SC(self, value):

Sets the subcooling and updates the list of known variables.

set_SH(self, value):

Sets the superheating and updates the list of known variables.

print_resume(self, unit_T=’K’, unit_p=’Pa’):

Prints a summary of the current properties in specified units.

Exceptions:

ValueError

Raised if an unsupported fluid name is used or if required variables for property calculation are missing.

Example of usage

You can see an interactive example in the following notebook: