CAPE-OPEN Unit Operation¶
![]()
Hosts an external CAPE-OPEN unit operation (a COM component registered on Windows) in the flowsheet. It creates the COM object, mirrors its ports as flowsheet connectors and its parameters as a local collection, connects the attached streams to the ports, calls the component's Calculate, and saves the component state through its persistence interfaces. CAPE-OPEN unit operations run only on Windows.
DWSIM.UnitOperations.UnitOperations.CapeOpenUO
Assembly DWSIM.UnitOperations.dll · Object ← BaseClass ← UnitOpBaseClass ← CapeOpenUO
At a glance¶

| Port | Index | Connected in the example |
|---|---|---|
| Inlet, material | 0 |
Feed |
| Outlet, material | 0 |
Product |
| Outlet, energy | 1 |
Heat |
Example¶
This code runs on every build of this site, and the output below is what it printed.
# The unit operation is a COM component registered on the machine, here the HeaterCooler
# of the free COCO simulator. The desktop application asks the user which one to host;
# a script answers through SelectorOverride before the object is created.
registered = CapeOpenUO.SearchRegisteredUnitOperations(False)
info = next(i for i in registered if i.TypeName == "COCO_COUS.HeaterCooler.1")
CapeOpenUO.SelectorOverride = System.Func[CapeOpenUnitOpInfo](lambda: info)
fs = (Flowsheet.Create("CapeOpenUOExample")
.WithCompounds("N-hexane", "N-heptane")
.WithPropertyPackage(PropertyPackages.PengRobinson))
feed = (fs.AddMaterialStream("Feed")
.At(Q.Celsius(25.0), Q.Bar(2.0))
.SetCompoundMassFlow("N-hexane", 0.9) # kg/s
.SetCompoundMassFlow("N-heptane", 0.6))
product = fs.AddMaterialStream("Product")
heat = fs.AddEnergyStream("Heat")
uo = fs.AddUnitOperation(ObjectType.CapeOpenUO, "CO-1")
CapeOpenUO.SelectorOverride = None # back to the default selector
# The ports are the ones the component declares, in its own order
uo.ConnectFeed(feed, 0).ConnectProduct(product, 0)
uo.ConnectEnergyProduct(heat, 1)
# The parameters too; inputs are set by name with SetPropertyValue
co = uo.Object.__implementation__
co.SetPropertyValue("Heat duty", 135840.0) # W
co.SetPropertyValue("Pressure drop", 0.0) # Pa
go = co.GraphicObject
print(f"Component = {info.Name} {info.Version} ({info.TypeName})")
print("Inlets = " + ", ".join(f"{c.ConnectorName} ({c.Type})" for c in go.InputConnectors))
print("Outlets = " + ", ".join(f"{c.ConnectorName} ({c.Type})" for c in go.OutputConnectors))
for name in ("Type", "Heat duty", "Pressure drop", "Thermo Version"):
print(f"{name:<15}= {co.GetPropertyValue(name)}")
fs.AutoLayout()
fs.Solve()
p = product.Object
print(f"Product = {p.GetTemperature() - 273.15:.1f} C, vapor fraction {p.Phases[2].Properties.molarfraction or 0.0:.3f}")
# the component writes the duty on its outlet energy port with the CAPE-OPEN sign
print(f"Heat stream = {heat.Object.EnergyFlow:.1f} kW")
Output
Component = HeaterCooler 3.8.0.0 (COCO_COUS.HeaterCooler.1)
Inlets = Inlet (ConIn)
Outlets = Outlet (ConOut), Heat (ConEn)
Type = Heat duty
Heat duty = 135840
Pressure drop = 0
Thermo Version = 1.0
Product = 65.0 C, vapor fraction 0.000
Heat stream = -135.8 kW
DWSIM 10.2.11.0, generated 2026-10-08.
Properties¶
IDs accepted by GetPropertyValue, SetPropertyValue, the sensitivity analysis, the optimizer, the Adjust block and dynamic events. Units are SI; pass another unit system to GetPropertyValue to get them converted.
| ID | Name | Unit (SI) | Input |
|---|---|---|---|
Type |
Component Type | yes | |
Outlet temperature |
yes | ||
Heat duty |
yes | ||
Pressure drop |
yes | ||
Thermo Version |
yes |
Learn more¶
-
User guide
API members¶
Public members declared by this class. Inherited members are documented on the base classes.
Constructors¶
CapeOpenUO(): Initializes a new default instance.
Initializes a new default instance.
CapeOpenUO(string, string): Initializes a new instance with a name and description.
Initializes a new instance with a name and description.
| Parameter | Type | Description |
|---|---|---|
name |
String |
|
desc |
String |
CapeOpenUO(string, string, IGraphicObject, bool): Initializes a new instance with a name, description, graphic object, and optional ChemSep mode.
Initializes a new instance with a name, description, graphic object, and optional ChemSep mode.
| Parameter | Type | Description |
|---|---|---|
name |
String |
|
description |
String |
|
gobj |
IGraphicObject |
|
chemsep |
Boolean |
Properties¶
ChemSepFinderOverride: Lets a host that is not WinForms supply ChemSep's CAPE-OPEN unit operation (from SearchRegisteredUnitOperations) for...
Lets a host that is not WinForms supply ChemSep's CAPE-OPEN unit operation (from SearchRegisteredUnitOperations) for the ChemSep-column shortcut. Leave it Nothing (the default) to keep using the built-in WinForms AddChemSepColumn path.
EmbeddedImageData: Gets or sets Base-64 encoded embedded image data for a custom icon.
Gets or sets Base-64 encoded embedded image data for a custom icon.
HasPropertiesForDynamicMode: Gets a value indicating this unit operation has no dedicated dynamic-mode properties.
Gets a value indicating this unit operation has no dedicated dynamic-mode properties.
MobileCompatible: Gets a value indicating whether this unit operation is compatible with mobile interfaces.
Gets a value indicating whether this unit operation is compatible with mobile interfaces.
ObjectClass: Gets or sets the simulation object class category (CAPEOPEN).
Gets or sets the simulation object class category (CAPEOPEN).
ProductAssembly: Gets the file location (server path) registered by the COM unit operation, or the name of this assembly if none is...
Gets the file location (server path) registered by the COM unit operation, or the name of this assembly if none is selected.
ProductAuthor: Gets the product author reported by the COM unit operation.
Gets the product author reported by the COM unit operation.
ProductContactInfo: Gets the help URL registered by the COM unit operation, or the DWSIM website if none is selected.
Gets the help URL registered by the COM unit operation, or the DWSIM website if none is selected.
ProductDescription: Gets the product description reported by the COM unit operation.
Gets the product description reported by the COM unit operation.
ProductName: Gets the product name reported by the COM unit operation.
Gets the product name reported by the COM unit operation.
ProductPage: Gets the vendor URL registered by the COM unit operation, or the DWSIM website if none is selected.
Gets the vendor URL registered by the COM unit operation, or the DWSIM website if none is selected.
ProductVersion: Gets the component version registered by the COM unit operation, or the version of this assembly if none is selected.
Gets the component version registered by the COM unit operation, or the version of this assembly if none is selected.
ReactionSetID: Gets or sets the ID of the reaction set used by the CAPE-OPEN unit operation.
Gets or sets the ID of the reaction set used by the CAPE-OPEN unit operation.
ReactionSetName: Gets or sets the name of the reaction set used by the CAPE-OPEN unit operation.
Gets or sets the name of the reaction set used by the CAPE-OPEN unit operation.
RecalcOutputStreams: Gets or sets whether output streams are recalculated (flashed) after the CAPE-OPEN calculation.
Gets or sets whether output streams are recalculated (flashed) after the CAPE-OPEN calculation.
SelectorOverride: Lets a host that is not WinForms supply the CAPE-OPEN unit operation to instantiate.
Lets a host that is not WinForms supply the CAPE-OPEN unit operation to instantiate. Leave it Nothing (the default) to keep using the built-in WinForms selector.
SupportsDynamicMode: Gets a value indicating this unit operation supports dynamic simulation mode.
Gets a value indicating this unit operation supports dynamic simulation mode.
SupportsRestoreStateAfterError: Gets a value indicating this unit operation does not support restoring state after an error.
Gets a value indicating this unit operation does not support restoring state after an error.
UseEmbeddedImage: Gets or sets whether the embedded image is used as the graphic object icon.
Gets or sets whether the embedded image is used as the graphic object icon.
Methods¶
Calculate(object): Calculates the CAPE-OPEN unit operation by marshalling data to/from the COM object.
Calculates the CAPE-OPEN unit operation by marshalling data to/from the COM object.
| Parameter | Type | Description |
|---|---|---|
args |
Object |
Clone2(): Creates a shallow clone of this CAPE-OPEN unit operation.
Creates a shallow clone of this CAPE-OPEN unit operation.
CloneXML(): Creates a deep copy via XML serialization.
Creates a deep copy via XML serialization.
CloseEditForm(): Closes and disposes the editing form.
Closes and disposes the editing form.
CreateConnectors(): Creates the graphic connectors from _ports: one inlet connector on the left side for each inlet port and...
Creates the graphic connectors from _ports: one inlet connector on the left side for each inlet port and one outlet connector on the right side for each outlet port, of material or energy type and named after the port.
DeCalculate(): Clears all calculated results.
Clears all calculated results.
DisconnectPorts(): Disconnects every connected port of the COM component.
Disconnects every connected port of the COM component. Called when the unit operation is disposed.
DisplayEditForm(): Opens or activates the editing form.
Opens or activates the editing form.
Edit(): Opens the COM component's own editor (ICapeUtilities.Edit) after reconnecting its ports, then reads back the...
Opens the COM component's own editor (ICapeUtilities.Edit) after reconnecting its ports, then reads back the parameters and ports and rebuilds the graphic connectors.
GetCAPEOPENObject(): Returns the underlying COM CAPE-OPEN unit operation object.
Returns the underlying COM CAPE-OPEN unit operation object.
GetDisplayDescription(): Returns the localised display description.
Returns the localised display description.
GetDisplayName(): Returns the localised display name.
Returns the localised display name.
GetIconBitmapBytes(): Returns the icon bitmap as a byte array.
Returns the icon bitmap as a byte array.
GetManagedUnitType(string): Loads a .NET assembly and returns the first non-abstract type in it that implements ICapeUnit.
Loads a .NET assembly and returns the first non-abstract type in it that implements ICapeUnit.
| Parameter | Type | Description |
|---|---|---|
filepath |
String |
Full path of the assembly file. |
GetParams(): Reads the parameters of the COM component and appends a local copy of each one (real, integer, boolean, option or...
Reads the parameters of the COM component and appends a local copy of each one (real, integer, boolean, option or array, with value, default, bounds and mode) to _params.
GetPorts(): Reads the ports of the COM component and appends a local copy of each one (name, description, direction and type) to...
Reads the ports of the COM component and appends a local copy of each one (name, description, direction and type) to _ports.
GetProperties(PropertyType): Returns an array of property identifiers for the specified property type.
Returns an array of property identifiers for the specified property type.
| Parameter | Type | Description |
|---|---|---|
proptype |
PropertyType |
GetPropertyUnit(string, IUnitsOfMeasure): Returns the unit string for the specified property.
Returns the unit string for the specified property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
|
su |
IUnitsOfMeasure |
GetPropertyValue(string, IUnitsOfMeasure): Returns the value of the specified property.
Returns the value of the specified property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
|
su |
IUnitsOfMeasure |
GetReport(IUnitsOfMeasure, CultureInfo, string): Generates a plain-text report of the CAPE-OPEN unit operation results.
Generates a plain-text report of the CAPE-OPEN unit operation results.
| Parameter | Type | Description |
|---|---|---|
su |
IUnitsOfMeasure |
|
ci |
CultureInfo |
|
numberformat |
String |
Init(): Initializes the COM component (ICapeUtilities.Initialize), gives it the flowsheet as simulation context and sets its...
Initializes the COM component (ICapeUtilities.Initialize), gives it the flowsheet as simulation context and sets its name and description from the graphic object.
InitNew(): Calls IPersistStreamInit.InitNew on the COM component, if it implements it, so it starts from a fresh state.
Calls IPersistStreamInit.InitNew on the COM component, if it implements it, so it starts from a fresh state. Errors are ignored.
InstantiateSelected(): Instantiates the COM object for the currently selected unit operation, reading its ports and parameters.
Instantiates the COM object for the currently selected unit operation, reading its ports and parameters. Public so a host can re-run it after changing the selection.
isCOUnit(Type): Returns whether the given type implements the CAPE-OPEN ICapeUnit interface.
Returns whether the given type implements the CAPE-OPEN ICapeUnit interface.
| Parameter | Type | Description |
|---|---|---|
t |
Type |
The type to test. |
LoadData(List<XElement>): Restores the CAPE-OPEN unit operation state from XML, including persisted COM data.
Restores the CAPE-OPEN unit operation state from XML, including persisted COM data.
| Parameter | Type | Description |
|---|---|---|
data |
List<XElement> |
PerformPostCalcValidation(): Performs post-calculation validation on the CAPE-OPEN unit operation.
Performs post-calculation validation on the CAPE-OPEN unit operation.
PersistLoad(StreamingContext): Restores the state of the COM component from the persisted data, through its IPersistStreamInit or IPersistStream...
Restores the state of the COM component from the persisted data, through its IPersistStreamInit or IPersistStream interface, creating the COM object first if needed. Then reads the parameters from the component or, when the component could not load its own data, writes the stored parameter values back to it.
| Parameter | Type | Description |
|---|---|---|
context |
StreamingContext |
Streaming context. Not used. |
PersistSave(StreamingContext): Asks the COM component to save its state through its IPersistStreamInit or IPersistStream interface and keeps the...
Asks the COM component to save its state through its IPersistStreamInit or IPersistStream interface and keeps the bytes for SaveData. Components without either interface save nothing.
| Parameter | Type | Description |
|---|---|---|
context |
StreamingContext |
Streaming context. Not used. |
RestoreParams(): Writes the values stored in _params back to the parameters of the COM component, skipping output parameters.
Writes the values stored in _params back to the parameters of the COM component, skipping output parameters. A value the component rejects produces a flowsheet warning.
RestorePorts(): Reconnects the ports of the COM component to the flowsheet objects recorded in _ports, disconnecting any...
Reconnects the ports of the COM component to the flowsheet objects recorded in _ports, disconnecting any object a port is already connected to first.
RunDynamicModel(): Performs the dynamic-mode calculation by calling the CAPE-OPEN Calculate method.
Performs the dynamic-mode calculation by calling the CAPE-OPEN Calculate method.
SaveData(): Serializes the CAPE-OPEN unit operation state to XML, including persisted COM data.
Serializes the CAPE-OPEN unit operation state to XML, including persisted COM data.
SaveTempData(): Saves the current UO data in a temporary placeholder, so it can be loaded by another thread which will reinstantiate...
Saves the current UO data in a temporary placeholder, so it can be loaded by another thread which will reinstantiate the COM object because of interop restrictions.
SearchRegisteredUnitOperations(bool): Scans HKCR and HKCU for COM classes registered under the CAPE-OPEN unit-operation category and returns their metadata.
Scans HKCR and HKCU for COM classes registered under the CAPE-OPEN unit-operation category and returns their metadata. Lives here rather than on the WinForms selector so hosts without WinForms can offer their own picker.
| Parameter | Type | Description |
|---|---|---|
chemseponly |
Boolean |
SetPropertyValue(string, object, IUnitsOfMeasure): Sets the value of the specified property.
Sets the value of the specified property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
|
propval |
Object |
|
su |
IUnitsOfMeasure |
ShowForm(): Selects the CAPE-OPEN unit operation to host, through SelectorOverride when set or the WinForms...
Selects the CAPE-OPEN unit operation to host, through SelectorOverride when set or the WinForms selector dialog otherwise. A ChemSep selection also resizes the graphic object.
Terminate(): Calls ICapeUtilities.Terminate on the COM component, if one exists.
Calls ICapeUtilities.Terminate on the COM component, if one exists.
UpdateConnectorPositions(): Stores the connector offsets relative to the graphic object position in its AdditionalInfo, so the connectors keep...
Stores the connector offsets relative to the graphic object position in its AdditionalInfo, so the connectors keep their places when the object is drawn or moved.
UpdateConnectors(): Rebuilds the graphic connectors from the current ports of the COM component (for example after its editor added or...
Rebuilds the graphic connectors from the current ports of the COM component (for example after its editor added or removed ports): disconnects all existing flowsheet connections, recreates the connectors and reconnects the streams each port reports as connected.
UpdateConnectors2(): Used after loading a flowsheet: updates the type, position and name of the existing graphic connectors from the...
Used after loading a flowsheet: updates the type, position and name of the existing graphic connectors from the ports of the COM component and connects each port to the stream attached to its connector.
UpdateEditForm(): Refreshes the editing form with updated data.
Refreshes the editing form with updated data.
UpdateParams(): Copies the current parameter values of the COM component into _params, rebuilding the local collection...
Copies the current parameter values of the COM component into _params, rebuilding the local collection first when the number of parameters changed.
UpdatePorts(): Rebuilds _ports from the current ports of the COM component, including the flowsheet object each port is...
Rebuilds _ports from the current ports of the COM component, including the flowsheet object each port is connected to.
UpdatePortsFromConnectors(): Synchronizes _ports with the graphic connectors (disconnects ports whose connector is free, connects ports...
Synchronizes _ports with the graphic connectors (disconnects ports whose connector is free, connects ports whose connector has a stream attached) and then applies the result to the COM component with RestorePorts.
Validate(): Validates the CAPE-OPEN unit operation configuration.
Validates the CAPE-OPEN unit operation configuration.
Fields¶
_params: Local copy of the parameters of the COM component (real, integer, boolean, option and array parameters), read from...
Local copy of the parameters of the COM component (real, integer, boolean, option and array parameters), read from the component and written back to it. Not serialized.
_ports: Local copy of the ports of the COM component (name, description, direction, type and connected object), used to...
Local copy of the ports of the COM component (name, description, direction, type and connected object), used to build the flowsheet connectors and to reconnect the ports.
_seluo: Registry information of the hosted CAPE-OPEN unit operation (name, description, ProgID, version, vendor and...
Registry information of the hosted CAPE-OPEN unit operation (name, description, ProgID, version, vendor and location), chosen by the user or by a host selector. Used to recreate the COM object on load.