{
 "metadata": {
  "name": "",
  "signature": "sha256:6fa8fe978c728d97fa9f04464822ea9606521023bb2c2c301624274cfcebacb1"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8 : GRAVITY DAMS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.1 pg : 376"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.integrate import quad \n",
      "\t\t\t\t\n",
      "#Given\n",
      "H = 100;              \t\t\t\t#heigth of dam\n",
      "wb = 70;              \t\t\t\t#width of base of dam\n",
      "wt = 7;               \t\t\t\t#width of top of dam\n",
      "l = 1;                \t\t\t\t#length of dam\n",
      "hw = 98;              \t\t\t\t#heigth of water in dam\n",
      "hsu = 90;             \t\t\t\t#heigth of slope on downstream side\n",
      "s = 1/0.7;            \t\t\t\t#slope on downstream side\n",
      "gammad = 24;          \t\t\t\t#unit weigth of dam\n",
      "gammaw = 9.81;        \t\t\t\t#unit weigth of water\n",
      "E = 2.05e7;           \t\t\t\t#modulus of elasticity\n",
      "\n",
      "\t\t\t\t#(a) inertial forces and moments\n",
      "alpha0 = 0.05;        \t\t\t\t#from table 8.1\n",
      "alphah = 2*alpha0;\n",
      "\t\t\t\t#at 10m from top\n",
      "\n",
      "def f0(y): \n",
      "\t return 25.2-0.25*y\n",
      "\n",
      "F10 =  quad(f0,0,10)[0]\n",
      "\n",
      "\n",
      "def f1(y): \n",
      "\t return 25.2*(1-0.01*y)*(10-y)\n",
      "\n",
      "M10 =  quad(f1,0,10)[0]\n",
      "\n",
      "\t\t\t\t#at 100m below top\n",
      "\n",
      "def f2(y): \n",
      "\t return 0.15*(1-0.01*y)*16.8*y\n",
      "\n",
      "F100 = F10+ quad(f2,10,100)[0]\n",
      "\n",
      "\n",
      "def f3(y): \n",
      "\t return 0.15*(1-0.01*y)*16.8*y*(100-y)\n",
      "\n",
      "M100 = M10+90*F10+ quad(f3,10,100)[0]\n",
      "\n",
      "print \"Inertial forces:At 10m from top: F = %.2f kn;M = %ikn-mAt 100m from top: F = %.2f kn;M = %ikn-m.\"%(F10,M10,F100,M100);\n",
      "\n",
      "\t\t\t\t#(b) hydrodynamic pressure and moment\n",
      "\t\t\t\t#at 10m from top\n",
      "y = 8.;\n",
      "W10 = 1680.;\n",
      "alphah = F10/W10;\n",
      "Cm = 0.735;\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "p = Cy*alphah*gammaw*hw;\n",
      "P10 = 0.726*p*y;\n",
      "Mp10 = 0.299*p*y**2;\n",
      "P10 = round(P10*100)/100;\n",
      "Mp10 = round(Mp10*100)/100;\n",
      "\t\t\t\t#at 100m from top\n",
      "y = 98;\n",
      "W100 = 84840;\n",
      "alphah = F100/W100;\n",
      "Cm = 0.735;\n",
      "Cy = (Cm/2)*(y*(2-y/hw)/hw+(y*(2-y/hw)/hw)**0.5);\n",
      "p = Cy*alphah*gammaw*hw;\n",
      "P100 = 0.726*p*y;\n",
      "Mp100 = 0.299*p*y**2;\n",
      "print \"Hydrodynamic forces:At 10m from top: F = %.2f kn;\\\n",
      "\\nM = %.2fkn-mAt 100m from top: F = %i kn;\\\n",
      "\\nM = %ikn-m.\"%(P10,Mp10,P100,Mp100);\n",
      "\n",
      "# rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Inertial forces:At 10m from top: F = 239.50 kn;M = 1218kn-mAt 100m from top: F = 4321.90 kn;M = 221790kn-m.\n",
        "Hydrodynamic forces:At 10m from top: F = 161.58 kn;\n",
        "M = 532.35kn-mAt 100m from top: F = 2561 kn;\n",
        "M = 103366kn-m.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2 pg : 378"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\t\n",
      "#Given\n",
      "H = 100;              \t\t\t\t#heigth of dam\n",
      "wb = 70;              \t\t\t\t#width of base of dam\n",
      "wt = 7;               \t\t\t\t#width of top of dam\n",
      "l = 1;                \t\t\t\t#length of dam\n",
      "hw = 98;              \t\t\t\t#heigth of water in dam\n",
      "hsu = 90;             \t\t\t\t#heigth of slope on downstream side\n",
      "s = 1/0.7;            \t\t\t\t#slope on downstream side\n",
      "gammad = 24;          \t\t\t\t#unit weigth of dam\n",
      "gammaw = 9.81;        \t\t\t\t#unit weigth of water\n",
      "E = 2.05e7;           \t\t\t\t#modulus of elasticity\n",
      "beta = 1;\n",
      "I = 2;\n",
      "Fo = 0.25;           \t\t\t\t#from table 8.2\n",
      "                  \t\t\t\t#t = Sa/g;\n",
      "t = 0.19;           \t\t\t\t#from fig. 8.4\n",
      "alphah = beta*I*Fo*t;\n",
      "T = 5.55*H**2/wb*(gammad/(gammaw*E))**0.5;\n",
      "\t\t\t\t#(a) Base shear\n",
      "W = l*gammad*(wt*H+((hsu/s)*hsu)/2);\n",
      "Fb = 0.6*W*alphah;\n",
      "print \"Base shear = %.2f KN.\"%(Fb);\n",
      "\n",
      "\t\t\t\t#(b) Base moment\n",
      "hbar = ((wt*H**2/2)+((hsu/s)*hsu**2/6))/((wt*H)+(hsu/s)*hsu/2);\n",
      "Mb = 0.9*W*hbar*alphah;\n",
      "print \"Base moment = %.2f KN-m.\"%(Mb);\n",
      "\n",
      "\t\t\t\t#(c) shear at 10m from top\n",
      "Cv = 0.08;\n",
      "F10 = Cv*Fb;\n",
      "F10 = round(F10);\n",
      "print \"shear at 10m from top = %.2f KN.\"%(F10);\n",
      "\n",
      "\t\t\t\t#(d) Moment at 10m from top\n",
      "Cm = 0.02;\n",
      "M10 = Cm*Mb;\n",
      "M10 = round(M10);\n",
      "print \"moment at 10m from top = %.2f KN.\"%(M10);\n",
      "\t\t\t\t#(e) Hydrodynamic pressure\n",
      "\t\t\t\t#at 10m from top\n",
      "y = 8;\n",
      "W10 = 1680;\n",
      "Cm = 0.735;\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "p = Cy*alphah*gammaw*hw;\n",
      "P10 = 0.726*p*y;\n",
      "Mp10 = 0.299*p*y**2;\n",
      "P10 = round(P10*100)/100;\n",
      "Mp10 = round(Mp10*100)/100;\n",
      "\t\t\t\t#at 100m from top\n",
      "y = 98;\n",
      "W100 = 84840;\n",
      "Cm = 0.735;\n",
      "Cy = (Cm/2)*(y*(2-y/hw)/hw+(y*(2-y/hw)/hw)**0.5);\n",
      "p = Cy*alphah*gammaw*hw;\n",
      "P100 = 0.726*p*y;\n",
      "Mp100 = 0.299*p*y**2;\n",
      "print \"Hydrodynamic forces:At 10m from top: F = %.2f kn;\\\n",
      "\\nM = %.2fkn-mAt 100m from top: F = %i \\\n",
      "kn;M = %ikn-m.\"%(P10,Mp10,P100,Mp100);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Base shear = 4835.88 KN.\n",
        "Base moment = 246342.60 KN-m.\n",
        "shear at 10m from top = 387.00 KN.\n",
        "moment at 10m from top = 4927.00 KN.\n",
        "Hydrodynamic forces:At 10m from top: F = 0.00 kn;\n",
        "M = 0.00kn-mAt 100m from top: F = 4776 kn;M = 192765kn-m.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.3 pg : 379"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "\n",
      "\t\t\t\t\n",
      "#Given\n",
      "H = 100;              \t\t\t\t#heigth of dam\n",
      "wb = 70;              \t\t\t\t#width of base of dam\n",
      "wt = 7;               \t\t\t\t#width of top of dam\n",
      "l = 1;                \t\t\t\t#length of dam\n",
      "hw = 98;              \t\t\t\t#heigth of water in dam\n",
      "hsu = 90;             \t\t\t\t#heigth of slope on downstream side\n",
      "s = 1/0.7;            \t\t\t\t#slope on downstream side\n",
      "gammad = 24;          \t\t\t\t#unit weigth of dam\n",
      "gammaw = 9.81;        \t\t\t\t#unit weigth of water\n",
      "E = 2.05e7;           \t\t\t\t#modulus of elasticity\n",
      "\t\t\t\t#(a) Seismic coefficient method\n",
      "alpha0 = 0.05;        \t\t\t\t#from table 8.1\n",
      "alphah = 2*alpha0;\n",
      "alphav = 0.75*alphah;\n",
      "\t\t\t\t#at 10m from top\n",
      "\n",
      "def f4(y): \n",
      "\t return alphav*168*(1-0.01*y)\n",
      "\n",
      "F10 =  quad(f4,0,10)[0]\n",
      "\n",
      "\t\t\t\t#at 100m below top\n",
      "\n",
      "def f5(y): \n",
      "\t return alphav*(1-0.01*y)*16.8*y\n",
      "\n",
      "F100 = F10+ quad(f5,10,100)[0]\n",
      "\n",
      "print \"Parta):At 10m from top: F = %.2f knAt 100m from top: F = %.2f kn.\"%(F10,F100);\n",
      "\n",
      "\t\t\t\t#(b)Response spectrum method\n",
      "beta = 1;\n",
      "I = 2;\n",
      "Fo = 0.25;           \t\t\t\t#from table 8.2\n",
      "                  \t\t\t\t#t = Sa/g;\n",
      "t = 0.19;           \t\t\t\t#from fig. 8.4\n",
      "alphah = beta*I*Fo*t;\n",
      "alphav = 0.75*alphah;\n",
      "\t\t\t\t#at 10m from top\n",
      "\n",
      "def f6(y): \n",
      "\t return alphav*168*(1-0.01*y)\n",
      "\n",
      "F10 =  quad(f6,0,10)[0]\n",
      "\n",
      "\t\t\t\t#at 100m below top\n",
      "\n",
      "def f7(y): \n",
      "\t return alphav*(1-0.01*y)*16.8*y\n",
      "\n",
      "F100 = F10+ quad(f7,10,100)[0]\n",
      "\n",
      "F100 = round(F100*100)/100;\n",
      "print \"Partb):At 10m from top: F = %.2f knAt 100m from top: F = %.2f kn.\"%(F10,F100);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Parta):At 10m from top: F = 119.70 knAt 100m from top: F = 2160.90 kn.\n",
        "Partb):At 10m from top: F = 113.72 knAt 100m from top: F = 2052.86 kn.\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.4 pg : 381\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "#Given\n",
      "H = 100.;              \t\t\t\t#heigth of dam\n",
      "wb = 73.;              \t\t\t\t#width of base of dam\n",
      "wt = 7;               \t\t\t\t#width of top of dam\n",
      "l = 1.;                \t\t\t\t#length of dam\n",
      "hw = 98.;              \t\t\t\t#heigth of water in dam\n",
      "hsu = 90.;             \t\t\t\t#heigth of slope on downstream side\n",
      "s = 1/0.7;            \t\t\t\t#slope on downstream side\n",
      "gammad = 24.;          \t\t\t\t#unit weigth of dam\n",
      "gammaw = 9.81;        \t\t\t\t#unit weigth of water\n",
      "E = 2.05e7;           \t\t\t\t#modulus of elasticity\n",
      "\n",
      "#at 10m from top\n",
      "y = 8;\n",
      "alphah = 0.1;\n",
      "Cm = 0.72;\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "p10 = Cy*alphah*gammaw*hw;\n",
      "F10 = 0.726*p10*y;\n",
      "Mp10 = 0.299*p10*y**2;\n",
      "\n",
      "#at 40m from top\n",
      "y = 38;\n",
      "alphah = 0.1;\n",
      "Cm = 0.72;\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "p40 = Cy*alphah*gammaw*hw;\n",
      "F40 = 0.726*p40*y;\n",
      "Mp40 = 0.299*p40*y**2;\n",
      "\n",
      "#at 100m from top\n",
      "y = 98;\n",
      "alphah = 0.1;\n",
      "Cm = 0.72;\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "p100 = Cy*alphah*gammaw*hw;\n",
      "F100 = 0.726*p100*y;\n",
      "Mp100 = 0.299*p100*y**2;\n",
      "p10 = round(p10*1000)/1000;\n",
      "F10 = round(F10*1000)/1000;\n",
      "Mp10 = round(Mp10*10)/10;\n",
      "p40 = round(p40*1000)/1000;\n",
      "F40 = round(F40*1000)/1000;\n",
      "Mp40 = round(Mp40*10)/10;\n",
      "p100 = round(p100*100)/100;\n",
      "F100 = round(F100*1000)/1000;\n",
      "Mp100 = round(Mp100*10)/10;\n",
      "print \"Hydrodynamic Forces:At 10m from top: P = %.2f KN/square m;\\\n",
      "\\nF = %.2f KN;\\\n",
      "\\nM = %.2f KN-m.At 40m from top: P = %.2f KN/square m.;\\\n",
      "\\nF = %.2f KN;\\\n",
      "\\nM = %.2f KN-m.At 100m from top: P = %.2f KN/square m;\\\n",
      "\\nF = %.2f KN;\\\n",
      "\\nM = %.2f KN-m.\"%(p10,F10,Mp10,p40,F40,Mp40,p100,F100,Mp100);\n",
      "\n",
      "#vertical component of reservior water on horizontal section\n",
      "s1 = 3./60;\n",
      "Wh = (F100-F40)*s1;\n",
      "Wh = round(Wh*100)/100;\n",
      "print \"vertical component of reservior water on horizontal section = %.2f kN/m.\"%(Wh);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hydrodynamic Forces:At 10m from top: P = 19.12 KN/square m;\n",
        "F = 111.03 KN;\n",
        "M = 365.80 KN-m.At 40m from top: P = 49.00 KN/square m.;\n",
        "F = 1351.85 KN;\n",
        "M = 21156.60 KN-m.At 100m from top: P = 69.22 KN/square m;\n",
        "F = 4924.82 KN;\n",
        "M = 198770.00 KN-m.\n",
        "vertical component of reservior water on horizontal section = 178.65 kN/m.\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8 pg : 413"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "#no tension is permissible\n",
      "#factor of safety against slidingis 1.5\n",
      "\n",
      "#Given\n",
      "\n",
      "wb = 3;          \t\t\t\t#width of dam;\n",
      "miu = 0.5;       \t\t\t\t#coefficient of friction\n",
      "Sg = 2.4;        \t\t\t\t#specific gravity of masonary\n",
      "gamma_w = 9.81;  \t\t\t\t#unit weigth of water\n",
      "c = 1;\n",
      "\n",
      "#when uplift is considered\n",
      "#when no tension is permissible then e = wb/6;\n",
      "\n",
      "p1 = wb*Sg*gamma_w;\n",
      "p2 = c*wb*gamma_w/2;\n",
      "p3 = p1-p2;\n",
      "p4 = p1*wb/2-p2*2;\n",
      "p5 = gamma_w/6;\n",
      "d1 = p4/p3; d2 = p5/p3;\n",
      "d3 = 1.5-d1;\n",
      "H = ((0.5-d3)/d2)**0.5;\n",
      "H = round(H*100)/100;\n",
      "print \"when uplift is considered:\"\n",
      "print \"Heigth of dam when no tension is permissible = %.2f m.\"%(H);\n",
      "H = p3*0.5/(1.5*p5*3);\n",
      "print \"Heigth of dam when factor of safety against sliding is 1.5 = %.2f m.\"%(H);\n",
      "\n",
      "#when uplift is not considered\n",
      "p1 = wb*Sg*gamma_w;\n",
      "p4 = p1*wb/2;\n",
      "p5 = gamma_w/6;\n",
      "d1 = p4/p1;\n",
      "d2 = p5/p1;\n",
      "H = (0.5/d2)**0.5;\n",
      "H = round(H*100)/100;\n",
      "print \"when uplift is not considered:\"\n",
      "print \"Heigth of dam when no tension is permissible = %.2f m.\"%(H);\n",
      "H = p1*0.5/(1.5*p5*3);\n",
      "print \"Heigth of dam when factor of safety against sliding is 1.5 = %.2f m.\"%(H);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "when uplift is considered:\n",
        "Heigth of dam when no tension is permissible = 3.55 m.\n",
        "Heigth of dam when factor of safety against sliding is 1.5 = 3.80 m.\n",
        "when uplift is not considered:\n",
        "Heigth of dam when no tension is permissible = 4.65 m.\n",
        "Heigth of dam when factor of safety against sliding is 1.5 = 4.80 m.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.9 pg : 414"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#Given\n",
      "c = 1;\n",
      "hw = 6;           \t\t\t\t#heigth of water in reservior\n",
      "Bt = 1.5;            \t\t\t\t#width of top of dam\n",
      "H = 6;           \t\t\t\t#heigth of the dam\n",
      "wb = 4.5;           \t\t\t\t#width of base of dam\n",
      "Sg = 2.4;           \t\t\t\t#specific gravity of masonary\n",
      "gamma_w = 9.81;    \t\t\t\t#weigth density of water\n",
      "\n",
      "W1 = Bt*gamma_w*Sg*H;\n",
      "W2 = gamma_w*Sg*H*(wb-Bt)/2;\n",
      "L1 = (wb-Bt)+(Bt/2);\n",
      "L2 = (2*(wb-Bt))/3\n",
      "M1 = W1*L1\n",
      "M2 = W2*L2\n",
      "\n",
      "#Reaervior empty\n",
      "SumW = W1+W2;\n",
      "SumM = M1+M2;\n",
      "x = SumM/SumW;\n",
      "e = wb/2-x;\n",
      "pnt = (SumW/wb)*(1+(6*e/wb));\n",
      "pnh = (SumW/wb)*(1-(6*e/wb));\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "print \"Reservior empty:\";\n",
      "print \" Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "\n",
      "#Reservior full\n",
      "W3 = gamma_w*H**2/2;\n",
      "U = gamma_w*H*c*wb/2;\n",
      "SumV = SumW-U;\n",
      "L3 = hw/3;\n",
      "L4 = 2*wb/3;             \t\t\t\t#lever arm\n",
      "M3 = W3*L3;\n",
      "M4 = U*L4;               \t\t\t\t#moment about toe\n",
      "SumM1 = SumM-M4-M3;\n",
      "x = SumM1/SumV;\n",
      "e = wb/2-x;\n",
      "pnt = (SumV/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV/wb)*(1-(6*e/wb));\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "print \"Reservior full:\";\n",
      "print \" Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reservior empty:\n",
        " Normal stress at toe = 15.70 kN/square.m.\n",
        "Normal stress at heel = 172.70 kN/square.m.\n",
        "Reservior full:\n",
        " Normal stress at toe = 120.30 kN/square.m.\n",
        "Normal stress at heel = 9.20 kN/square.m.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10 pg : 415"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import roots\n",
      "\n",
      "\n",
      "#check the stability\n",
      "\n",
      "#Given\n",
      "c = 1;\n",
      "hw = 6;              \t\t\t\t#heigth of water in reservior\n",
      "Bt = 1.5;            \t\t\t\t#width of top of dam\n",
      "H = 6;              \t\t\t\t#heigth of the dam\n",
      "gamma_m = 20;       \t\t\t\t#unit weigth of masonary \n",
      "gamma_w = 9.81;    \t\t\t\t#weigth density of water\n",
      "f = 1800;          \t\t\t\t#compressive strength\n",
      "miu = 0.6;         \t\t\t\t#coefficient of friction\n",
      "\n",
      "#to develop no tension e = b/6;x = b/3.\n",
      "#hence on solving the relations we get\n",
      "\n",
      "P = [1,2.944,-39.074]\n",
      "wb = roots(P)[1];                          \t\t\t\t#sign of coefficient is 2.944 is not taken correctly in book\n",
      "#roots are 4.94 and -7.89\n",
      "#math.since negative value cannot be taken\n",
      "print \"Neglecting the negative value.Width of base is = 4.94 m.\";\n",
      "W1 = Bt*gamma_m*H;\n",
      "W2 = gamma_m*H*(wb-Bt)/2;\n",
      "L1 = (wb-Bt)+(Bt/2);\n",
      "L2 = (2*(wb-Bt))/3;\n",
      "M1 = W1*L1,\n",
      "M2 = W2*L2;\n",
      "U = gamma_w*H*c*wb/2;\n",
      "L4 = 2*wb/3;\n",
      "M4 = U*L4;\n",
      "W3 = gamma_w*H**2/2;\n",
      "L3 = hw/3;\n",
      "M3 = W3*L3;\n",
      "SumW = W1+W2-U;\n",
      "SumM = M1+M2-M4-M3;\n",
      "pn = 2*SumW/wb;\n",
      "pn = round(pn*10)/10;\n",
      "print \"Maximum stress = %.2f kN/square.m.\"%(pn);\n",
      "print \"Dam is safe against compression\";\n",
      "FOS = miu*SumW/W3;\n",
      "FOS = round(FOS*100)/100;\n",
      "print \"Factor of safety against sliding = %.2f. <1\"%(FOS);\n",
      "print \"Dam is unsafe against sliding.\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neglecting the negative value.Width of base is = 4.94 m.\n",
        "Maximum stress = 97.50 kN/square.m.\n",
        "Dam is safe against compression\n",
        "Factor of safety against sliding = 0.82. <1\n",
        "Dam is unsafe against sliding.\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.11 pg : 416"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import roots\n",
      "\t\t\t\t#check the stability if uplift is neglected\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1;\n",
      "hw = 6;              \t\t\t\t#heigth of water in reservior\n",
      "Bt = 1.5;            \t\t\t\t#width of top of dam\n",
      "H = 6;              \t\t\t\t#heigth of the dam\n",
      "gamma_m = 20;       \t\t\t\t#unit weigth of masonary \n",
      "gamma_w = 9.81;    \t\t\t\t#weigth density of water\n",
      "f = 1800;          \t\t\t\t#compressive strength\n",
      "miu = 0.6;         \t\t\t\t#coefficient of friction\n",
      "\n",
      "\t\t\t\t#to develop no tension e = b/6;x = b/3.\n",
      "\t\t\t\t#hence on solving the relations we get\n",
      "\n",
      "P = [1,1.5,-19.908]\n",
      "wb = roots(P)[1];\n",
      "\n",
      "#roots are 3.774 and -5.27\n",
      "#math.since negative value cannot be taken\n",
      "\n",
      "print \"Neglecting the negative value.Width of base is = %.2f m.\"%wb;\n",
      "\n",
      "W1 = Bt*gamma_m*H;\n",
      "W2 = gamma_m*H*(wb-Bt)/2;\n",
      "L1 = (wb-Bt)+(Bt/2);\n",
      "L2 = (2*(wb-Bt))/3;\n",
      "M1 = W1*L1,\n",
      "M2 = W2*L2;\n",
      "W3 = gamma_w*H**2/2;\n",
      "L3 = hw/3;\n",
      "M3 = W3*L3;\n",
      "SumW = W1+W2;\n",
      "SumM = M1+M2-M3;\n",
      "pn = 2*SumW/wb;\n",
      "pn = round(pn*10)/10;\n",
      "print \"Maximum stress = %.2f kN/square.m.\"%(pn);\n",
      "print \"Dam is safe against compression\";\n",
      "\n",
      "FOS = miu*SumW/W3;\n",
      "FOS = round(FOS*1000)/1000;\n",
      "print \"Factor of safety against sliding = %.2f. > 1\"%(FOS);\n",
      "print \"Dam is safe against sliding.\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Neglecting the negative value.Width of base is = 3.77 m.\n",
        "Maximum stress = 167.70 kN/square.m.\n",
        "Dam is safe against compression\n",
        "Factor of safety against sliding = 1.07. > 1\n",
        "Dam is safe against sliding.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.12 pg : 417"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# calculate maximum permissible heigth of shutter so that no tension develops\n",
      "\t\t\t\t\n",
      "#Given\n",
      "Bt = 3;            \t\t\t\t#width of top of dam\n",
      "H = 12;           \t\t\t\t#heigth of the dam\n",
      "wb = 9;           \t\t\t\t#width of base of dam\n",
      "gamma_m = 21;           \t\t\t\t#unit weigth of masonary\n",
      "gamma_w = 9.81;    \t\t\t\t#weigth density of water\n",
      "\n",
      "W1 = Bt*gamma_m*H;\n",
      "W2 = gamma_m*H*(wb-Bt)/2;\n",
      "\n",
      "#taking moment about a point on base at 3m from toe\n",
      "L1 = 3+Bt/2;\n",
      "L2 = (2*(wb-Bt)/3)-3;\n",
      "M1 = W1*L1\n",
      "M2 = W2*L2;\n",
      "M = M1+M2;\n",
      "\n",
      "#net moment about this point should be zero for equilibrium\n",
      "s = (M*6/gamma_w)**(1./3)-12;\n",
      "s = round(s*100)/100;\n",
      "\n",
      "# Results\n",
      "print \"maximum permissible heigth of shutter = %.2f m.\"%(s);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "maximum permissible heigth of shutter = 1.22 m.\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.13 pg : 417"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "\t\t\t\t#moment at 50m below water surface\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1;\n",
      "H = 100;           \t\t\t\t#heigth of dam\n",
      "hw = 100;          \t\t\t\t#heigth of water in reservior\n",
      "FB = 1;            \t\t\t\t#free board\n",
      "s = 0.15;          \t\t\t\t#slope of upstream face\n",
      "gamma_w = 9.81;    \t\t\t\t#unit weigth of water\n",
      "alphah = 0.1;\n",
      "\n",
      "theta = math.atan(s);\n",
      "y = 50;\n",
      "Cm = 0.735*(1-(theta*2/math.pi));\n",
      "Cy = (Cm/2)*((y*(2-y/hw)/hw)+(y*(2-y/hw)/hw)**0.5);\n",
      "pe = Cy*alphah*gamma_w*hw;\n",
      "F = 0.726*pe*y;\n",
      "M = 0.299*pe*y**2;\n",
      "pe = round(pe*1000)/1000;\n",
      "F = round(F*10)/10;\n",
      "M = round(M*10)/10;\n",
      "print \"hydrodynamic earthquake pressure = %.2f kN/square.mshear = %.2f kN/m.Moment = %.2f kN-m/m.\"%(pe,F,M);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hydrodynamic earthquake pressure = 65.27 kN/square.mshear = 2369.30 kN/m.Moment = 48788.60 kN-m/m.\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.14 pg : 418"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from sympy import sec\n",
      "\n",
      "#check stability\n",
      "\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1.;\n",
      "H = 10.;             \t\t\t\t#heigth of dam\n",
      "hw = 10.;            \t\t\t\t#heigth of water in reservior\n",
      "wb = 8.25;          \t\t\t\t#bottom width\n",
      "Bt = 1.;             \t\t\t\t#top width\n",
      "Hs1 = 0.1;          \t\t\t\t#slope on upstream side\n",
      "gamma_w = 9.81;     \t\t\t\t#unit weigth of water\n",
      "gamma_m = 22.4;     \t\t\t\t#unit weigth of masonary\n",
      "f = 1400.;           \t\t\t\t#permissible shear stress at joint\n",
      "miu = 0.75;         \t\t\t\t#coefficient of friction\n",
      "fi = math.atan(0.625);\n",
      "theta = math.atan(0.1);\n",
      "\n",
      "W1 = Bt*H*gamma_m;\n",
      "W2 = H*H*Hs1*gamma_m/2;\n",
      "W3 = H*6.25*gamma_m/2;\n",
      "W4 = hw*gamma_w*H*Hs1/2;\n",
      "P = gamma_w*hw**2/2;\n",
      "U = wb*gamma_w*hw*c/2;\n",
      "SumV = W1+W2+W3+W4-U;\n",
      "L3 = 2*(wb-(Hs1*H)-Bt)/3;\n",
      "L1 = (wb-(Hs1*H)-Bt)+Bt/2;\n",
      "L2 = (wb-(Hs1*H)-Bt)+Bt+(Hs1*H/3);\n",
      "L4 = (wb-(Hs1*H)-Bt)+Bt+(2*Hs1*H/3);\n",
      "L5 = 2*wb/3;L6 = hw/3;\n",
      "M1 = W1*L1;\n",
      "M2 = W2*L2;\n",
      "M3 = W3*L3;\n",
      "M4 = W4*L4;\n",
      "M5 = U*L5;\n",
      "M6 = P*L6;\n",
      "SumM = M1+M2+M3+M4-M5-M6;\n",
      "Mplus = M1+M2+M3+M4;\n",
      "Mminus = M5+M6;\n",
      "FOS = miu*SumV/P;\n",
      "SFF = (miu*SumV+wb*1400)/P;\n",
      "FOO = Mplus/Mminus;\n",
      "FOS = round(FOS*100)/100;\n",
      "SFF = round(SFF*10)/10;\n",
      "FOO = round(FOO*100)/100;\n",
      "print \"Factor of safety against sliding = %.2f. >1 \"%(FOS);\n",
      "print \"Shear friction factor = %.2f.\"%(SFF);\n",
      "print \"Factor of safety against overturning = %.2f. <1.5\"%(FOO);\n",
      "print \"Dam is unsafe against overturning\";\n",
      "\n",
      "x = SumM/SumV;\n",
      "e = wb/2-x;\n",
      "p = hw*gamma_w;\n",
      "pnt = (SumV/wb)*(1+(6*e/wb));      \t\t\t\t#calculation is done wrong in book;value of b is not taken correctly\n",
      "pnh = (SumV/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "sigmah = pnh*sec(theta)**2-p*math.tan(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = -(pnh-p)*math.tan(theta);\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "sigmat = round(sigmat*10)/10;\n",
      "sigmah = round(sigmah*10)/10;\n",
      "taut = round(taut*10)/10;\n",
      "tauh = round(tauh*10)/10;\n",
      "print \"Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %.2f kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %.2f kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %.2f kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %.2f kN/square.m.\"%(tauh);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Factor of safety against sliding = 1.04. >1 \n",
        "Shear friction factor = 24.60.\n",
        "Factor of safety against overturning = 1.47. <1.5\n",
        "Dam is unsafe against overturning\n",
        "Normal stress at toe = 170.70 kN/square.m.\n",
        "Normal stress at heel = -5.80 kN/square.m.\n",
        "Principal stress at toe = 237.40 kN/square.m.\n",
        "Principal stress at heel = -6.80 kN/square.m.\n",
        "Shear stress at toe = 106.70 kN/square.m.\n",
        "Shear stress at heel = 10.40 kN/square.m.\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.15 pg : 420"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t#Check the stability and determine sliding factor and shear factor\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1;\n",
      "miu = 0.75;          \t\t\t\t#coefficient of friction\n",
      "H = 90;              \t\t\t\t#heigth of dam\n",
      "wb = 73.1;           \t\t\t\t#width of base\n",
      "Bt = 7;              \t\t\t\t#width of top of dam\n",
      "hw = 89;             \t\t\t\t#heigth of water in reservior\n",
      "Hs1 = 28;            \t\t\t\t#heigth of slope on upstream side\n",
      "Hs2 = 83;            \t\t\t\t#heigth of slope on downstream side\n",
      "Cm = 0.735;\n",
      "alphah = 0.1;\n",
      "gamma_m = 23.5;        \t\t\t\t#unit weigth of concrete\n",
      "gamma_w = 9.81;        \t\t\t\t#unit weigth of water\n",
      "theta = math.atan(8./28);\n",
      "fi = math.atan(0.7);\n",
      "\t\t\t\t#self weigth of dam\n",
      "W1 = (Hs1*8*gamma_m)/2\n",
      "W2 = (Bt*H*gamma_m)\n",
      "W3 = (Hs2**2*0.7*gamma_m)/2\n",
      "\t\t\t\t#weigth of superimposed water\n",
      "W4 = (Hs1*8*gamma_w)/2\n",
      "W5 = (hw-Hs1)*8*gamma_w\n",
      "U = hw*wb*2*gamma_w/6;                  \t\t\t\t#uplift force\n",
      "wp = hw**2*gamma_w/2;                   \t\t\t\t#water pressure\n",
      "hp = 0.726*Cm*alphah*gamma_w*hw**2;     \t\t\t\t#hydrodynamic pressure\n",
      "Mhp = 0.299*Cm*alphah*gamma_w*hw**3;    \t\t\t\t#moment due to hydrodynamic pressure\n",
      "\t\t\t\t#inertial load due to horizontal acceleration\n",
      "I1 = W2/10;\n",
      "I2 = W3/10;\n",
      "I3 = W1/10;\n",
      "SumV = W1+W2+W3+W4+W5-U;\n",
      "SumH = wp+hp+I1+I2+I3;\n",
      "L1 = (wb-8)+8/3\n",
      "L2 = (0.7*Hs2)+(Bt/2)\n",
      "L3 = (2*Hs2*0.7)/3.\n",
      "L4 = (wb-8)+(2*8)/3.\n",
      "L5 = (wb-8)+(8./2)\n",
      "L6 = hw/3;\n",
      "L7 = 2*wb/3;\n",
      "M1 = W1*L1\n",
      "M2 = W2*L2\n",
      "M3 = W3*L3\n",
      "M4 = W4*L4;\n",
      "M5 = W5*L5;\n",
      "M6 = wp*L6;\n",
      "M7 = U*L7;\n",
      "M8 = I1*45;\n",
      "M9 = I2*83/3;\n",
      "M10 = I3*28/3;\n",
      "Mplus = M1+M2+M3+M4+M5;\n",
      "Mminus = M6+M7+M8+M9+M10+Mhp;\n",
      "SumM = Mplus-Mminus;\n",
      "x = SumM/SumV;\n",
      "e = wb/2-x;\n",
      "pnt = (SumV/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "p = hw*gamma_w;\n",
      "pe = Cm*alphah*gamma_w*hw;\n",
      "sigmah = pnh*sec(theta)**2-(p+pe)*math.tan(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = -(-pnh-(p+pe))*math.tan(theta);\n",
      "print \"Normal stress at toe = %i kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %i kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %i kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %i kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %i kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %i kN/square.m.\"%(tauh);\n",
      "\n",
      "FOS = miu*SumV/SumH;\n",
      "SFF = (miu*SumV+wb*1400)/SumH;\n",
      "FOO = Mplus/Mminus;\n",
      "Ffi = 1.2;Fc = 2.4;\n",
      "F = (miu*SumV/Ffi+1400*wb/Fc)/SumH;\n",
      "FOS = round(FOS*100)/100;\n",
      "F = round(F*100)/100;\n",
      "SFF = round(SFF*100)/100;\n",
      "FOO = round(FOO*100)/100;\n",
      "print \"Factor of safety against sliding as per IS:6512-1972 = %.2f. <1.5\"%(FOS);\n",
      "print \"Factor of safety against sliding as per IS:6512-1984 = %.2f. >1\"%(F);\n",
      "print \"Shear friction factor = %.2f. <6\"%(SFF);\n",
      "print \"Factor of safety against overturning = %.2f. <1.5\"%(FOO);\n",
      "print \"Dam is unsafe for given loading conditions\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Normal stress at toe = 1929 kN/square.m.\n",
        "Normal stress at heel = -323 kN/square.m.\n",
        "Principal stress at toe = 2874 kN/square.m.\n",
        "Principal stress at heel = -426 kN/square.m.\n",
        "Shear stress at toe = 1350 kN/square.m.\n",
        "Shear stress at heel = 175 kN/square.m.\n",
        "Factor of safety against sliding as per IS:6512-1972 = 0.87. <1.5\n",
        "Factor of safety against sliding as per IS:6512-1984 = 1.57. >1\n",
        "Shear friction factor = 2.90. <6\n",
        "Factor of safety against overturning = 1.45. <1.5\n",
        "Dam is unsafe for given loading conditions\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.16 pg : 423"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t#Check the stability and determine principal and shear stress at toe and heel\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1;\n",
      "miu = 0.7;          \t\t\t\t#coefficient of friction\n",
      "H = 70;              \t\t\t\t#heigth of dam\n",
      "ht = 0;              \t\t\t\t#heigth of tail water\n",
      "Lf = 6.5;           \t\t\t\t#location of foundation gallery from heel\n",
      "wb = 52.5;           \t\t\t\t#width of base\n",
      "Bt = 7;              \t\t\t\t#width of top of dam\n",
      "hw = 70;             \t\t\t\t#heigth of water in reservior\n",
      "Hs1 = 35;            \t\t\t\t#heigth of slope on upstream side\n",
      "Hs2 = 60;            \t\t\t\t#heigth of slope on downstream side\n",
      "gamma_m = 24;        \t\t\t\t#unit weigth of concrete\n",
      "gamma_w = 9.81;        \t\t\t\t#unit weigth of water\n",
      "theta = math.atan(0.1);\n",
      "fi = math.atan(0.7);\n",
      "\t\t\t\t#self weigth of dam\n",
      "W1 = (Hs1*3.5*gamma_m)/2\n",
      "W2 = (Bt*H*gamma_m)\n",
      "W3 = (Hs2**2*0.7*gamma_m)/2\n",
      "\t\t\t\t#weigth of superimposed water\n",
      "W4 = (Hs1*3.5*gamma_w)/2\n",
      "W5 = (hw-Hs1)*3.5*gamma_w\n",
      "wp = hw**2*gamma_w/2;                   \t\t\t\t#water pressure\n",
      "Pt = gamma_w*ht\n",
      "Ph = gamma_w*hw\n",
      "Pg = (ht+(hw-ht)/3)*gamma_w\n",
      "U = (Pt*(wb-Lf))+(Pg*Lf)+((Ph-Pg)*Lf/2)+((Pg-Pt)*(wb-Lf)/2)*c\n",
      "l1 = (wb-Lf)/2\n",
      "l2 = (2*(wb-Lf))/3\n",
      "l3 = (wb-Lf)+(Lf/2)\n",
      "l4 = (wb-Lf)+((2*Lf)/3)\n",
      "L7 = (((Pt*(wb-Lf))*l1)+((Pg-Pt)*(wb-Lf)*l2/2)+((Pg*Lf)*l3)+((Ph-Pg)*Lf*l4/2))/U\n",
      "L1 = (wb-3.5)+3.5/3\n",
      "L2 = (0.7*Hs2)+(Bt/2)\n",
      "L3 = (2*Hs2*0.7)/3\n",
      "L4 = (wb-3.5)+(2*3.5)/3\n",
      "L5 = (wb-3.5)+(3.5/2)\n",
      "L6 = hw/3;\n",
      "M1 = W1*L1\n",
      "M2 = W2*L2\n",
      "M3 = W3*L3\n",
      "M4 = W4*L4;\n",
      "M5 = W5*L5;\n",
      "M6 = wp*L6;\n",
      "M7 = U*L7;\n",
      "SumV1 = W1+W2+W3;\n",
      "SumM1 = M1+M2+M3;\n",
      "SumV2 = SumV1+W4+W5;\n",
      "SumM2 = SumM1+M4+M5-M6;\n",
      "SumV3 = SumV2-U;\n",
      "SumM3 = SumM2-M7;\n",
      "Mplus = 1547377;\n",
      "Mminus = 870421;\n",
      "SumH = wp;\n",
      "\n",
      "\t\t\t\t#case 1. Reservior empty\n",
      "x = SumM1/SumV1;\n",
      "e = wb/2-x;\n",
      "pnt = (SumV1/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV1/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "sigmah = pnh*sec(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = pnh*math.tan(theta);\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "sigmat = round(sigmat*10)/10;\n",
      "sigmah = round(sigmah*10)/10;\n",
      "taut = round(taut*10)/10;\n",
      "tauh = round(tauh*10)/10;\n",
      "print \"case 1. Reservior empty:\";\n",
      "print \"Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %.2f kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %.2f kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %.2f kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %.2f kN/square.m.\"%(tauh);\n",
      "\n",
      "\t\t\t\t#case2. reservior full without uplift\n",
      "x = SumM2/SumV2;\n",
      "e = wb/2-x;\n",
      "p = hw*gamma_w;\n",
      "pnt = (SumV2/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV2/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "sigmah = pnh*sec(theta)**2-p*math.tan(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = -(pnh-p)*math.tan(theta);\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "sigmat = round(sigmat*10)/10;\n",
      "sigmah = round(sigmah*10)/10;\n",
      "taut = round(taut*10)/10;\n",
      "tauh = round(tauh*10)/10;\n",
      "print \"case 2. reservior full without uplift:\";\n",
      "print \"Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %.2f kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %.2f kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %.2f kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %.2f kN/square.m.\"%(tauh);\n",
      "\n",
      "\t\t\t\t#case3. reservior full with uplift\n",
      "x = SumM3/SumV3;\n",
      "e = wb/2-x;\n",
      "p = hw*gamma_w;\n",
      "pnt = (SumV3/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV3/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "sigmah = pnh*sec(theta)**2-p*math.tan(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = -(pnh-p)*math.tan(theta);\n",
      "pnt = round(pnt);\n",
      "pnh = round(pnh);\n",
      "sigmat = round(sigmat);\n",
      "sigmah = round(sigmah);\n",
      "taut = round(taut);\n",
      "tauh = round(tauh);\n",
      "print \"case 3. reservior full with uplift:\";\n",
      "print \"Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %.2f kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %.2f kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %.2f kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %.2f kN/square.m.\"%(tauh);\n",
      "\n",
      "FOS = miu*SumV3/SumH;\n",
      "SFF = (miu*SumV3+wb*1400)/SumH;\n",
      "FOO = Mplus/Mminus;\n",
      "Ffi = 1.5;Fc = 3.6;\n",
      "F = (miu*SumV3/Ffi+1400*wb/Fc)/SumH;\n",
      "FOS = round(FOS*1000)/1000;\n",
      "SFF = round(SFF*100)/100;\n",
      "FOO = round(FOO*100)/100;\n",
      "F = round(F*1000)/1000;\n",
      "print \"Factor of safety against sliding = %.2f.\"%(FOS);\n",
      "print \"Shear friction factor = %.2f.\"%(SFF);\n",
      "print \"Factor of safety against overturning = %.2f.\"%(FOO);\n",
      "print \"Factor of safety for load combination B = %.2f. > 1\"%(F);\n",
      "print \"Dam is safe \";\n",
      "\n",
      "\t\t\t\t#Case4.considering seismic forces\n",
      "Cm = 0.712;\n",
      "alphah = 0.1;\n",
      "alphav = 0.08;\n",
      "hp = 0.726*Cm*alphah*gamma_w*hw**2;     \t\t\t\t#hydrodynamic pressure\n",
      "Mhp = 0.299*Cm*alphah*gamma_w*hw**3;    \t\t\t\t#moment due to hydrodynamic pressure\n",
      "\t\t\t\t#inertial load due to horizontal acceleration\n",
      "I1 = W2/10;\n",
      "I2 = W3/10;\n",
      "I3 = W1/10;\n",
      "v = SumV1*alphav;\n",
      "Mv = 116444;\n",
      "SumV4 = SumV3-v;\n",
      "SumH1 = SumH+I1+I2+I3+hp;\n",
      "M8 = I1*35;\n",
      "M9 = I2*20;\n",
      "M10 = I3*35/3;\n",
      "Mminus1 = 1161849;\n",
      "SumM4 = SumM3-M8-M9-M10-Mhp-Mv;\n",
      "\n",
      "x = SumM4/SumV4;\n",
      "e = wb/2-x;\n",
      "p = hw*gamma_w;\n",
      "pe = Cm*alphah*gamma_w*hw;\n",
      "pnt = (SumV4/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV4/wb)*(1-(6*e/wb));\n",
      "sigmat = pnt*sec(fi)**2;\n",
      "sigmah = pnh*sec(theta)**2-(p+pe)*math.tan(theta)**2;\n",
      "taut = pnt*math.tan(fi);\n",
      "tauh = (-pnh+(p+pe))*math.tan(theta);\n",
      "pnt = round(pnt);\n",
      "pnh = round(pnh);\n",
      "sigmat = round(sigmat);\n",
      "sigmah = round(sigmah);\n",
      "taut = round(taut);\n",
      "tauh = round(tauh);\n",
      "print \"case 4.considering seismic forces\";\n",
      "print \"Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n",
      "print \"Principal stress at toe = %.2f kN/square.m.\"%(sigmat);\n",
      "print \"Principal stress at heel = %.2f kN/square.m.\"%(sigmah);\n",
      "print \"Shear stress at toe = %.2f kN/square.m.\"%(taut);\n",
      "print \"Shear stress at heel = %.2f kN/square.m.\"%(tauh);   \t\t\t\t#answer is wrong in book\n",
      "\n",
      "FOS = miu*SumV4/SumH1;\n",
      "SFF = (miu*SumV4+wb*1400)/SumH1;\n",
      "FOO = Mplus/Mminus1;\n",
      "Ffi = 1.2;Fc = 2.7;\n",
      "F = (miu*SumV4/Ffi+1400*wb/Fc)/SumH1;\n",
      "FOS = round(FOS*1000)/1000;\n",
      "SFF = round(SFF*100)/100;\n",
      "FOO = round(FOO*100)/100;\n",
      "F = round(F*100)/100;\n",
      "print \"Factor of safety against sliding = %.2f.\"%(FOS);\n",
      "print \"Shear friction factor = %.2f.\"%(SFF);\n",
      "print \"Factor of safety against overturning = %.2f.\"%(FOO);\n",
      "print \"Factor of safety for load combination E = %.2f. > 1\"%(F);\n",
      "print \"Dam is safe \";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "case 1. Reservior empty:\n",
        "Normal stress at toe = 156.30 kN/square.m.\n",
        "Normal stress at heel = 1499.70 kN/square.m.\n",
        "Principal stress at toe = 232.80 kN/square.m.\n",
        "Principal stress at heel = 1514.70 kN/square.m.\n",
        "Shear stress at toe = 109.40 kN/square.m.\n",
        "Shear stress at heel = 150.00 kN/square.m.\n",
        "case 2. reservior full without uplift:\n",
        "Normal stress at toe = 1297.10 kN/square.m.\n",
        "Normal stress at heel = 427.60 kN/square.m.\n",
        "Principal stress at toe = 1932.60 kN/square.m.\n",
        "Principal stress at heel = 425.00 kN/square.m.\n",
        "Shear stress at toe = 907.90 kN/square.m.\n",
        "Shear stress at heel = 25.90 kN/square.m.\n",
        "case 3. reservior full with uplift:\n",
        "Normal stress at toe = 1344.00 kN/square.m.\n",
        "Normal stress at heel = 70.00 kN/square.m.\n",
        "Principal stress at toe = 2002.00 kN/square.m.\n",
        "Principal stress at heel = 64.00 kN/square.m.\n",
        "Shear stress at toe = 941.00 kN/square.m.\n",
        "Shear stress at heel = 62.00 kN/square.m.\n",
        "Factor of safety against sliding = 1.08.\n",
        "Shear friction factor = 4.14.\n",
        "Factor of safety against overturning = 1.00.\n",
        "Factor of safety for load combination B = 1.57. > 1\n",
        "Dam is safe \n",
        "case 4.considering seismic forces\n",
        "Normal stress at toe = 1713.00 kN/square.m.\n",
        "Normal stress at heel = -432.00 kN/square.m.\n",
        "Principal stress at toe = 2552.00 kN/square.m.\n",
        "Principal stress at heel = -443.00 kN/square.m.\n",
        "Shear stress at toe = 1199.00 kN/square.m.\n",
        "Shear stress at heel = 117.00 kN/square.m.\n",
        "Factor of safety against sliding = 0.76.\n",
        "Shear friction factor = 3.14.\n",
        "Factor of safety against overturning = 1.00.\n",
        "Factor of safety for load combination E = 1.52. > 1\n",
        "Dam is safe \n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.17 pg : 429"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#design practical profile of gravity dam\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1;\n",
      "rlb = 1450;          \t\t\t\t#R.L of base of dam\n",
      "rlw = 1480.5;        \t\t\t\t#R.L of water level\n",
      "Sg = 2.4;            \t\t\t\t#specific gravity of masonary\n",
      "gamma_w = 9.81;      \t\t\t\t#unit weigth of water\n",
      "w = 1;               \t\t\t\t#heigth of waves\n",
      "f = 1200;            \t\t\t\t#safe compressive stress for masonary\n",
      "FB = 1.5*w;\n",
      "rlt = FB+rlw;        \t\t\t\t#R.L of top of dam\n",
      "H = rlt-rlb;         \t\t\t\t#heigth of dam\n",
      "LH = f/(gamma_w*(Sg+1))\n",
      "LH = round(LH*100)/100;\n",
      "print \"Heigth of dam = %.2f m.\"%(H);\n",
      "print \"limiting heigth of dam = %.2f m.\"%(LH);\n",
      "print \"Dam is low gravity dam\";\n",
      "hw = rlw-rlb;\n",
      "\t\t\t\t#keep top width,a = 4.5.\n",
      "a = 4.5;\n",
      "P = hw/(Sg**0.5);\n",
      "P = round(P*10)/10;\n",
      "print \"Base width of elementary profile = %.2f m.\"%(P);\n",
      "uo = a/16;\n",
      "wb = uo+P;\n",
      "wb = round(wb);\n",
      "print \"Base width = %.2f m.\"%(wb);\n",
      "D = 2*a*(Sg**0.5);\n",
      "D = round(D);\n",
      "print \"Dismath.tance upto which u/s slope is vertical from water level = %.2f m.\"%(D);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heigth of dam = 32.00 m.\n",
        "limiting heigth of dam = 35.98 m.\n",
        "Dam is low gravity dam\n",
        "Base width of elementary profile = 19.70 m.\n",
        "Base width = 20.00 m.\n",
        "Dismath.tance upto which u/s slope is vertical from water level = 14.00 m.\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.18 pg : 430"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#determine if dam is safe against sliding\n",
      "\t\t\t\t\n",
      "#Given\n",
      "hw = 97.;           \t\t\t\t#heigth of water in reservior\n",
      "Bt = 7.;            \t\t\t\t#width of top of dam\n",
      "H = 100.;           \t\t\t\t#heigth of the dam\n",
      "Hs2 = 90.;          \t\t\t\t#heigth of slope on downstream side\n",
      "wb = 75.;           \t\t\t\t#width of base of dam\n",
      "miu = 0.75;        \t\t\t\t#coefficient of friction\n",
      "gamma_d = 2.4;     \t\t\t\t#weigth density of concrete\n",
      "gamma_w = 1000.;    \t\t\t\t#weigth density of water\n",
      "\n",
      "# Calculations\n",
      "P = gamma_w*hw**2/(2*1000);\n",
      "W1 = Bt*gamma_d*H;\n",
      "W2 = (wb-Bt)*Hs2*gamma_d/2;\n",
      "W = W1+W2;\n",
      "FOS = miu*W/P;\n",
      "FOS = round(FOS*1000)/1000;\n",
      "\n",
      "# Results\n",
      "print \"Factor of safety against sliding = %.2f.\"%(FOS);\n",
      "print \"Dam is safe against sliding\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Factor of safety against sliding = 1.44.\n",
        "Dam is safe against sliding\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.19 pg : 430"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#Factor of safety against overturning\n",
      "#Factor of safety against sliding\n",
      "#Shear friction factor\n",
      "\n",
      "#Given\n",
      "c = 1.;\n",
      "H = 10.;             \t\t\t\t#heigth of dam\n",
      "hw = 10.;            \t\t\t\t#heigth of water in reservior\n",
      "wb = 8.25;          \t\t\t\t#bottom width\n",
      "Bt = 1.;             \t\t\t\t#top width\n",
      "Hs1 = 0.1;          \t\t\t\t#slope on upstream side\n",
      "gamma_w = 9.81;     \t\t\t\t#unit weigth of water\n",
      "gamma_m = 22.4;     \t\t\t\t#unit weigth of masonary\n",
      "f = 1400.;           \t\t\t\t#permissible shear stress at joint\n",
      "miu = 0.75;         \t\t\t\t#coefficient of friction\n",
      "fi = math.atan(0.625);\n",
      "theta = math.atan(0.1);\n",
      "\n",
      "# Calculations\n",
      "W1 = Bt*H*gamma_m;\n",
      "W2 = H*H*Hs1*gamma_m/2;\n",
      "W3 = H*6.25*gamma_m/2;\n",
      "W4 = hw*gamma_w*H*Hs1/2;\n",
      "P = gamma_w*hw**2/2;\n",
      "U = wb*gamma_w*hw*c/2;\n",
      "SumV = W1+W2+W3+W4-U;\n",
      "L3 = 2*(wb-(Hs1*H)-Bt)/3;\n",
      "L1 = (wb-(Hs1*H)-Bt)+Bt/2;\n",
      "L2 = (wb-(Hs1*H)-Bt)+Bt+(Hs1*H/3);\n",
      "L4 = (wb-(Hs1*H)-Bt)+Bt+(2*Hs1*H/3);\n",
      "L5 = 2*wb/3;L6 = hw/3;\n",
      "M1 = W1*L1;M2 = W2*L2;M3 = W3*L3;M4 = W4*L4;\n",
      "M5 = U*L5;M6 = P*L6;\n",
      "SumM = M1+M2+M3+M4-M5-M6;\n",
      "Mplus = M1+M2+M3+M4;\n",
      "Mminus = M5+M6;\n",
      "FOS = miu*SumV/P;\n",
      "SFF = (miu*SumV+wb*1400)/P;\n",
      "FOO = Mplus/Mminus;\n",
      "FOS = round(FOS*100)/100;\n",
      "SFF = round(SFF*10)/10;\n",
      "FOO = round(FOO*100)/100;\n",
      "\n",
      "# Results\n",
      "print \"Factor of safety against sliding = %.2f.\"%(FOS);\n",
      "print \"Shear friction factor = %.2f.\"%(SFF);\n",
      "print \"Factor of safety against overturning = %.2f.\"%(FOO);\n",
      "print \"Dam is unsafe against overturning\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Factor of safety against sliding = 1.04.\n",
        "Shear friction factor = 24.60.\n",
        "Factor of safety against overturning = 1.47.\n",
        "Dam is unsafe against overturning\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.20 pg : 431"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Given\n",
      "c = 1.;\n",
      "hw = 80.;           \t\t\t\t#heigth of water in reservior\n",
      "Bt = 6.;            \t\t\t\t#width of top of dam\n",
      "H = 84.;           \t\t\t\t#heigth of the dam\n",
      "Hs2 = 75.;          \t\t\t\t#heigth of slope on downstream side\n",
      "wb = 56.;           \t\t\t\t#width of base of dam\n",
      "Lf = 8.;             \t\t\t\t#dismath.tance of foundation gallery from heel\n",
      "gamma_d = 23.5;     \t\t\t\t#weigth density of concrete\n",
      "gamma_w = 9.81;    \t\t\t\t#weigth density of water\n",
      "ht = 6.;            \t\t\t\t#heigth of tail water\n",
      "\n",
      "# Calculations\n",
      "W1 = Bt*gamma_d*H;\n",
      "W2 = gamma_d*Hs2*(wb-Bt)/2;\n",
      "W3 = gamma_w*ht*4/2;\n",
      "W4 = gamma_w*hw**2/2;\n",
      "W5 = gamma_w*ht**2/2;\n",
      "Pt = gamma_w*ht\n",
      "Ph = gamma_w*hw\n",
      "Pg = (ht+(hw-ht)/3)*gamma_w\n",
      "U = (Pt*(wb-Lf))+(Pg*Lf)+((Ph-Pg)*Lf/2)+((Pg-Pt)*(wb-Lf)/2)*c\n",
      "l1 = (wb-Lf)/2\n",
      "l2 = (2*(wb-Lf))/3\n",
      "l3 = (wb-Lf)+(Lf/2)\n",
      "l4 = (wb-Lf)+((2*Lf)/3)\n",
      "L6 = (((Pt*(wb-Lf))*l1)+((Pg-Pt)*(wb-Lf)*l2/2)+((Pg*Lf)*l3)+((Ph-Pg)*Lf*l4/2))/U\n",
      "L1 = (wb-Bt)+(Bt/2)\n",
      "L2 = (2*(wb-Bt))/3\n",
      "L3 = 4./3;\n",
      "L4 = hw/3;\n",
      "L5 = ht/3;\n",
      "M1 = W1*L1\n",
      "M2 = W2*L2\n",
      "M3 = W3*L3\n",
      "M4 = W4*L4\n",
      "M5 = W5*L5\n",
      "M6 = U*L6;\n",
      "SumV = W1+W2+W3-U;\n",
      "SumH = W4-W5;\n",
      "SumM = M1+M2+M3-M4+M5-M6;\n",
      "x = SumM/SumV;\n",
      "e = wb/2-x;\n",
      "pnt = (SumV/wb)*(1+(6*e/wb));\n",
      "pnh = (SumV/wb)*(1-(6*e/wb));\n",
      "pnt = round(pnt*10)/10;\n",
      "pnh = round(pnh*10)/10;\n",
      "\n",
      "# Results\n",
      "print \"Maximum Normal stress at toe = %.2f kN/square.m.\"%(pnt);\n",
      "print \"Maximum Normal stress at heel = %.2f kN/square.m.\"%(pnh);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum Normal stress at toe = 1586.70 kN/square.m.\n",
        "Maximum Normal stress at heel = -49.30 kN/square.m.\n"
       ]
      }
     ],
     "prompt_number": 22
    }
   ],
   "metadata": {}
  }
 ]
}