Reputation: 25
Can someone please tell me how to list all the components in a stream using COM and Python?
I have this output stream and its path in aspen plus variable explorer is:
aspen.Tree.FindNode("\Data\Streams\COM1\Output\STR_MAIN\MASSFLMX\MIXED")
This stream as 8 components: Water, SO2,CO2, etc as shown in the pic linked below:
Variable explorer image from Aspen Plus
How can I list the components in this stream in python environment?
Thanks, Gargeya.
Upvotes: 1
Views: 1642
Reputation: 1
I have been working with aspen with pycom32 for a bit now and the function below should provide you with what you want. It also has the caveat of ignoring all 'USER' inputs since they can cause issues due to them typically requiring additional information before simulating.
def node_attribute(aspen, path):
node=aspen.Tree.FindNode(path)
if node is not None:
node_attribute_val = node.AttributeValue(5).__str__()
node_val = node_attribute_val.split('\n')
node_val = [val for val in node_val if val !='USER']
return node, node_val
Upvotes: 0
Reputation: 1
I have created a new library which can be used to control Aspen Plus via Python: https://github.com/YouMayCallMeJesus/AspenPlus-Python-Interface It is currently not completed yet but until 01.07.22 its finished. There are also some tutorials, documentation, cases and such.
You are able to edit the flowsheet, run, set values, get values, debug, automatically extract all outputs and insert all inputs into blocks and much more.
In this case, you would need to instantiate the simulation and then use the functions built in the library
sim = Simulation (*args)
sim.STRM_Get_MoleFlowPerCompound()
Upvotes: 0