Skip to content

Recycle

Represents a material recycle convergence block that iterates stream conditions until inlet and outlet properties match within the specified tolerances. Supports Wegstein, Dominant Eigenvalue, and successive substitution acceleration methods.

DWSIM.UnitOperations.SpecialOps.Recycle
Assembly DWSIM.UnitOperations.dll · Object ← BaseClass ← SpecialOpBaseClass ← Recycle

At a glance

Recycle in the example flowsheet

Port Index Connected in the example
Inlet, material 0 Recycle-in
Outlet, material 0 Recycle-out

Example

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

fs = (Flowsheet.Create("RecycleExample")
      .WithCompounds("Methanol", "Water")
      .WithPropertyPackage(PropertyPackages.NRTL))

feed = (fs.AddMaterialStream("Feed")
        .At(Q.Celsius(25.0), Q.Bar(1.01325))
        .SetCompoundMolarFlow("Methanol", 10.0)     # mol/s
        .SetCompoundMolarFlow("Water", 10.0))
mixed = fs.AddMaterialStream("Mixed")
heated = fs.AddMaterialStream("Heated")
vapor = fs.AddMaterialStream("Vapor")
liquid = fs.AddMaterialStream("Liquid")
purge = fs.AddMaterialStream("Bottoms")
tear_in = fs.AddMaterialStream("Recycle-in")       # leaves the splitter
tear_out = fs.AddMaterialStream("Recycle-out")     # leaves the recycle block

fs.AddMixer("MIX-1").ConnectFeed(feed, 0).ConnectFeed(tear_out, 1).ConnectProduct(mixed)
(fs.AddHeater("H-1").WithOutletTemperature(Q.Celsius(80.0)).WithPressureDrop(Q.Pascal(0.0))
   .ConnectFeed(mixed).ConnectProduct(heated))
fs.AddSeparator("V-1").ConnectFeed(heated).ConnectProduct(vapor, 0).ConnectProduct(liquid, 1)
(fs.AddSplitter("SP-1").WithSplitRatios(0.5, 0.5)
   .ConnectFeed(liquid).ConnectProduct(purge, 0).ConnectProduct(tear_in, 1))

recycle = (fs.AddUnitOperation(ObjectType.OT_Recycle, "REC-1")
           .ConnectFeed(tear_in)
           .ConnectProduct(tear_out))
rec = recycle.Object.__implementation__
rec.MaximumIterations = 50
# The default mass flow tolerance, 0.01 kg/s, is loose for a 0.5 kg/s loop: tighten it.
rec.SetPropertyValue("PROP_RY_1", 1.0e-5)     # mass flow tolerance, kg/s
rec.SetPropertyValue("PROP_RY_2", 0.01)       # temperature tolerance, K

fs.AutoLayout()
fs.Solve()

m_in = feed.MassFlowKgPerSecond
m_out = vapor.MassFlowKgPerSecond + purge.MassFlowKgPerSecond
print(f"Converged          = {rec.Converged} after {rec.IterationsTaken} iterations")
print(f"Recycle flow       = {tear_out.MolarFlowMolPerSecond:.3f} mol/s "
      f"(splitter side {tear_in.MolarFlowMolPerSecond:.3f} mol/s)")
print(f"Vapor product      = {vapor.MolarFlowMolPerSecond:.3f} mol/s, "
      f"methanol {vapor.OverallMoleFraction('Methanol'):.4f}")
print(f"Mass balance       = {m_in:.5f} kg/s in, {m_out:.5f} kg/s out")

Output

