Skip to content
LIBRARY
Examples.CSTRPlant.md

Examples.CSTRPlant ​

Continuously stirred tank reactor with reactions A → B → C and 2A → D, controlled by the feed F and the cooling-jacket heat flow Qdot. States: concentrations of A and B, reactor temperature, jacket temperature. Translated from DyadControlSystems.ControlDemoSystems.cstr (time in hours).

Usage ​

MPCComponents.Examples.CSTRPlant(K0_ab=1.287e12, K0_bc=1.287e12, K0_ad=9.043e9, E_A_ab=9758.3, E_A_bc=9758.3, E_A_ad=8560.0, Hr_ab=4.2, Hr_bc=-11.0, Hr_ad=-41.85, Rou=0.9342, Cp=3.01, Cpk=2.0, Ar=0.215, Vr=10.0, mk=5.0, T_in=130.0, K_w=4032.0, C_A0=5.1, Ca0=0.8, Cb0=0.5, Tr0=134.14, Tk0=130.0)

Parameters: ​

NameDescriptionUnitsDefault value
K0_ab–1.287e12
K0_bc–1.287e12
K0_ad–9.043e9
E_A_ab–9758.3
E_A_bc–9758.3
E_A_ad–8560.0
Hr_ab–4.2
Hr_bc–-11.0
Hr_ad–-41.85
Rou–0.9342
Cp–3.01
Cpk–2.0
Ar–0.215
Vr–10.0
mk–5.0
T_in–130.0
K_w–4032.0
C_A0–5.1
Ca0–0.8
Cb0–0.5
Tr0–134.14
Tk0–130.0

Connectors ​

  • F - This connector represents a real signal as an input to a component (RealInput)

  • Qdot - This connector represents a real signal as an input to a component (RealInput)

  • Ca_out - This connector represents a real signal as an output from a component (RealOutput)

  • Cb_out - This connector represents a real signal as an output from a component (RealOutput)

  • Tr_out - This connector represents a real signal as an output from a component (RealOutput)

  • Tk_out - This connector represents a real signal as an output from a component (RealOutput)

Variables ​

NameDescriptionUnits
Ca–
Cb–
Tr–
Tk–
K1–
K2–
K3–

Behavior ​

Behavior of this component cannot be rendered because it includes path variables.

Source ​

dyad
"""
Continuously stirred tank reactor with reactions A → B → C and 2A → D, controlled by the feed `F` and
the cooling-jacket heat flow `Qdot`. States: concentrations of A and B, reactor temperature, jacket
temperature. Translated from `DyadControlSystems.ControlDemoSystems.cstr` (time in hours).
"""
component CSTRPlant
  "Feed"
  F = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 260, "y2": 360}}}
  }
  "Heat flow to the cooling jacket"
  Qdot = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 650, "y2": 750}}}
  }
  "Concentration of A"
  Ca_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 90, "y2": 190}}}
  }
  "Concentration of B"
  Cb_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 340, "y2": 440}}}
  }
  "Reactor temperature"
  Tr_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 550, "y2": 650}}}
  }
  "Cooling-jacket temperature"
  Tk_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 790, "y2": 890}}}
  }
  parameter K0_ab::Real = 1.287e12
  parameter K0_bc::Real = 1.287e12
  parameter K0_ad::Real = 9.043e9
  parameter E_A_ab::Real = 9758.3
  parameter E_A_bc::Real = 9758.3
  parameter E_A_ad::Real = 8560.0
  parameter Hr_ab::Real = 4.2
  parameter Hr_bc::Real = -11.0
  parameter Hr_ad::Real = -41.85
  parameter Rou::Real = 0.9342
  parameter Cp::Real = 3.01
  parameter Cpk::Real = 2.0
  parameter Ar::Real = 0.215
  parameter Vr::Real = 10.0
  parameter mk::Real = 5.0
  parameter T_in::Real = 130.0
  parameter K_w::Real = 4032.0
  parameter C_A0::Real = 5.1
  parameter Ca0::Real = 0.8
  parameter Cb0::Real = 0.5
  parameter Tr0::Real = 134.14
  parameter Tk0::Real = 130.0
  variable Ca::Real
  variable Cb::Real
  variable Tr::Real
  variable Tk::Real
  variable K1::Real
  variable K2::Real
  variable K3::Real
