{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains course material from [CBE30338](https://jckantor.github.io/CBE30338)\n", "by Jeffrey Kantor (jeff at nd.edu); the content is available [on Github](https://github.com/jckantor/CBE30338.git).\n", "The text is released under the [CC-BY-NC-ND-4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode),\n", "and code is released under the [MIT license](https://opensource.org/licenses/MIT).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Linear Approximation of a Process Model](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/03.02-Linear-Approximation-of-a-Process-Model.ipynb) | [Contents](toc.ipynb) | [Fitting First Order plus Time Delay to Step Response](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/03.04-Fitting-First-Order-plus-Time-Delay-to-Step-Response.ipynb) >

\"Open

\"Download\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Linear Approximation of a Multivariable Model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Multivariable Systems" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Most process models consist of more than a single state and a single input. Techniques for linearization extend naturally to multivariable systems. The most convenient mathematical tools involve some linear algebra." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example: Gravity Drained Tanks\n", "\n", "Here we develop a linear approximation to a process model for a system consisting of coupled gravity-drained tanks. \n", "\n", "![Gravity Drained Tanks](figures/GravityDrainedTanks.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Model\n", "\n", "\\begin{eqnarray*}\n", "A_{1}\\frac{dh_{1}}{dt} & = & q_{in}-C_{1}\\sqrt{h_{1}}\\\\\n", "A_{2}\\frac{dh_{2}}{dt} & = & q_{d}+C_{1}\\sqrt{h_{1}}-C_{2}\\sqrt{h_{2}}\n", "\\end{eqnarray*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Nominal Inputs\n", "\n", "\\begin{eqnarray*}\n", "\\bar{q}_{in} & = & \\bar{q}_{in}\\\\\n", "\\bar{q}_{d} & = & 0\n", "\\end{eqnarray*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Steady State for nominal input\n", "\n", "\\begin{eqnarray*}\n", "\\bar{h}_{1} & = & \\frac{\\bar{q}_{in}^{2}}{C_{1}^{2}}\\\\\n", "\\bar{h}_{2} & = & \\frac{\\bar{q}_{in}^{2}}{C_{2}^{2}}\n", "\\end{eqnarray*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Deviation Variables\n", "\n", "States\n", "\n", "\\begin{eqnarray*}\n", "x_{1} & = & h_{1}-\\bar{h}_{1}\\\\\n", "x_{2} & = & h_{2}-\\bar{h}_{2}\n", "\\end{eqnarray*}\n", "\n", "Control input\n", "$$u=q_{in}-\\bar{q}_{in}$$\n", "\n", "Disturbance input\n", "$$d=q_{d}-\\bar{q}_{d}$$\n", "\n", "Measured output\n", "$$y=h_{2}-\\bar{h}_{2}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Linearization \n", "\n", "\\begin{eqnarray*}\n", "\\frac{dh_{1}}{dt} & = & \\frac{1}{A_{1}}\\left(q_{in}-C_{1}\\sqrt{h_{1}}\\right)=f_{1}(h_{1},h_{2},q_{in},q_{d})\\\\\n", "\\frac{dh_{2}}{dt} & = & \\frac{1}{A_{2}}\\left(q_{d}+C_{1}\\sqrt{h_{1}}-C_{2}\\sqrt{h_{2}}\\right)=f_{2}(h_{1},h_{2},q_{in},q_{d})\n", "\\end{eqnarray*}\n", "\n", "Taylor series expansion for the first tank\n", "\n", "\\begin{eqnarray*}\n", "\\frac{dx_{1}}{dt} & = & f_{1}(\\bar{h}_{1}+x_{1},\\bar{h}_{2}+x_{2},\\bar{q}_{in}+u,\\bar{q}_{d}+d)\\\\\n", " & \\approx & \\underbrace{f_{1}(\\bar{h}_{1},\\bar{h}_{2},\\bar{q}_{in})}_{0}+\\left.\\frac{\\partial f_{1}}{\\partial h_{1}}\\right|_{SS}x_{1}+\\left.\\frac{\\partial f_{1}}{\\partial h_{2}}\\right|_{SS}x_{2}+\\left.\\frac{\\partial f_{1}}{\\partial q_{in}}\\right|_{SS}u+\\left.\\frac{\\partial f_{1}}{\\partial q_{d}}\\right|_{SS}d\\\\\n", " & \\approx & \\left(-\\frac{C_{1}}{2A_{1}\\sqrt{\\bar{h}_{1}}}\\right)x_{1}+\\left(0\\right)x_{2}+\\left(\\frac{1}{A_{1}}\\right)u+\\left(0\\right)d\\\\\n", " & \\approx & \\left(-\\frac{C_{1}^{2}}{2A_{1}\\bar{q}_{in}}\\right)x_{1}+\\left(\\frac{1}{A_{1}}\\right)u\n", "\\end{eqnarray*}\n", "\n", "Taylor series expansion for the second tank\n", "\n", "\\begin{eqnarray*}\n", "\\frac{dx_{2}}{dt} & = & f_{2}(\\bar{h}_{1}+x_{1},\\bar{h}_{2}+x_{2},\\bar{q}_{in}+u,\\bar{q}_{d}+d)\\\\\n", " & \\approx & \\underbrace{f_{2}(\\bar{h}_{1},\\bar{h}_{2},\\bar{q}_{in})}_{0}+\\left.\\frac{\\partial f_{2}}{\\partial h_{1}}\\right|_{SS}x_{1}+\\left.\\frac{\\partial f_{2}}{\\partial h_{2}}\\right|_{SS}x_{2}+\\left.\\frac{\\partial f_{2}}{\\partial q_{in}}\\right|_{SS}u+\\left.\\frac{\\partial f_{2}}{\\partial q_{d}}\\right|_{SS}d\\\\\n", " & \\approx & \\left(\\frac{C_{1}}{2A_{2}\\sqrt{\\bar{h}_{1}}}\\right)x_{1}+\\left(-\\frac{C_{2}}{2A_{2}\\sqrt{\\bar{h}_{2}}}\\right)x_{2}+\\left(0\\right)u+\\left(\\frac{1}{A_{2}}\\right)d\\\\\n", " & \\approx & \\left(\\frac{C_{1}^{2}}{2A_{2}\\bar{q}_{in}}\\right)x_{1}+\\left(-\\frac{C_{2}^{2}}{2A_{2}\\bar{q}_{in}}\\right)x_{2}+\\left(\\frac{1}{A_{2}}\\right)d\n", "\\end{eqnarray*}\n", "\n", "Measured outputs\n", "\n", "\\begin{eqnarray*}\n", "y & = & h_{2}-\\bar{h}_{2}\\\\\n", " & = & x_{2}\n", "\\end{eqnarray*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Summary of the linear model using matrix/vector notation\n", "\n", "\\begin{eqnarray*}\n", "\\frac{d}{dt}\\left[\\begin{array}{c}\n", "x_{1}\\\\\n", "x_{2}\n", "\\end{array}\\right] & = & \\left[\\begin{array}{cc}\n", "-\\frac{C_{1}^{2}}{2A_{1}\\bar{q}_{in}} & 0\\\\\n", "\\frac{C_{1}^{2}}{2A_{2}\\bar{q}_{in}} & -\\frac{C_{2}^{2}}{2A_{2}\\bar{q}_{in}}\n", "\\end{array}\\right]\\left[\\begin{array}{c}\n", "x_{1}\\\\\n", "x_{2}\n", "\\end{array}\\right]+\\left[\\begin{array}{c}\n", "\\frac{1}{A_{1}}\\\\\n", "0\n", "\\end{array}\\right]u+\\left[\\begin{array}{c}\n", "0\\\\\n", "\\frac{1}{A_{2}}\n", "\\end{array}\\right]d\\\\\n", "y & = & \\left[\\begin{array}{cc}\n", "0 & 1\\end{array}\\right]\\left[\\begin{array}{c}\n", "x_{1}\\\\\n", "x_{2}\n", "\\end{array}\\right]+\\left[\\begin{array}{c}\n", "0\\end{array}\\right]u+\\left[\\begin{array}{c}\n", "0\\end{array}\\right]d\n", "\\end{eqnarray*}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercises" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### First Order Reaction in a CSTR\n", "A first-order reaction\n", "\n", "$$A\\longrightarrow\\mbox{Products}$$\n", "takes place in an isothermal CSTR with constant volume $V$, volumetric\n", "flowrate in and out the same value $q$, reaction rate constant $k$,\n", "and feed concentration $c_{AF}$.\n", "\n", "* Write the material balance equation for this system as a first-order ordinary differential equation. \n", "* Algebraically determine the steady-state solution to this equation. \n", "* For what values of $q$, $k$, $V$, and $c_{AF}$ is this stable?\n", "* For a particular reaction $k$ = 2 1/min. We run this reaction in a vessel of volume $V$ =10 liters, volumetric flowrate $q$ = 50 liters/min. The desired exit concentrationof $A$ is $0.1$ gmol/liter. Assume that we can manipulate $c_{AF}$, the concentration of $A$ entering the CSTR, with proportional control, in order to control the concentration of $A$ exiting the reactor. Substitute the appropriate control law into the mathematical model and rearrange it to get a model of the same form as part (a).\n", "* Determine the steady-state solution to this equation. If we set $K_{c}=100$, what is the absolute value of the offset between the exit concentration of $A$ and the desired exit concentration of $A$? " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Two Gravity Drained Tanks in Series\n", "Consider the two-tank model. Assuming the tanks are identical, and\n", "using the same parameter values as used for the single gravity-drained\n", "tank, compute values for all coefficients appearing in the multivariable\n", "linear model. Is the system stable? What makes you think so? " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Isothermal CSTR with second-order reaction\n", "Consider an isothermal CSTR with a single reaction \n", "$$A\\longrightarrow\\mbox{Products}$$\n", "whose reaction rate is second-order. Assume constant volume, $V$,\n", "and density, $\\rho$, and a time-dependent volumetric flow rate $q(t)$.\n", "The input to the reactor has concentration $c_{A,in}$.\n", "\n", "* Write the modeling equation for this system. \n", "* Assume that the state variable is the concentration of $A$ in the\n", "output, $c_{A}$, and the flow rate $q$ is an input variable. There\n", "is a steady-state operating point corresponding to $q=1$ L/min. Other\n", "parameters are $k=1$ L/mol/min, $V=2$ L, $c_{A,in}=2$ mol/L. Find\n", "the linearized model for $\\frac{dc'_{A}}{dt}$ valid in the neighborhood\n", "of this steady state.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Linear Approximation of a Process Model](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/03.02-Linear-Approximation-of-a-Process-Model.ipynb) | [Contents](toc.ipynb) | [Fitting First Order plus Time Delay to Step Response](http://nbviewer.jupyter.org/github/jckantor/CBE30338/blob/master/notebooks/03.04-Fitting-First-Order-plus-Time-Delay-to-Step-Response.ipynb) >

\"Open

\"Download\"" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }