8. PipeSim interface (via Openlink)¶
The OpenLink functionality (available for all the PipeSim versions <= 2012.4) provides a COM interface to both single branch and network models.
Like for other COM interfaces the Dispatch
method of the pywin32
module can be used to communicate with PipeSim. For example to open the a network model called base_model.bpn
you can:
o = Dispatch("NET32COM.INetModel")
o.OpenModel(path_to/base_model.bpn)
Once loaded the model all the the different elements can be checked or modified: o.GetNameList(i)
returns a 2-elements tuple containing the all the names and the number of elements corresponding to the index i
. For example:
o.GetNameList(2)[0]
would return all the names of the sources of the model.
Once the name of the source you want to modify is known it is possilbe to use o.SetBoundaryFluidrate
to define a new fluid rate:
o.SetBoundaryFluidrate(source_name, 0, new_value, 'STB/d')
SetBoundaryFluidrate as second parameter accepts an integer:
- 0 for liquid flowrate
- 1 for gas flowrate
o.SaveModel
can be use to save as (it requires as parameter the path and the new name of the model as a string)
8.1. Run a case¶
To run a case in the background:
o.RunNetwork2(False, "-B")
and to check if it is still simulating:
o.GetIsModelRunning()
8.2. Node results¶
Node results can be estracted using the Dispatch("PNSREADER.PNSCom")
:
results.ReadPnsFile(pns_file_path)
idx = results.GetNodeIndex(interesting_node)
pt = results.GetNodeVariableValue(idx, 'Pressure')