Flowsheet Unit Operation¶
![]()
Represents a Flowsheet Unit Operation that embeds a complete sub-flowsheet as a single block in the parent flowsheet. Input and output streams are mapped to corresponding streams in the sub-flowsheet, enabling modular process simulation.
DWSIM.UnitOperations.UnitOperations.Flowsheet
Assembly DWSIM.UnitOperations.dll · Object ← BaseClass ← UnitOpBaseClass ← Flowsheet
At a glance¶

| Port | Index | Connected in the example |
|---|---|---|
| Inlet, material | 0 |
Feed |
| Inlet, material | 1 |
|
| Inlet, material | 2 |
|
| Inlet, material | 3 |
|
| Inlet, material | 4 |
|
| Inlet, material | 5 |
|
| Inlet, material | 6 |
|
| Inlet, material | 7 |
|
| Inlet, material | 8 |
|
| Inlet, material | 9 |
|
| Outlet, material | 0 |
Product |
| Outlet, material | 1 |
|
| Outlet, material | 2 |
|
| Outlet, material | 3 |
|
| Outlet, material | 4 |
|
| Outlet, material | 5 |
|
| Outlet, material | 6 |
|
| Outlet, material | 7 |
|
| Outlet, material | 8 |
|
| Outlet, material | 9 |
Example¶
This code runs on every build of this site, and the output below is what it printed.
import os
import tempfile
# 1. The child flowsheet: heat to 80 C, then let down to 1 bar. Its feed is a
# placeholder that the parent overwrites on every run.
child = (Flowsheet.Create("Child")
.WithCompounds("N-hexane", "N-heptane")
.WithPropertyPackage(PropertyPackages.PengRobinson))
c_in = (child.AddMaterialStream("In")
.At(Q.Celsius(25.0), Q.Bar(2.0))
.SetCompoundMolarFlow("N-hexane", 1.0)
.SetCompoundMolarFlow("N-heptane", 1.0))
c_hot = child.AddMaterialStream("Hot")
c_out = child.AddMaterialStream("Out")
c_q = child.AddEnergyStream("Q")
(child.AddHeater("H-1").WithOutletTemperature(Q.Celsius(80.0))
.ConnectFeed(c_in).ConnectProduct(c_hot).ConnectEnergyFeed(c_q, 1))
(child.AddValve("V-1").WithOutletPressure(Q.Bar(1.0))
.ConnectFeed(c_hot).ConnectProduct(c_out))
child.AutoLayout()
child.Solve()
path = os.path.join(tempfile.gettempdir(), "dwsim_child_flowsheet.dwxmz")
child.Save(path)
# 2. The parent flowsheet runs the saved file as a unit operation
fs = (Flowsheet.Create("FlowsheetUOExample")
.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")
uo = (fs.AddUnitOperation(ObjectType.FlowsheetUO, "FS-1")
.ConnectFeed(feed, 0)
.ConnectProduct(product, 0))
sub = uo.Object.__implementation__ # the Flowsheet unit operation
sub.SimulationFile = path
sub.InitializeInternalFlowsheet() # loads the child flowsheet into sub.Fsheet
# Map the ports to child streams (by their internal names)
sub.InputConnections[0] = sub.Fsheet.GetFlowsheetSimulationObject("In").Name
sub.OutputConnections[0] = sub.Fsheet.GetFlowsheetSimulationObject("Out").Name
fs.AutoLayout()
fs.Solve()
p = product.Object
duty = sub.Fsheet.GetFlowsheetSimulationObject("Q").__implementation__.EnergyFlow
print(f"Product T = {product.TemperatureK - 273.15:.2f} C")
print(f"Product P = {product.PressurePa / 1e5:.3f} bar")
print(f"Vapor fraction = {p.Phases[2].Properties.molarfraction:.4f}")
print(f"Child heater duty = {duty:.2f} kW")
print(f"Mass balance error= {sub.MassBalanceError:.2e} %")
Output
Product T = 77.22 C
Product P = 1.000 bar
Vapor fraction = 0.0213
Child heater duty = 190.09 kW
Mass balance error= 0.00e+00 %
DWSIM 10.2.11.0, generated 2026-10-08.
Learn more¶
-
User guide
API members¶
Public members declared by this class. Inherited members are documented on the base classes.
Constructors¶
Flowsheet(): Initializes a new default instance.
Initializes a new default instance.
Flowsheet(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 |
|
description |
String |
Properties¶
CompoundMappings: Gets or sets the dictionary mapping parent-flowsheet compound names to sub-flowsheet compound names.
Gets or sets the dictionary mapping parent-flowsheet compound names to sub-flowsheet compound names.
EmbeddedFileName: Gets or sets the embedded file name when the sub-flowsheet is embedded.
Gets or sets the embedded file name when the sub-flowsheet is embedded.
FileIsEmbedded: Gets or sets whether the sub-flowsheet file is embedded in the parent simulation file.
Gets or sets whether the sub-flowsheet file is embedded in the parent simulation file.
Initialized: Gets or sets whether the sub-flowsheet has been loaded into Fsheet.
Gets or sets whether the sub-flowsheet has been loaded into Fsheet. Not saved with the flowsheet.
InitializeOnLoad: Gets or sets whether the sub-flowsheet is initialized when the parent flowsheet loads.
Gets or sets whether the sub-flowsheet is initialized when the parent flowsheet loads.
InputConnections: Gets or sets the list of input stream connection IDs in the sub-flowsheet.
Gets or sets the list of input stream connection IDs in the sub-flowsheet.
InputParams: Gets or sets the dictionary of input parameter mappings, keyed by parameter ID.
Gets or sets the dictionary of input parameter mappings, keyed by parameter ID.
MassBalanceError: Gets or sets the mass balance error across the sub-flowsheet (fractional).
Gets or sets the mass balance error across the sub-flowsheet (fractional).
MassTransferMode: Gets or sets how compound flows are transferred between parent and sub-flowsheet streams.
Gets or sets how compound flows are transferred between parent and sub-flowsheet streams.
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 (UserModels).
Gets or sets the simulation object class category (UserModels).
OutputConnections: Gets or sets the list of output stream connection IDs in the sub-flowsheet.
Gets or sets the list of output stream connection IDs in the sub-flowsheet.
OutputParams: Gets or sets the dictionary of output parameter mappings, keyed by parameter ID.
Gets or sets the dictionary of output parameter mappings, keyed by parameter ID.
RedirectOutput: Gets or sets whether output from the sub-flowsheet solver is redirected to the parent flowsheet log.
Gets or sets whether output from the sub-flowsheet solver is redirected to the parent flowsheet log.
SimulationFile: Gets or sets the file path to the sub-flowsheet simulation file.
Gets or sets the file path to the sub-flowsheet simulation file.
UpdateOnSave: Gets or sets whether the sub-flowsheet file is updated when the parent flowsheet is saved.
Gets or sets whether the sub-flowsheet file is updated when the parent flowsheet is saved.
Methods¶
AddGraphicObjects(IFlowsheet, IFlowsheet, List<XElement>, ConcurrentBag<Exception>, string, int, bool): Creates the graphic objects described by the XML elements of a saved simulation, adds them to a flowsheet and...
Creates the graphic objects described by the XML elements of a saved simulation, adds them to a flowsheet and restores their material and energy connections. Errors are collected instead of thrown.
| Parameter | Type | Description |
|---|---|---|
fs |
IFlowsheet |
The flowsheet that receives the graphic objects. |
mainfs |
IFlowsheet |
The parent flowsheet, used to resolve external unit operations by description. |
data |
List<XElement> |
The "GraphicObjects" XML elements of the saved simulation. |
excs |
ConcurrentBag<Exception> |
Collection that receives any exception raised while loading objects or connections. |
pkey |
String |
Optional prefix added to every object name (and its connection references); when not empty, duplicate tags are renumbered. |
shift |
Int32 |
Optional offset added to the X and Y coordinates of every object, in drawing units. |
reconnectinlets |
Boolean |
Optional. If True, inlet connections are also re-created from the source objects' free outlet ports. |
Calculate(object): Transfers input data to the sub-flowsheet, solves it, and maps results back to the parent.
Transfers input data to the sub-flowsheet, solves it, and maps results back to the parent.
| Parameter | Type | Description |
|---|---|---|
args |
Object |
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.
DisplayEditForm(): Opens or activates the editing form.
Opens or activates the editing form.
ExtractXML(string): Extracts all files of a compressed simulation file (.dwxmz) into the system temporary folder.
Extracts all files of a compressed simulation file (.dwxmz) into the system temporary folder.
| Parameter | Type | Description |
|---|---|---|
zippath |
String |
Full path of the compressed simulation file. |
GetDisplayDescription(): Returns the localised display description.
Returns the localised display description.
GetDisplayName(): Returns the localised display name.
Returns the localised display name.
GetEditingForm(): Returns the editing form instance.
Returns the editing form instance.
GetIconBitmapBytes(): Returns the icon bitmap as a byte array.
Returns the icon bitmap as a byte array.
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, converted to the given unit system.
Returns the value of the specified property, converted to the given unit system.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
|
su |
IUnitsOfMeasure |
GetReport(IUnitsOfMeasure, CultureInfo, string): Generates a plain-text report of the flowsheet UO results.
Generates a plain-text report of the flowsheet UO results.
| Parameter | Type | Description |
|---|---|---|
su |
IUnitsOfMeasure |
|
ci |
CultureInfo |
|
numberformat |
String |
InitializeFlowsheet(MemoryStream, IFlowsheet, IFlowsheet): Creates and initializes a sub-flowsheet from a compressed memory stream.
Creates and initializes a sub-flowsheet from a compressed memory stream.
| Parameter | Type | Description |
|---|---|---|
compressedstream |
MemoryStream |
|
form |
IFlowsheet |
|
mainfs |
IFlowsheet |
InitializeFlowsheet(string, IFlowsheet, IFlowsheet): Creates and initializes a sub-flowsheet from the given file path.
Creates and initializes a sub-flowsheet from the given file path.
| Parameter | Type | Description |
|---|---|---|
fpath |
String |
|
form |
IFlowsheet |
|
mainfs |
IFlowsheet |
InitializeInternalFlowsheet(): Initializes the internal sub-flowsheet object from the simulation file or embedded data.
Initializes the internal sub-flowsheet object from the simulation file or embedded data.
InitializeMappings(): Initialises compound mappings between parent and sub-flowsheet using name matching.
Initialises compound mappings between parent and sub-flowsheet using name matching.
LoadData(List<XElement>): Restores the flowsheet UO state, including parameter mappings and connections, from XML.
Restores the flowsheet UO state, including parameter mappings and connections, from XML.
| Parameter | Type | Description |
|---|---|---|
data |
List<XElement> |
ParseFilePath(): Resolves the sub-flowsheet file path relative to the parent flowsheet file.
Resolves the sub-flowsheet file path relative to the parent flowsheet file.
ReturnProcessData(IFlowsheetBag): Serializes the current sub-flowsheet data to a compressed memory stream.
Serializes the current sub-flowsheet data to a compressed memory stream.
| Parameter | Type | Description |
|---|---|---|
Form |
IFlowsheetBag |
SaveData(): Serializes the flowsheet UO state, including parameter mappings and connections, to XML.
Serializes the flowsheet UO state, including parameter mappings and connections, to XML.
SetPropertyValue(string, object, IUnitsOfMeasure): Sets the value of the specified property from the given value and unit system.
Sets the value of the specified property from the given value and unit system.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
|
propval |
Object |
|
su |
IUnitsOfMeasure |
UpdateEditForm(): Refreshes the editing form with updated data.
Refreshes the editing form with updated data.
UpdateProcessData(IFlowsheetBag, XDocument): Updates process-level data in the XML document from the given flowsheet bag.
Updates process-level data in the XML document from the given flowsheet bag.
| Parameter | Type | Description |
|---|---|---|
form |
IFlowsheetBag |
|
xdoc |
XDocument |
UpdateProcessData(string): Saves the current sub-flowsheet state back to the file at the given path.
Saves the current sub-flowsheet state back to the file at the given path.
| Parameter | Type | Description |
|---|---|---|
path |
String |
Fields¶
f: The classic (WinForms) editor window open for this unit operation, if any.
The classic (WinForms) editor window open for this unit operation, if any. Not saved with the flowsheet.