{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16 Earliness of Mixing, Segregation, and RTD"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.1 pageno : 358"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "Co = 1.\n",
      "k = 1.\n",
      "t = 1.      #given\n",
      "\n",
      "# Calculations and Results\n",
      "C1 = (-1+math.sqrt(1-4*t*(-Co)))/2*t;\n",
      "#For the plug flow reactor\n",
      "#t = 1/k(1/C2-1/C1)\n",
      "C2 = C1/(1+k*t*C1);\n",
      "print \" Conversion for flow scheme A is %.3f\"%(C2)\n",
      "\n",
      "#For plug flow\n",
      "C3 = Co/(1+k*t*Co);\n",
      "#For mixed flow reactor\n",
      "C4 = (-1+math.sqrt(1-4*t*(-C3)))/2*t;\n",
      "print \" Conversion for flow scheme B is %.3f\"%(C4)\n",
      "\n",
      "#Using exit age distribution fn for 2 equal plug-mixed flow reactor system,umath.sing fig 12.1\n",
      "t_bar = 2.\n",
      "in_ = 1000.\n",
      "\n",
      "def f3(t): \n",
      "\t return (2/t_bar)*(math.exp(1-2*t/t_bar))/(1+Co*k*t)\n",
      "\n",
      "C5 =  quad(f3,t_bar/2,in_)[0]\n",
      "\n",
      "print \" Conversion for flow scheme C,D,E is %.3f\"%(C5)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Conversion for flow scheme A is 0.382\n",
        " Conversion for flow scheme B is 0.366\n",
        " Conversion for flow scheme C,D,E is 0.361"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}