Material Stream Switch¶
DWSIM Plus
Available with a DWSIM Plus (Patreon) subscription.
![]()
Material stream switch: routes the inlet material stream to outlet 1 when Expression evaluates to true and to outlet 2 otherwise; the other outlet gets a copy of the inlet with zero flow.
DWSIM.UnitOperations.ExtensionPack.MaterialStreamSwitch
Assembly DWSIM.UnitOperations.ExtensionPack.dll · Object ← BaseClass ← UnitOpBaseClass ← MaterialStreamSwitch
At a glance¶

| Port | Index | Connected in the example |
|---|---|---|
| Inlet, material | 0 |
Gas |
| Outlet, material | 0 |
To sales |
| Outlet, material | 1 |
To separator |
Example¶
This code runs on every build of this site, and the output below is what it printed.
fs = (Flowsheet.Create("MaterialSwitchExample")
.WithCompounds("Methane", "Propane", "N-butane")
.WithPropertyPackage(PropertyPackages.PengRobinson))
gas = (fs.AddMaterialStream("Gas")
.At(Q.Celsius(5.0), Q.Bar(30.0))
.SetCompoundMolarFlow("Methane", 80.0)
.SetCompoundMolarFlow("Propane", 15.0)
.SetCompoundMolarFlow("N-butane", 5.0))
to_sales = fs.AddMaterialStream("To sales")
to_separator = fs.AddMaterialStream("To separator")
# Inlet variables: T (K), P (Pa), W (kg/s), M (mol/s), Q (m3/s), VF, LF, SF.
# TRUE routes the whole inlet to outlet 1, FALSE to outlet 2.
switch = (fs.AddMaterialStreamSwitch("MSW-1")
.WithExpression("VF > 0.999")
.ConnectFeed(gas)
.ConnectProduct(to_sales, 0)
.ConnectProduct(to_separator, 1))
fs.AutoLayout()
fs.Solve()
vf = gas.Object.Phases[2].Properties.molarfraction
print(f"Inlet vapor fraction = {vf:.4f}")
print(f"To sales = {to_sales.Object.GetMassFlow():.4f} kg/s")
print(f"To separator = {to_separator.Object.GetMassFlow():.4f} kg/s")
Output
DWSIM 10.2.11.0, generated 2026-10-08.
Learn more¶
-
User guide
-
FluentAPI
API members¶
Public members declared by this class. Inherited members are documented on the base classes.
Constructors¶
MaterialStreamSwitch(): Initializes a new default instance of the MaterialStreamSwitch class.
Initializes a new default instance of the MaterialStreamSwitch class.
MaterialStreamSwitch(string, string): Initializes a new instance of the MaterialStreamSwitch class with a name and description.
Initializes a new instance of the MaterialStreamSwitch class with a name and description.
| Parameter | Type | Description |
|---|---|---|
Name |
String |
The name of this unit operation. |
Description |
String |
A brief description of this unit operation. |
Properties¶
ComponentDescription: Gets or sets the CAPE-OPEN component description for this unit operation.
Gets or sets the CAPE-OPEN component description for this unit operation.
ComponentName: Gets or sets the CAPE-OPEN component name for this unit operation.
Gets or sets the CAPE-OPEN component name for this unit operation.
Expression: Gets or sets the logical routing expression, written with the inlet stream variables T (K), P (Pa), W (mass flow...
Gets or sets the logical routing expression, written with the inlet stream variables T (K), P (Pa), W (mass flow, kg/s), M (molar flow, mol/s), Q (volumetric flow, m3/s), and the vapor, liquid and solid phase mole fractions VF, LF and SF. True routes the inlet to outlet 1, false to outlet 2. Calculation fails if the expression is empty.
IsPremium: Gets a value indicating whether this unit operation is a premium (DWSIM Patreon) unit operation.
Gets a value indicating whether this unit operation is a premium (DWSIM Patreon) unit operation. Always True; the object palette lists it under the Premium category.
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. Always False.
ObjectClass: Gets or sets the simulation object class category (Logical).
Gets or sets the simulation object class category (Logical).
Methods¶
Calculate(object): Calculates the object.
Calculates the object.
| Parameter | Type | Description |
|---|---|---|
args |
Object |
CloneXML(): Creates a deep copy of this object by round-tripping through XML serialization.
Creates a deep copy of this object by round-tripping through XML serialization.
CloseEditForm(): Closes the editor of this object, if it is open.
Closes the editor of this object, if it is open.
DeCalculate(): Decalculates the object.
Decalculates the object.
DisplayEditForm(): Opens the editor of this object.
Opens the editor of this object. A host that has no editor for it does nothing.
GetDisplayDescription(): Returns the description string for this unit operation type.
Returns the description string for this unit operation type.
GetDisplayName(): Returns the display name for this unit operation type.
Returns the display name for this unit operation type.
GetIconBitmapBytes(): Returns the raw bytes of the icon image for this unit operation.
Returns the raw bytes of the icon image for this unit operation.
GetPropertyDescription(string): Returns the description of the specified property.
Returns the description of the specified property.
| Parameter | Type | Description |
|---|---|---|
p |
String |
The property name. |
LoadData(List<XElement>): Restores the unit operation state from a list of XML elements previously produced by SaveData.
Restores the unit operation state from a list of XML elements previously produced by SaveData.
| Parameter | Type | Description |
|---|---|---|
data |
List<XElement> |
The list of XElement objects containing serialized state. |
SaveData(): Serializes the unit operation state to a list of XML elements for persistence.
Serializes the unit operation state to a list of XML elements for persistence.
UpdateEditForm(): Redraws the editor of this object with the current values, if it is open.
Redraws the editor of this object with the current values, if it is open.
Fields¶