{
 "metadata": {
  "name": "",
  "signature": "sha256:79f5af56f872c7416bcd3bda5e7a1179e040bd757ab8803628993204af617cfd"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter5-Applications Of Energy Methods"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the Values of P and Q and small displacement component\n",
      "\n",
      "## initialization of variables\n",
      "import math\n",
      "## part (b)\n",
      "K1=2. ##N/mm (K1=E1A1/L1)\n",
      "K2=3. ##N/mm (K2=E2A2/L2)\n",
      "b1=400. ## mm (b1=h)\n",
      "h=400. ## mm\n",
      "b2=300. ##mm\n",
      "u=30. ##mm\n",
      "v=40. ##mm\n",
      "## calculations\n",
      "## Units convertion\n",
      "K1=K1*10**3\n",
      "K2=K2*10**3\n",
      "b1=b1*10**-3\n",
      "b2=b2*10**-3\n",
      "h=h*10**-3\n",
      "u=u*10**-3\n",
      "v=v*10**-3\n",
      "L1=math.sqrt(b1**2+h**2)\n",
      "L2=math.sqrt(b2**2+h**2)\n",
      "N1=math.sqrt((b1+u)**2+(h+v)**2)-L1\n",
      "N2=math.sqrt((b1+u)**2+(h+v)**2)\n",
      "N3=math.sqrt((b2-u)**2+(h+v)**2)-L2\n",
      "N4=math.sqrt((b2-u)**2+(h+v)**2)\n",
      "P=K1*(b1+u)*N1/N2-K2*(b2-u)*N3/N4\n",
      "Q=K1*(h+v)*N1/N2+K2*(h+v)*N3/N4\n",
      "## results\n",
      "print('part (b)')\n",
      "print\"%s %.2f %s\"%('\\n P = ',P,' N')\n",
      "print\"%s %.2f %s\"%('\\n Q =',Q,' N')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (b)\n",
        "\n",
        " P =  43.77  N\n",
        "\n",
        " Q = 112.37  N\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg154"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the small displacement components\n",
      "## initialization of variables\n",
      "import math\n",
      "## Loads and stresses and dimensions\n",
      "P=10. ##kN\n",
      "Q=30. ##kN\n",
      "S0=70. ##MPa\n",
      "eps0=0.001\n",
      "b1=400. ##mm\n",
      "h=400. ##mm\n",
      "b2=300. ##mm\n",
      "A1=300. ##mm^2\n",
      "A2=300. ##mm^2\n",
      "## calculations\n",
      "## Units convertion\n",
      "P=P*10**3\n",
      "Q=Q*10**3\n",
      "S0=S0*10**6\n",
      "b1=b1*10**-3\n",
      "b2=b2*10**-3\n",
      "h=h*10**-3\n",
      "A1=A1*10**-6\n",
      "A2=A2*10**-6\n",
      "L1=math.sqrt(b1**2+h**2)\n",
      "L2=math.sqrt(b2**2+h**2)\n",
      "a=L1*(Q*b2+P*h)/(A1*S0*h*(b1+b2))\n",
      "b=L2*(Q*b1-P*h)/(A2*S0*h*(b1+b2))\n",
      "c=L1**2*eps0/(b1+b2)\n",
      "d=L2**2*eps0/(b1+b2)\n",
      "u=c*math.sinh(a)-d*math.sinh(b)\n",
      "v=b2/h*c*math.sinh(a)+b1/h*d*math.sinh(b)\n",
      "## results\n",
      "print\"%s %.2f %s\"%('u = ',u*10**3,' mm')\n",
      "print\"%s %.2f %s\"%('\\n v =',v*10**3,' mm')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "u =  0.47  mm\n",
        "\n",
        " v = 0.81  mm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the deflection of the free end of the beam\n",
      "## initialization of variables\n",
      "import math\n",
      "## Material constants\n",
      "E=200. ##GPa\n",
      "G=77.5 ## GPa\n",
      "Lh=5. ## Lh = L/h\n",
      "## part (b)\n",
      "rhs1=1.8*Lh*E/G\n",
      "rhs2=7.*12.*Lh**3./16.\n",
      "LHS=1.8*Lh*E/G+7.*12.*Lh**3./16.\n",
      "e=rhs1/LHS*100.\n",
      "print\"%s %.2f %s\"%('The error in neglecting small terms is ',e,' per cent')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The error in neglecting small terms is  3.42  per cent\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the rotation of section B\n",
      "## initialization of variables\n",
      "import math\n",
      "## Specifications\n",
      "T=2. ##kN.m\n",
      "E=72. ## G Pa\n",
      "G=27. ## GPa\n",
      "b=30. ##mm\n",
      "h=40. ##mm\n",
      "d=60. ##mm\n",
      "l1=400. ##mm\n",
      "l2=800. ##mm\n",
      "## calculations\n",
      "E=E*10**9\n",
      "G=G*10**9\n",
      "b=b*10**-3\n",
      "h=h*10**-3\n",
      "d=d*10**-3\n",
      "l1=l1*10**-3\n",
      "l2=l2*10**-3\n",
      "T=T*10**3 ##N.m\n",
      "Ix=b*h**3./12.\n",
      "J=math.pi*d**4/32.\n",
      "thB= 2.*l1**3./3.*0.001**2*T/(E*Ix)+T*l2/(G*J)\n",
      "print\"%s %.2f %s\"%('The rotation of shaft B is th = ',thB,' rad')\n",
      "## Wrong answer to an extent in the textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rotation of shaft B is th =  0.05  rad\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex9-pg168"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the deflection of the free end of curved beam in he direction and error deflection\n",
      "## initialization of variables\n",
      "import math\n",
      "## specification\n",
      "R=65. ##mm\n",
      "E=200. ##GPa\n",
      "G=77.5 ##GPa\n",
      "v=0.29\n",
      "P=6.##kN\n",
      "##calculations\n",
      "R=R*10**-3\n",
      "E=E*10**9\n",
      "G=G*10**9\n",
      "P=P*10**3\n",
      "A=30**2*10**-6\n",
      "I=30**4./12.*10**-12\n",
      "q_p1=3*math.pi*P*R/(4.*E*A)+1.2*3.*math.pi*P*R/(4.*G*A)+(9.*math.pi/4.+2.)*P*R**3./(E*I)\n",
      "print('part (a)')\n",
      "print\"%s %.2f %s\"%('\\n qp = ',q_p1*10**3,' mm')\n",
      "##part (b)\n",
      "## if Un and Us are neglected\n",
      "q_p2=(9.*math.pi/4.+2.)*P*R**3./(E*I)\n",
      "e=(q_p1-q_p2)/q_p1*100.\n",
      "print('\\n part (b)')\n",
      "print\"%s %.2f %s\"%('\\n error = ',e,' per cent')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a)\n",
        "\n",
        " qp =  1.13  mm\n",
        "\n",
        " part (b)\n",
        "\n",
        " error =  1.85  per cent\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex10-pg169"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the  effect of neglecting the strain energy Us due to shear and vertical deflection\n",
      "## initialization of variables\n",
      "import math\n",
      "## part (b)\n",
      "## Specifications\n",
      "P=150. ##N\n",
      "R=200. ##mm\n",
      "d=20. ##mm\n",
      "E=200. ##GPa\n",
      "G=77.5 ##GPa\n",
      "##calculations\n",
      "R=R*10**-3.\n",
      "d=d*10**-3.\n",
      "E=E*10**9.\n",
      "G=G*10**9.\n",
      "r1=R+d/2.\n",
      "r2=R-d/2.\n",
      "A=314.*10**-6 \n",
      "I=7850.*10**-12 ##m**4\n",
      "Ax=3.*math.pi/4.*P*R/(E*A)\n",
      "Sh=3.*math.pi/4.*1.33*P*R/(G*A)\n",
      "M=(7.*math.pi/4.+1.)*P*R**3./(E*I)\n",
      "##qc=3*%pi/4*P*R/(E*A)+3*%pi/4*1.33*P*R/(G*A)+(7*%pi/4+1)*P*R**3/(E*I)\n",
      "qc=Ax+Sh+M\n",
      "print\"%s %.2f %s %.2f %s %.2f %s %.2f %s\"%('qc = ',qc*10**3,' mm 'and 'among which due to Axial is ',Ax*10**3,' mm'and '',Sh*10**3, 'mm'and ' is due to shear, and ',M*10**3,' mm is due to moment')\n",
      "\n",
      "print('\\n which means The concentrations of axial loads and shear are negligible')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "qc =  4.97 among which due to Axial is  0.00  0.00  is due to shear, and  4.97  mm is due to moment\n",
        "\n",
        " which means The concentrations of axial loads and shear are negligible\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex12-pg174"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the rotation of member BE caused by the loads P and Q\n",
      "## initialization of variables\n",
      "import math\n",
      "## Material properties and dimensions\n",
      "E=72. ##G Pa\n",
      "P=10. ##kN\n",
      "Q=5. ##kN\n",
      "Aab=150. ##mm**2\n",
      "Abc=900. ##mm**2\n",
      "Acd=900. ##mm**2\n",
      "Ade=900. ##mm**2\n",
      "Abd=150. ##mm**2\n",
      "Abe=150. ##mm**2\n",
      "Lab=2. ##m\n",
      "Lbc=2.5 ##m\n",
      "Lbd=1.5 ##m\n",
      "Lbe=2.5 ##m\n",
      "Lcd=2. ##m\n",
      "Lde=2. ##m\n",
      "##calculations\n",
      "E=E*10**9.\n",
      "P=P*10**3.\n",
      "Q=Q*10**3.\n",
      "Aab=150.\n",
      "Aab=Aab*10**-6.\n",
      "Abc=Abc*10**-6.\n",
      "Acd=Acd*10**-6.\n",
      "Ade=Ade*10**-6.\n",
      "Abd=Abd*10**-6.\n",
      "Abe=Abe*10**-6.\n",
      "M=0.\n",
      "Nab=4./3.*(Q+2.*P)-5.*M/(3.*Lbe)\n",
      "dNab=-5./(3.*Lbe)\n",
      "Nbc=-5./3.*(Q+P)\n",
      "dNbc=0.\n",
      "Nbd=Q\n",
      "dNbd=0.\n",
      "Nbe=5.*P/3.-4./3.*M/Lbe\n",
      "dNbe=-4./(3.*Lbe)\n",
      "Ncd=-4.*P/3.+5./3.*M/Lbe\n",
      "dNcd=5./(3.*Lbe)\n",
      "Nde=Ncd\n",
      "thBE=Nab*Lab*dNab/(E*Aab)+Nbc*Lbc*dNbc/(E*Abc)+Nbd*Lbd*dNbd/(E*Abd)+Nbe*Lbe*dNbe/(E*Abe)+2.*Ncd*Lcd*dNcd/(E*Lcd)\n",
      "print\"%s %.2f %s\"%('The rotation of member BE is ',thBE,' rad')\n",
      "## Wrong answer in the text\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rotation of member BE is  -0.01  rad\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}