Skip to content

Adjust

Represents an Adjust (controller) block that iterates a manipulated variable of one simulation object until the controlled variable of another object reaches a specified target value. Uses a bisection or secant numerical method with an optional reference object for relative targets.

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

At a glance

Adjust in the example flowsheet

This object has no stream connections; it acts on other objects through their properties.

Example

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

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

feed = (fs.AddMaterialStream("Cold water")
        .At(Q.Celsius(25.0), Q.Bar(2.0))
        .WithMassFlow(Q.KgPerSecond(2.0)))
product = fs.AddMaterialStream("Hot water")
duty = fs.AddEnergyStream("Q-1")

heater = (fs.AddHeater("H-1")
          .WithHeatAdded(Q.Kilowatts(100.0))      # first guess, the adjust changes it
          .ConnectFeed(feed)
          .ConnectProduct(product)
          .ConnectEnergyFeed(duty, 1))          # energy inlet is port 1

def target(obj, prop):
    info = SpecialOpObjectInfo()
    info.ID = obj.Object.Name
    info.Name = obj.Object.GraphicObject.Tag
    info.PropertyName = prop
    info.ObjectType = obj.Object.GetDisplayName()
    return info

builder = fs.AddUnitOperation(ObjectType.OT_Adjust, "ADJ-1")
adj = builder.Object.__implementation__
adj.ManipulatedObjectData = target(heater, "PROP_HT_3")   # heat added (kW)
adj.ControlledObjectData = target(product, "PROP_MS_0")   # temperature
adj.ManipulatedObject = heater.Object
adj.ControlledObject = product.Object
adj.GraphicObject.__implementation__.ConnectedToMv = heater.Object.GraphicObject   # drawing links
adj.GraphicObject.__implementation__.ConnectedToCv = product.Object.GraphicObject
adj.AdjustValue = 273.15 + 80.0         # target, in SI units (K)
adj.Tolerance = 0.01                    # in the flowsheet display units (C here)
adj.SimultaneousAdjust = True           # solved by the flowsheet solver

fs.AutoLayout()
fs.Solve()

h_in = feed.Object.Phases[0].Properties.enthalpy        # kJ/kg
h_out = product.Object.Phases[0].Properties.enthalpy
print(f"Outlet temperature  = {product.TemperatureK - 273.15:.3f} C (target 80 C)")
print(f"Heater duty found   = {heater.HeatDutyKW:.2f} kW")
print(f"Check, m.(h2 - h1)  = {2.0 * (h_out - h_in):.2f} kW")

Output

Outlet temperature  = 80.000 C (target 80 C)
Heater duty found   = 460.10 kW
Check, m.(h2 - h1)  = 460.10 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
MinVal Manipulated Variable Minimum yes
MaxVal Manipulated Variable Maximum yes
AdjustValue Set-Point yes
Tolerance Tolerance (Maximum Error) yes
StepSize Initial Step Size yes
MaximumIterations Maximum Iterations yes

Learn more

API members

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

Constructors

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

Initializes a new default instance of the Adjust class.

public Adjust()
Public Sub New()

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

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

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

Properties

ControlledObject: Gets or sets the controlled simulation object instance (not serialized).

Gets or sets the controlled simulation object instance (not serialized).

public BaseClass ControlledObject { get; set; }
Public Property ControlledObject As BaseClass

ControlledVariable: Gets or sets the property identifier of the variable to be controlled (driven to the target value).

Gets or sets the property identifier of the variable to be controlled (driven to the target value).

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

CvOk: Gets or sets whether the controlled variable object and property are correctly configured.

Gets or sets whether the controlled variable object and property are correctly configured.

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

InitialEstimate: Gets or sets the optional initial estimate for the manipulated variable used to seed the solver.

Gets or sets the optional initial estimate for the manipulated variable used to seed the solver.

public double? InitialEstimate { get; set; }
Public Property InitialEstimate As Double?

ManipulatedObject: Gets or sets the manipulated simulation object instance (not serialized).

Gets or sets the manipulated simulation object instance (not serialized).

public BaseClass ManipulatedObject { get; set; }
Public Property ManipulatedObject As BaseClass

