成长值: 67885
|
Python has become very popular recently, so here is simple code to integrate Python with Hysys.
You will see:
1- how to open a Hysys case using Python.
2- how to change some parameters in the Hsysy case using Python.
3- how to read data from Hysys.
The Code:
import win32com.client as win32 # Import COM
def openHysys(hyFilePath):
hyApp = win32.Dispatch('HYSYS.Application')
hyCase = hyApp.SimulationCases.Open(hyFilePath)
hyCase.Visible = True
#streamPress = hyCase.Flowsheet.MaterialStreams.Item("FeedStream").Pressure.setValue(3,"bar_g")
streamPress = hyCase.Flowsheet.MaterialStreams.Item("FeedStream").Pressure.setValue(400,"kPa")
streamPress = hyCase.Flowsheet.MaterialStreams.Item("FeedStream").Pressure.getValue("kPa")
print(streamPress," kPa")
streamPress = hyCase.Flowsheet.MaterialStreams.Item("FeedStream").Pressure.getValue("bar_g")
print(streamPress, " bar_g")
compEff = hyCase.Flowsheet.Operations.Item("K-100").CompPolytropicEff
exArea = hyCase.Flowsheet.Operations.Item("E-101").HeatTransferArea
print(compEff, " %")
print(exArea," m2")
return()
hyFilePath = r"C:\Users\HassanElbanhawi\Desktop\Pressure Relief Benchmark.hsc"
print('')
openHysysCase = openHysys(hyFilePath)
|
|