Logo of AmsterCHEMAmsterCHEM released today a new CAPE-OPEN Unit Operation where the model can be written as a Python script. The simplicity of the Python language is appealing to many: reading Python is much like reading English. This is the reason why it is so easy to learn, understand, and code Python. At the latest CAPE-OPEN Annual Meeting, use of Python for developing process engineering models was repeatedly mentioned by participants as a must to have.

This new CAPE-OPEN Unit Operation from AmsterCHEM complements a rather extensive list of similar CAPE-OPEN Unit Operations by AmsterCHEM such as the Scilab Unit Operation, the MATLAB® Unit Operation and the Microsoft Excel Unit Operation. All of these CAPE-OPEN Unit Operations have been put to much use already within many organizations.

Prior to its official release, Martin GAINVILLE, from the Fluid Mechanics Department at IFP Energies Nouvelles had the opportunity to test rather extensively the Python CAPE-OPEN Unit Operation and here is his report (Disclaimer: the views expressed here do not necessarily reflect the views or policies of IFP Energies Nouvelles): “I was able to quickly and successfully use the Python CAPE-OPEN Unit Operation, starting with the examples provided by AmsterCHEM (Examples 1 to 11 worked fine, encountered an issue with example 12 while importing scipy.optimize Python package¹, and examples 13 and 14 need to be further looked at).

In addition, I prototyped a simple pipe with the Python Unit Operation, calculating pressure drop and heat exchange with the pipe surroundings on a 1D mesh and dealing with all the present phases. For the model, I relied on a previously developed Python script working with the Python CAPE-OPEN Thermo Import by AmsterCHEM. This Python Unit Operation was integrated into a COFE flowsheet where the pipe diameter (a parameter of the Python Unit Operation) was tuned using a controller to reach the output pressure specification (15 bar). Calculations were performed using either a TEA Property Package (PR: CO2 + WATER) or a Multiflash Property Package (CO2, H2O, DODECANE).

COFE Flowsheet with Pipe as Python Unit Operation

Pressure, temperature and phase fraction profiles were plotted in the Python Unit Operation GUI and calculation results were written into a report accessible to the flowsheet environment.

Plot of results calculated by a Pipe developed using the Python CAPE-OPEN Unit Operation

The Python Unit Operation is really useful for integrating existing Python scripts into a flowsheet environment and to get access to Property Package methods for calculations internal to the Unit Operation.The “Help on Python Unit Operation” web page provides all the necessary information about object structures and methods. The next step will be for me to validate the interoperability in third-party CAPE-OPEN flowsheet environments such as Aspen HYSYS, Unisim Design or Pro/II.

Martin GAINVILLE has not been the only one testing the Python CAPE-OPEN Unit Operation. Dr Volker SIEPMANN from Yara International (Disclaimer: the views expressed here do not necessarily reflect the views or policies of Yara International) stated to CO-LaN: “The release of the Python CAPE-OPEN Unit Operation by AmsterCHEM is very welcome. Jasper van BATEN was, as always, very helpful and responsive when I tested it. It worked practically out of the box, but Jasper used my feedback to allow for accessing unit operation code that is hosted as a Python module outside the unit operation code itself. This is a very useful feature for easing maintenance and avoiding code duplication.

Before this event, CAPE-OPEN technology was difficult for us to utilize, as our custom unit operation code is mostly developed in Python today. We never really succeeded to make a CAPE-OPEN COM PMC in Python. Now, with the Python CAPE-OPEN Unit Operation (actually being the C++ COM server and calling Python code in its own Python engine instance), this door is re-opened again.”. Volker attended the CAPE-OPEN 2016 Annual Meeting and keeps himself aware of CAPE-OPEN developments.

CO-LaN welcomes this new addition to the list of available CAPE-OPEN Unit Operations. This will further increase the use of CAPE-OPEN based interoperability in process engineering. It is worth noting that AmsterCHEM used COBIA for the development of this new Unit Operation.

¹ AmsterCHEM: the issues underlying the use of scipy in win32 Python in example 12 are unrelated to the Python Unit Operation itself. It appears to be a bug in the win32 anaconda distribution of scipy for Python 3.8. The x64 anaconda distribution of scipy works fine. Also CPython / win32 with scipy from pip works fine.