{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# HDA Flowsheet Simulation and Optimization\n", "\n", "\n", "## Learning outcomes\n", "\n", "\n", "- Construct a steady-state flowsheet using the IDAES unit model library\n", "- Connecting unit models in a flowsheet using Arcs\n", "- Using the SequentialDecomposition tool to initialize a flowsheet with recycle\n", "- Fomulate and solve an optimization problem\n", " - Defining an objective function\n", " - Setting variable bounds\n", " - Adding additional constraints \n", "\n", "\n", "## Problem Statement\n", "\n", "Hydrodealkylation is a chemical reaction that often involves reacting\n", "an aromatic hydrocarbon in the presence of hydrogen gas to form a\n", "simpler aromatic hydrocarbon devoid of functional groups. In this\n", "example, toluene will be reacted with hydrogen gas at high temperatures\n", " to form benzene via the following reaction:\n", "\n", "**C6H5CH3 + H2 → C6H6 + CH4**\n", "\n", "\n", "This reaction is often accompanied by an equilibrium side reaction\n", "which forms diphenyl, which we will neglect for this example.\n", "\n", "This example is based on the 1967 AIChE Student Contest problem as\n", "present by Douglas, J.M., Chemical Design of Chemical Processes, 1988,\n", "McGraw-Hill.\n", "\n", "The flowsheet that we will be using for this module is shown below with the stream conditions. We will be processing toluene and hydrogen to produce at least 370 TPY of benzene. As shown in the flowsheet, there are two flash tanks, F101 to separate out the non-condensibles and F102 to further separate the benzene-toluene mixture to improve the benzene purity. Note that typically a distillation column is required to obtain high purity benzene but that is beyond the scope of this workshop. The non-condensibles separated out in F101 will be partially recycled back to M101 and the rest will be either purged or combusted for power generation.We will assume ideal gas for this flowsheet. The properties required for this module are available in the same directory:\n", "\n", "- hda_ideal_VLE.py\n", "- hda_reaction.py\n", "\n", "The state variables chosen for the property package are **flows of component by phase, temperature and pressure**. The components considered are: **toluene, hydrogen, benzene and methane**. Therefore, every stream has 8 flow variables, 1 temperature and 1 pressure variable. \n", "\n", "![](HDA_flowsheet.png)\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing required pyomo and idaes components\n", "\n", "\n", "To construct a flowsheet, we will need several components from the pyomo and idaes package. Let us first import the following components from Pyomo:\n", "- Constraint (to write constraints)\n", "- Var (to declare variables)\n", "- ConcreteModel (to create the concrete model object)\n", "- Expression (to evaluate values as a function of variables defined in the model)\n", "- Objective (to define an objective function for optimization)\n", "- SolverFactory (to solve the problem)\n", "- TransformationFactory (to apply certain transformations)\n", "- Arc (to connect two unit models)\n", "- SequentialDecomposition (to initialize the flowsheet in a sequential mode)\n", "\n", "For further details on these components, please refer to the pyomo documentation: https://pyomo.readthedocs.io/en/latest/\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pyomo.environ import (Constraint,\n", " Var,\n", " ConcreteModel,\n", " Expression,\n", " Objective,\n", " SolverFactory,\n", " TransformationFactory,\n", " value)\n", "from pyomo.network import Arc, SequentialDecomposition" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From idaes, we will be needing the FlowsheetBlock and the following unit models:\n", "- Mixer\n", "- Heater\n", "- StoichiometricReactor\n", "- **Flash**\n", "- Separator (splitter) \n", "- PressureChanger" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from idaes.core import FlowsheetBlock" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from idaes.models.unit_models import (PressureChanger,\n", " Mixer,\n", " Separator as Splitter,\n", " Heater,\n", " StoichiometricReactor)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "