{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 20 : Computational fluid dynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 20.1 page no : 588\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate first derivative and second derivative of the fluid flow\n",
      "\n",
      "# variables\n",
      "y_fd2=0.4336                    #m\n",
      "y_fd1=0.4375                    #m\n",
      "delta_yfd=y_fd2-y_fd1           #m\n",
      "x_fd2=0.75                      #m\n",
      "x=0.5                           #m\n",
      "delta_xfd=x_fd2-x               #m\n",
      "y_bd2=0.4375                    #m\n",
      "y_bd1=0.2461                    #m\n",
      "delta_ybd=y_bd2-y_bd1           #m\n",
      "x_bd1=0.25                      #m\n",
      "delta_xbd=x-x_bd1               #m\n",
      "\n",
      "# calculation\n",
      "#Let D denote d/dx and D2 denote d^2/dx^2\n",
      "Dy_fd=delta_yfd/delta_xfd       #dimentionless\n",
      "Dy_bd=delta_ybd/delta_xbd       #dimentionless\n",
      "Dy=(Dy_fd+Dy_bd)/2              #dimentionless\n",
      "D2y=(Dy_fd-Dy_bd)/delta_xfd     #dimentionless\n",
      "\n",
      "# result\n",
      "print \"The first derivative of fluid flow is %f\\n\"%Dy\n",
      "print \"The second derivative of fluid flow is %.3f\"%D2y"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The first derivative of fluid flow is 0.375000\n",
        "\n",
        "The second derivative of fluid flow is -3.125\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 20.3 page no : 592\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the grid velocities\n",
      "\n",
      "# variables\n",
      "v=1.077*10**(-5)                  #ft^2/s\n",
      "t=2.                              #sec\n",
      "dy=0.01                           #ft\n",
      "w=v*t/dy**2                       #dimentionless\n",
      "\n",
      "#Let Vij represent velocity through the i,j grid\n",
      "V00=5.                            #ft/s\n",
      "V10=5.                            #ft/s\n",
      "V01=0.                            #ft/s\n",
      "V02=0.                            #ft/s\n",
      "V12=0.                            #ft/s\n",
      "\n",
      "# calculation\n",
      "V11=V01+w*(V00-2*V01+V02)         #ft/s\n",
      "V21=V11+w*(V10-2*V11+V12)         #ft/s\n",
      "V13=0.                            #ft/s\n",
      "V22=V12+w*(V11-2*V12+V13)         #ft/s\n",
      "\n",
      "# result\n",
      "print \"The grid velocity for 2,1 is %.3f ft/s\\n\"%V21\n",
      "print \"The grid velocity for 2,2 is %.3f ft/s\\n\"%V22"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The grid velocity for 2,1 is 1.690 ft/s\n",
        "\n",
        "The grid velocity for 2,2 is 0.232 ft/s\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}