{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Design for Parallel Reactions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2 page no : 159"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "#Initial Concentration(mol/litre)eactant in combined feed\n",
      "CAo = 10.\n",
      "CBo = 10. \n",
      "XA = 0.9;             # conversion\n",
      "CAf = CAo*(1-XA);\n",
      "CA = CAf;\n",
      "\n",
      "# Calculations\n",
      "def f4(CA): \n",
      "\t return 1./(1+CA**0.5)\n",
      "\n",
      "Qp = (-1./(CAo-CAf))* quad(f4,CAo,CAf)[0]\n",
      "\n",
      "CRf = 9*Qp;\n",
      "CSf = 9*(1-Qp)\n",
      "# Results\n",
      "print \" Part a\"\n",
      "print \" For Plug Flow\"\n",
      "print \" Concentration of R in the product stream is %.2f mol/litre\"%(CRf)\n",
      "print \" Csf is %.2f mol/litre\"%(CSf)\n",
      "\n",
      "Qm = CA/(CA+CA**1.5);\n",
      "CRf = 9*Qm;\n",
      "Csf = 9*(1-Qm)\n",
      "print \" Part b\"\n",
      "print \" For Mixed Flow\"\n",
      "print \" Concentration of R in the product stream is %.2f mol/litre \"%(CRf)\n",
      "print \" Csf is %.2f mol/litre\"%(Csf)\n",
      "\n",
      "CAo = 19.\n",
      "CB = 1;\n",
      "\n",
      "def f5(CA): \n",
      "\t return CA/(CA+CB**1.5)\n",
      "\n",
      "Q = -1./(CAo-CAf)* quad(f5,CAo,CAf)[0]\n",
      "CRf = 9*Q;\n",
      "Csf = 9*(1-Q)\n",
      "print \" Part c\"\n",
      "print \" For Plug flow A Mixed flow B\"\n",
      "print \" Concentration of R in the product stream is %.2f  mol/litre\"%(CRf)\n",
      "print \" Csf is %.2f mol/litre\"%(Csf)\n",
      "print ('The result for plug flow varies as there seems to be typographical error in integration done in book')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Part a\n",
        " For Plug Flow\n",
        " Concentration of R in the product stream is 2.86 mol/litre\n",
        " Csf is 6.14 mol/litre\n",
        " Part b\n",
        " For Mixed Flow\n",
        " Concentration of R in the product stream is 4.50 mol/litre \n",
        " Csf is 4.50 mol/litre\n",
        " Part c\n",
        " For Plug flow A Mixed flow B\n",
        " Concentration of R in the product stream is 7.85  mol/litre\n",
        " Csf is 1.15 mol/litre\n",
        "The result for plug flow varies as there seems to be typographical error in integration done in book\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3 page no : 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "CAo = 2;          # decomposition of A\n",
      "CA = 0.5;\n",
      "CAf = 0.;\n",
      "\n",
      "Csf = (CAo-CA)*2*CA/(1+CA)**2;\n",
      "\n",
      "print \" Part a\"\n",
      "print \" For Mixed Flow Reactor\"\n",
      "print \" Maximum expected Cs is %.3f\"%(Csf)\n",
      "\n",
      "# Calculations\n",
      "def f12(CA): \n",
      "\t return 2*CA/(1+CA)**2\n",
      "\n",
      "Csf = -1* quad(f12,CAo,CAf)[0]\n",
      "\n",
      "# Results\n",
      "print \" Part b\"\n",
      "print \" For Plug Flow\"\n",
      "print \" Maximum expected concentration of S is %.3f \"%(Csf)\n",
      "\n",
      "CA = 1.;\n",
      "Csf = (CAo-CA)*2*CA/(1+CA)**2;\n",
      "\n",
      "print \"Part c\"\n",
      "print \" For MFR with separation and recycle\" \n",
      "print \" Concentration of Csf is %.2f\"%(Csf)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Part a\n",
        " For Mixed Flow Reactor\n",
        " Maximum expected Cs is 0.667\n",
        " Part b\n",
        " For Plug Flow\n",
        " Maximum expected concentration of S is 0.864 \n",
        "Part c\n",
        " For MFR with separation and recycle\n",
        " Concentration of Csf is 0.50\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4 page no : 164"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "CAo = 2.     # based on example 7.3\n",
      "CA = 1.\n",
      "Q = 0.5\n",
      "\n",
      "# Calculations\n",
      "Cs1 = Q*(CAo-CA);\n",
      "\n",
      "def f6(CA): \n",
      "\t return 2*CA/(1+CA)**2\n",
      "\n",
      "Cs2 = -1* quad(f6,1,0)[0]\n",
      "\n",
      "#Total amount of CS formed is\n",
      "Cs = Cs1+Cs2;\n",
      "\n",
      "# Results\n",
      "print \"Mixed flow followed by plug flow would be best\"\n",
      "print \" Total amount of CS formed is %.3f mol/litre\"%(Cs)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mixed flow followed by plug flow would be best\n",
        " Total amount of CS formed is 0.886 mol/litre\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}