As to follow up in our conversation at the AGM yesterday, here are some pointers towards creation of a property calculation routine. Property calculation routines are a type of CAPE-OPEN software components that can, in principle, be used by any PME to allow a custom property calculation routine, without the need to implement an entire property package. A property package implementation requires more than just property calculations. A property package should provide the compound definitions, the phase definitions, the phase equilibrium (flash) calculator, etc.
Although a property calculation routine is therefore much easier to write, currently there is not much support for property calculation routines as stand-alone CAPE-OPEN objects. Nevertheless, COCO's TEA does support such routines.
To write a property calculation routine, you need to write a CAPE-OPEN object that is a Primary PMC object, and is registered with the following category ID: "CAPE-OPEN 1.1 Physical Property Calculator" (CF51E385-0110-4ed8-ACB7-B50CFDE6908E); this is described in the CAPE-OPEN 1.1 thermodynamic standard specification document.
Such a software component needs to implement the following interfaces:
- ICapeIdentification - required by all CAPE-OPEN components and provides the name of the component
- ICapeUtilities - required by all Primary PMC CAPE-OPEN objects
- ICapeThermoPropertyRoutine - this actually implements the property routine functionality
- IcapeThermoMaterialContext - this allows the object to receive the material object on which the calculations are performed
In addition, the component may implement the following CAPE-OPEN interfaces:
- ICapePerist (CAPE-OPEN 1.2, or for CAPE-OPEN 1.1, any of the persistence interface): only needed if the component can be configured and the configuration must be saved
- ICapeThermoPhases: only needed in case the property calculation applies to specific phases only. ICapeThermoPhases identifies these phases
- ICapeThermoCompounds: only needed in case the property calculation applies only to specific compounds. ICapeThermoCompounds identifies these compounds.
For more information, see the CAPE-OPEN 1.1 specification:
https://www.colan.org/specifications/th ... tion-v1-1/
https://www.colan.org/wp-content/upload ... on_311.pdf
particularly section 5.5: Physical Property Calculator component responsibilities
To implement such an object, one can either make a COM component (an explanation of how to do that is a bit out of the scope of this post, let me know if you need more information), or you can use COBIA. The latter route makes things a bit simpler, but requires some C++ programming. If you have access to Visual Studio (2017, 2019, the free community edition will do), I would suggest checking out the COBIA CAPE-OPEN Wizard visual studio add-in:
https://marketplace.visualstudio.com/it ... OBIAWizard
After installing this, you will find that the help ("Help on COBIA Wizard" from the Visual Studio help menu) will provide a step-by-step walk through on how to create a CAPE-OPEN Unit Operation. The work flow for creating a Property Calculator is not much different, except you will have to implement a different set of CAPE-OPEN interfaces, as outlined above.
In COCO/TEA you can use such Property Calculation routine, by editing the TEA package configuration. After registration your routine should show up on the External Routines tab, if you click Add (note that TEA can also use any CAPE-OPEN 1.1 compliant property package as external calculation routine, as a property package implements a superset of a Property Routine's functionality):

- extrouitine1.png (21.4 KiB) Viewed 43460 times
Then, after adding the routine, you can go to the Properties tab, and change the routine that is used for an individual property:

- extrouitine2.png (20.71 KiB) Viewed 43460 times
Please be aware that your property calculation may be requested for a list of compounds that differs (may be a sub set, may be in different order) from the compounds in the package. You should get the list of compounds from the material object that was set through SetMaterial (the material on which the calculations are done) prior to doing the calculations. You can assume that the list of compounds on the Material Object will not have changed in the next calculation, unless SetMaterial was called again (perhaps with a different material object, or perhaps with a reconfigured material object).
Hope that helps. I am available for questions.