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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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(HysysModel.FACTORY.get_material_stream) 35 ) 36 37 def get_overhead_outlets(self) -> HysysDictionary[HysysMaterialStream]: 38 """Get the overhead outlets. 39 40 Returns: 41 HysysDictionary[HysysMaterialStream]: Overhead outlets 42 """ 43 return ( 44 self.get_dict("OverheadOutlets") 45 .map(HysysModel.FACTORY.get_material_stream) 46 ) 47 48 def get_bottoms_outlet(self) -> HysysMaterialStream: 49 """Get the bottoms outlet. 50 51 Returns: 52 HysysMaterialStream: Bottoms outlet 53 """ 54 return HysysModel.FACTORY.get_material_stream( 55 self.get_named_obj("BottomOutlets") 56 ) 57 58 def get_energy_inlets(self) -> HysysDictionary[HysysEnergyStream]: 59 """Get the energy inlets. 60 61 Returns: 62 HysysDictionary[HysysEnergyStream]: Energy inlets 63 """ 64 return ( 65 self.get_dict("EnergyInlets") 66 .map(HysysModel.FACTORY.get_energy_stream) 67 ) 68 69 def get_split_basis(self) -> HysysArray: 70 """Get the split basis. 71 72 Returns: 73 HysysArray: Split basis 74 """ 75 return self.get_array("SplitBasis") 76 77 def get_split_type(self) -> HysysArray: 78 """Get the split type. 79 80 Returns: 81 HysysArray: Split type 82 """ 83 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.
Args: 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(HysysModel.FACTORY.get_material_stream) 35 )
Get the inlets.
Returns: HysysDictionary[HysysMaterialStream]: Inlets
37 def get_overhead_outlets(self) -> HysysDictionary[HysysMaterialStream]: 38 """Get the overhead outlets. 39 40 Returns: 41 HysysDictionary[HysysMaterialStream]: Overhead outlets 42 """ 43 return ( 44 self.get_dict("OverheadOutlets") 45 .map(HysysModel.FACTORY.get_material_stream) 46 )
Get the overhead outlets.
Returns: HysysDictionary[HysysMaterialStream]: Overhead outlets
48 def get_bottoms_outlet(self) -> HysysMaterialStream: 49 """Get the bottoms outlet. 50 51 Returns: 52 HysysMaterialStream: Bottoms outlet 53 """ 54 return HysysModel.FACTORY.get_material_stream( 55 self.get_named_obj("BottomOutlets") 56 )
Get the bottoms outlet.
Returns: HysysMaterialStream: Bottoms outlet
58 def get_energy_inlets(self) -> HysysDictionary[HysysEnergyStream]: 59 """Get the energy inlets. 60 61 Returns: 62 HysysDictionary[HysysEnergyStream]: Energy inlets 63 """ 64 return ( 65 self.get_dict("EnergyInlets") 66 .map(HysysModel.FACTORY.get_energy_stream) 67 )
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.
Args: 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.
Args: 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.
Args: 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.
Args: 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_int("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(HysysModel.FACTORY.get_process_stream) 120 .filter( 121 lambda _, stream: ( 122 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 123 ), 124 ) 125 .items() 126 ) 127 } 128 129 def get_feed_streams(self) -> dict[str, HysysMaterialStream]: 130 return { 131 key: HysysModel.FACTORY.get_material_stream(value) 132 for key, value in ( 133 self._get_flowsheet() 134 .get_dict("FeedStreams") 135 .map(HysysModel.FACTORY.get_process_stream) 136 .filter( 137 lambda _, stream: ( 138 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 139 ), 140 ) 141 .items() 142 ) 143 } 144 145 def specify_feed_location(self, feed: str | HysysObject, tray: int) -> None: 146 if isinstance(feed, str): 147 feed_obj = self.get_feed_streams().get(feed) 148 149 if feed_obj is None: 150 message = f"Feed stream named '{feed}' does not exist." 151 raise PysysError(message) 152 153 feed = feed_obj 154 155 with feed as feed_com_obj: 156 func = self._get_main_tower().get_func("SpecifyFeedLocation") 157 func.call(feed_com_obj, tray) 158 159 def add_material_feed(self, feed_name: str, tray: int) -> None: 160 """Add a feed stream. 161 162 Args: 163 feed_name (str): Stream name 164 tray (int): Tray number 165 """ 166 self._get_main_tower().get_func("AddFeedStream").call(feed_name, tray, False) # noqa: FBT003 167 168 def _confirm_main_and_subflowsheet_feeds_match(self) -> None: 169 flowsheet_feed_names: set[str] = set(self.get_attached_material_feeds().keys()) 170 subflowsheet_feed_names: set[str] = set(self.get_feed_streams().keys()) 171 172 if flowsheet_feed_names != subflowsheet_feed_names: 173 flowsheet_feed_names_str = ", ".join(flowsheet_feed_names) 174 subflowsheet_feed_names_str = ", ".join(subflowsheet_feed_names) 175 176 error_message = ( 177 "Feed trays cannot be identified, possibly due to " 178 "a mismatch in stream names between the main and column flowsheets." 179 f"\nMain = {flowsheet_feed_names_str}" 180 f", Column = {subflowsheet_feed_names_str}." 181 ) 182 183 raise PysysError(error_message) 184 185 def get_feed_trays(self) -> dict[str, int]: 186 self._confirm_main_and_subflowsheet_feeds_match() 187 188 feed_trays_hysys_dict = self._get_main_tower().get_dict("FeedStages") 189 feed_trays_dict: dict[str, int] = {} 190 191 for key in feed_trays_hysys_dict: 192 feed_tray = feed_trays_hysys_dict.get(key) 193 streams_at_feed_tray = feed_tray.get_dict("FeedStreams") 194 195 if len(streams_at_feed_tray) == 0: 196 continue 197 198 feed_tray_number = feed_tray.get_int("IFaceStageNumber") 199 200 for stream_name in streams_at_feed_tray: 201 feed_trays_dict.update({stream_name: feed_tray_number}) 202 203 return feed_trays_dict 204 205 def get_tray_count(self) -> int: 206 """Get the tray count. 207 208 Returns: 209 int: Tray count 210 """ 211 return int(self._get_main_tower().get_float("NumberOfTrays")) 212 213 def set_tray_count(self, count: int) -> None: 214 """Set the tray count. 215 216 Args: 217 count (int): New value 218 219 Raises: 220 PysysError: Tray count is lesser than 3. 221 """ 222 if count < MIN_TRAY_COUNT: 223 message = "Tray count must not be lesser than 3." 224 raise PysysError(message) 225 226 self._get_main_tower().set_float("NumberOfTrays", count) 227 228 def get_current_iteration(self) -> int: 229 """Get the number of finished iterations. 230 231 Returns: 232 int: Current iteration 233 """ 234 return self._get_flowsheet().get_int("CurrentIteration") - 1 235 236 def _get_column_trays(self) -> HysysDictionary: 237 return self._get_flowsheet().get_dict("ColumnStages") 238 239 def _get_separation_tray(self, position: int) -> HysysObject: 240 main_tower_name = self._get_main_tower().get_name() 241 tray_name = f"{position}__{main_tower_name}" 242 243 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.
Args: 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_int("MaximumIterations", max_iterations) 105 106 run_func = self._get_flowsheet().get_func("Run") 107 run_func.call()
Run the column.
Args: 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(HysysModel.FACTORY.get_process_stream) 120 .filter( 121 lambda _, stream: ( 122 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 123 ), 124 ) 125 .items() 126 ) 127 }
129 def get_feed_streams(self) -> dict[str, HysysMaterialStream]: 130 return { 131 key: HysysModel.FACTORY.get_material_stream(value) 132 for key, value in ( 133 self._get_flowsheet() 134 .get_dict("FeedStreams") 135 .map(HysysModel.FACTORY.get_process_stream) 136 .filter( 137 lambda _, stream: ( 138 stream.get_stream_type() == HysysStreamType.MATERIAL_STREAM 139 ), 140 ) 141 .items() 142 ) 143 }
145 def specify_feed_location(self, feed: str | HysysObject, tray: int) -> None: 146 if isinstance(feed, str): 147 feed_obj = self.get_feed_streams().get(feed) 148 149 if feed_obj is None: 150 message = f"Feed stream named '{feed}' does not exist." 151 raise PysysError(message) 152 153 feed = feed_obj 154 155 with feed as feed_com_obj: 156 func = self._get_main_tower().get_func("SpecifyFeedLocation") 157 func.call(feed_com_obj, tray)
159 def add_material_feed(self, feed_name: str, tray: int) -> None: 160 """Add a feed stream. 161 162 Args: 163 feed_name (str): Stream name 164 tray (int): Tray number 165 """ 166 self._get_main_tower().get_func("AddFeedStream").call(feed_name, tray, False) # noqa: FBT003
Add a feed stream.
Args: feed_name (str): Stream name tray (int): Tray number
185 def get_feed_trays(self) -> dict[str, int]: 186 self._confirm_main_and_subflowsheet_feeds_match() 187 188 feed_trays_hysys_dict = self._get_main_tower().get_dict("FeedStages") 189 feed_trays_dict: dict[str, int] = {} 190 191 for key in feed_trays_hysys_dict: 192 feed_tray = feed_trays_hysys_dict.get(key) 193 streams_at_feed_tray = feed_tray.get_dict("FeedStreams") 194 195 if len(streams_at_feed_tray) == 0: 196 continue 197 198 feed_tray_number = feed_tray.get_int("IFaceStageNumber") 199 200 for stream_name in streams_at_feed_tray: 201 feed_trays_dict.update({stream_name: feed_tray_number}) 202 203 return feed_trays_dict
205 def get_tray_count(self) -> int: 206 """Get the tray count. 207 208 Returns: 209 int: Tray count 210 """ 211 return int(self._get_main_tower().get_float("NumberOfTrays"))
Get the tray count.
Returns: int: Tray count
213 def set_tray_count(self, count: int) -> None: 214 """Set the tray count. 215 216 Args: 217 count (int): New value 218 219 Raises: 220 PysysError: Tray count is lesser than 3. 221 """ 222 if count < MIN_TRAY_COUNT: 223 message = "Tray count must not be lesser than 3." 224 raise PysysError(message) 225 226 self._get_main_tower().set_float("NumberOfTrays", count)
Set the tray count.
Args: count (int): New value
Raises: PysysError: Tray count is lesser than 3.
228 def get_current_iteration(self) -> int: 229 """Get the number of finished iterations. 230 231 Returns: 232 int: Current iteration 233 """ 234 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
Args: 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.
20class HysysUnitOperation(HysysModel, ABC): 21 """Class that represents an unit operation from the HYSYS app.""" 22 23 def __init__( 24 self, 25 connection: HysysCase, 26 obj: HysysNamedObjReadable, 27 model_type: HysysUnitOpType | None = None, 28 ) -> None: 29 """Create an opinionated Pythonic representation of a HYSYS unit operation. 30 31 Args: 32 connection (HysysCase): Simulation case 33 obj (HysysNamedObjReadable): HYSYS object 34 model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None. 35 36 Raises: 37 PysysError: When the unit operation is not of the given type. 38 """ # noqa: E501 39 super().__init__(connection, obj, model_type) 40 type_name = self.get_type_name() 41 42 if model_type is None: 43 try: 44 model_type = HysysUnitOpType(type_name) 45 except ValueError: 46 pass 47 else: 48 self._model_type = model_type 49 50 elif model_type != type_name: 51 message = ( 52 f"Unit operation {self.get_name()} is not of type {model_type}" 53 f" (actual: {type_name})." 54 ) 55 raise PysysError(message) 56 57 @override 58 def __repr__(self) -> str: 59 return f"{self.get_name()} (HYSYS {self.get_visible_type_name()})" 60 61 def get_operation_type(self) -> HysysUnitOpType | None: 62 """Get the operation type. 63 64 Returns: 65 HysysUnitOpType: Operation type 66 """ 67 if self.get_model_type() is None: 68 return None 69 70 return HysysUnitOpType(self.get_model_type()) 71 72 def ignore(self) -> None: 73 """Ignore the operation.""" 74 self.set_bool("IsIgnored", True) # noqa: FBT003 75 76 def unignore(self) -> None: 77 """Unignore the operation.""" 78 self.set_bool("IsIgnored", False) # noqa: FBT003 79 80 def get_ignored_status(self) -> bool: 81 """Get the ignored status. 82 83 Returns: 84 bool: If the operation is ignored 85 """ 86 return self.get_bool("IsIgnored") 87 88 def get_attached_feeds[T: HysysProcessStream](self) -> HysysDictionary[T]: 89 """Get the attached feeds. 90 91 Returns: 92 HysysDictionary[HysysProcessStream]: Attached feeds 93 """ 94 return ( 95 self.get_dict("AttachedFeeds") 96 .map(HysysModel.FACTORY.get_process_stream) 97 ) 98 99 def get_attached_products[T: HysysProcessStream](self) -> HysysDictionary[T]: 100 """Get the attached products. 101 102 Returns: 103 HysysDictionary[HysysProcessStream]: Attached products 104 """ 105 return ( 106 self.get_dict("AttachedProducts") 107 .map(HysysModel.FACTORY.get_process_stream) 108 ) 109 110 def get_attached_logical_ops[T: HysysUnitOperation](self) -> HysysDictionary[T]: 111 """Get the attached logical ops. 112 113 Returns: 114 HysysDictionary[HysysProcessStream]: Attached logical ops 115 """ 116 return ( 117 self.get_dict("AttachedLogicalOps") 118 .map(HysysModel.FACTORY.get_unit_operation) 119 )
Class that represents an unit operation from the HYSYS app.
23 def __init__( 24 self, 25 connection: HysysCase, 26 obj: HysysNamedObjReadable, 27 model_type: HysysUnitOpType | None = None, 28 ) -> None: 29 """Create an opinionated Pythonic representation of a HYSYS unit operation. 30 31 Args: 32 connection (HysysCase): Simulation case 33 obj (HysysNamedObjReadable): HYSYS object 34 model_type (HysysUnitOpType, optional): Type of unit operation. Defaults to None. 35 36 Raises: 37 PysysError: When the unit operation is not of the given type. 38 """ # noqa: E501 39 super().__init__(connection, obj, model_type) 40 type_name = self.get_type_name() 41 42 if model_type is None: 43 try: 44 model_type = HysysUnitOpType(type_name) 45 except ValueError: 46 pass 47 else: 48 self._model_type = model_type 49 50 elif model_type != type_name: 51 message = ( 52 f"Unit operation {self.get_name()} is not of type {model_type}" 53 f" (actual: {type_name})." 54 ) 55 raise PysysError(message)
Create an opinionated Pythonic representation of a HYSYS unit operation.
Args: 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.
61 def get_operation_type(self) -> HysysUnitOpType | None: 62 """Get the operation type. 63 64 Returns: 65 HysysUnitOpType: Operation type 66 """ 67 if self.get_model_type() is None: 68 return None 69 70 return HysysUnitOpType(self.get_model_type())
Get the operation type.
Returns: HysysUnitOpType: Operation type
72 def ignore(self) -> None: 73 """Ignore the operation.""" 74 self.set_bool("IsIgnored", True) # noqa: FBT003
Ignore the operation.
76 def unignore(self) -> None: 77 """Unignore the operation.""" 78 self.set_bool("IsIgnored", False) # noqa: FBT003
Unignore the operation.
80 def get_ignored_status(self) -> bool: 81 """Get the ignored status. 82 83 Returns: 84 bool: If the operation is ignored 85 """ 86 return self.get_bool("IsIgnored")
Get the ignored status.
Returns: bool: If the operation is ignored
88 def get_attached_feeds[T: HysysProcessStream](self) -> HysysDictionary[T]: 89 """Get the attached feeds. 90 91 Returns: 92 HysysDictionary[HysysProcessStream]: Attached feeds 93 """ 94 return ( 95 self.get_dict("AttachedFeeds") 96 .map(HysysModel.FACTORY.get_process_stream) 97 )
Get the attached feeds.
Returns: HysysDictionary[HysysProcessStream]: Attached feeds
99 def get_attached_products[T: HysysProcessStream](self) -> HysysDictionary[T]: 100 """Get the attached products. 101 102 Returns: 103 HysysDictionary[HysysProcessStream]: Attached products 104 """ 105 return ( 106 self.get_dict("AttachedProducts") 107 .map(HysysModel.FACTORY.get_process_stream) 108 )
Get the attached products.
Returns: HysysDictionary[HysysProcessStream]: Attached products
110 def get_attached_logical_ops[T: HysysUnitOperation](self) -> HysysDictionary[T]: 111 """Get the attached logical ops. 112 113 Returns: 114 HysysDictionary[HysysProcessStream]: Attached logical ops 115 """ 116 return ( 117 self.get_dict("AttachedLogicalOps") 118 .map(HysysModel.FACTORY.get_unit_operation) 119 )
Get the attached logical ops.
Returns: HysysDictionary[HysysProcessStream]: Attached logical ops