Skip to content

Energy Stream Switch

DWSIM Plus

Available with a DWSIM Plus (Patreon) subscription.

Energy stream switch: routes the inlet energy stream to outlet 1 when Expression evaluates to true and to outlet 2 otherwise; the other outlet gets zero energy flow.

DWSIM.UnitOperations.ExtensionPack.EnergyStreamSwitch
Assembly DWSIM.UnitOperations.ExtensionPack.dll · Object ← BaseClass ← UnitOpBaseClass ← EnergyStreamSwitch

At a glance

Energy Stream Switch in the example flowsheet

Port Index Connected in the example
Inlet, energy 0 C-1 duty
Outlet, energy 0 Cooling tower
Outlet, energy 1 Air cooler

Example

This code runs on every build of this site, and the output below is what it printed.

fs = (Flowsheet.Create("EnergySwitchExample")
      .WithCompound("Water")
      .WithPropertyPackage(PropertyPackages.SteamTables))

hot = fs.AddMaterialStream("Water-in").At(Q.Celsius(90.0), Q.Bar(2.0)).WithMassFlow(Q.KgPerSecond(4.0))
cold = fs.AddMaterialStream("Water-out")
duty = fs.AddEnergyStream("C-1 duty")
large = fs.AddEnergyStream("Cooling tower")
small = fs.AddEnergyStream("Air cooler")

(fs.AddCooler("C-1").WithOutletTemperature(Q.Celsius(40.0))
   .ConnectFeed(hot).ConnectProduct(cold).ConnectEnergyProduct(duty, 0))

# HF is the inlet heat flow in kW. TRUE sends it to outlet 1, FALSE to outlet 2.
switch = (fs.AddEnergyStreamSwitch("ESW-1")
          .WithExpression("HF > 500")
          .ConnectEnergyFeed(duty, 0)
          .ConnectEnergyProduct(large, 0))
switch.ConnectEnergyProduct(small, 1)

fs.AutoLayout()
fs.Solve()

print(f"Cooler duty   = {duty.EnergyFlowKW:.1f} kW")
print(f"Cooling tower = {large.EnergyFlowKW:.1f} kW")
print(f"Air cooler    = {small.EnergyFlowKW:.1f} kW")

Output

Cooler duty   = 837.4 kW
Cooling tower = 837.4 kW
Air cooler    = 0.0 kW

DWSIM 10.2.11.0, generated 2026-10-08.

Learn more

API members

Public members declared by this class. Inherited members are documented on the base classes.

Constructors

EnergyStreamSwitch(): Initializes a new default instance of the EnergyStreamSwitch class.

Initializes a new default instance of the EnergyStreamSwitch class.

public EnergyStreamSwitch()
Public Sub New()

EnergyStreamSwitch(string, string): Initializes a new instance of the EnergyStreamSwitch class with a name and description.

Initializes a new instance of the EnergyStreamSwitch 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.
public EnergyStreamSwitch(string Name, string Description)
Public Sub New(Name As String, Description As String)

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.

public override string ComponentDescription { get; set; }
Public Overrides Property ComponentDescription As String

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.

public override string ComponentName { get; set; }
Public Overrides Property ComponentName As String

Expression: Gets or sets the logical routing expression.

Gets or sets the logical routing expression. It can use the variable HF, the inlet heat flow in kW. True routes the inlet to outlet 1, false to outlet 2. Calculation fails if the expression is empty.

public string Expression { get; set; }
Public Property Expression As String

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.

public bool IsPremium { get; }
Public ReadOnly Property IsPremium As Boolean

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.

public override bool MobileCompatible { get; }
Public Overrides ReadOnly Property MobileCompatible As Boolean

ObjectClass: Gets or sets the simulation object class category (Logical).

Gets or sets the simulation object class category (Logical).

public override SimulationObjectClass ObjectClass { get; set; }
Public Overrides Property ObjectClass As SimulationObjectClass

Methods

Calculate(object): Calculates the object.

Calculates the object.

Parameter Type Description
args Object
public override void Calculate(object args = null)
Public Overrides Sub Calculate(args As Object = Nothing)

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.

public override object CloneXML()
Public Overrides Function CloneXML() As Object

CloseEditForm(): Closes the editor of this object, if it is open.

Closes the editor of this object, if it is open.

public override void CloseEditForm()
Public Overrides Sub CloseEditForm()

DeCalculate(): Decalculates the object.

Decalculates the object.

public override void DeCalculate()
Public Overrides Sub DeCalculate()

DisplayEditForm(): Opens the editor of this object.

Opens the editor of this object. A host that has no editor for it does nothing.

public override void DisplayEditForm()
Public Overrides Sub DisplayEditForm()

GetDisplayDescription(): Returns the description string for this unit operation type.

Returns the description string for this unit operation type.

public override string GetDisplayDescription()
Public Overrides Function GetDisplayDescription() As String

GetDisplayName(): Returns the display name for this unit operation type.

Returns the display name for this unit operation type.

public override string GetDisplayName()
Public Overrides Function GetDisplayName() As String

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.

public override byte[] GetIconBitmapBytes()
Public Overrides Function GetIconBitmapBytes() As Byte()

GetPropertyDescription(string): Returns the description of the specified property.

Returns the description of the specified property.

Parameter Type Description
p String The property name.
public override string GetPropertyDescription(string p)
Public Overrides Function GetPropertyDescription(p As String) As String

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.
public override bool LoadData(List<XElement> data)
Public Overrides Function LoadData(data As List(Of XElement)) As Boolean

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.

public override List<XElement> SaveData()
Public Overrides Function SaveData() As List(Of XElement)

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.

public override void UpdateEditForm()
Public Overrides Sub UpdateEditForm()

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.

public EditingForm_ESSwitch f
Public f As EditingForm_ESSwitch