Converged          = True after 13 iterations
Recycle flow       = 6.366 mol/s (splitter side 6.366 mol/s)
Vapor product      = 13.634 mol/s, methanol 0.6221
Mass balance       = 0.50057 kg/s in, 0.50058 kg/s out

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
PROP_RY_0 Maximum Iterations yes
PROP_RY_1 Mass Flow Tolerance kg/s yes
PROP_RY_2 Temperature Tolerance K (difference) yes
PROP_RY_3 Pressure Tolerance Pa yes
PROP_RY_4 Mass Flow Error kg/s result
PROP_RY_5 Temperature Error K (difference) result
PROP_RY_6 Pressure Error Pa result
PROP_RY_7 Relative Mass Flow Tolerance yes

Learn more

API members

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

Constructors

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

Initializes a new default instance of the Recycle class.

public Recycle()
Public Sub New()

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

Initializes a new instance of the Recycle class with a name and description.

Parameter Type Description
name String The display name of the recycle block.
description String A brief description of the recycle block.
public Recycle(string name, string description)
Public Sub New(name As String, description As String)

Properties

ConvergenceParameters: Gets or sets the convergence tolerance parameters (temperature, pressure, mass flow, etc.).

Gets or sets the convergence tolerance parameters (temperature, pressure, mass flow, etc.).

public ConvergenceParameters ConvergenceParameters { get; set; }
Public Property ConvergenceParameters As ConvergenceParameters

CopyOnStreamDataError: Gets or sets whether stream data should be copied even when an error occurs reading stream properties.

Gets or sets whether stream data should be copied even when an error occurs reading stream properties.

public bool CopyOnStreamDataError { get; set; }
Public Property CopyOnStreamDataError As Boolean

HasPropertiesForDynamicMode: Gets a value indicating whether this recycle block exposes properties for dynamic mode.

Gets a value indicating whether this recycle block exposes properties for dynamic mode.

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

IterationCount: Gets or sets the current iteration counter during an active convergence run.

Gets or sets the current iteration counter during an active convergence run.

public int IterationCount { get; set; }
Public Property IterationCount As Integer

IterationsTaken: Gets or sets the total number of iterations taken during the last convergence run.

Gets or sets the total number of iterations taken during the last convergence run.

public int IterationsTaken { get; set; }
Public Property IterationsTaken As Integer

LegacyMode: Gets or sets whether to use the legacy convergence algorithm.

Gets or sets whether to use the legacy convergence algorithm.

public bool LegacyMode { get; set; }
Public Property LegacyMode As Boolean

MaximumIterations: Gets or sets the maximum number of iterations allowed before convergence is considered failed.

Gets or sets the maximum number of iterations allowed before convergence is considered failed.

public int MaximumIterations { get; set; }
Public Property MaximumIterations As Integer

MobileCompatible: Gets a value indicating whether this recycle block is compatible with the DWSIM mobile interface.

Gets a value indicating whether this recycle block is compatible with the DWSIM mobile interface.

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

SmoothingFactor: Gets or sets the damping factor applied to variable updates during convergence iterations (1.0 = no damping).

Gets or sets the damping factor applied to variable updates during convergence iterations (1.0 = no damping).

public double SmoothingFactor { get; set; }
Public Property SmoothingFactor As Double

SupportsDynamicMode: Gets a value indicating whether this recycle block supports dynamic simulation mode.

Gets a value indicating whether this recycle block supports dynamic simulation mode.

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

WegsteinParameters: Gets or sets the Wegstein acceleration parameters used during convergence.

Gets or sets the Wegstein acceleration parameters used during convergence.

public WegsteinParameters WegsteinParameters { get; set; }
Public Property WegsteinParameters As WegsteinParameters

Methods

Calculate(object): Performs one iteration of the recycle convergence check, optionally applying Wegstein or Broyden acceleration, and...

Performs one iteration of the recycle convergence check, optionally applying Wegstein or Broyden acceleration, and updates the outlet stream with the new estimated values.

Parameter Type Description
args Object Optional calculation arguments (not used).
public override void Calculate(object args = null)
Public Overrides Sub Calculate(args As Object = Nothing)

CloneXML(): Creates a deep copy of this recycle block via XML serialization.

Creates a deep copy of this recycle block via XML serialization.

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

