Skip to content

Gibbs Reactor

Represents a Gibbs Reactor that determines the equilibrium product composition by minimising the total Gibbs free energy of the system. Two solving approaches are available: direct minimisation (elemental balance constraints) and reaction-extent minimisation.

DWSIM.UnitOperations.Reactors.Reactor_Gibbs
Assembly DWSIM.UnitOperations.dll · Object ← BaseClass ← UnitOpBaseClass ← Reactor ← Reactor_Gibbs

At a glance

Gibbs Reactor in the example flowsheet

Port Index Connected in the example
Inlet, material 0 Feed
Inlet, energy 1 Q
Outlet, material 0 Syngas
Outlet, material 1 Liquid

Example

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

compounds = ["Methane", "Water", "Carbon monoxide", "Carbon dioxide", "Hydrogen"]
fs = (Flowsheet.Create("GibbsReactorExample")
      .WithCompounds(*compounds)
      .WithPropertyPackage(PropertyPackages.PengRobinson))

# methane and steam, steam to carbon ratio 3
feed = (fs.AddMaterialStream("Feed")
        .At(Q.Celsius(850.0), Q.Bar(15.0))
        .WithMolarFlow(Q.MolPerSecond(4.0))
        .SetCompoundMolarFlow("Methane", 1.0)
        .SetCompoundMolarFlow("Water", 3.0))
syngas = fs.AddMaterialStream("Syngas")
liquid = fs.AddMaterialStream("Liquid")          # empty here, but the port must be connected
duty = fs.AddEnergyStream("Q")

reformer = (fs.AddGibbsReactor("R-1")
            .Isothermal()
            .WithPressureDrop(Q.Bar(0.0))
            .ConnectFeed(feed, 0)
            .ConnectProduct(syngas, 0)
            .ConnectProduct(liquid, 1)
            .ConnectEnergyFeed(duty, 1))
# compounds that take part in the minimization; the element matrix is built from the feed
ids = List[String]()
for c in compounds:
    ids.Add(c)
reformer.Object.ComponentIDs = ids
reformer.Object.CreateElementMatrix()

fs.AutoLayout()
fs.Solve()

y = {c: syngas.OverallMoleFraction(c) for c in compounds}
p_bar = 15.0
k_smr = y["Carbon monoxide"] * y["Hydrogen"] ** 3 * p_bar ** 2 / (y["Methane"] * y["Water"])
print(f"CH4 conversion       = {100.0 * reformer.Object.ComponentConversions['Methane']:.1f} %")
print(f"Syngas H2 / CO       = {100.0 * y['Hydrogen']:.2f} / {100.0 * y['Carbon monoxide']:.2f} mol %")
print(f"Syngas CH4           = {100.0 * y['Methane']:.2f} mol %")
print(f"Kp reforming         = {k_smr:.0f} bar2 (ln K = 30.114 - 26830/T: {math.exp(30.114 - 26830.0 / 1123.15):.0f} bar2)")
print(f"Heat supplied        = {reformer.HeatDutyKW:.1f} kW")

Output

CH4 conversion       = 89.1 %
Syngas H2 / CO       = 51.69 / 9.95 mol %
Syngas CH4           = 1.89 mol %
Kp reforming         = 529 bar2 (ln K = 30.114 - 26830/T: 506 bar2)
Heat supplied        = 191.3 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
PROP_GR_0 Pressure Drop Pa yes
PROP_GR_1 Outlet Temperature K yes
Calculation Mode Select the calculation mode of this reactor. result
Initial Gibbs Energy kW result
Final Gibbs Energy kW result
Element Balance Residue result
Methane: Conversion % result
Water: Conversion % result
Carbon monoxide: Conversion % result
Carbon dioxide: Conversion % result
Hydrogen: Conversion % result

Dynamic mode

Extra properties used when the flowsheet runs in dynamic mode.

Name Unit
Operating Pressure (Dynamics) Pa
Liquid Level m
Volume m3
Height m
Minimum Pressure Pa
Initialize using Inlet Stream
Reset Contents

Learn more

API members

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

Constructors

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

Initializes a new default instance of the Reactor_Gibbs class.

public Reactor_Gibbs()
Public Sub New()

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

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

Parameter Type Description
name String The display name of the Gibbs reactor.
description String A brief description of the Gibbs reactor.
public Reactor_Gibbs(string name, string description)
Public Sub New(name As String, description As String)

Properties

AlternateSolvingMethod: Gets or sets whether the alternate (Lagrange multiplier) solving method is used.

Gets or sets whether the alternate (Lagrange multiplier) solving method is used.

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

ComponentIDs: Gets or sets the list of compound IDs used in direct minimisation.

Gets or sets the list of compound IDs used in direct minimisation.

public List<string> ComponentIDs { get; set; }
Public Property ComponentIDs As List(Of String)

