aspen_pysys.model.unit_operation
Package containing all Pythonic functionality for HYSYS unit operations.
1# Copyright 2026 Hariidaran Tamilmaran 2 3"""Package containing all Pythonic functionality for HYSYS unit operations.""" 4 5from aspen_pysys.model.unit_operation.operation import HysysUnitOperation 6from aspen_pysys.model.unit_operation.operation_type import ( 7 HysysUnitOpType, 8) 9from aspen_pysys.model.unit_operation.types.adjust import HysysAdjust 10from aspen_pysys.model.unit_operation.types.component_splitter import ( 11 HysysComponentSplitter, 12) 13from aspen_pysys.model.unit_operation.types.compressor import HysysCompressor 14from aspen_pysys.model.unit_operation.types.control_valve import HysysControlValve 15from aspen_pysys.model.unit_operation.types.conversion_reactor import ( 16 HysysConversionReactor, 17) 18from aspen_pysys.model.unit_operation.types.cooler import HysysCooler 19from aspen_pysys.model.unit_operation.types.distillation_column import ( 20 HysysDistillationColumn, 21) 22from aspen_pysys.model.unit_operation.types.fired_heater import HysysFiredHeater 23from aspen_pysys.model.unit_operation.types.heat_exchanger import ( 24 HysysHeatExchanger, 25) 26from aspen_pysys.model.unit_operation.types.heater import HysysHeater 27from aspen_pysys.model.unit_operation.types.mixer import HysysMixer 28from aspen_pysys.model.unit_operation.types.pump import HysysPump 29from aspen_pysys.model.unit_operation.types.recycle import HysysRecycle 30from aspen_pysys.model.unit_operation.types.set import HysysSet 31from aspen_pysys.model.unit_operation.types.shortcut_column import ( 32 HysysShortcutColumn, 33) 34from aspen_pysys.model.unit_operation.types.spreadsheet import HysysSpreadsheet 35from aspen_pysys.model.unit_operation.types.stream_cutter import HysysStreamCutter 36from aspen_pysys.model.unit_operation.types.tee import HysysTee 37 38__all__ = [ 39 "HysysAdjust", 40 "HysysComponentSplitter", 41 "HysysCompressor", 42 "HysysControlValve", 43 "HysysConversionReactor", 44 "HysysCooler", 45 "HysysDistillationColumn", 46 "HysysFiredHeater", 47 "HysysHeatExchanger", 48 "HysysHeater", 49 "HysysMixer", 50 "HysysPump", 51 "HysysRecycle", 52 "HysysSet", 53 "HysysShortcutColumn", 54 "HysysSpreadsheet", 55 "HysysStreamCutter", 56 "HysysTee", 57 "HysysUnitOpType", 58 "HysysUnitOperation", 59]
16class HysysAdjust(HysysUnitOperation): 17 """Class that represents a Adjust model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.ADJUST) 21 22 def get_target_value(self) -> float: 23 """Get the target value. 24 25 Returns: 26 float: Target value 27 """ 28 return self.get_float("TargetValue") 29 30 def set_target_value(self, value: float) -> None: 31 """Set the target value. 32 33 Args: 34 value (float): New value 35 """ 36 self.set_float("TargetValue", value) 37 38 def get_tolerance(self) -> float: 39 """Get the tolerance value. 40 41 Returns: 42 float: Tolerance value 43 """ 44 return self.get_float("Tolerance") 45 46 def set_tolerance(self, value: float) -> None: 47 """Set the tolerance value. 48 49 Args: 50 value (float): New value 51 """ 52 self.set_float("Tolerance", value) 53 54 def get_step_size(self) -> float: 55 """Get the step size. 56 57 Returns: 58 float: Step size 59 """ 60 return self.get_float("StepSize") 61 62 def set_step_size(self, value: float) -> None: 63 """Set the step size. 64 65 Args: 66 value (float): New value 67 """ 68 self.set_float("StepSize", value) 69 70 def get_max_iterations(self) -> int: 71 """Get the maximum number of iterations. 72 73 Returns: 74 float: Maximum number of iterations 75 """ 76 return int(self.get_float("MaximumIterations")) 77 78 def set_max_iterations(self, value: int) -> None: 79 """Set the maximum number of iterations. 80 81 Args: 82 value (float): New value 83 """ 84 self.set_float("MaximumIterations", float(value))
Class that represents a Adjust model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.ADJUST)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
22 def get_target_value(self) -> float: 23 """Get the target value. 24 25 Returns: 26 float: Target value 27 """ 28 return self.get_float("TargetValue")
Get the target value.
Returns:
float: Target value
30 def set_target_value(self, value: float) -> None: 31 """Set the target value. 32 33 Args: 34 value (float): New value 35 """ 36 self.set_float("TargetValue", value)
Set the target value.
Arguments:
- value (float): New value
38 def get_tolerance(self) -> float: 39 """Get the tolerance value. 40 41 Returns: 42 float: Tolerance value 43 """ 44 return self.get_float("Tolerance")
Get the tolerance value.
Returns:
float: Tolerance value
46 def set_tolerance(self, value: float) -> None: 47 """Set the tolerance value. 48 49 Args: 50 value (float): New value 51 """ 52 self.set_float("Tolerance", value)
Set the tolerance value.
Arguments:
- value (float): New value
54 def get_step_size(self) -> float: 55 """Get the step size. 56 57 Returns: 58 float: Step size 59 """ 60 return self.get_float("StepSize")
Get the step size.
Returns:
float: Step size
62 def set_step_size(self, value: float) -> None: 63 """Set the step size. 64 65 Args: 66 value (float): New value 67 """ 68 self.set_float("StepSize", value)
Set the step size.
Arguments:
- value (float): New value
70 def get_max_iterations(self) -> int: 71 """Get the maximum number of iterations. 72 73 Returns: 74 float: Maximum number of iterations 75 """ 76 return int(self.get_float("MaximumIterations"))
Get the maximum number of iterations.
Returns:
float: Maximum number of iterations
78 def set_max_iterations(self, value: int) -> None: 79 """Set the maximum number of iterations. 80 81 Args: 82 value (float): New value 83 """ 84 self.set_float("MaximumIterations", float(value))
Set the maximum number of iterations.
Arguments:
- value (float): New value
20class HysysComponentSplitter(HysysUnitOperation): 21 """Class that represents a Component Splitter model from the HYSYS app.""" 22 23 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 24 super().__init__(connection, obj, HysysUnitOpType.COMPONENT_SPLITTER) 25 26 def get_inlets(self) -> HysysDictionary[HysysMaterialStream]: 27 """Get the inlets. 28 29 Returns: 30 HysysDictionary[HysysMaterialStream]: Inlets 31 """ 32 return ( 33 self.get_dict("Inlets") 34 .map(HysysNamedObject.from_obj) 35 .map(HysysModel.FACTORY.get_material_stream) 36 ) 37 38 def get_overhead_outlets(self) -> HysysDictionary[HysysMaterialStream]: 39 """Get the overhead outlets. 40 41 Returns: 42 HysysDictionary[HysysMaterialStream]: Overhead outlets 43 """ 44 return ( 45 self.get_dict("OverheadOutlets") 46 .map(HysysNamedObject.from_obj) 47 .map(HysysModel.FACTORY.get_material_stream) 48 ) 49 50 def get_bottoms_outlet(self) -> HysysMaterialStream: 51 """Get the bottoms outlet. 52 53 Returns: 54 HysysMaterialStream: Bottoms outlet 55 """ 56 return HysysModel.FACTORY.get_material_stream( 57 self.get_named_obj("BottomOutlets") 58 ) 59 60 def get_energy_inlets(self) -> HysysDictionary[HysysEnergyStream]: 61 """Get the energy inlets. 62 63 Returns: 64 HysysDictionary[HysysEnergyStream]: Energy inlets 65 """ 66 return ( 67 self.get_dict("EnergyInlets") 68 .map(HysysNamedObject.from_obj) 69 .map(HysysModel.FACTORY.get_energy_stream) 70 ) 71 72 def get_split_basis(self) -> HysysArray: 73 """Get the split basis. 74 75 Returns: 76 HysysArray: Split basis 77 """ 78 return self.get_array("SplitBasis") 79 80 def get_split_type(self) -> HysysArray: 81 """Get the split type. 82 83 Returns: 84 HysysArray: Split type 85 """ 86 return self.get_array("SplitType")
Class that represents a Component Splitter model from the HYSYS app.
23 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 24 super().__init__(connection, obj, HysysUnitOpType.COMPONENT_SPLITTER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
26 def get_inlets(self) -> HysysDictionary[HysysMaterialStream]: 27 """Get the inlets. 28 29 Returns: 30 HysysDictionary[HysysMaterialStream]: Inlets 31 """ 32 return ( 33 self.get_dict("Inlets") 34 .map(HysysNamedObject.from_obj) 35 .map(HysysModel.FACTORY.get_material_stream) 36 )
Get the inlets.
Returns:
HysysDictionary[HysysMaterialStream]: Inlets
38 def get_overhead_outlets(self) -> HysysDictionary[HysysMaterialStream]: 39 """Get the overhead outlets. 40 41 Returns: 42 HysysDictionary[HysysMaterialStream]: Overhead outlets 43 """ 44 return ( 45 self.get_dict("OverheadOutlets") 46 .map(HysysNamedObject.from_obj) 47 .map(HysysModel.FACTORY.get_material_stream) 48 )
Get the overhead outlets.
Returns:
HysysDictionary[HysysMaterialStream]: Overhead outlets
50 def get_bottoms_outlet(self) -> HysysMaterialStream: 51 """Get the bottoms outlet. 52 53 Returns: 54 HysysMaterialStream: Bottoms outlet 55 """ 56 return HysysModel.FACTORY.get_material_stream( 57 self.get_named_obj("BottomOutlets") 58 )
Get the bottoms outlet.
Returns:
HysysMaterialStream: Bottoms outlet
60 def get_energy_inlets(self) -> HysysDictionary[HysysEnergyStream]: 61 """Get the energy inlets. 62 63 Returns: 64 HysysDictionary[HysysEnergyStream]: Energy inlets 65 """ 66 return ( 67 self.get_dict("EnergyInlets") 68 .map(HysysNamedObject.from_obj) 69 .map(HysysModel.FACTORY.get_energy_stream) 70 )
Get the energy inlets.
Returns:
HysysDictionary[HysysEnergyStream]: Energy inlets
21class HysysCompressor( 22 FeedStreamGetterMixin, 23 ProductStreamGetterMixin, 24 EnergyStreamGetterMixin, 25 HysysUnitOperation, 26): 27 """Class that represents a Compressor model from the HYSYS app.""" 28 29 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 30 super().__init__(connection, obj, HysysUnitOpType.COMPRESSOR) 31 32 def get_delta_pressure(self) -> float: 33 """Get the pressure difference. 34 35 Returns: 36 float: Pressure difference 37 """ 38 return self.get_float("DeltaP") 39 40 def get_delta_temperature(self) -> float: 41 """Get the temperature difference. 42 43 Returns: 44 float: Temperature difference 45 """ 46 return self.get_float("DeltaT") 47 48 def get_duty(self) -> float: 49 """Get the duty. 50 51 Returns: 52 float: Duty 53 """ 54 return self.get_energy_stream().heat_flow()
Class that represents a Compressor model from the HYSYS app.
29 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 30 super().__init__(connection, obj, HysysUnitOpType.COMPRESSOR)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
32 def get_delta_pressure(self) -> float: 33 """Get the pressure difference. 34 35 Returns: 36 float: Pressure difference 37 """ 38 return self.get_float("DeltaP")
Get the pressure difference.
Returns:
float: Pressure difference
21class HysysControlValve( 22 FeedStreamGetterMixin, 23 ProductStreamGetterMixin, 24 HysysUnitOperation, 25): 26 """Class that represents a Control Valve model from the HYSYS app.""" 27 28 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 29 super().__init__(connection, obj, HysysUnitOpType.CONTROL_VALVE) 30 31 def get_pressure_drop(self) -> float: 32 """Get the pressure drop. 33 34 Returns: 35 float: Pressure drop. 36 """ 37 return self.get_float("PressureDrop") 38 39 def has_backflow(self) -> bool: 40 """Check if the valve has backflow. 41 42 Returns: 43 bool: If the valve has backflow 44 """ 45 return is_negative(self.get_pressure_drop()) 46 47 def has_no_pressure_drop(self) -> bool: 48 """Check if the valve has zero pressure drop. 49 50 Returns: 51 bool: If the valve has zero pressure drop 52 """ 53 return is_zero(self.get_pressure_drop())
Class that represents a Control Valve model from the HYSYS app.
28 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 29 super().__init__(connection, obj, HysysUnitOpType.CONTROL_VALVE)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
31 def get_pressure_drop(self) -> float: 32 """Get the pressure drop. 33 34 Returns: 35 float: Pressure drop. 36 """ 37 return self.get_float("PressureDrop")
Get the pressure drop.
Returns:
float: Pressure drop.
39 def has_backflow(self) -> bool: 40 """Check if the valve has backflow. 41 42 Returns: 43 bool: If the valve has backflow 44 """ 45 return is_negative(self.get_pressure_drop())
Check if the valve has backflow.
Returns:
bool: If the valve has backflow
47 def has_no_pressure_drop(self) -> bool: 48 """Check if the valve has zero pressure drop. 49 50 Returns: 51 bool: If the valve has zero pressure drop 52 """ 53 return is_zero(self.get_pressure_drop())
Check if the valve has zero pressure drop.
Returns:
bool: If the valve has zero pressure drop
16class HysysConversionReactor(HysysUnitOperation): 17 """Class that represents a Conversion Reactor model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.CONVERSION_REACTOR)
Class that represents a Conversion Reactor model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.CONVERSION_REACTOR)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
17class HysysCooler(HysysUnitOperation): 18 """Class that represents a Cooler model from the HYSYS app.""" 19 20 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 21 super().__init__(connection, obj, HysysUnitOpType.COOLER) 22 23 def get_delta_temperature(self) -> float: 24 """Get the temperature difference. 25 26 Returns: 27 float: Temperature difference 28 """ 29 return self.get_float("DeltaT") 30 31 def has_temperature_decrease(self) -> float: 32 """Check if the temperature decreases across the cooler. 33 34 Returns: 35 bool: If the temperature decreases 36 """ 37 return is_negative(self.get_delta_temperature())
Class that represents a Cooler model from the HYSYS app.
20 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 21 super().__init__(connection, obj, HysysUnitOpType.COOLER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
23 def get_delta_temperature(self) -> float: 24 """Get the temperature difference. 25 26 Returns: 27 float: Temperature difference 28 """ 29 return self.get_float("DeltaT")
Get the temperature difference.
Returns:
float: Temperature difference
31 def has_temperature_decrease(self) -> float: 32 """Check if the temperature decreases across the cooler. 33 34 Returns: 35 bool: If the temperature decreases 36 """ 37 return is_negative(self.get_delta_temperature())
Check if the temperature decreases across the cooler.
Returns:
bool: If the temperature decreases
26class HysysDistillationColumn(HysysUnitOperation): 27 """Class that represents a Distillation Column model from the HYSYS app.""" 28 29 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 30 super().__init__(connection, obj, HysysUnitOpType.DISTILLATION_COLUMN) 31 32 def _get_flowsheet(self) -> HysysObject: 33 return self.get_obj("ColumnFlowsheet") 34 35 def _get_operations(self) -> HysysDictionary: 36 return self._get_flowsheet().get_dict("Operations") 37 38 def _get_main_tower(self) -> HysysNamedObject: 39 return HysysNamedObject( 40 self.get_connection(), 41 self._get_operations().get("Main Tower"), 42 ) 43 44 def _get_condenser(self) -> HysysObject: 45 return self._get_operations().get("Condenser") 46 47 def _get_reboiler(self) -> HysysObject: 48 return self._get_operations().get("Reboiler") 49 50 def get_condenser_pressure(self) -> float: 51 """Get the condenser pressure. 52 53 Returns: 54 float: Condenser pressure 55 """ 56 return self._get_condenser().get_float("VesselPressure") 57 58 def get_condenser_duty(self) -> float: 59 """Get the condenser duty. 60 61 Returns: 62 float: Condenser duty 63 """ 64 return self._get_condenser().get_float("HeatFlow") 65 66 def get_reboiler_pressure(self) -> float: 67 """Get the reboiler pressure. 68 69 Returns: 70 float: Reboiler pressure 71 """ 72 return self._get_reboiler().get_float("VesselPressure") 73 74 def get_reboiler_duty(self) -> float: 75 """Get the reboiler duty. 76 77 Returns: 78 float: Reboiler duty 79 """ 80 return self._get_reboiler().get_float("HeatFlow") 81 82 def get_pressure_diff(self) -> float: 83 """Get the pressure difference between the reboiler and the condenser. 84 85 Returns: 86 float: Pressure difference 87 """ 88 return self.get_reboiler_pressure() - self.get_condenser_pressure() 89 90 def is_converged(self) -> bool: 91 """Check if the column has converged. 92 93 Returns: 94 bool: If the column has converged. 95 """ 96 return self._get_flowsheet().get_bool("CfsConverged") 97 98 def run(self, max_iterations: int = 10000) -> None: 99 """Run the column. 100 101 Args: 102 max_iterations (int, optional): Maximum number of iterations. Defaults to 10000. 103 """ # noqa: E501 104 self._get_flowsheet().set_attr("MaximumIterations", max_iterations) 105 106 run_func = self._get_flowsheet().get_func("Run") 107 run_func.call() 108 109 def reset(self) -> None: 110 """Reset the column flowsheet.""" 111 func = self._get_flowsheet().get_func("Reset") 112 func.call() 113 114 def get_attached_material_feeds(self) -> dict[str, HysysMaterialStream]: 115 return { 116 key: HysysModel.FACTORY.get_material_stream(value) 117 for key, value in ( 118 self.get_attached_feeds() 119 .map(HysysNamedObject.from_obj) 120 .map(HysysModel.FACTORY.get_process_stream) 121 .filter( 122 lambda _, stream: ( 123 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 124 ), 125 ) 126 .items() 127 ) 128 } 129 130 def get_feed_streams(self) -> dict[str, HysysMaterialStream]: 131 return { 132 key: HysysModel.FACTORY.get_material_stream(value) 133 for key, value in ( 134 self._get_flowsheet() 135 .get_dict("FeedStreams") 136 .map(HysysNamedObject.from_obj) 137 .map(HysysModel.FACTORY.get_process_stream) 138 .filter( 139 lambda _, stream: ( 140 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 141 ), 142 ) 143 .items() 144 ) 145 } 146 147 def specify_feed_location(self, feed: str | HysysObject, tray: int) -> None: 148 if isinstance(feed, str): 149 feed_obj = self.get_feed_streams().get(feed) 150 151 if feed_obj is None: 152 message = f"Feed stream named '{feed}' does not exist." 153 raise PysysError(message) 154 155 feed = feed_obj 156 157 with feed as feed_com_obj: 158 func = self._get_main_tower().get_func("SpecifyFeedLocation") 159 func.call(feed_com_obj, tray) 160 161 def add_material_feed(self, feed_name: str, tray: int) -> None: 162 """Add a feed stream. 163 164 Args: 165 feed_name (str): Stream name 166 tray (int): Tray number 167 """ 168 self._get_main_tower().get_func("AddFeedStream").call(feed_name, tray, False) # noqa: FBT003 169 170 def _confirm_main_and_subflowsheet_feeds_match(self) -> None: 171 flowsheet_feed_names: set[str] = set(self.get_attached_material_feeds().keys()) 172 subflowsheet_feed_names: set[str] = set(self.get_feed_streams().keys()) 173 174 if flowsheet_feed_names != subflowsheet_feed_names: 175 flowsheet_feed_names_str = ", ".join(flowsheet_feed_names) 176 subflowsheet_feed_names_str = ", ".join(subflowsheet_feed_names) 177 178 error_message = ( 179 "Feed trays cannot be identified, possibly due to " 180 "a mismatch in stream names between the main and column flowsheets." 181 f"\nMain = {flowsheet_feed_names_str}" 182 f", Column = {subflowsheet_feed_names_str}." 183 ) 184 185 raise PysysError(error_message) 186 187 def get_feed_trays(self) -> dict[str, int]: 188 self._confirm_main_and_subflowsheet_feeds_match() 189 190 feed_trays_hysys_dict = self._get_main_tower().get_dict("FeedStages") 191 feed_trays_dict: dict[str, int] = {} 192 193 for key in feed_trays_hysys_dict: 194 feed_tray = feed_trays_hysys_dict.get(key) 195 streams_at_feed_tray = feed_tray.get_dict("FeedStreams") 196 197 if len(streams_at_feed_tray) == 0: 198 continue 199 200 feed_tray_number = feed_tray.get_int("IFaceStageNumber") 201 202 for stream_name in streams_at_feed_tray: 203 feed_trays_dict.update({stream_name: feed_tray_number}) 204 205 return feed_trays_dict 206 207 def get_tray_count(self) -> int: 208 """Get the tray count. 209 210 Returns: 211 int: Tray count 212 """ 213 return int(self._get_main_tower().get_float("NumberOfTrays")) 214 215 def set_tray_count(self, count: int) -> None: 216 """Set the tray count. 217 218 Args: 219 count (int): New value 220 221 Raises: 222 PysysError: Tray count is lesser than 3. 223 """ 224 if count < MIN_TRAY_COUNT: 225 message = "Tray count must not be lesser than 3." 226 raise PysysError(message) 227 228 self._get_main_tower().set_float("NumberOfTrays", count) 229 230 def get_current_iteration(self) -> int: 231 """Get the number of finished iterations. 232 233 Returns: 234 int: Current iteration 235 """ 236 return self._get_flowsheet().get_int("CurrentIteration") - 1 237 238 def _get_column_trays(self) -> HysysDictionary: 239 return self._get_flowsheet().get_dict("ColumnStages") 240 241 def _get_separation_tray(self, position: int) -> HysysObject: 242 main_tower_name = self._get_main_tower().get_name() 243 tray_name = f"{position}__{main_tower_name}" 244 245 return self._get_column_trays().get(tray_name).get_obj("SeparationStage")
Class that represents a Distillation Column model from the HYSYS app.
29 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 30 super().__init__(connection, obj, HysysUnitOpType.DISTILLATION_COLUMN)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
50 def get_condenser_pressure(self) -> float: 51 """Get the condenser pressure. 52 53 Returns: 54 float: Condenser pressure 55 """ 56 return self._get_condenser().get_float("VesselPressure")
Get the condenser pressure.
Returns:
float: Condenser pressure
58 def get_condenser_duty(self) -> float: 59 """Get the condenser duty. 60 61 Returns: 62 float: Condenser duty 63 """ 64 return self._get_condenser().get_float("HeatFlow")
Get the condenser duty.
Returns:
float: Condenser duty
66 def get_reboiler_pressure(self) -> float: 67 """Get the reboiler pressure. 68 69 Returns: 70 float: Reboiler pressure 71 """ 72 return self._get_reboiler().get_float("VesselPressure")
Get the reboiler pressure.
Returns:
float: Reboiler pressure
74 def get_reboiler_duty(self) -> float: 75 """Get the reboiler duty. 76 77 Returns: 78 float: Reboiler duty 79 """ 80 return self._get_reboiler().get_float("HeatFlow")
Get the reboiler duty.
Returns:
float: Reboiler duty
82 def get_pressure_diff(self) -> float: 83 """Get the pressure difference between the reboiler and the condenser. 84 85 Returns: 86 float: Pressure difference 87 """ 88 return self.get_reboiler_pressure() - self.get_condenser_pressure()
Get the pressure difference between the reboiler and the condenser.
Returns:
float: Pressure difference
90 def is_converged(self) -> bool: 91 """Check if the column has converged. 92 93 Returns: 94 bool: If the column has converged. 95 """ 96 return self._get_flowsheet().get_bool("CfsConverged")
Check if the column has converged.
Returns:
bool: If the column has converged.
98 def run(self, max_iterations: int = 10000) -> None: 99 """Run the column. 100 101 Args: 102 max_iterations (int, optional): Maximum number of iterations. Defaults to 10000. 103 """ # noqa: E501 104 self._get_flowsheet().set_attr("MaximumIterations", max_iterations) 105 106 run_func = self._get_flowsheet().get_func("Run") 107 run_func.call()
Run the column.
Arguments:
- max_iterations (int, optional): Maximum number of iterations. Defaults to 10000.
109 def reset(self) -> None: 110 """Reset the column flowsheet.""" 111 func = self._get_flowsheet().get_func("Reset") 112 func.call()
Reset the column flowsheet.
114 def get_attached_material_feeds(self) -> dict[str, HysysMaterialStream]: 115 return { 116 key: HysysModel.FACTORY.get_material_stream(value) 117 for key, value in ( 118 self.get_attached_feeds() 119 .map(HysysNamedObject.from_obj) 120 .map(HysysModel.FACTORY.get_process_stream) 121 .filter( 122 lambda _, stream: ( 123 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 124 ), 125 ) 126 .items() 127 ) 128 }
130 def get_feed_streams(self) -> dict[str, HysysMaterialStream]: 131 return { 132 key: HysysModel.FACTORY.get_material_stream(value) 133 for key, value in ( 134 self._get_flowsheet() 135 .get_dict("FeedStreams") 136 .map(HysysNamedObject.from_obj) 137 .map(HysysModel.FACTORY.get_process_stream) 138 .filter( 139 lambda _, stream: ( 140 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 141 ), 142 ) 143 .items() 144 ) 145 }
147 def specify_feed_location(self, feed: str | HysysObject, tray: int) -> None: 148 if isinstance(feed, str): 149 feed_obj = self.get_feed_streams().get(feed) 150 151 if feed_obj is None: 152 message = f"Feed stream named '{feed}' does not exist." 153 raise PysysError(message) 154 155 feed = feed_obj 156 157 with feed as feed_com_obj: 158 func = self._get_main_tower().get_func("SpecifyFeedLocation") 159 func.call(feed_com_obj, tray)
161 def add_material_feed(self, feed_name: str, tray: int) -> None: 162 """Add a feed stream. 163 164 Args: 165 feed_name (str): Stream name 166 tray (int): Tray number 167 """ 168 self._get_main_tower().get_func("AddFeedStream").call(feed_name, tray, False) # noqa: FBT003
Add a feed stream.
Arguments:
- feed_name (str): Stream name
- tray (int): Tray number
187 def get_feed_trays(self) -> dict[str, int]: 188 self._confirm_main_and_subflowsheet_feeds_match() 189 190 feed_trays_hysys_dict = self._get_main_tower().get_dict("FeedStages") 191 feed_trays_dict: dict[str, int] = {} 192 193 for key in feed_trays_hysys_dict: 194 feed_tray = feed_trays_hysys_dict.get(key) 195 streams_at_feed_tray = feed_tray.get_dict("FeedStreams") 196 197 if len(streams_at_feed_tray) == 0: 198 continue 199 200 feed_tray_number = feed_tray.get_int("IFaceStageNumber") 201 202 for stream_name in streams_at_feed_tray: 203 feed_trays_dict.update({stream_name: feed_tray_number}) 204 205 return feed_trays_dict
207 def get_tray_count(self) -> int: 208 """Get the tray count. 209 210 Returns: 211 int: Tray count 212 """ 213 return int(self._get_main_tower().get_float("NumberOfTrays"))
Get the tray count.
Returns:
int: Tray count
215 def set_tray_count(self, count: int) -> None: 216 """Set the tray count. 217 218 Args: 219 count (int): New value 220 221 Raises: 222 PysysError: Tray count is lesser than 3. 223 """ 224 if count < MIN_TRAY_COUNT: 225 message = "Tray count must not be lesser than 3." 226 raise PysysError(message) 227 228 self._get_main_tower().set_float("NumberOfTrays", count)
Set the tray count.
Arguments:
- count (int): New value
Raises:
- PysysError: Tray count is lesser than 3.
230 def get_current_iteration(self) -> int: 231 """Get the number of finished iterations. 232 233 Returns: 234 int: Current iteration 235 """ 236 return self._get_flowsheet().get_int("CurrentIteration") - 1
Get the number of finished iterations.
Returns:
int: Current iteration
16class HysysFiredHeater(HysysUnitOperation): 17 """Class that represents a Fired Heater model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.FIRED_HEATER)
Class that represents a Fired Heater model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.FIRED_HEATER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
23class HysysHeatExchanger(HysysUnitOperation): 24 """Class that represents a Heat Exchanger model from the HYSYS app.""" 25 26 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 27 super().__init__(connection, obj, HysysUnitOpType.HEAT_EXCHANGER) 28 29 @override 30 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super() 33 .get_attached_feeds() 34 .map( 35 HysysModel.FACTORY.get_material_stream, 36 ) 37 ) 38 39 @override 40 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 41 return ( 42 super() 43 .get_attached_products() 44 .map( 45 HysysModel.FACTORY.get_material_stream, 46 ) 47 ) 48 49 def get_duty(self) -> float: 50 """Get the duty. 51 52 Returns: 53 float: Duty 54 """ 55 return self.get_float("Duty") 56 57 def get_lmtd(self) -> float: 58 """Get the log mean temperature difference (LMTD). 59 60 Returns: 61 float: LMTD 62 """ 63 return self.get_float("LMTD") 64 65 def get_tube_side_feed(self) -> HysysMaterialStream: 66 """Get the tube side's feed stream. 67 68 Returns: 69 HysysMaterialStream: Tube side's feed stream 70 """ 71 return HysysModel.FACTORY.get_material_stream( 72 self.get_named_obj("TubeSideFeed") 73 ) 74 75 def get_tube_side_product(self) -> HysysMaterialStream: 76 """Get the tube side's product stream. 77 78 Returns: 79 HysysMaterialStream: Tube side's product stream 80 """ 81 return HysysModel.FACTORY.get_material_stream( 82 self.get_named_obj("TubeSideProduct") 83 ) 84 85 def get_shell_side_feed(self) -> HysysMaterialStream: 86 """Get the shell side's feed stream. 87 88 Returns: 89 HysysMaterialStream: Shell side's feed stream 90 """ 91 return HysysModel.FACTORY.get_material_stream( 92 self.get_named_obj("ShellSideFeed") 93 ) 94 95 def get_shell_side_product(self) -> HysysMaterialStream: 96 """Get the shell side's product stream. 97 98 Returns: 99 HysysMaterialStream: Shell side's product stream 100 """ 101 return HysysModel.FACTORY.get_material_stream( 102 self.get_named_obj("ShellSideProduct") 103 ) 104 105 def is_tube_side_hot(self) -> bool: 106 """Check if the tube side is the hot side. 107 108 Returns: 109 bool: If the tube side is the hot side 110 """ 111 tube_side_feed_temp = self.get_tube_side_feed().get_temperature() 112 tube_side_product_temp = self.get_tube_side_product().get_temperature() 113 114 return tube_side_feed_temp > tube_side_product_temp 115 116 def get_tube_heat_transf_coef(self) -> float: 117 """Get the tube side's heat transfer coefficient. 118 119 Returns: 120 float: Tube side's heat transfer coefficient. 121 """ 122 return self.get_float("TubeHeatTransferCoef") 123 124 def set_tube_heat_transf_coef(self, value: float) -> None: 125 """Set the tube side's heat transfer coefficient. 126 127 Args: 128 value (float): New value. 129 """ 130 return self.set_float("TubeHeatTransferCoef", value) 131 132 def get_shell_heat_transf_coef(self) -> float: 133 """Get the shell side's heat transfer coefficient. 134 135 Returns: 136 float: Shell side's heat transfer coefficient. 137 """ 138 return self.get_float("ShellHeatTransferCoef") 139 140 def set_shell_heat_transf_coef(self, value: float) -> None: 141 """Set the shell side's heat transfer coefficient. 142 143 Args: 144 value (float): New value. 145 """ 146 return self.set_float("ShellHeatTransferCoef", value) 147 148 def get_sides_dict(self) -> HysysHXSidesDict: 149 """Get a dictionary containing the hot and cold sides' feed and product streams. 150 151 Returns: 152 HysysHXSidesDict: Hot and cold sides' feed and product streams 153 """ 154 if self.is_tube_side_hot(): 155 return { 156 "Hot": (self.get_tube_side_feed(), self.get_tube_side_product()), 157 "Cold": (self.get_shell_side_feed(), self.get_shell_side_product()), 158 } 159 160 return { 161 "Hot": (self.get_shell_side_feed(), self.get_shell_side_product()), 162 "Cold": (self.get_tube_side_feed(), self.get_tube_side_product()), 163 }
Class that represents a Heat Exchanger model from the HYSYS app.
26 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 27 super().__init__(connection, obj, HysysUnitOpType.HEAT_EXCHANGER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
29 @override 30 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super() 33 .get_attached_feeds() 34 .map( 35 HysysModel.FACTORY.get_material_stream, 36 ) 37 )
Get the attached feeds.
Returns:
HysysDictionary[HysysProcessStream]: Attached feeds
39 @override 40 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 41 return ( 42 super() 43 .get_attached_products() 44 .map( 45 HysysModel.FACTORY.get_material_stream, 46 ) 47 )
Get the attached products.
Returns:
HysysDictionary[HysysProcessStream]: Attached products
49 def get_duty(self) -> float: 50 """Get the duty. 51 52 Returns: 53 float: Duty 54 """ 55 return self.get_float("Duty")
Get the duty.
Returns:
float: Duty
57 def get_lmtd(self) -> float: 58 """Get the log mean temperature difference (LMTD). 59 60 Returns: 61 float: LMTD 62 """ 63 return self.get_float("LMTD")
Get the log mean temperature difference (LMTD).
Returns:
float: LMTD
65 def get_tube_side_feed(self) -> HysysMaterialStream: 66 """Get the tube side's feed stream. 67 68 Returns: 69 HysysMaterialStream: Tube side's feed stream 70 """ 71 return HysysModel.FACTORY.get_material_stream( 72 self.get_named_obj("TubeSideFeed") 73 )
Get the tube side's feed stream.
Returns:
HysysMaterialStream: Tube side's feed stream
75 def get_tube_side_product(self) -> HysysMaterialStream: 76 """Get the tube side's product stream. 77 78 Returns: 79 HysysMaterialStream: Tube side's product stream 80 """ 81 return HysysModel.FACTORY.get_material_stream( 82 self.get_named_obj("TubeSideProduct") 83 )
Get the tube side's product stream.
Returns:
HysysMaterialStream: Tube side's product stream
85 def get_shell_side_feed(self) -> HysysMaterialStream: 86 """Get the shell side's feed stream. 87 88 Returns: 89 HysysMaterialStream: Shell side's feed stream 90 """ 91 return HysysModel.FACTORY.get_material_stream( 92 self.get_named_obj("ShellSideFeed") 93 )
Get the shell side's feed stream.
Returns:
HysysMaterialStream: Shell side's feed stream
95 def get_shell_side_product(self) -> HysysMaterialStream: 96 """Get the shell side's product stream. 97 98 Returns: 99 HysysMaterialStream: Shell side's product stream 100 """ 101 return HysysModel.FACTORY.get_material_stream( 102 self.get_named_obj("ShellSideProduct") 103 )
Get the shell side's product stream.
Returns:
HysysMaterialStream: Shell side's product stream
105 def is_tube_side_hot(self) -> bool: 106 """Check if the tube side is the hot side. 107 108 Returns: 109 bool: If the tube side is the hot side 110 """ 111 tube_side_feed_temp = self.get_tube_side_feed().get_temperature() 112 tube_side_product_temp = self.get_tube_side_product().get_temperature() 113 114 return tube_side_feed_temp > tube_side_product_temp
Check if the tube side is the hot side.
Returns:
bool: If the tube side is the hot side
116 def get_tube_heat_transf_coef(self) -> float: 117 """Get the tube side's heat transfer coefficient. 118 119 Returns: 120 float: Tube side's heat transfer coefficient. 121 """ 122 return self.get_float("TubeHeatTransferCoef")
Get the tube side's heat transfer coefficient.
Returns:
float: Tube side's heat transfer coefficient.
124 def set_tube_heat_transf_coef(self, value: float) -> None: 125 """Set the tube side's heat transfer coefficient. 126 127 Args: 128 value (float): New value. 129 """ 130 return self.set_float("TubeHeatTransferCoef", value)
Set the tube side's heat transfer coefficient.
Arguments:
- value (float): New value.
132 def get_shell_heat_transf_coef(self) -> float: 133 """Get the shell side's heat transfer coefficient. 134 135 Returns: 136 float: Shell side's heat transfer coefficient. 137 """ 138 return self.get_float("ShellHeatTransferCoef")
Get the shell side's heat transfer coefficient.
Returns:
float: Shell side's heat transfer coefficient.
140 def set_shell_heat_transf_coef(self, value: float) -> None: 141 """Set the shell side's heat transfer coefficient. 142 143 Args: 144 value (float): New value. 145 """ 146 return self.set_float("ShellHeatTransferCoef", value)
Set the shell side's heat transfer coefficient.
Arguments:
- value (float): New value.
148 def get_sides_dict(self) -> HysysHXSidesDict: 149 """Get a dictionary containing the hot and cold sides' feed and product streams. 150 151 Returns: 152 HysysHXSidesDict: Hot and cold sides' feed and product streams 153 """ 154 if self.is_tube_side_hot(): 155 return { 156 "Hot": (self.get_tube_side_feed(), self.get_tube_side_product()), 157 "Cold": (self.get_shell_side_feed(), self.get_shell_side_product()), 158 } 159 160 return { 161 "Hot": (self.get_shell_side_feed(), self.get_shell_side_product()), 162 "Cold": (self.get_tube_side_feed(), self.get_tube_side_product()), 163 }
Get a dictionary containing the hot and cold sides' feed and product streams.
Returns:
HysysHXSidesDict: Hot and cold sides' feed and product streams
17class HysysHeater(HysysUnitOperation): 18 """Class that represents a Heater model from the HYSYS app.""" 19 20 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 21 super().__init__(connection, obj, HysysUnitOpType.HEATER) 22 23 def get_delta_temperature(self) -> float: 24 """Get the temperature difference. 25 26 Returns: 27 float: Temperature difference 28 """ 29 return self.get_float("DeltaT") 30 31 def has_temperature_increase(self) -> bool: 32 """Check if the temperature increases across the heater. 33 34 Returns: 35 bool: If the temperature increases 36 """ 37 return is_positive(self.get_delta_temperature())
Class that represents a Heater model from the HYSYS app.
20 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 21 super().__init__(connection, obj, HysysUnitOpType.HEATER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
23 def get_delta_temperature(self) -> float: 24 """Get the temperature difference. 25 26 Returns: 27 float: Temperature difference 28 """ 29 return self.get_float("DeltaT")
Get the temperature difference.
Returns:
float: Temperature difference
31 def has_temperature_increase(self) -> bool: 32 """Check if the temperature increases across the heater. 33 34 Returns: 35 bool: If the temperature increases 36 """ 37 return is_positive(self.get_delta_temperature())
Check if the temperature increases across the heater.
Returns:
bool: If the temperature increases
19class HysysMixer(HysysUnitOperation): 20 """Class that represents a Mixer model from the HYSYS app.""" 21 22 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 23 super().__init__(connection, obj, HysysUnitOpType.MIXER) 24 25 @override 26 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 27 return super().get_attached_feeds().map(HysysModel.FACTORY.get_material_stream) 28 29 @override 30 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super().get_attached_products().map(HysysModel.FACTORY.get_material_stream) 33 )
Class that represents a Mixer model from the HYSYS app.
22 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 23 super().__init__(connection, obj, HysysUnitOpType.MIXER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
25 @override 26 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 27 return super().get_attached_feeds().map(HysysModel.FACTORY.get_material_stream)
Get the attached feeds.
Returns:
HysysDictionary[HysysProcessStream]: Attached feeds
29 @override 30 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super().get_attached_products().map(HysysModel.FACTORY.get_material_stream) 33 )
Get the attached products.
Returns:
HysysDictionary[HysysProcessStream]: Attached products
22class HysysPump( 23 FeedStreamGetterMixin, 24 ProductStreamGetterMixin, 25 EnergyStreamGetterMixin, 26 HysysUnitOperation, 27): 28 """Class that represents a Pump model from the HYSYS app.""" 29 30 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 31 super().__init__(connection, obj, HysysUnitOpType.PUMP) 32 33 def get_duty(self) -> float: 34 """Get the duty. 35 36 Returns: 37 float: Duty 38 """ 39 return self.get_work() 40 41 def get_work(self) -> float: 42 """Get the duty. 43 44 Returns: 45 float: Duty 46 """ 47 return self.get_float("Work") 48 49 def get_delta_pressure(self) -> float: 50 """Get the pressure difference. 51 52 Returns: 53 float: Pressure difference 54 """ 55 return self.get_float("Head") 56 57 def set_delta_pressure(self, value: float) -> None: 58 """Set the pressure difference. 59 60 Args: 61 value (float): New pressure difference 62 """ 63 self.set_float("Head", value) 64 65 def get_delta_temperature(self) -> float: 66 """Get the temperature difference. 67 68 Returns: 69 float: Temperature difference 70 """ 71 return self.get_float("DeltaT") 72 73 def has_vapour_in_inlet(self) -> bool: 74 """Check if the pump has vapour in its inlet stream. 75 76 Returns: 77 bool: Status 78 """ 79 inlet_vapour_frac = self.get_feed_stream().get_vapour_fraction() 80 return not is_zero(inlet_vapour_frac) 81 82 def has_negative_head(self) -> bool: 83 """Check if the pump has negative head. 84 85 Returns: 86 bool: Status 87 """ 88 return is_negative(self.get_delta_pressure())
Class that represents a Pump model from the HYSYS app.
30 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 31 super().__init__(connection, obj, HysysUnitOpType.PUMP)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
33 def get_duty(self) -> float: 34 """Get the duty. 35 36 Returns: 37 float: Duty 38 """ 39 return self.get_work()
Get the duty.
Returns:
float: Duty
41 def get_work(self) -> float: 42 """Get the duty. 43 44 Returns: 45 float: Duty 46 """ 47 return self.get_float("Work")
Get the duty.
Returns:
float: Duty
49 def get_delta_pressure(self) -> float: 50 """Get the pressure difference. 51 52 Returns: 53 float: Pressure difference 54 """ 55 return self.get_float("Head")
Get the pressure difference.
Returns:
float: Pressure difference
57 def set_delta_pressure(self, value: float) -> None: 58 """Set the pressure difference. 59 60 Args: 61 value (float): New pressure difference 62 """ 63 self.set_float("Head", value)
Set the pressure difference.
Arguments:
- value (float): New pressure difference
65 def get_delta_temperature(self) -> float: 66 """Get the temperature difference. 67 68 Returns: 69 float: Temperature difference 70 """ 71 return self.get_float("DeltaT")
Get the temperature difference.
Returns:
float: Temperature difference
73 def has_vapour_in_inlet(self) -> bool: 74 """Check if the pump has vapour in its inlet stream. 75 76 Returns: 77 bool: Status 78 """ 79 inlet_vapour_frac = self.get_feed_stream().get_vapour_fraction() 80 return not is_zero(inlet_vapour_frac)
Check if the pump has vapour in its inlet stream.
Returns:
bool: Status
20class HysysRecycle(FeedStreamGetterMixin, ProductStreamGetterMixin, HysysUnitOperation): 21 """Class that represents a Recycle model from the HYSYS app.""" 22 23 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 24 super().__init__(connection, obj, HysysUnitOpType.RECYCLE)
Class that represents a Recycle model from the HYSYS app.
23 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 24 super().__init__(connection, obj, HysysUnitOpType.RECYCLE)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
16class HysysSet(HysysUnitOperation): 17 """Class that represents a Set model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SET) 21 22 def get_multiplier(self) -> float: 23 """Get the multiplier. 24 25 Returns: 26 float: Multiplier 27 """ 28 return self.get_float("Multiplier") 29 30 def set_multiplier(self, value: float) -> None: 31 """Set the multiplier. 32 33 Args: 34 value (float): New multiplier 35 """ 36 self.set_float("Multiplier", value) 37 38 def get_offset(self) -> float: 39 """Get the offset. 40 41 Returns: 42 float: Offset 43 """ 44 return self.get_float("Offset") 45 46 def set_offset(self, value: float) -> None: 47 """Set the offset. 48 49 Args: 50 value (float): New offset 51 """ 52 self.set_float("Offset", value)
Class that represents a Set model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SET)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
22 def get_multiplier(self) -> float: 23 """Get the multiplier. 24 25 Returns: 26 float: Multiplier 27 """ 28 return self.get_float("Multiplier")
Get the multiplier.
Returns:
float: Multiplier
30 def set_multiplier(self, value: float) -> None: 31 """Set the multiplier. 32 33 Args: 34 value (float): New multiplier 35 """ 36 self.set_float("Multiplier", value)
Set the multiplier.
Arguments:
- value (float): New multiplier
16class HysysShortcutColumn(HysysUnitOperation): 17 """Class that represents a Shortcut Column model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SHORTCUT_COLUMN)
Class that represents a Shortcut Column model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SHORTCUT_COLUMN)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
16class HysysSpreadsheet(HysysUnitOperation): 17 """Class that represents a Spreadsheet model from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SPREADSHEET)
Class that represents a Spreadsheet model from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 super().__init__(connection, obj, HysysUnitOpType.SPREADSHEET)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
18class HysysStreamCutter(HysysUnitOperation): 19 """Class that represents a Stream Cutter model from the HYSYS app.""" 20 21 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 22 super().__init__(connection, obj, HysysUnitOpType.STREAM_CUTTER) 23 24 def get_inlet(self) -> HysysMaterialStream: 25 """Get the inlet stream. 26 27 Returns: 28 HysysMaterialStream: Inlet stream 29 """ 30 return HysysModel.FACTORY.get_material_stream(self.get_named_obj("Inlet")) 31 32 def get_outlet(self) -> HysysMaterialStream: 33 """Get the outlet stream. 34 35 Returns: 36 HysysMaterialStream: Outlet stream 37 """ 38 return HysysModel.FACTORY.get_material_stream(self.get_named_obj("Outlet"))
Class that represents a Stream Cutter model from the HYSYS app.
21 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 22 super().__init__(connection, obj, HysysUnitOpType.STREAM_CUTTER)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
24 def get_inlet(self) -> HysysMaterialStream: 25 """Get the inlet stream. 26 27 Returns: 28 HysysMaterialStream: Inlet stream 29 """ 30 return HysysModel.FACTORY.get_material_stream(self.get_named_obj("Inlet"))
Get the inlet stream.
Returns:
HysysMaterialStream: Inlet stream
19class HysysTee(HysysUnitOperation): 20 """Class that represents a Tee model from the HYSYS app.""" 21 22 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 23 super().__init__(connection, obj, HysysUnitOpType.TEE) 24 25 @override 26 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 27 return super().get_attached_feeds().map(HysysModel.FACTORY.get_material_stream) 28 29 @override 30 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super().get_attached_products().map(HysysModel.FACTORY.get_material_stream) 33 )
Class that represents a Tee model from the HYSYS app.
22 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 23 super().__init__(connection, obj, HysysUnitOpType.TEE)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
25 @override 26 def get_attached_feeds(self) -> HysysDictionary[HysysMaterialStream]: 27 return super().get_attached_feeds().map(HysysModel.FACTORY.get_material_stream)
Get the attached feeds.
Returns:
HysysDictionary[HysysProcessStream]: Attached feeds
29 @override 30 def get_attached_products(self) -> HysysDictionary[HysysMaterialStream]: 31 return ( 32 super().get_attached_products().map(HysysModel.FACTORY.get_material_stream) 33 )
Get the attached products.
Returns:
HysysDictionary[HysysProcessStream]: Attached products
9class HysysUnitOpType(HysysModelType): 10 """Class that represents the type of a unit operation from the HYSYS app.""" 11 12 # Heat Transfer 13 14 HEATER = "heaterop" 15 """Value indicating a HYSYS Heater operation""" 16 17 COOLER = "coolerop" 18 """Value indicating a HYSYS Cooler operation""" 19 20 HEAT_EXCHANGER = "heatexop" 21 """Value indicating a HYSYS Heat Exchanger operation""" 22 23 FIRED_HEATER = "dynamicfiredheaterop" 24 """Value indicating a HYSYS Fired Heater operation""" 25 26 # Manipulator 27 28 ADJUST = "adjust" 29 """Value indicating a HYSYS Adjust operation""" 30 31 SPREADSHEET = "spreadsheetop" 32 """Value indicating a HYSYS Spreadsheet operation""" 33 34 RECYCLE = "recycle" 35 """Value indicating a HYSYS Recycle operation""" 36 37 SET = "setop" 38 """Value indicating a HYSYS Set operation""" 39 40 STREAM_CUTTER = "streamcutterop" 41 """Value indicating a HYSYS Stream Cutter operation""" 42 43 # Piping & Hydraulic 44 45 MIXER = "mixerop" 46 """Value indicating a HYSYS Mixer operation""" 47 48 TEE = "teeop" 49 """Value indicating a HYSYS Tee operation""" 50 51 # Pressure Changer 52 53 PUMP = "pumpop" 54 """Value indicating a HYSYS Pump operation""" 55 56 CONTROL_VALVE = "valveop" 57 """Value indicating a HYSYS Control Valve operation""" 58 59 COMPRESSOR = "compressor" 60 """Value indicating a HYSYS Compressor operation""" 61 62 # Separator 63 64 COMPONENT_SPLITTER = "fractop" 65 """Value indicating a HYSYS Component Splitter operation""" 66 67 SHORTCUT_COLUMN = "shdistop" 68 """Value indicating a HYSYS Shortcut Column opersation""" 69 70 DISTILLATION_COLUMN = "distillation" 71 """Value indicating a HYSYS Distillation Column operation""" 72 73 # Reactor 74 75 CONVERSION_REACTOR = "conversionreactorop" 76 """Value indicating a HYSYS Conversion Reactor operation"""
Class that represents the type of a unit operation from the HYSYS app.
21class HysysUnitOperation(HysysModel, ABC): 22 """Class that represents an unit operation from the HYSYS app.""" 23 24 def __init__( 25 self, 26 connection: HysysCase, 27 obj: HysysNamedObjReadable, 28 model_type: HysysUnitOpType | None = None, 29 ) -> None: 30 """Create an opinionated Pythonic representation of a HYSYS unit operation. 31 32 Args: 33 connection (HysysCase): Simulation case 34 obj (HysysNamedObjReadable): HYSYS object 35 model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None. 36 37 Raises: 38 PysysError: When the unit operation is not of the given type. 39 """ # noqa: E501 40 super().__init__(connection, obj, model_type) 41 type_name = self.get_type_name() 42 43 if model_type is None: 44 model_type = HysysUnitOpType(type_name) 45 self._model_type = model_type 46 47 elif model_type != type_name: 48 message = ( 49 f"Unit operation {self.get_name()} is not of type {model_type}" 50 f" (actual: {type_name})." 51 ) 52 raise PysysError(message) 53 54 @override 55 def __repr__(self) -> str: 56 return f"{self.get_name()} (HYSYS {self.get_visible_type_name()})" 57 58 def get_operation_type(self) -> HysysUnitOpType | None: 59 """Get the operation type. 60 61 Returns: 62 HysysUnitOpType: Operation type 63 """ 64 if self.get_model_type() is None: 65 return None 66 67 return HysysUnitOpType(self.get_model_type()) 68 69 def ignore(self) -> None: 70 """Ignore the operation.""" 71 self.set_bool("IsIgnored", True) # noqa: FBT003 72 73 def unignore(self) -> None: 74 """Unignore the operation.""" 75 self.set_bool("IsIgnored", False) # noqa: FBT003 76 77 def get_ignored_status(self) -> bool: 78 """Get the ignored status. 79 80 Returns: 81 bool: If the operation is ignored 82 """ 83 return self.get_bool("IsIgnored") 84 85 def get_attached_feeds[T: HysysProcessStream](self) -> HysysDictionary[T]: 86 """Get the attached feeds. 87 88 Returns: 89 HysysDictionary[HysysProcessStream]: Attached feeds 90 """ 91 return ( 92 self.get_dict("AttachedFeeds") 93 .map(HysysNamedObject.from_obj) 94 .map(HysysModel.FACTORY.get_process_stream) 95 ) 96 97 def get_attached_products[T: HysysProcessStream](self) -> HysysDictionary[T]: 98 """Get the attached products. 99 100 Returns: 101 HysysDictionary[HysysProcessStream]: Attached products 102 """ 103 return ( 104 self.get_dict("AttachedProducts") 105 .map(HysysNamedObject.from_obj) 106 .map(HysysModel.FACTORY.get_process_stream) 107 ) 108 109 def get_attached_logical_ops[T: HysysUnitOperation](self) -> HysysDictionary[T]: 110 """Get the attached logical ops. 111 112 Returns: 113 HysysDictionary[HysysProcessStream]: Attached logical ops 114 """ 115 return ( 116 self.get_dict("AttachedLogicalOps") 117 .map(HysysNamedObject.from_obj) 118 .map(HysysModel.FACTORY.get_unit_operation) 119 )
Class that represents an unit operation from the HYSYS app.
24 def __init__( 25 self, 26 connection: HysysCase, 27 obj: HysysNamedObjReadable, 28 model_type: HysysUnitOpType | None = None, 29 ) -> None: 30 """Create an opinionated Pythonic representation of a HYSYS unit operation. 31 32 Args: 33 connection (HysysCase): Simulation case 34 obj (HysysNamedObjReadable): HYSYS object 35 model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None. 36 37 Raises: 38 PysysError: When the unit operation is not of the given type. 39 """ # noqa: E501 40 super().__init__(connection, obj, model_type) 41 type_name = self.get_type_name() 42 43 if model_type is None: 44 model_type = HysysUnitOpType(type_name) 45 self._model_type = model_type 46 47 elif model_type != type_name: 48 message = ( 49 f"Unit operation {self.get_name()} is not of type {model_type}" 50 f" (actual: {type_name})." 51 ) 52 raise PysysError(message)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): HYSYS object
- model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None.
Raises:
- PysysError: When the unit operation is not of the given type.
58 def get_operation_type(self) -> HysysUnitOpType | None: 59 """Get the operation type. 60 61 Returns: 62 HysysUnitOpType: Operation type 63 """ 64 if self.get_model_type() is None: 65 return None 66 67 return HysysUnitOpType(self.get_model_type())
Get the operation type.
Returns:
HysysUnitOpType: Operation type
69 def ignore(self) -> None: 70 """Ignore the operation.""" 71 self.set_bool("IsIgnored", True) # noqa: FBT003
Ignore the operation.
73 def unignore(self) -> None: 74 """Unignore the operation.""" 75 self.set_bool("IsIgnored", False) # noqa: FBT003
Unignore the operation.
77 def get_ignored_status(self) -> bool: 78 """Get the ignored status. 79 80 Returns: 81 bool: If the operation is ignored 82 """ 83 return self.get_bool("IsIgnored")
Get the ignored status.
Returns:
bool: If the operation is ignored
85 def get_attached_feeds[T: HysysProcessStream](self) -> HysysDictionary[T]: 86 """Get the attached feeds. 87 88 Returns: 89 HysysDictionary[HysysProcessStream]: Attached feeds 90 """ 91 return ( 92 self.get_dict("AttachedFeeds") 93 .map(HysysNamedObject.from_obj) 94 .map(HysysModel.FACTORY.get_process_stream) 95 )
Get the attached feeds.
Returns:
HysysDictionary[HysysProcessStream]: Attached feeds
97 def get_attached_products[T: HysysProcessStream](self) -> HysysDictionary[T]: 98 """Get the attached products. 99 100 Returns: 101 HysysDictionary[HysysProcessStream]: Attached products 102 """ 103 return ( 104 self.get_dict("AttachedProducts") 105 .map(HysysNamedObject.from_obj) 106 .map(HysysModel.FACTORY.get_process_stream) 107 )
Get the attached products.
Returns:
HysysDictionary[HysysProcessStream]: Attached products
109 def get_attached_logical_ops[T: HysysUnitOperation](self) -> HysysDictionary[T]: 110 """Get the attached logical ops. 111 112 Returns: 113 HysysDictionary[HysysProcessStream]: Attached logical ops 114 """ 115 return ( 116 self.get_dict("AttachedLogicalOps") 117 .map(HysysNamedObject.from_obj) 118 .map(HysysModel.FACTORY.get_unit_operation) 119 )
Get the attached logical ops.
Returns:
HysysDictionary[HysysProcessStream]: Attached logical ops