relations
  initial Ca = Ca0
  initial Cb = Cb0
  initial Tr = Tr0
  initial Tk = Tk0
  K1 = K0_ab * exp(-E_A_ab / (Tr + 273.15))
  K2 = K0_bc * exp(-E_A_bc / (Tr + 273.15))
  K3 = K0_ad * exp(-E_A_ad / (Tr + 273.15))
  der(Ca) = F * (C_A0 - Ca) - K1 * Ca - K3 * Ca ^ 2
  der(Cb) = -F * Cb + K1 * Ca - K2 * Cb
  der(Tr) = (K1 * Ca * Hr_ab + K2 * Cb * Hr_bc + K3 * Ca ^ 2 * Hr_ad) / (-Rou * Cp) + F * (T_in - Tr) + K_w * Ar * (Tk - Tr) / (Rou * Cp * Vr)
  der(Tk) = (Qdot + K_w * Ar * (Tr - Tk)) / (mk * Cpk)
  Ca_out = Ca
  Cb_out = Cb
  Tr_out = Tr
  Tk_out = Tk
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MPCComponents/CSTRPlant.svg"},
    "doc": {"behavior": false}
  }
}
end
Flattened Source
dyad
"""
Continuously stirred tank reactor with reactions A → B → C and 2A → D, controlled by the feed `F` and
the cooling-jacket heat flow `Qdot`. States: concentrations of A and B, reactor temperature, jacket
temperature. Translated from `DyadControlSystems.ControlDemoSystems.cstr` (time in hours).
"""
component CSTRPlant
  "Feed"
  F = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 260, "y2": 360}}}
  }
  "Heat flow to the cooling jacket"
  Qdot = RealInput() {
    "Dyad": {"placement": {"diagram": {"x1": -100, "x2": 0, "y1": 650, "y2": 750}}}
  }
  "Concentration of A"
  Ca_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 90, "y2": 190}}}
  }
  "Concentration of B"
  Cb_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 340, "y2": 440}}}
  }
  "Reactor temperature"
  Tr_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 550, "y2": 650}}}
  }
  "Cooling-jacket temperature"
  Tk_out = RealOutput() {
    "Dyad": {"placement": {"diagram": {"x1": 1000, "x2": 1100, "y1": 790, "y2": 890}}}
  }
  parameter K0_ab::Real = 1.287e12
  parameter K0_bc::Real = 1.287e12
  parameter K0_ad::Real = 9.043e9
  parameter E_A_ab::Real = 9758.3
  parameter E_A_bc::Real = 9758.3
  parameter E_A_ad::Real = 8560.0
  parameter Hr_ab::Real = 4.2
  parameter Hr_bc::Real = -11.0
  parameter Hr_ad::Real = -41.85
  parameter Rou::Real = 0.9342
  parameter Cp::Real = 3.01
  parameter Cpk::Real = 2.0
  parameter Ar::Real = 0.215
  parameter Vr::Real = 10.0
  parameter mk::Real = 5.0
  parameter T_in::Real = 130.0
  parameter K_w::Real = 4032.0
  parameter C_A0::Real = 5.1
  parameter Ca0::Real = 0.8
  parameter Cb0::Real = 0.5
  parameter Tr0::Real = 134.14
  parameter Tk0::Real = 130.0
  variable Ca::Real
  variable Cb::Real
  variable Tr::Real
  variable Tk::Real
  variable K1::Real
  variable K2::Real
  variable K3::Real
relations
  initial Ca = Ca0
  initial Cb = Cb0
  initial Tr = Tr0
  initial Tk = Tk0
  K1 = K0_ab * exp(-E_A_ab / (Tr + 273.15))
  K2 = K0_bc * exp(-E_A_bc / (Tr + 273.15))
  K3 = K0_ad * exp(-E_A_ad / (Tr + 273.15))
  der(Ca) = F * (C_A0 - Ca) - K1 * Ca - K3 * Ca ^ 2
  der(Cb) = -F * Cb + K1 * Ca - K2 * Cb
  der(Tr) = (K1 * Ca * Hr_ab + K2 * Cb * Hr_bc + K3 * Ca ^ 2 * Hr_ad) / (-Rou * Cp) + F * (T_in - Tr) + K_w * Ar * (Tk - Tr) / (Rou * Cp * Vr)
  der(Tk) = (Qdot + K_w * Ar * (Tr - Tk)) / (mk * Cpk)
  Ca_out = Ca
  Cb_out = Cb
  Tr_out = Tr
  Tk_out = Tk
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MPCComponents/CSTRPlant.svg"},
    "doc": {"behavior": false}
  }
}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses