aspen_pysys.model.process_stream
Package containing all Pythonic functionality for HYSYS material streams and energy streams.
1# Copyright 2026 Hariidaran Tamilmaran 2 3"""Package containing all Pythonic functionality for HYSYS material streams and energy streams.""" # noqa: E501 4 5from aspen_pysys.model.process_stream.energy_stream import HysysEnergyStream 6from aspen_pysys.model.process_stream.material_stream import HysysMaterialStream 7from aspen_pysys.model.process_stream.process_stream import HysysProcessStream 8from aspen_pysys.model.process_stream.stream_type import HysysStreamType 9 10__all__ = [ 11 "HysysEnergyStream", 12 "HysysMaterialStream", 13 "HysysProcessStream", 14 "HysysStreamType", 15]
16class HysysEnergyStream(HysysProcessStream): 17 """Class that represents an energy stream from the HYSYS app.""" 18 19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 """Create a Pythonic representation of an energy stream from the HYSYS app. 21 22 Args: 23 connection (HysysCase): Simulation case 24 obj (HysysNamedObjReadable): Object 25 """ 26 super().__init__(connection, obj, HysysStreamType.ENERGY_STREAM) 27 28 def heat_flow(self) -> float: 29 """Get the heat flow. 30 31 Returns: 32 float: Heat flow 33 """ 34 return self.get_float("HeatFlow")
Class that represents an energy stream from the HYSYS app.
19 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 20 """Create a Pythonic representation of an energy stream from the HYSYS app. 21 22 Args: 23 connection (HysysCase): Simulation case 24 obj (HysysNamedObjReadable): Object 25 """ 26 super().__init__(connection, obj, HysysStreamType.ENERGY_STREAM)
Create a Pythonic representation of an energy stream from the HYSYS app.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): Object
23class HysysMaterialStream(HysysProcessStream): # noqa: PLR0904 24 """Class that represents a material stream from the HYSYS app.""" 25 26 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 27 """Create a Pythonic representation of a material stream from the HYSYS app. 28 29 Args: 30 connection (HysysCase): Simulation case 31 obj (HysysNamedObjReadable): Object 32 """ 33 super().__init__(connection, obj, HysysStreamType.MATERIAL_STREAM) 34 35 def __repr__(self) -> str: 36 return f"{self.get_name()} (HYSYS Material Stream)" 37 38 def get_pressure(self) -> float: 39 """Get stream pressure. 40 41 Returns: 42 float: Pressure 43 """ 44 return self.get_float("Pressure") 45 46 def set_pressure(self, value: Number) -> None: 47 """Set stream pressure. 48 49 Args: 50 value (Number): New pressure 51 """ 52 self.set_float("Pressure", value) 53 54 def get_temperature(self) -> float: 55 """Get stream temperature. 56 57 Returns: 58 float: Temperature 59 """ 60 return self.get_float("Temperature") 61 62 def set_temperature(self, value: Number) -> None: 63 """Set stream temperature. 64 65 Args: 66 value (Number): New temperature 67 """ 68 self.set_float("Temperature", value) 69 70 def get_mass_flow(self) -> float: 71 """Get stream mass flow. 72 73 Returns: 74 float: Mass flow 75 """ 76 return self.get_float("MassFlow") 77 78 def set_mass_flow(self, value: Number) -> None: 79 """Set stream mass flow. 80 81 Args: 82 value (Number): New mass flow 83 """ 84 self.set_float("MassFlow", value) 85 86 def get_molar_flow(self) -> float: 87 """Get the molar flow. 88 89 Returns: 90 float: Molar flow 91 """ 92 return self.get_float("MolarFlow") 93 94 def set_molar_flow(self, value: Number) -> None: 95 """Set the molar flow. 96 97 Args: 98 value (Number): New value 99 """ 100 self.set_float("MolarFlow", value) 101 102 def get_actual_volume_flow(self) -> float: 103 """Get the actual volume flow. 104 105 Returns: 106 float: Actual volume flow 107 """ 108 return self.get_float("ActualVolumeFlow") 109 110 def get_ideal_liquid_volume_flow(self) -> float: 111 """Get the ideal liquid volume flow. 112 113 Returns: 114 float: Ideal liquid volume flow 115 """ 116 return self.get_float("IdealLiquidVolumeFlow") 117 118 def set_ideal_liquid_volume_flow(self, value: Number) -> None: 119 """Set the ideal liquid volume flow. 120 121 Args: 122 value (Number): New value 123 """ 124 self.set_float("IdealLiquidVolumeFlow", value) 125 126 def get_std_liquid_volume_flow(self) -> float: 127 """Get the standard liquid volume flow. 128 129 Returns: 130 float: Std. liquid volume flow 131 """ 132 return self.get_float("StdLiqVolFlow") 133 134 def set_std_liquid_volume_flow(self, value: Number) -> None: 135 """Set the standard liquid volume flow. 136 137 Args: 138 value (Number): New value 139 """ 140 self.set_float("StdLiqVolFlow", value) 141 142 def get_specific_heat_capacity(self) -> float: 143 """Get the specific heat capacity. 144 145 Returns: 146 float: Specific heat capacity 147 """ 148 return self.get_float("MassHeatCapacity") 149 150 def set_specific_heat_capacity(self, value: Number) -> None: 151 """Set the specific heat capacity. 152 153 Args: 154 value (Number): New value 155 """ 156 self.set_float("MassHeatCapacity", value) 157 158 def get_molar_heat_capacity(self) -> float: 159 """Get the molar heat capacity. 160 161 Returns: 162 float: Molar heat capacity 163 """ 164 return self.get_float("MolarHeatCapacity") 165 166 def set_molar_heat_capacity(self, value: Number) -> None: 167 """Set the molar heat capacity. 168 169 Args: 170 value (Number): New value 171 """ 172 self.set_float("MolarHeatCapacity", value) 173 174 def has_no_flow(self) -> bool: 175 """Check if there is no flow. 176 177 Returns: 178 bool: If there is no material flow 179 """ 180 return is_zero(self.get_mass_flow()) 181 182 def has_negative_flow(self) -> bool: 183 """Check if there is negative flow. 184 185 Returns: 186 bool: If there is negative flow 187 """ 188 return not is_negative(self.get_mass_flow()) 189 190 def is_single_phase(self) -> bool: 191 """Check for single-phase. 192 193 Returns: 194 bool: If the stream is only a single phase. 195 """ 196 vapour_fraction: float = self.get_vapour_fraction() 197 return isclose(vapour_fraction, 0) or isclose(vapour_fraction, 1) 198 199 def get_vapour_fraction(self) -> float: 200 """Get the vapour fraction. 201 202 Returns: 203 float: Vapour fraction 204 """ 205 return self.get_float("VapourFraction") 206 207 def get_liquid_fraction(self) -> float: 208 """Get the liquid fraction. 209 210 Returns: 211 float: Liquid fraction 212 """ 213 return self.get_float("LiquidFraction") 214 215 def _get_component_values(self, metric: str, names: ComponentNames) -> tuple[float]: 216 return itemgetter( 217 *self.get_connection().get_flowsheet().get_component_indices(names), 218 )( 219 self.get_array(metric), 220 ) 221 222 def _set_component_values( 223 self, 224 metric: str, 225 names: ComponentNames, 226 values: Numbers, 227 ) -> None: 228 component_indices = ( 229 self.get_connection() 230 .get_flowsheet() 231 .get_component_indices( 232 names, 233 ) 234 ) 235 236 if len(values) != len(component_indices): 237 message = "Number of values does not match number of provided components." 238 raise PysysError(message) 239 240 current_values = list(self.get_array(metric)[:]) 241 242 for index in component_indices: 243 current_values[index] = values[index] 244 245 self.get_array(metric)[:] = current_values 246 247 def get_component_molar_fractions(self, names: ComponentNames) -> tuple[float]: 248 """Get component molar fractions. 249 250 Args: 251 names (ComponentNames): Component names 252 253 Returns: 254 tuple[float]: Component molar fractions 255 """ 256 return self._get_component_values("ComponentMolarFraction", names) 257 258 def set_component_molar_fractions( 259 self, 260 names: ComponentNames, 261 values: Numbers, 262 ) -> None: 263 """Set component molar fractions. 264 265 Args: 266 names (ComponentNames): Names of components to update values for 267 values (Numbers): New values 268 """ 269 self._set_component_values("ComponentMolarFraction", names, values) 270 271 def get_component_molar_flows(self, names: ComponentNames) -> tuple[float]: 272 """Get component molar flows. 273 274 Args: 275 names (ComponentNames): Component names 276 277 Returns: 278 tuple[float]: Component molar flows 279 """ 280 return self._get_component_values("ComponentMolarFlow", names) 281 282 def set_component_molar_flows(self, names: ComponentNames, values: Numbers) -> None: 283 """Set component molar flows. 284 285 Args: 286 names (ComponentNames): Names of components to update values for 287 values (Numbers): New values 288 """ 289 self._set_component_values("ComponentMolarFlow", names, values) 290 291 def get_component_mass_fractions(self, names: ComponentNames) -> tuple[float]: 292 """Get component mass fractions. 293 294 Args: 295 names (ComponentNames): Component names 296 297 Returns: 298 tuple[float]: Component mass fractions 299 """ 300 return self._get_component_values("ComponentMassFraction", names) 301 302 def set_component_mass_fractions( 303 self, 304 names: ComponentNames, 305 values: Numbers, 306 ) -> None: 307 """Set component mass fractions. 308 309 Args: 310 names (ComponentNames): Names of components to update values for 311 values (Numbers): New values 312 """ 313 self._set_component_values("ComponentMassFraction", names, values) 314 315 def get_component_mass_flows(self, names: ComponentNames) -> tuple[float]: 316 """Get component mass flows. 317 318 Args: 319 names (ComponentNames): Component names 320 321 Returns: 322 tuple[float]: Component mass flows 323 """ 324 return self._get_component_values("ComponentMassFlow", names) 325 326 def set_component_mass_flows(self, names: ComponentNames, values: Numbers) -> None: 327 """Set component mass flows. 328 329 Args: 330 names (ComponentNames): Names of components to update values for 331 values (Numbers): New values 332 """ 333 self._set_component_values("ComponentMassFlow", names, values) 334 335 def get_component_volume_fractions(self, names: ComponentNames) -> tuple[float]: 336 """Get component volume fractions. 337 338 Args: 339 names (ComponentNames): Component names 340 341 Returns: 342 tuple[float]: Component volume fractions 343 """ 344 return self._get_component_values("ComponentVolumeFraction", names) 345 346 def set_component_volume_fractions( 347 self, 348 names: ComponentNames, 349 values: Numbers, 350 ) -> None: 351 """Set component volume fractions. 352 353 Args: 354 names (ComponentNames): Names of components to update values for 355 values (Numbers): New values 356 """ 357 self._set_component_values("ComponentVolumeFraction", names, values) 358 359 def get_component_volume_flows(self, names: ComponentNames) -> tuple[float]: 360 """Get component volume flows. 361 362 Args: 363 names (ComponentNames): Component names 364 365 Returns: 366 tuple[float]: Component volume flows 367 """ 368 return self._get_component_values("ComponentVolumeFlow", names) 369 370 def set_component_volume_flows( 371 self, 372 names: ComponentNames, 373 values: Numbers, 374 ) -> None: 375 """Set component volume flows. 376 377 Args: 378 names (ComponentNames): Names of components to update values for 379 values (Numbers): New values 380 """ 381 self._set_component_values("ComponentVolumeFlow", names, values)
Class that represents a material stream from the HYSYS app.
26 def __init__(self, connection: HysysCase, obj: HysysNamedObjReadable) -> None: 27 """Create a Pythonic representation of a material stream from the HYSYS app. 28 29 Args: 30 connection (HysysCase): Simulation case 31 obj (HysysNamedObjReadable): Object 32 """ 33 super().__init__(connection, obj, HysysStreamType.MATERIAL_STREAM)
Create a Pythonic representation of a material stream from the HYSYS app.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): Object
38 def get_pressure(self) -> float: 39 """Get stream pressure. 40 41 Returns: 42 float: Pressure 43 """ 44 return self.get_float("Pressure")
Get stream pressure.
Returns:
float: Pressure
46 def set_pressure(self, value: Number) -> None: 47 """Set stream pressure. 48 49 Args: 50 value (Number): New pressure 51 """ 52 self.set_float("Pressure", value)
Set stream pressure.
Arguments:
- value (Number): New pressure
54 def get_temperature(self) -> float: 55 """Get stream temperature. 56 57 Returns: 58 float: Temperature 59 """ 60 return self.get_float("Temperature")
Get stream temperature.
Returns:
float: Temperature
62 def set_temperature(self, value: Number) -> None: 63 """Set stream temperature. 64 65 Args: 66 value (Number): New temperature 67 """ 68 self.set_float("Temperature", value)
Set stream temperature.
Arguments:
- value (Number): New temperature
70 def get_mass_flow(self) -> float: 71 """Get stream mass flow. 72 73 Returns: 74 float: Mass flow 75 """ 76 return self.get_float("MassFlow")
Get stream mass flow.
Returns:
float: Mass flow
78 def set_mass_flow(self, value: Number) -> None: 79 """Set stream mass flow. 80 81 Args: 82 value (Number): New mass flow 83 """ 84 self.set_float("MassFlow", value)
Set stream mass flow.
Arguments:
- value (Number): New mass flow
86 def get_molar_flow(self) -> float: 87 """Get the molar flow. 88 89 Returns: 90 float: Molar flow 91 """ 92 return self.get_float("MolarFlow")
Get the molar flow.
Returns:
float: Molar flow
94 def set_molar_flow(self, value: Number) -> None: 95 """Set the molar flow. 96 97 Args: 98 value (Number): New value 99 """ 100 self.set_float("MolarFlow", value)
Set the molar flow.
Arguments:
- value (Number): New value
102 def get_actual_volume_flow(self) -> float: 103 """Get the actual volume flow. 104 105 Returns: 106 float: Actual volume flow 107 """ 108 return self.get_float("ActualVolumeFlow")
Get the actual volume flow.
Returns:
float: Actual volume flow
110 def get_ideal_liquid_volume_flow(self) -> float: 111 """Get the ideal liquid volume flow. 112 113 Returns: 114 float: Ideal liquid volume flow 115 """ 116 return self.get_float("IdealLiquidVolumeFlow")
Get the ideal liquid volume flow.
Returns:
float: Ideal liquid volume flow
118 def set_ideal_liquid_volume_flow(self, value: Number) -> None: 119 """Set the ideal liquid volume flow. 120 121 Args: 122 value (Number): New value 123 """ 124 self.set_float("IdealLiquidVolumeFlow", value)
Set the ideal liquid volume flow.
Arguments:
- value (Number): New value
126 def get_std_liquid_volume_flow(self) -> float: 127 """Get the standard liquid volume flow. 128 129 Returns: 130 float: Std. liquid volume flow 131 """ 132 return self.get_float("StdLiqVolFlow")
Get the standard liquid volume flow.
Returns:
float: Std. liquid volume flow
134 def set_std_liquid_volume_flow(self, value: Number) -> None: 135 """Set the standard liquid volume flow. 136 137 Args: 138 value (Number): New value 139 """ 140 self.set_float("StdLiqVolFlow", value)
Set the standard liquid volume flow.
Arguments:
- value (Number): New value
142 def get_specific_heat_capacity(self) -> float: 143 """Get the specific heat capacity. 144 145 Returns: 146 float: Specific heat capacity 147 """ 148 return self.get_float("MassHeatCapacity")
Get the specific heat capacity.
Returns:
float: Specific heat capacity
150 def set_specific_heat_capacity(self, value: Number) -> None: 151 """Set the specific heat capacity. 152 153 Args: 154 value (Number): New value 155 """ 156 self.set_float("MassHeatCapacity", value)
Set the specific heat capacity.
Arguments:
- value (Number): New value
158 def get_molar_heat_capacity(self) -> float: 159 """Get the molar heat capacity. 160 161 Returns: 162 float: Molar heat capacity 163 """ 164 return self.get_float("MolarHeatCapacity")
Get the molar heat capacity.
Returns:
float: Molar heat capacity
166 def set_molar_heat_capacity(self, value: Number) -> None: 167 """Set the molar heat capacity. 168 169 Args: 170 value (Number): New value 171 """ 172 self.set_float("MolarHeatCapacity", value)
Set the molar heat capacity.
Arguments:
- value (Number): New value
174 def has_no_flow(self) -> bool: 175 """Check if there is no flow. 176 177 Returns: 178 bool: If there is no material flow 179 """ 180 return is_zero(self.get_mass_flow())
Check if there is no flow.
Returns:
bool: If there is no material flow
182 def has_negative_flow(self) -> bool: 183 """Check if there is negative flow. 184 185 Returns: 186 bool: If there is negative flow 187 """ 188 return not is_negative(self.get_mass_flow())
Check if there is negative flow.
Returns:
bool: If there is negative flow
190 def is_single_phase(self) -> bool: 191 """Check for single-phase. 192 193 Returns: 194 bool: If the stream is only a single phase. 195 """ 196 vapour_fraction: float = self.get_vapour_fraction() 197 return isclose(vapour_fraction, 0) or isclose(vapour_fraction, 1)
Check for single-phase.
Returns:
bool: If the stream is only a single phase.
199 def get_vapour_fraction(self) -> float: 200 """Get the vapour fraction. 201 202 Returns: 203 float: Vapour fraction 204 """ 205 return self.get_float("VapourFraction")
Get the vapour fraction.
Returns:
float: Vapour fraction
207 def get_liquid_fraction(self) -> float: 208 """Get the liquid fraction. 209 210 Returns: 211 float: Liquid fraction 212 """ 213 return self.get_float("LiquidFraction")
Get the liquid fraction.
Returns:
float: Liquid fraction
247 def get_component_molar_fractions(self, names: ComponentNames) -> tuple[float]: 248 """Get component molar fractions. 249 250 Args: 251 names (ComponentNames): Component names 252 253 Returns: 254 tuple[float]: Component molar fractions 255 """ 256 return self._get_component_values("ComponentMolarFraction", names)
Get component molar fractions.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component molar fractions
258 def set_component_molar_fractions( 259 self, 260 names: ComponentNames, 261 values: Numbers, 262 ) -> None: 263 """Set component molar fractions. 264 265 Args: 266 names (ComponentNames): Names of components to update values for 267 values (Numbers): New values 268 """ 269 self._set_component_values("ComponentMolarFraction", names, values)
Set component molar fractions.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
271 def get_component_molar_flows(self, names: ComponentNames) -> tuple[float]: 272 """Get component molar flows. 273 274 Args: 275 names (ComponentNames): Component names 276 277 Returns: 278 tuple[float]: Component molar flows 279 """ 280 return self._get_component_values("ComponentMolarFlow", names)
Get component molar flows.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component molar flows
282 def set_component_molar_flows(self, names: ComponentNames, values: Numbers) -> None: 283 """Set component molar flows. 284 285 Args: 286 names (ComponentNames): Names of components to update values for 287 values (Numbers): New values 288 """ 289 self._set_component_values("ComponentMolarFlow", names, values)
Set component molar flows.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
291 def get_component_mass_fractions(self, names: ComponentNames) -> tuple[float]: 292 """Get component mass fractions. 293 294 Args: 295 names (ComponentNames): Component names 296 297 Returns: 298 tuple[float]: Component mass fractions 299 """ 300 return self._get_component_values("ComponentMassFraction", names)
Get component mass fractions.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component mass fractions
302 def set_component_mass_fractions( 303 self, 304 names: ComponentNames, 305 values: Numbers, 306 ) -> None: 307 """Set component mass fractions. 308 309 Args: 310 names (ComponentNames): Names of components to update values for 311 values (Numbers): New values 312 """ 313 self._set_component_values("ComponentMassFraction", names, values)
Set component mass fractions.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
315 def get_component_mass_flows(self, names: ComponentNames) -> tuple[float]: 316 """Get component mass flows. 317 318 Args: 319 names (ComponentNames): Component names 320 321 Returns: 322 tuple[float]: Component mass flows 323 """ 324 return self._get_component_values("ComponentMassFlow", names)
Get component mass flows.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component mass flows
326 def set_component_mass_flows(self, names: ComponentNames, values: Numbers) -> None: 327 """Set component mass flows. 328 329 Args: 330 names (ComponentNames): Names of components to update values for 331 values (Numbers): New values 332 """ 333 self._set_component_values("ComponentMassFlow", names, values)
Set component mass flows.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
335 def get_component_volume_fractions(self, names: ComponentNames) -> tuple[float]: 336 """Get component volume fractions. 337 338 Args: 339 names (ComponentNames): Component names 340 341 Returns: 342 tuple[float]: Component volume fractions 343 """ 344 return self._get_component_values("ComponentVolumeFraction", names)
Get component volume fractions.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component volume fractions
346 def set_component_volume_fractions( 347 self, 348 names: ComponentNames, 349 values: Numbers, 350 ) -> None: 351 """Set component volume fractions. 352 353 Args: 354 names (ComponentNames): Names of components to update values for 355 values (Numbers): New values 356 """ 357 self._set_component_values("ComponentVolumeFraction", names, values)
Set component volume fractions.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
359 def get_component_volume_flows(self, names: ComponentNames) -> tuple[float]: 360 """Get component volume flows. 361 362 Args: 363 names (ComponentNames): Component names 364 365 Returns: 366 tuple[float]: Component volume flows 367 """ 368 return self._get_component_values("ComponentVolumeFlow", names)
Get component volume flows.
Arguments:
- names (ComponentNames): Component names
Returns:
tuple[float]: Component volume flows
370 def set_component_volume_flows( 371 self, 372 names: ComponentNames, 373 values: Numbers, 374 ) -> None: 375 """Set component volume flows. 376 377 Args: 378 names (ComponentNames): Names of components to update values for 379 values (Numbers): New values 380 """ 381 self._set_component_values("ComponentVolumeFlow", names, values)
Set component volume flows.
Arguments:
- names (ComponentNames): Names of components to update values for
- values (Numbers): New values
20class HysysProcessStream(HysysModel): 21 """Class that represents a process stream from the HYSYS app.""" 22 23 def __init__( 24 self, 25 connection: HysysCase, 26 obj: HysysNamedObjReadable, 27 typ: HysysStreamType | None = None, 28 ) -> None: 29 """Create a Pythonic representation of an unit operation from the HYSYS app. 30 31 Args: 32 connection (HysysCase): Simulation case 33 obj (HysysNamedObjReadable): Object 34 typ (HysysStreamType | None, optional): Type of stream. Defaults to None. 35 36 Raises: 37 PysysError: When stream type does not match provided type. 38 """ 39 super().__init__(connection, obj, typ) 40 type_name = self.get_type_name() 41 42 if typ is None: 43 typ = HysysStreamType(type_name) 44 self._model_type = typ 45 46 elif typ != type_name: 47 message = f"Stream {self.get_name()} is not of type {typ} " 48 f"(actual: {type_name})." 49 raise PysysError(message) 50 51 def get_stream_type(self) -> HysysStreamType: 52 """Get the stream type. 53 54 Returns: 55 HysysStreamType: Stream type 56 """ 57 return HysysStreamType(self.get_model_type()) 58 59 def get_attached_operations(self) -> HysysDictionary[HysysUnitOperation]: 60 """Get the operations attached to the stream. 61 62 Returns: 63 HysysDictionary[HysysUnitOperation]: Attached operations 64 """ 65 return ( 66 self.get_dict("AttachedOpers") 67 .map(HysysNamedObject.from_obj) 68 .map(HysysModel.FACTORY.get_unit_operation) 69 ) 70 71 def get_upstream_operations(self) -> HysysDictionary[HysysUnitOperation]: 72 """Get the upstream operations attached to the stream. 73 74 Returns: 75 HysysDictionary[HysysUnitOperation]: Attached upstream operations 76 """ 77 return ( 78 self.get_dict("UpstreamOpers") 79 .map(HysysNamedObject.from_obj) 80 .map(HysysModel.FACTORY.get_unit_operation) 81 ) 82 83 def get_downstream_operations(self) -> HysysDictionary[HysysUnitOperation]: 84 """Get the downstream operations attached to the stream. 85 86 Returns: 87 HysysDictionary[HysysUnitOperation]: Attached downstream operations 88 """ 89 return ( 90 self.get_dict("DownstreamOpers") 91 .map(HysysNamedObject.from_obj) 92 .map(HysysModel.FACTORY.get_unit_operation) 93 )
Class that represents a process stream from the HYSYS app.
23 def __init__( 24 self, 25 connection: HysysCase, 26 obj: HysysNamedObjReadable, 27 typ: HysysStreamType | None = None, 28 ) -> None: 29 """Create a Pythonic representation of an unit operation from the HYSYS app. 30 31 Args: 32 connection (HysysCase): Simulation case 33 obj (HysysNamedObjReadable): Object 34 typ (HysysStreamType | None, optional): Type of stream. Defaults to None. 35 36 Raises: 37 PysysError: When stream type does not match provided type. 38 """ 39 super().__init__(connection, obj, typ) 40 type_name = self.get_type_name() 41 42 if typ is None: 43 typ = HysysStreamType(type_name) 44 self._model_type = typ 45 46 elif typ != type_name: 47 message = f"Stream {self.get_name()} is not of type {typ} " 48 f"(actual: {type_name})." 49 raise PysysError(message)
Create a Pythonic representation of an unit operation from the HYSYS app.
Arguments:
- connection (HysysCase): Simulation case
- obj (HysysNamedObjReadable): Object
- typ (HysysStreamType | None, optional): Type of stream. Defaults to None.
Raises:
- PysysError: When stream type does not match provided type.
51 def get_stream_type(self) -> HysysStreamType: 52 """Get the stream type. 53 54 Returns: 55 HysysStreamType: Stream type 56 """ 57 return HysysStreamType(self.get_model_type())
Get the stream type.
Returns:
HysysStreamType: Stream type
59 def get_attached_operations(self) -> HysysDictionary[HysysUnitOperation]: 60 """Get the operations attached to the stream. 61 62 Returns: 63 HysysDictionary[HysysUnitOperation]: Attached operations 64 """ 65 return ( 66 self.get_dict("AttachedOpers") 67 .map(HysysNamedObject.from_obj) 68 .map(HysysModel.FACTORY.get_unit_operation) 69 )
Get the operations attached to the stream.
Returns:
HysysDictionary[HysysUnitOperation]: Attached operations
71 def get_upstream_operations(self) -> HysysDictionary[HysysUnitOperation]: 72 """Get the upstream operations attached to the stream. 73 74 Returns: 75 HysysDictionary[HysysUnitOperation]: Attached upstream operations 76 """ 77 return ( 78 self.get_dict("UpstreamOpers") 79 .map(HysysNamedObject.from_obj) 80 .map(HysysModel.FACTORY.get_unit_operation) 81 )
Get the upstream operations attached to the stream.
Returns:
HysysDictionary[HysysUnitOperation]: Attached upstream operations
83 def get_downstream_operations(self) -> HysysDictionary[HysysUnitOperation]: 84 """Get the downstream operations attached to the stream. 85 86 Returns: 87 HysysDictionary[HysysUnitOperation]: Attached downstream operations 88 """ 89 return ( 90 self.get_dict("DownstreamOpers") 91 .map(HysysNamedObject.from_obj) 92 .map(HysysModel.FACTORY.get_unit_operation) 93 )
Get the downstream operations attached to the stream.
Returns:
HysysDictionary[HysysUnitOperation]: Attached downstream operations
9class HysysStreamType(HysysModelType): 10 """Class that represents the type of a process stream from the HYSYS app.""" 11 12 MATERIAL_STREAM = "materialstream" 13 """Value indicating a HYSYS material stream""" 14 15 ENERGY_STREAM = "energystream" 16 """Value indicating a HYSYS energy stream"""
Class that represents the type of a process stream from the HYSYS app.