ComponentIDs_RE: Gets or sets the list of compound IDs used in reaction-extent mode.

Gets or sets the list of compound IDs used in reaction-extent mode.

public List<string> ComponentIDs_RE { get; set; }
Public Property ComponentIDs_RE As List(Of String)

DampingLowerLimit: Gets or sets the lower bound for the damping factor.

Gets or sets the lower bound for the damping factor.

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

DampingUpperLimit: Gets or sets the upper bound for the damping factor.

Gets or sets the upper bound for the damping factor.

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

DerivativePerturbation: Gets or sets the relative perturbation used for numerical derivative estimation.

Gets or sets the relative perturbation used for numerical derivative estimation.

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

ElementBalance: Gets or sets the relative element balance error after convergence.

Gets or sets the relative element balance error after convergence.

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

ElementMatrix: Gets or sets the element–compound formula matrix used for elemental balance constraints.

Gets or sets the element–compound formula matrix used for elemental balance constraints.

public double[,] ElementMatrix { get; set; }
Public Property ElementMatrix As Double(,)

Elements: Gets or sets the array of chemical element symbols involved in the minimisation.

Gets or sets the array of chemical element symbols involved in the minimisation.

public string[] Elements { get; set; }
Public Property Elements As String()

EnableDamping: Gets or sets whether damping is applied to the Newton step during the Lagrange method iteration.

Gets or sets whether damping is applied to the Newton step during the Lagrange method iteration.

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

FinalGibbsEnergy: Gets or sets the final total Gibbs free energy after minimisation.

Gets or sets the final total Gibbs free energy after minimisation.

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

HasPropertiesForDynamicMode: Gets a value indicating whether this reactor exposes dedicated dynamic-mode properties.

Gets a value indicating whether this reactor exposes dedicated dynamic-mode properties.

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

InitialEstimates: Gets or sets the list of user-supplied initial estimates for the minimisation variables.

Gets or sets the list of user-supplied initial estimates for the minimisation variables.

public List<double> InitialEstimates { get; set; }
Public Property InitialEstimates As List(Of Double)

InitialGibbsEnergy: Gets or sets the initial total Gibbs free energy before minimisation.

Gets or sets the initial total Gibbs free energy before minimisation.

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

InitializeFromPreviousSolution: Gets or sets whether the solver initialises from the previous converged solution.

Gets or sets whether the solver initialises from the previous converged solution.

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

InternalTolerance: Gets or sets the convergence tolerance for the inner minimisation loop.

Gets or sets the convergence tolerance for the inner minimisation loop.

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

LagrangeCoeffsEstimationTemperature: Gets or sets the temperature (K) used to estimate initial Lagrange coefficients.

Gets or sets the temperature (K) used to estimate initial Lagrange coefficients.

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

MaximumInternalIterations: Gets or sets the maximum number of iterations for the inner minimisation loop.

Gets or sets the maximum number of iterations for the inner minimisation loop.

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

MobileCompatible: Gets a value indicating whether this reactor is compatible with mobile/cross-platform interfaces.

Gets a value indicating whether this reactor is compatible with mobile/cross-platform interfaces.

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

PreviousSolution: Gets or sets the list of variable values from the previous solution, used for warm-starting.

Gets or sets the list of variable values from the previous solution, used for warm-starting.

public List<double> PreviousSolution { get; set; }
Public Property PreviousSolution As List(Of Double)

ReactionExtents: Gets the dictionary of calculated reaction extents, keyed by reaction ID.

Gets the dictionary of calculated reaction extents, keyed by reaction ID.

public Dictionary<string, double> ReactionExtents { get; }
Public ReadOnly Property ReactionExtents As Dictionary(Of String, Double)

ReactivePhaseBehavior: Gets or sets the reactive-phase behaviour for the Gibbs minimisation.

Gets or sets the reactive-phase behaviour for the Gibbs minimisation.

public Reactor_Gibbs.ReactivePhaseType ReactivePhaseBehavior { get; set; }
Public Property ReactivePhaseBehavior As Reactor_Gibbs.ReactivePhaseType

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

Gets a value indicating whether this reactor supports dynamic simulation mode.

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

TotalElements: Gets or sets the array of total element amounts (mol) in the feed.

Gets or sets the array of total element amounts (mol) in the feed.

public double[] TotalElements { get; set; }
Public Property TotalElements As Double()

UseIPOPTSolver: Gets or sets whether the IPOPT solver is used for the Gibbs minimisation.

Gets or sets whether the IPOPT solver is used for the Gibbs minimisation.

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

Methods

Calculate(object): Performs the Gibbs reactor calculation, delegating to either direct minimisation or Lagrange multiplier method...

Performs the Gibbs reactor calculation, delegating to either direct minimisation or Lagrange multiplier method depending on the selected solving approach.