CloseEditForm(): Closes and disposes the editing form for this recycle block if it is open.

Closes and disposes the editing form for this recycle block if it is open.

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

DeCalculate(): Resets the iteration counter, effectively unsetting the convergence state.

Resets the iteration counter, effectively unsetting the convergence state.

public void DeCalculate()
Public Sub DeCalculate()

DisplayEditForm(): Opens or activates the editing form for this recycle block.

Opens or activates the editing form for this recycle block.

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

GetDisplayDescription(): Returns the localized display description for the recycle block type.

Returns the localized display description for the recycle block type.

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

GetDisplayName(): Returns the localized display name for the recycle block type.

Returns the localized display name for the recycle block type.

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

GetIconBitmapBytes(): Returns the raw bytes of the recycle block icon image resource.

Returns the raw bytes of the recycle block icon image resource.

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

GetProperties(PropertyType): Returns the list of property identifiers available for this recycle block filtered by property type.

Returns the list of property identifiers available for this recycle block filtered by property type.

Parameter Type Description
proptype PropertyType The type of properties to retrieve.
public override string[] GetProperties(PropertyType proptype)
Public Overrides Function GetProperties(proptype As PropertyType) As String()

GetPropertyUnit(string, IUnitsOfMeasure): Returns the unit string for the specified property in the given unit system.

Returns the unit string for the specified property in the given unit system.

Parameter Type Description
prop String The property identifier string.
su IUnitsOfMeasure The unit system to use; defaults to SI if not provided.
public override string GetPropertyUnit(string prop, IUnitsOfMeasure su = null)
Public Overrides Function GetPropertyUnit(prop As String, su As IUnitsOfMeasure = Nothing) As String

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 The property identifier string (e.g., "PROP_RY_0").
su IUnitsOfMeasure The unit system to use; defaults to SI if not provided.
public override object GetPropertyValue(string prop, IUnitsOfMeasure su = null)
Public Overrides Function GetPropertyValue(prop As String, su As IUnitsOfMeasure = Nothing) As Object

LoadData(List<XElement>): Restores the recycle block state from a list of XML elements.

Restores the recycle block state from a list of XML elements.

Parameter Type Description
data List<XElement> The list of XElement objects containing the serialized state.
public override bool LoadData(List<XElement> data)
Public Overrides Function LoadData(data As List(Of XElement)) As Boolean

MAX(object): Returns the maximum value from an array-like object.

Returns the maximum value from an array-like object.

Parameter Type Description
Vv Object An array whose maximum element is to be found.
public object MAX(object Vv)
Public Function MAX(Vv As Object) As Object

RunDynamicModel(): Executes one dynamic-mode step by directly assigning the inlet stream properties to the outlet stream.

Executes one dynamic-mode step by directly assigning the inlet stream properties to the outlet stream.

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

SaveData(): Serializes the recycle block state to a list of XML elements for persistence.

Serializes the recycle block state to a list of XML elements for persistence.

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

SetPropertyValue(string, object, IUnitsOfMeasure): Sets the value of the specified property after converting from the given unit system to SI.

Sets the value of the specified property after converting from the given unit system to SI.

Parameter Type Description
prop String The property identifier string.
propval Object The new value in the units of su.
su IUnitsOfMeasure The unit system of the supplied value; defaults to SI if not provided.
public override bool SetPropertyValue(string prop, object propval, IUnitsOfMeasure su = null)
Public Overrides Function SetPropertyValue(prop As String, propval As Object, su As IUnitsOfMeasure = Nothing) As Boolean

UpdateEditForm(): Refreshes the displayed data in the editing form if it is currently open.

Refreshes the displayed data in the editing form if it is currently open.

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

Fields

f: The classic (WinForms) editor window open for this logical block, if any.

The classic (WinForms) editor window open for this logical block, if any. Not saved with the flowsheet.

public object f
Public f As Object