{
 "metadata": {
  "name": "",
  "signature": "sha256:e231d69245822a18a4c67d44b8a7db0b930a7622a43a07f791250d8e1c3f4a37"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : Hydrostatic Pressure"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1 Page No : 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Variables :\n",
      "D = 30*10**-2;\t\t\t#in m\n",
      "F = 9810.;\t\t\t#in N\n",
      "\n",
      "# Calculations\n",
      "A = math.pi*D**2/4;\t\t\t#in m**2\n",
      "p = F/A;\t\t\t#in N/m**2 or Pa\n",
      "p = p/1000;\t\t\t#kPa\n",
      "\n",
      "# Results\n",
      "print \"Intensity of pressure at the bottom of container in kPa : %.2f\"%p\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Intensity of pressure at the bottom of container in kPa : 138.78\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2 Page No : 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "h = 1.5;\t\t\t#in m\n",
      "w_w = 9.81;\t\t\t#in kN/m**3\n",
      "w_g = 1.26;\t\t\t#in kN/m**3\n",
      "w_m = 13.6;\t\t\t#in kN/m**3\n",
      "\n",
      "# Calculations and Results\n",
      "f = h*w_w;\t\t\t#kN/m**2\n",
      "print \"Intensity of pressure exerted by water column in kN/m**2 : \",f\n",
      "f = h*w_w*w_g;\t\t\t#kN/m**2\n",
      "print \"Intensity of pressure exerted by glycerine column in kN/m**2 : \",f\n",
      "f = h*w_w*w_m;\t\t\t#kN/m**2\n",
      "print \"Intensity of pressure exerted by mercury column in kN/m**2 : \",f\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Intensity of pressure exerted by water column in kN/m**2 :  14.715\n",
        "Intensity of pressure exerted by glycerine column in kN/m**2 :  18.5409\n",
        "Intensity of pressure exerted by mercury column in kN/m**2 :  200.124\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3 Page No : 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "p = 2;\t\t\t#in kN/m**2\n",
      "w_w = 9.81;\t\t\t#in kN/m**3\n",
      "w_alcohol = w_w*0.789;\t\t\t#in kN/m**3\n",
      "w_m = 13.6;\t\t\t#in kN/m**3\n",
      "\n",
      "# Calculations and Results\n",
      "H = p/w_alcohol;\t\t\t#in m\n",
      "print \"Depth of alcohol in meter : %.3f\"%H\n",
      "P_head_w = p/w_w;\t\t\t#m\n",
      "print \"Pressure head in terms of water in meter : %.3f\"%P_head_w\n",
      "P_head_m = p/w_w/w_m;\t\t\t#m\n",
      "print \"Pressure head in terms of mercury in meter : %.3f\"%P_head_m\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Depth of alcohol in meter : 0.258\n",
        "Pressure head in terms of water in meter : 0.204\n",
        "Pressure head in terms of mercury in meter : 0.015\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4 Page No : 31\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "Hwater = 6.;\t\t\t#m(Pressure head of water)\n",
      "S_oil = 0.70;\t\t\t#(specific gravity of oil)\n",
      "\n",
      "# Calculations and Results\n",
      "H_oil = Hwater/S_oil;\t\t\t#in m(Pressure head in terms of oil)\n",
      "print \"Pressure head of water in terms of oil in meter : %.2f\"%H_oil\n",
      "S_oil = 0.825;\t\t\t#(specific gravity of oil)\n",
      "S_mercury = 13.6;\t\t\t#(specific gravity of mercury)\n",
      "Hmercury = 70./100;\t\t\t#m(Pressure head of mercury)\n",
      "H_oil = S_mercury/S_oil*Hmercury;\t\t\t#in m(Pressure head in terms of oil)\n",
      "print \"Pressure head of mercury in terms of oil in meter : %.3f\"%H_oil\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure head of water in terms of oil in meter : 8.57\n",
        "Pressure head of mercury in terms of oil in meter : 11.539\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5 Page No : 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "w = 9.81;\t\t\t#in kN/m**3\n",
      "l = 3.;\t\t\t#in m\n",
      "b = 2.;\t\t\t#in m\n",
      "h = 1.;\t\t\t#in m\n",
      "\n",
      "# Calculations and Results\n",
      "f_bottom = w*h;\t\t\t#in kN/m**2(Pressure intensity at bottom)\n",
      "p_bottom = f_bottom*l*b;\t\t\t#kN\n",
      "print \"Total pressure on the bottom in kN : \",p_bottom\n",
      "f_long_vertical = f_bottom/2;\t\t\t#kN\n",
      "p_long_vertical = f_long_vertical*l*h;\t\t\t#kN\n",
      "print \"Total pressure on long vertical wall in kN : \",p_long_vertical\n",
      "f_short_vertical = f_bottom/2;\t\t\t#kN\n",
      "p_short_vertical = f_short_vertical*b*h;\t\t\t#kN\n",
      "print \"Total pressure on short vertical wall in kN : \",p_short_vertical\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure on the bottom in kN :  58.86\n",
        "Total pressure on long vertical wall in kN :  14.715\n",
        "Total pressure on short vertical wall in kN :  9.81\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6 Page No : 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "p_water = 1000.;\t\t\t#in kg/m**3\n",
      "p_liquid = 800.;\t\t\t#in kg/m**3\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "h1 = 1.5;\t\t\t#m\n",
      "\n",
      "# Calculations and Results\n",
      "px1 = p_liquid*g*h1/1000;\t\t\t#kN/m**2\n",
      "print \"Pressure at a point 1.5 meter below free surface in kN/m**2 : \",px1\n",
      "h2 = 2.;\t\t\t#m\n",
      "px2 = p_liquid*g*h2/1000;\t\t\t#kN/m**2\n",
      "print \"Pressure at a point 2 meter below free surface in kN/m**2 : \",px2\n",
      "h31 = 2.;\t\t\t#m(for liquid)\n",
      "h32 = 0.5;\t\t\t#m(for water)\n",
      "px1 = p_liquid*g*h31/1000;\t\t\t#kN/m**2\n",
      "px2 = p_water*g*h32/1000;\t\t\t#kN/m**2\n",
      "px3 = (px1+px2);\t\t\t#kN/m**2\n",
      "print \"Pressure at a point 2.5 meter below free surface in kN/m**2 : \",px3\n",
      "h = 2.;\t\t\t#meter(water level)\n",
      "b = 8.;\t\t\t#meter(width of wall)\n",
      "p_bottom = px1+(p_water*g*h)/1000;\t\t\t#kN/m**2\n",
      "p_avg1 = (px1+0)/2;\t\t\t#kN/m**2(top 2m liquid layer)\n",
      "p_avg2 = (px1+p_bottom)/2;\t\t\t#kN/m**2(top 2m water layer)\n",
      "F_per_meter = p_avg1*h*1+p_avg2*h*1;\t\t\t#kN\n",
      "Fwall = F_per_meter*b;\t\t\t#kN\n",
      "print \"Force on the wall in kN : \",Fwall\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at a point 1.5 meter below free surface in kN/m**2 :  11.772\n",
        "Pressure at a point 2 meter below free surface in kN/m**2 :  15.696\n",
        "Pressure at a point 2.5 meter below free surface in kN/m**2 :  20.601\n",
        "Force on the wall in kN :  533.664\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7  Page No : 46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "b = 3.;\t\t\t#in meter\n",
      "h = 3.;\t\t\t#in meter\n",
      "S_oil = 0.8;\t\t\t#(specific gravity of oil)\n",
      "\n",
      "# Calculations\n",
      "A = 1./2*h*b;\t\t\t#in m**2\n",
      "x_bar = 2./3*3;\t\t\t#in meter\n",
      "SW_water = 9.81*1000;\t\t\t#in N/m**3\n",
      "SW_oil = SW_water*S_oil;\t\t\t#in N/m**3\n",
      "F_surface = SW_oil*A*x_bar;\t\t\t#in kN\n",
      "IG = b*h**3/36;\t\t\t#in m**3\n",
      "h_bar = IG/A/x_bar+x_bar;\t\t\t#in meter\n",
      "\n",
      "# Results\n",
      "print \"Force shall act at depth of centre of pressure. This depth in meter is : \",h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Force shall act at depth of centre of pressure. This depth in meter is :  2.25\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8 Page No : 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "l = 3.;\t\t\t#in meter\n",
      "b = 2.;\t\t\t#in meter\n",
      "p = 2.*10**6;\t\t\t#in Pa\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "w = g*1000.;\t\t\t#in N/m**3\n",
      "\n",
      "# Calculations and Results\n",
      "h = p/w;\t\t\t#in meter\n",
      "xbar = h-1.5;\t\t\t#in meter\n",
      "A = l*b;\t\t\t#in m**2\n",
      "p_gate = w*A*xbar/10**6;\t\t\t#in MN\n",
      "print \"Total pressure on the gate in MN : %.3f\"%p_gate\n",
      "IG = b*l**3/12;\t\t\t#in m**3\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure is \",round(h_bar-xbar,3),\" meter below the centroid of gate.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure on the gate in MN : 11.912\n",
        "Position of centre of pressure is  0.004  meter below the centroid of gate.\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9 Page No : 48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity\n",
      "GH = 4.;\t\t\t#meter\n",
      "IJ = 4.;\t\t\t#meter\n",
      "IC = 2.;\t\t\t#meter\n",
      "GC = 3.;\t\t\t#meter\n",
      "AG = (10.-4)/2;\t\t\t#meter\n",
      "BH = (10.-4)/2;\t\t\t#meter\n",
      "EI = AG*IC/GC;\t\t\t#meter\n",
      "JF = AG*IC/GC;\t\t\t#meter\n",
      "EF = EI+IJ+JF;\t\t\t#meter\n",
      "A = (8.+4.)/2*2;\t\t\t#in m**2\n",
      "a = 4.;\t\t\t#meter\n",
      "b = 8.;\t\t\t#meter\n",
      "d = 2.;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "xbar = (2*a+b)/(a+b)*d/3;\t\t\t#in meter\n",
      "w = g*1000;\t\t\t#in N/m**3\n",
      "p_gate = w*A*xbar/10**3;\t\t\t#in kN\n",
      "print \"Total pressure in kN : \",p_gate\n",
      "IG = (a**2+4*a*b+b**2)/(a+b)*d**3/36;\t\t\t#in m**3\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Depth of centre of pressure is \",h_bar,\" meter.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure in kN :  104.64\n",
        "Depth of centre of pressure is  1.25  meter.\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10 Page No : 50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity\n",
      "xbar = 8.;\t\t\t#meter\n",
      "D = 4.;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = math.pi*D**2/4;\t\t\t#meter**2\n",
      "w = g*1000;\t\t\t#in N/m**3\n",
      "p = w*A*xbar/10**3;\t\t\t#in kN\n",
      "print \"Total pressure in kN : %.2f\"%p\n",
      "IG = math.pi*D**4/64;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Depth of centre of pressure is \",(h_bar),\" meter.\"\n",
      "\n",
      "# note : Answer of total pressure is wrong in the book.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure in kN : 986.21\n",
        "Depth of centre of pressure is  8.125  meter.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11 Page No : 51"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity\n",
      "D = 4.;\t\t\t#meter\n",
      "xbar = (10.+7)/2;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = math.pi*D**2/4;\t\t\t#meter**2\n",
      "w = g*1000;\t\t\t#in N/m**3\n",
      "p = w*A*xbar/10**6;\t\t\t#in MN\n",
      "print \"Total pressure in MN : %.3f\"%p\n",
      "BC = 3;\t\t\t#meter\n",
      "AB = 4;\t\t\t#mete\n",
      "math.sin_theta = BC/AB;\n",
      "IG = math.pi*D**4/64;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar*math.sin_theta**2+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure is \",(h_bar),\" meter.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure in MN : 1.048\n",
        "Position of centre of pressure is  8.5  meter.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12 Page No : 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "a = 3.;\t\t\t#meter\n",
      "b = 4.;\t\t\t#meter(altitude)\n",
      "S = 1.2;\t\t\t#specific gravity\n",
      "theta = 30.;\t\t\t#degree\n",
      "d = 2.5;\t\t\t#meter\n",
      "g = 9.81;\t\t\t#gravity\n",
      "AG = b/3;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "xbar = d+AG*math.sin(math.radians(theta));\t\t\t#meter\n",
      "A = 1./2*a*b;\t\t\t#meter**2\n",
      "w = S*g*1000;\t\t\t#in N/m**3\n",
      "p = w*A*xbar/10**3;\t\t\t#in kN\n",
      "print \"Total pressure in kN : \",p\n",
      "IG = a*b**3/36;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar;\t\t\t#in meter\n",
      "print \"Depth of centre of pressure is \",round(h_bar,3),\" meter.\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure in kN :  223.668\n",
        "Depth of centre of pressure is  3.237  meter.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13 Page No : 54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables :\n",
      "a = 8.;\t\t\t#meter\n",
      "b = 6.;\t\t\t#meter\n",
      "h = 3.;\t\t\t#meter\n",
      "CD = 2.;\t\t\t#meter\n",
      "theta = 30.;\t\t\t#degree\n",
      "\n",
      "# Calculations and Results\n",
      "A = (a+b)/2*h;\t\t\t#meter**2\n",
      "AB = (a+2*b)/(a+b)*h/3;\t\t\t#meter\n",
      "x1bar = AB;\t\t\t#meter\n",
      "BC = AB*math.sin(math.radians(theta));\t\t\t#meter\n",
      "BD = BC+CD;\t\t\t#meter\n",
      "xbar = BD;\t\t\t#meter\n",
      "g = 9.81;\t\t\t#gravity\n",
      "w = g*1000;\t\t\t#in N/m**3\n",
      "p = w*A*xbar/10**3;\t\t\t#in kN\n",
      "print \"Total pressure in kN : \",p\n",
      "IG = (a**2+b**2+4*a*b)/(a+b)*h**3/36;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar;\t\t\t#in meter\n",
      "print \"Depth of centre of pressure is \",round(h_bar,3),\" meter.\"\n",
      "\n",
      "# note : rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total pressure in kN :  559.17\n",
        "Depth of centre of pressure is  2.783  meter.\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14 Page No :  55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "l = 2.;\t\t\t#meter\n",
      "b = 2.;\t\t\t#meter\n",
      "p_i = 98.1;\t\t\t#kN/m**3(Pressure intensity)\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "BC = 1.;\t\t\t#meter\n",
      "AB = 2.;\t\t\t#meter\n",
      "theta = 30.;\t\t\t#degree\n",
      "B = p_i/w;\t\t\t#m\n",
      "\n",
      "# Calculations\n",
      "BD = BC*math.sin(math.radians(theta));\t\t\t#m\n",
      "xbar = 10+0.5;\t\t\t#meter\n",
      "A = l*b;\t\t\t#m**2\n",
      "p = w*A*xbar;\t\t\t#kN\n",
      "IG = (2*l**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar;\t\t\t#in meter\n",
      "DI = h_bar-xbar;\t\t\t#m\n",
      "FC = DI/math.sin(math.radians(theta));\t\t\t#m\n",
      "FB = FC+BC;\t\t\t#meter\n",
      "P = p*FB/AB;\t\t\t#kN\n",
      "\n",
      "# Results\n",
      "print \"Force in kN : \",P\n",
      "RB = p-P;\t\t\t#kN\n",
      "print \"Reaction at hinge B in kN : \",RB\n",
      "\n",
      "#Answer in the book is slightly differ due to limited accuracy used in the book as compared to SCILAB.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Force in kN :  209.28\n",
        "Reaction at hinge B in kN :  202.74\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15 Page No : 57"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "l = 4.;\t\t\t#meter\n",
      "b = 2.;\t\t\t#meter\n",
      "h = 1.8;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "xbar = 6.-2\t\t\t#meter\n",
      "\n",
      "# Calculations\n",
      "A = l*b;\t\t\t#m**2\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "IG = (2*l**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "# As P acts at h_bar-xbar : \n",
      "F = P*((h_bar-xbar)-(b-h))/h;\t\t\t#kN\n",
      "\n",
      "# Results\n",
      "print \"Horizontal Force in kN : %.3f\"%F\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horizontal Force in kN : 23.253\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16 Page No : 58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\t\t\t\n",
      "# Variables :\n",
      "b = 2.;\t\t\t#meter\n",
      "d = 3.;\t\t\t#meter\n",
      "h = 2.;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "xbar = 2+3./2;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = b*d;\t\t\t#m**2\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "print \"Total Pressure in kN : \",P\n",
      "IG = (b*d**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure in meter : %.3f\"%h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Pressure in kN :  206.01\n",
        "Position of centre of pressure in meter : 3.714\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17 Page No : 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "b = 4.;\t\t\t#meter\n",
      "d = 4.;\t\t\t#meter\n",
      "h = 8.;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "xbar = 8.;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = b*d;\t\t\t#m**2\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "print \"Total Pressure in kN : \",P\n",
      "IG = (b*d**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure in meter : %.3f\"%h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Pressure in kN :  1255.68\n",
        "Position of centre of pressure in meter : 8.167\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.18 Page No : 60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "D = 1.5;\t\t\t#meter\n",
      "BE = 2.;\t\t\t#meter\n",
      "AD = 0.75;\t\t\t#meter\n",
      "CE = AD;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "BC = BE-AD;\t\t\t#meter\n",
      "FG = CE+BC/2;\t\t\t#meter\n",
      "xbar = FG;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "A = math.pi*D**2/4;\t\t\t#m**2\n",
      "AB = D;\t\t\t#meter\n",
      "sin_theta = BC/AB;\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "print \"Total Pressure in kN : %.3f\"%P\n",
      "IG = (math.pi/64*D**4);\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar*sin_theta**2+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure in meter : %.3f\"%h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Pressure in kN : 23.837\n",
        "Position of centre of pressure in meter : 1.446\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.19 Page No : 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "b = 3.;\t\t\t#meter\n",
      "a = 3.;\t\t\t#meter\n",
      "S_oil = 0.8;\t\t\t#specific gravity of oil\n",
      "w = 9.81*S_oil;\t\t\t#kN/m**2\n",
      "xbar = 1./3*b;\t\t\t#meter\n",
      "A = 1./2*a*b;\t\t\t#m**2\n",
      "\n",
      "# Calculations and Results\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "print \"Total Pressure in kN : \",P\n",
      "IG = (a*b**3)/36;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Centre of pressure in meter : \",h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Pressure in kN :  35.316\n",
        "Centre of pressure in meter :  1.5\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.20  Page No : 63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "a = 2.;\t\t\t#meter\n",
      "b = 1.;\t\t\t#meter\n",
      "d = 2.;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "xbar = 2+a/2;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = a*b;\t\t\t#m**2\n",
      "P = w*A*xbar;\t\t\t#kN\n",
      "print \"Total Pressure in kN : \",P\n",
      "IG = (b*d**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of pressure in meter : %.3f\"%h_bar\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total Pressure in kN :  58.86\n",
        "Position of centre of pressure in meter : 3.111\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.21  Page No : 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables :\n",
      "r = 2.;\t\t\t#meter\n",
      "l = 4.;\t\t\t#meter\n",
      "A = r*l;\t\t\t#m**2\n",
      "xbar = 2+r/2;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "\n",
      "# Calculations and Results\n",
      "PH = w*A*xbar;\t\t\t#kN\n",
      "print \"Horizontal component of resulting Pressure in kN : \",PH\n",
      "PV = 2*r*l*w+math.pi*r**2/4*l*w;\t\t\t#kN\n",
      "print \"Verticalal component of resulting Pressure in kN : %.3f\"%PV\n",
      "IG = (l*r**3)/12;\t\t\t#in m**4\n",
      "h_bar = IG/A/xbar+xbar;\t\t\t#in meter\n",
      "print \"Position of centre of horizontal component of pressure in meter : %.3f\"%h_bar\n",
      "x = (2*r+math.pi*r**2/4*(4*r/3/math.pi))/(2*r+math.pi*r**2/4);\t\t\t#meter\n",
      "P = math.sqrt(PH**2+PV**2);\t\t\t#kN\n",
      "print \"Resultant pressure in kN : %.3f\"%P\n",
      "theta = math.degrees(math.atan(PV/PH));\t\t\t#degree\n",
      "print \"Direction of resultant pressure in degree : %.2f\"%theta\n",
      "\n",
      "# note : rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horizontal component of resulting Pressure in kN :  235.44\n",
        "Verticalal component of resulting Pressure in kN : 280.236\n",
        "Position of centre of horizontal component of pressure in meter : 3.111\n",
        "Resultant pressure in kN : 366.011\n",
        "Direction of resultant pressure in degree : 49.96\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.22 Page No :  69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "A = 2.*1;\t\t\t#m**2\n",
      "xbar = 2+2./2;\t\t\t#meter\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "\n",
      "# Calculations and Results\n",
      "PH = w*A*xbar;\t\t\t#kN\n",
      "print \"Horizontal component of resultant Pressure in kN : \",PH\n",
      "PV = w*(2*2+2*2-math.pi*2**2/4)*1;\t\t\t#kN\n",
      "print \"Verticalal component of resultant Pressure in kN : %.3f\"%PV\n",
      "P = math.sqrt(PH**2+PV**2);\t\t\t#kN\n",
      "print \"resultant pressure in kN : %.3f\"%P\n",
      "theta = math.degrees(math.atan(PV/PH));\t\t\t#degree\n",
      "print \"Direction of resultant pressure in degree : %.2f\"%theta\n",
      "\n",
      "# note : rounding ogg error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horizontal component of resultant Pressure in kN :  58.86\n",
        "Verticalal component of resultant Pressure in kN : 47.661\n",
        "resultant pressure in kN : 75.737\n",
        "Direction of resultant pressure in degree : 39.00\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.23 Page No : 70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "ABbar = math.sqrt(2)*4;\t\t\t#meter\n",
      "xbar = ABbar/2;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "A = ABbar*1;\t\t\t#m**2\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "PH = w*A*xbar;\t\t\t#kN\n",
      "print \"Horizontal component of resultant Pressure in kN : \",PH\n",
      "hbar = 2./3*ABbar;\t\t\t#meter\n",
      "print \"Position of horizontal component of pressure is \",round(hbar,3),\" meter below free water surface.\"\n",
      "PV = w*(math.pi*4**2/4-4*4./2)*1;\t\t\t#kN\n",
      "print \"Verticalal component of resultant Pressure in kN : %.3f\"%PV\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horizontal component of resultant Pressure in kN :  156.96\n",
        "Position of horizontal component of pressure is  3.771  meter below free water surface.\n",
        "Verticalal component of resultant Pressure in kN : 44.796\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.24 Page No : 74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables :\n",
      "h = 24.;\t\t\t#meter\n",
      "b = 15.;\t\t\t#meter\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "Wm = 2000.*g;\t\t\t#N/m**3\n",
      "W = b*h/2*Wm;\t\t\t#N\n",
      "w = 9.81;\t\t\t#kN/m**2\n",
      "\n",
      "# Calculations and Results\n",
      "PH = w*20**2/2.*1000;\t\t\t#N\n",
      "y = PH/W*20/3+5;\t\t\t#meter\n",
      "e = y-b/2;\t\t\t#meter\n",
      "MaxStress = W/b*(1+6*e/b);\t\t\t#N/m**2\n",
      "print \"Maximum stress in N/m**2 : \",MaxStress\n",
      "MinStress = W/b*(1-6*e/b);\t\t\t#N/m**2\n",
      "print \"Minimum stress in N/m**2 : \",MinStress\n",
      "\n",
      "\n",
      "#Answer in the book is slightly differ due to limited accuracy used in the book as compared to PYTHON.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum stress in N/m**2 :  348800.0\n",
        "Minimum stress in N/m**2 :  122080.0\n"
       ]
      }
     ],
     "prompt_number": 28
    }
   ],
   "metadata": {}
  }
 ]
}