Specification¶
![]()
Represents a Spec (specification) block that copies a property from a source simulation object, evaluates an optional mathematical expression using that value, and writes the result to a target simulation object. Optionally clamps the result within configurable minimum/maximum bounds.
DWSIM.UnitOperations.SpecialOps.Spec
Assembly DWSIM.UnitOperations.dll · Object ← BaseClass ← SpecialOpBaseClass ← Spec
At a glance¶

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("SpecExample")
.WithCompound("Water")
.WithPropertyPackage(PropertyPackages.SteamTables))
cw = (fs.AddMaterialStream("CW supply")
.At(Q.Celsius(28.0), Q.Bar(3.0))
.WithMassFlow(Q.KgPerSecond(20.0)))
hot = (fs.AddMaterialStream("Hot water")
.At(Q.Celsius(90.0), Q.Bar(2.0))
.WithMassFlow(Q.KgPerSecond(3.0)))
cooled = fs.AddMaterialStream("Cooled water")
duty = fs.AddEnergyStream("C-1 duty")
cooler = (fs.AddCooler("C-1")
.WithOutletTemperature(Q.Celsius(50.0)) # overwritten by the spec
.ConnectFeed(hot)
.ConnectProduct(cooled)
.ConnectEnergyProduct(duty))
builder = fs.AddUnitOperation(ObjectType.OT_Spec, "SPEC-1")
spec = builder.Object.__implementation__
def link(info, obj, prop, role):
info.ID = obj.Object.Name
info.Name = obj.Object.GraphicObject.Tag
info.PropertyName = prop
info.ObjectType = obj.Object.GetDisplayName()
obj.Object.IsSpecAttached = True # what the editor does when you pick an object
obj.Object.AttachedSpecId = spec.Name
obj.Object.SpecVarType = role
spec.SourceObjectData = SpecialOpObjectInfo()
spec.TargetObjectData = SpecialOpObjectInfo()
link(spec.SourceObjectData, cw, "PROP_MS_0", SpecVarType.Source) # X: CW temperature
link(spec.TargetObjectData, cooler, "PROP_CL_2", SpecVarType.Target) # Y: cooler outlet temperature
spec.SourceObject = cw.Object
spec.TargetObject = cooler.Object
spec.GraphicObject.__implementation__.ConnectedToSv = cw.Object.GraphicObject # drawing links
spec.GraphicObject.__implementation__.ConnectedToTv = cooler.Object.GraphicObject
spec.Expression = "X + 10" # Y = X + 10, in the flowsheet display units (C here)
# Run the spec right before the cooler is calculated, so the cooler uses the new value.
fs.Inner.FlowsheetOptions.SpecCalculationMode = SpecCalcMode.BeforeTargetObject
fs.AutoLayout()
fs.Solve()
t_cw = cw.TemperatureK - 273.15
t_out = cooled.TemperatureK - 273.15
print(f"CW supply temperature = {t_cw:.2f} C")
print(f"Cooler outlet = {t_out:.2f} C")
print(f"Approach = {t_out - t_cw:.2f} K")
print(f"Heat removed = {cooler.HeatRemovedKW:.1f} kW")
Output
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 |
|---|---|---|---|
SpecMin |
Target Variable Minimum | yes | |
SpecMax |
Target Variable Maximum | yes | |
Expression |
result |
Learn more¶
-
User guide
API members¶
Public members declared by this class. Inherited members are documented on the base classes.
Constructors¶
Spec(): Initializes a new default instance of the Spec class.
Initializes a new default instance of the Spec class.
Spec(string, string): Initializes a new instance of the Spec class with a name and description.
Initializes a new instance of the Spec class with a name and description.
| Parameter | Type | Description |
|---|---|---|
name |
String |
The display name of the spec block. |
description |
String |
A brief description of the block. |
Properties¶
CalculateTargetObject: Gets or sets whether the target simulation object should be recalculated after the specification is applied.
Gets or sets whether the target simulation object should be recalculated after the specification is applied.
ExpContext: Gets or sets the expression evaluation context providing variable bindings and math imports (not serialized).
Gets or sets the expression evaluation context providing variable bindings and math imports (not serialized).
Expr: Gets or sets the compiled generic expression object used to evaluate the specification formula (not serialized).
Gets or sets the compiled generic expression object used to evaluate the specification formula (not serialized).
Expression: Gets or sets the mathematical expression string evaluated by this spec block (variables: X = source value, Y =...
Gets or sets the mathematical expression string evaluated by this spec block (variables: X = source value, Y = target value).
HasPropertiesForDynamicMode: Gets a value indicating whether this block exposes properties for dynamic mode.
Gets a value indicating whether this block exposes properties for dynamic mode.
MaxVal: Gets or sets the optional upper bound clamping value applied to the evaluated expression result.
Gets or sets the optional upper bound clamping value applied to the evaluated expression result.
MinVal: Gets or sets the optional lower bound clamping value applied to the evaluated expression result.
Gets or sets the optional lower bound clamping value applied to the evaluated expression result.
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.
SourceObject: Gets or sets the source simulation object instance (not serialized).
Gets or sets the source simulation object instance (not serialized).
SourceObjectData: Gets or sets the metadata describing the source simulation object and property whose value is read.
Gets or sets the metadata describing the source simulation object and property whose value is read.
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.
SupportsDynamicMode: Gets a value indicating whether this block supports dynamic simulation mode.
Gets a value indicating whether this block supports dynamic simulation mode.
TargetObject: Gets or sets the target simulation object instance (not serialized).
Gets or sets the target simulation object instance (not serialized).
TargetObjectData: Gets or sets the metadata describing the target simulation object and property that receives the expression result.
Gets or sets the metadata describing the target simulation object and property that receives the expression result.
Methods¶
Calculate(object): Evaluates the expression and writes the result to the target simulation object's property.
Evaluates the expression and writes the result to the target simulation object's property. Clamps the result within MinVal and MaxVal if both are set.
| Parameter | Type | Description |
|---|---|---|
args |
Object |
Optional calculation arguments (not used). |
CloneXML(): Creates a deep copy of this spec block via XML serialization.
Creates a deep copy of this spec block via XML serialization.
CloseEditForm(): Closes and disposes the editing form for this spec block if it is open.
Closes and disposes the editing form for this spec block if it is open.
DisplayEditForm(): Opens or activates the editing form for this spec block.
Opens or activates the editing form for this spec block.
GetDisplayDescription(): Returns the localized display description for the spec block type.
Returns the localized display description for the spec block type.
GetDisplayName(): Returns the localized display name for the spec block type.
Returns the localized display name for the spec block type.
GetIconBitmapBytes(): Returns the raw bytes of the spec block icon image resource.
Returns the raw bytes of the spec block icon image resource.
GetProperties(PropertyType): Returns the list of property identifiers available for this spec block.
Returns the list of property identifiers available for this spec block. The expression is text, so it is listed only under ALL: the numeric lists that adjusts and sensitivity analyses offer leave it out.
| Parameter | Type | Description |
|---|---|---|
proptype |
PropertyType |
The type of properties to retrieve. |
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 |
GetPropertyUnit(string, IUnitsOfMeasure): Returns the unit string for the specified property.
Returns the unit string for the specified property.
| Parameter | Type | Description |
|---|---|---|
prop |
String |
The property identifier string. |
su |
IUnitsOfMeasure |
The unit system to use; defaults to SI if not provided. |
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 string. |
su |
IUnitsOfMeasure |
The unit system to use; defaults to SI if not provided. |
GetSourceVarUnit(): Returns the unit string for the source variable in the active unit system.
Returns the unit string for the source variable in the active unit system.
GetSourceVarValue(): Returns the current value of the source variable in the active unit system.
Returns the current value of the source variable in the active unit system.
GetTargetVarUnit(): Returns the unit string for the target variable in the active unit system.
Returns the unit string for the target variable in the active unit system.
GetTargetVarValue(): Returns the current value of the target variable in the active unit system.
Returns the current value of the target variable in the active unit system.
LoadData(List<XElement>): Restores the spec block state from a list of XML elements.
Restores the spec block state from a list of XML elements.
| Parameter | Type | Description |
|---|---|---|
data |
List<XElement> |
The list of XElement objects containing the serialized state. |
ParseExpression(): Compiles and evaluates the expression string using the current source (X) and target (Y) variable values.
Compiles and evaluates the expression string using the current source (X) and target (Y) variable values.
SaveData(): Serializes the spec block state to a list of XML elements for persistence.
Serializes the spec block state to a list of XML elements for persistence.
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 string. |
propval |
Object |
The new value to assign. |
su |
IUnitsOfMeasure |
The unit system of the supplied value; defaults to SI if not provided. |
SetTargetVarValue(double?): Writes a value to the target variable of the configured target simulation object.
Writes a value to the target variable of the configured target simulation object.
| Parameter | Type | Description |
|---|---|---|
val |
Nullable<Double> |
The value to assign, expressed in the active unit system. |
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.
Fields¶