Parameter Type Description
args Object Optional. If True, indicates a dynamic-mode call.
public override void Calculate(object args = null)
Public Overrides Sub Calculate(args As Object = Nothing)

Calculate_GibbsMin(object): Solves the Gibbs minimisation using IPOPT or simplex subject to elemental balance constraints.

Solves the Gibbs minimisation using IPOPT or simplex subject to elemental balance constraints.

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

Calculate_Lagrange(object): Solves the Gibbs minimisation using the Lagrange multiplier (simultaneous correction) method.

Solves the Gibbs minimisation using the Lagrange multiplier (simultaneous correction) method.

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

CheckCompoundIDs(): Validates and updates the compound ID list, removing compounds no longer present in the simulation.

Validates and updates the compound ID list, removing compounds no longer present in the simulation.

public void CheckCompoundIDs()
Public Sub CheckCompoundIDs()

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

Creates a deep copy of this reactor via XML serialization.

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

CloseEditForm(): Closes and disposes the editing form.

Closes and disposes the editing form.

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

CreateDynamicProperties(): Registers the dynamic properties for dynamic simulation mode.

Registers the dynamic properties for dynamic simulation mode.

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

CreateElementMatrix(): Builds the element–compound formula matrix from the compound database, identifying which chemical elements are...

Builds the element–compound formula matrix from the compound database, identifying which chemical elements are present and their stoichiometric counts per compound.

public void CreateElementMatrix()
Public Sub CreateElementMatrix()

DeCalculate(): Clears the calculated results from the outlet material streams.

Clears the calculated results from the outlet material streams.

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

DisplayDynamicsEditForm(): Opens or activates the dynamics property editor form for this reactor.

Opens or activates the dynamics property editor form for this reactor.

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

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

Opens or activates the editing form for this reactor.

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

GetDisplayDescription(): Returns the localised display description for this reactor.

Returns the localised display description for this reactor.

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

GetDisplayName(): Returns the localised display name for this reactor.

Returns the localised display name for this reactor.

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

GetIconBitmapBytes(): Returns the icon bitmap as a byte array.

Returns the icon bitmap as a byte array.

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

GetProperties(PropertyType): Returns an array of property identifiers for the specified property type.

Returns an array of property identifiers for the specified property type.

Parameter Type Description
proptype PropertyType
public override string[] GetProperties(PropertyType proptype)
Public Overrides Function GetProperties(proptype As PropertyType) As String()

GetPropertyDescription(string): Returns a human-readable description of the specified property.

Returns a human-readable description of the specified property.

Parameter Type Description
p String
public override string GetPropertyDescription(string p)
Public Overrides Function GetPropertyDescription(p As String) As 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
su IUnitsOfMeasure
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
su IUnitsOfMeasure
public override object GetPropertyValue(string prop, IUnitsOfMeasure su = null)
Public Overrides Function GetPropertyValue(prop As String, su As IUnitsOfMeasure = Nothing) As Object

GetReport(IUnitsOfMeasure, CultureInfo, string): Generates a plain-text report of the reactor results using the specified units and format.

Generates a plain-text report of the reactor results using the specified units and format.

Parameter Type Description
su IUnitsOfMeasure
ci CultureInfo
numberformat String
public override string GetReport(IUnitsOfMeasure su, CultureInfo ci, string numberformat)
Public Overrides Function GetReport(su As IUnitsOfMeasure, ci As CultureInfo, numberformat As String) As String

GetStructuredReport(): Generates a structured report of the reactor results as a list of typed tuples.

Generates a structured report of the reactor results as a list of typed tuples.

public override List<Tuple<ReportItemType, string[]>> GetStructuredReport()
Public Overrides Function GetStructuredReport() As List(Of Tuple(Of ReportItemType, String()))

LoadData(List<XElement>): Restores the reactor state, including element matrices and initial estimates, from XML.

Restores the reactor state, including element matrices and initial estimates, from XML.

Parameter Type Description
data List<XElement>
public override bool LoadData(List<XElement> data)
Public Overrides Function LoadData(data As List(Of XElement)) As Boolean

RunDynamicModel(): Executes one dynamic simulation time step for the Gibbs reactor.

Executes one dynamic simulation time step for the Gibbs reactor.

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

SaveData(): Serializes the reactor state, including element matrices and compound lists, to XML.

Serializes the reactor state, including element matrices and compound lists, to XML.

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

SetPropertyValue(string, object, IUnitsOfMeasure): Sets the value of the specified property from the given value and unit system.

Sets the value of the specified property from the given value and unit system.

Parameter Type Description
prop String
propval Object
su IUnitsOfMeasure
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 editing form with updated data.

Refreshes the editing form with updated data.

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

Validate(): Validates that inlet and outlet streams are connected before calculation.

Validates that inlet and outlet streams are connected before calculation.

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

Fields

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

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

public object f
Public f As Object