{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 11 - Accounting for the rate laws"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Max. velocity and Michaelis constant\n",
      "#Initialization of variables\n",
      "import math\n",
      "import numpy as np\n",
      "from numpy import linalg\n",
      "S=[10, 20, 40, 80, 120, 180, 300]\n",
      "v=[0.32, 0.58, 0.9, 1.22, 1.42, 1.58, 1.74]\n",
      "#calculations\n",
      "n=len(S)\n",
      "def fun1(x):\n",
      "\tfor i in range(0,len(x)):\n",
      "\t\tx[i]=1000./(x[i])\n",
      "\treturn x\n",
      "\n",
      "\n",
      "def fun2(x):\n",
      "\tfor i in range(0,len(x)):\n",
      "\t\tx[i]=1./(x[i])\n",
      "\treturn x\n",
      "bys=fun1(S)\n",
      "byv=fun2(v)\n",
      "x=bys\n",
      "y=byv\n",
      "A = np.vstack([x, np.ones(len(x))]).T\n",
      "m1, b1 = np.linalg.lstsq(A, y)[0]\n",
      "print '%s' %(\"From graph,\")\n",
      "vmax=1/b1\n",
      "Km=m1*1000./b1\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Max. velocity  =\",vmax,\" mumol/L s\")\n",
      "print '%s %.1f %s' %(\"\\n Michaelis constant =\",Km,\" mumol/L\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From graph,\n",
        "Max. velocity  = 2.10  mumol/L s\n",
        "\n",
        " Michaelis constant = 55.0  mumol/L\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 257"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Equilibrium constant\n",
      "#Initialization of variables\n",
      "c=1.234\n",
      "m=2.044\n",
      "#calculations\n",
      "Ki=c/m\n",
      "#results\n",
      "print '%s %.2f' %(\"KI = \",Ki)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "KI =  0.60\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 265"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the no. of diheptane molecules destroyed \n",
      "#Initialization of variables\n",
      "import math\n",
      "P=50. #J/s\n",
      "l=313.*math.pow(10,-9) #m\n",
      "h=6.62608*math.pow(10,-34) #Js\n",
      "N=6.023*math.pow(10,23)\n",
      "c=2.99792*math.pow(10,8) #m/s\n",
      "yiel=0.21\n",
      "#calculations\n",
      "rate=P*l/(h*c)\n",
      "Frate=yiel*rate\n",
      "molrate=Frate/N\n",
      "#results\n",
      "print '%s %.1e %s' %(\"No.of diheptane molecules destroyed =\",Frate,\" s^-1\")\n",
      "print '%s %.2e %s' %(\"\\n Moles of  diheptane molecules destroyed =\",molrate,\"mol s^-1\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No.of diheptane molecules destroyed = 1.7e+19  s^-1\n",
        "\n",
        " Moles of  diheptane molecules destroyed = 2.75e-05 mol s^-1\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I1 - Pg 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Equilibrium constant for dimerization\n",
      "#Initialization of variables\n",
      "import math\n",
      "kf=8.18*math.pow(10,8) #L/mol s\n",
      "kb=2*math.pow(10,6) #s^-1\n",
      "#calculations\n",
      "K=kf/kb\n",
      "#results\n",
      "print '%s %.1e' %(\"Equilibrium constant for dimerization = \",K)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equilibrium constant for dimerization =  4.1e+02\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example I2 - Pg 248"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate if the reaction step is far from equilibrium and calculate the heat generated\n",
      "#Initialization of variables\n",
      "import math\n",
      "F16bP=1.9*math.pow(10,-5) #mmol/L\n",
      "ADP=1.3/1000.  #mmol/L\n",
      "ATP=11.4/1000.  #mmol/L\n",
      "F6P=8.9*math.pow(10,-5)  #mmol/L\n",
      "k=1.2*1000.\n",
      "#calculations\n",
      "Q=F16bP*ADP/(F6P*ATP)\n",
      "if(Q<k):\n",
      "    print '%s %.3f' %(\"The reaction step is far from equilibrium and Q= \",Q)\n",
      "else:\n",
      "    print '%s %.3f' %(\"The reaction step is at equilibrium and Q= \",Q)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reaction step is far from equilibrium and Q=  0.024\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}