ManipulatedVariable: Gets or sets the property identifier of the variable to be manipulated by the solver.

Gets or sets the property identifier of the variable to be manipulated by the solver.

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

MaximumIterations: Gets or sets the maximum number of solver iterations allowed before declaring non-convergence.

Gets or sets the maximum number of solver iterations allowed before declaring non-convergence.

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

MaxVal: Gets or sets the optional upper bound for the manipulated variable search range.

Gets or sets the optional upper bound for the manipulated variable search range.

public double? MaxVal { get; set; }
Public Property MaxVal As Double?

MinVal: Gets or sets the optional lower bound for the manipulated variable search range.

Gets or sets the optional lower bound for the manipulated variable search range.

public double? MinVal { get; set; }
Public Property MinVal As Double?

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

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

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

MvOk: Gets or sets whether the manipulated variable object and property are correctly configured.

Gets or sets whether the manipulated variable object and property are correctly configured.

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

ReferenceObject: Gets or sets the optional reference simulation object instance (not serialized).

Gets or sets the optional reference simulation object instance (not serialized).

public BaseClass ReferenceObject { get; set; }
Public Property ReferenceObject As BaseClass

ReferenceVariable: Gets or sets the property identifier of the optional reference variable used as a relative target basis.

Gets or sets the property identifier of the optional reference variable used as a relative target basis.

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

RvOk: Gets or sets whether the reference variable object and property are correctly configured.

Gets or sets whether the reference variable object and property are correctly configured.

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

SolvingMethodSelf: Gets or sets the solving method index used by this block (0 = bisection, 1 = secant, etc.).

Gets or sets the solving method index used by this block (0 = bisection, 1 = secant, etc.).

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

Status: Gets or sets a status message describing the outcome of the last calculation attempt.

Gets or sets a status message describing the outcome of the last calculation attempt.

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

StepSize: Gets or sets the step size used by the initial perturbation of the manipulated variable.

Gets or sets the step size used by the initial perturbation of the manipulated variable.

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

Methods

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

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

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

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

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

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

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

Opens or activates the editing form for this adjust block.

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

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

Returns the localized display description for the adjust block type.

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

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

Returns the localized display name for the adjust block type.

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

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

Returns the raw bytes of the adjust 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 adjust block.

Returns the list of property identifiers available for this adjust block.

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()

GetPropertyDescription(string): Readable names for the property identifiers, which are the .NET property names.

Readable names for the property identifiers, which are the .NET property names.

Parameter Type Description
prop String
public override string GetPropertyDescription(string prop)
Public Overrides Function GetPropertyDescription(prop As String) As String

GetPropertyUnit(string, IUnitsOfMeasure): Returns the unit string for the specified property (always an empty string for this block).

Returns the unit string for the specified property (always an empty string for this block).

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.

Returns the value of the specified property.

Parameter Type Description
prop String The property identifier or name string.
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 adjust block state from a list of XML elements.

Restores the adjust 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

PerformAdjust(string, double, double): Solves the adjust with a numerical root finder: changes the manipulated variable and re-solves the flowsheet until...

Solves the adjust with a numerical root finder: changes the manipulated variable and re-solves the flowsheet until the controlled variable matches the target value (or the referenced variable plus the target offset). If the solver fails, the manipulated variable is restored to its initial value and the exception is rethrown.

Parameter Type Description
solver String Root finder to use (case-insensitive): "secant", "brent", "newton" or "ipopt".
minval Double Optional lower bound of the manipulated variable, in the flowsheet's selected units. Used by the Brent and IPOPT solvers; when both bounds are given, the secant solver takes its limits from MinVal and MaxVal.
maxval Double Optional upper bound of the manipulated variable, in the flowsheet's selected units, used in the same way as minval.
public double PerformAdjust(string solver, double minval = NaN, double maxval = NaN)
Public Function PerformAdjust(solver As String, minval As Double = NaN, maxval As Double = NaN) As Double

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

Serializes the adjust 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.

Sets the value of the specified property.

Parameter Type Description
prop String The property identifier or name string.
propval Object The new value to assign.
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