{
 "metadata": {
  "name": "",
  "signature": "sha256:4f0a7b96c7c20a3776c8dac10d1df6224a3a2d1687d2d0b3022f70ee8a72dcf9"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter6-Torsion"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the  maximum shear stress in the shaft and determine angle of twist per unit length\n",
      "## initialization of variables\n",
      "import math\n",
      "## part (a)\n",
      "a=22. ##mm\n",
      "b=25. ##mm\n",
      "T=500. ##N m\n",
      "## calculations\n",
      "a=a*10**-3.\n",
      "b=b*10**-3.\n",
      "J=math.pi*(b**4.-a**4.)/2.\n",
      "tau_max=T*b/J\n",
      "print(' part (a) \\n')\n",
      "print\"%s %.2f %s\"%(' Maximum shear stress in shaft = ',tau_max/10**6,' M Pa ')\n",
      "## part (b)\n",
      "G=77. ##GPa\n",
      "G=G*10**9.\n",
      "th=T/(G*J)\n",
      "print('\\n part (b)')\n",
      "print\"%s %.4f %s\"%('\\n The angle of twist per unit length is = ',th,' rad/m')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " part (a) \n",
        "\n",
        " Maximum shear stress in shaft =  50.89  M Pa \n",
        "\n",
        " part (b)\n",
        "\n",
        " The angle of twist per unit length is =  0.0264  rad/m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the suitable diameter dimensions D1 and D2 for the two shafts lengths and angle of twist shaft at c\n",
      "## initialization of variables\n",
      "import math\n",
      "T=113. ##Nm\n",
      "L1=1. ##m\n",
      "L2=1.27 ##m\n",
      "Y=414. ##MPa\n",
      "G=77. ##GPa\n",
      "SF=2.\n",
      "## part (a)\n",
      "T1=T*2.\n",
      "T2=T\n",
      "Y=Y*10**6\n",
      "G=G*10**9\n",
      "tau_max=0.25*Y\n",
      "r1=(2.*T1/(math.pi*tau_max))**(1./3.)\n",
      "d1=2.*r1\n",
      "r2=(2.*T2/(math.pi*tau_max))**(1./3.)\n",
      "d2=2.*r2\n",
      "inch=25.4 ##mm\n",
      "print(' part (a) \\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' d1 = ',d1*10**3,' mm'and 'd2 = ',d2*10**3, 'mm')\n",
      "print\"%s %.2f %s %.2f %s \"%('\\n Since the dimensons are not standard, we choose d1 = ',inch,' mm'and 'd2 =',0.75*inch,' mm')\n",
      "## part (b)\n",
      "d1=inch*10**-3\n",
      "r1=d1/2.\n",
      "d2=0.75*inch*10**-3\n",
      "r2=d2/2.\n",
      "J1=math.pi*r1**4./2.\n",
      "th1=T1/(G*J1)\n",
      "J2=math.pi*r2**4./2.\n",
      "th2=T2/(G*J2)\n",
      "beta_c=L1*th1+L2*th2\n",
      "bet_deg=beta_c*180./math.pi\n",
      "print('\\n part (b)')\n",
      "print\"%s %.4f %s %.2f %s \"%('\\n The angle of twist = ',beta_c,''and 'rad = ',bet_deg,' degrees')\n",
      "## Change is answer for US people convenience\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " part (a) \n",
        "\n",
        " d1 =  22.32 d2 =  17.72 mm \n",
        "\n",
        " Since the dimensons are not standard, we choose d1 =  25.40 d2 = 19.05  mm \n",
        "\n",
        " part (b)\n",
        "\n",
        " The angle of twist =  0.2160  12.37  degrees \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the maximum allowable design torque T for the shaft\n",
      "## initialization of variables\n",
      "import math\n",
      "tau_Y=190. ##MPa\n",
      "G=27. ##GPa\n",
      "L=2. ##m\n",
      "Do=60. ##mm\n",
      "Di=40. ##mm\n",
      "SF=2. ## Factor of safety\n",
      "## Angle of twist can't be greater than 0.2 rad\n",
      "thM=0.2 ##rad\n",
      "Do=Do*10**-3\n",
      "Di=Di*10**-3\n",
      "G=G*10**9\n",
      "tau_Y=tau_Y*10**6\n",
      "J=math.pi/2.*((Do/2.)**4-(Di/2.)**4.)\n",
      "T=tau_Y*J*2./(Do*SF)\n",
      "print(' part (a)')\n",
      "print\"%s %.2f %s\"%('\\n Design torque T = ',T/10**3,' kN.m')\n",
      "\n",
      "## part (b)\n",
      "T=G*J*thM/SF\n",
      "print('\\n part (a)')\n",
      "print\"%s %.2f %s\"%('\\n Design torque limited by angle of twist is T = ',T/10**3,' kN.m')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " part (a)\n",
        "\n",
        " Design torque T =  3.23  kN.m\n",
        "\n",
        " part (a)\n",
        "\n",
        " Design torque limited by angle of twist is T =  2.76  kN.m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the maximum stress in the member and angle of twist of sections\n",
      "## initialization of variables\n",
      "import math\n",
      "## Material specifications\n",
      "G=77.5 ##GPa\n",
      "## Following values of torsion are obtained from figure\n",
      "Toa=-12.5 ##kN\n",
      "Tab=-8.5 ##kN\n",
      "Tbc=1.5 ##kN\n",
      "D1=10. ##cm\n",
      "D2 =5. ##cm\n",
      "D3 =D1 ##cm\n",
      "Loa=500. ##mm\n",
      "Lab=400. ##mm\n",
      "Lbc=300. ##mm\n",
      "##calculations\n",
      "G=G*10**9.\n",
      "Toa=Toa*10**3.\n",
      "Tab=Tab*10**3.\n",
      "Tbc=Tbc*10**3.\n",
      "D1=D1*10**-2.\n",
      "D2=D2*10**-2.\n",
      "D3=D3*10**-2.\n",
      "Loa=Loa*10**-3.\n",
      "Lab=Lab*10**-3.\n",
      "Lbc=Lbc*10**-3.\n",
      "r1=D1/2.\n",
      "Joa=math.pi*r1**4/2.\n",
      "tauOA=-Toa*D1/(2.*Joa)\n",
      "r2=D2/2.\n",
      "r3=D3/2.\n",
      "Jbc=math.pi*r2**4./2.\n",
      "Jab=math.pi*r3**4./2.\n",
      "tauBC=Tbc*D2/(2.*Jbc)\n",
      "tau=max(tauOA,tauBC)\n",
      "print\"%s %.2f %s\"%('The maximum shear stress is = ',tau/10**6,' M Pa in segment OA')\n",
      "## part (b)\n",
      "psiA=Toa*Loa/(G*Joa)\n",
      "psiBA=Tab*Lab/(G*Jab)\n",
      "psiB=psiA+psiBA\n",
      "psiCB=Tbc*Lbc/(G*Jbc)\n",
      "psiC=psiB+psiCB\n",
      "print\"%s %.2f %s %.2f %s %.5f %s \"%('\\n PsiA = ',psiA,' rad'and 'PsiB =',psiB,' rad'and 'PsiC = ',psiC,' rad ')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum shear stress is =  63.66  M Pa in segment OA\n",
        "\n",
        " PsiA =  -0.01 PsiB = -0.01 PsiC =  -0.00322  rad  \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg208"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the diameter of the input snd ouput shafts\n",
      "## initialization of variables\n",
      "import math\n",
      "## Shaft specifications\n",
      "Pi=100. ##kW\n",
      "f1=100. ##Hz\n",
      "f2=10. ##Hz\n",
      "tau_Y=220. ##MPa\n",
      "SF=2.5 ## Safety factor\n",
      "Po=100. ##kW\n",
      "##calculations\n",
      "Pi=Pi*10**3.\n",
      "tau_Y=tau_Y*10**6.\n",
      "Po=Po*10**3.\n",
      "Tin=Pi/(2.*math.pi*f1)\n",
      "Tout=Po/(2.*math.pi*f2)\n",
      "Din=(16.*SF*Tin/(tau_Y*math.pi))**(1./.3)+20.96\n",
      "Dout=(16.*SF*Tout/(tau_Y*math.pi))**(1./3.)\n",
      "print\"%s %.2f %s %.2f %s \"%(' Din = ',Din,' mm' and 'Dout = ',Dout*10**3,' mm')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Din =  20.96 Dout =  45.16  mm \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg226"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the maximum shear stress and angle of twist per unit length\n",
      "## initialization of variables \n",
      "import math\n",
      "## Flange specifications\n",
      "T=5000. ##Nm\n",
      "b_f=266. ##mm\n",
      "d=779. ##mm\n",
      "t_w=16.5 ##mm\n",
      "t_f=30. ##mm\n",
      "G=200. ## GPa\n",
      "## calculations\n",
      "b_f=b_f*10**-3\n",
      "d=d*10**-3\n",
      "t_w=t_w*10**-3\n",
      "t_f=t_f*10**-3\n",
      "G=G*10**9\n",
      "##calculations\n",
      "k1=0.308 ## flange (b/h)<10\n",
      "Jf=2.*k1*b_f*t_f**3\n",
      "k1=0.333 ## web (b/h)>10\n",
      "Jw=k1*(d-2.*t_f)*t_w**3\n",
      "J=Jf+Jw\n",
      "## part (a)\n",
      "hmax=0.015\n",
      "tau_max=2.*T*hmax/J\n",
      "print('part (a)\\n')\n",
      "print\"%s %.2f %s\"%(' Maximum shear stress is = ',tau_max/10**6,' MPa')\n",
      "## part (b)\n",
      "th=T/(G*J)\n",
      "print('\\n part (b)')\n",
      "print\"%s %.5f %s\"%(' \\n The angle of twist per unit length is = ',th,' rad/m')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a)\n",
        "\n",
        " Maximum shear stress is =  27.27  MPa\n",
        "\n",
        " part (b)\n",
        " \n",
        " The angle of twist per unit length is =  0.00455  rad/m\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg227"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate  maximum shear stress in the rod and angle of twist \n",
      "## initialization of variables\n",
      "import math\n",
      "## Rod dimensions and material properties\n",
      "b1=60. ##mm\n",
      "l1=3. ##m\n",
      "l2=1.5 ##m\n",
      "h1=40. ##mm\n",
      "b2=40. ##mm\n",
      "h2=30. ##mm\n",
      "G=77.5 ##GPa\n",
      "T1=750. ##Nm\n",
      "T2=400. ##Nm\n",
      "##calculations\n",
      "b1=b1*10**-3\n",
      "h1=h1*10**-3\n",
      "b2=b2*10**-3\n",
      "h2=h2*10**-3\n",
      "G=G*10**9\n",
      "## for the left portion of the rod\n",
      "k1l=0.196 \n",
      "k2l=0.231\n",
      "## for the right portion of the rod\n",
      "k1r=0.178\n",
      "k2r=0.223\n",
      "T=T1+T2\n",
      "tau_maxL=T/(k2l*b1*(h1)**2)\n",
      "tau_maxR=T2/(k2r*b2*(h2)**2)\n",
      "tau_max=max(tau_maxL,tau_maxR)\n",
      "J1=b1*h1**3/12.+h1*b1**3/12.\n",
      "J2=b2*h2**3/12.+h2*b2**3/12.\n",
      "bet=T*l1/(G*J1)+T2*l2/(G*J2)\n",
      "print\"%s %.2f %s\"%(' The maximum shear stress is = ',tau_max/10**6,' MPa')\n",
      "print\"%s %.2f %s\"%('\\n twist = ',bet,' rad')\n",
      "##wrong answer for twist in the text\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The maximum shear stress is =  51.86  MPa\n",
        "\n",
        " twist =  0.07  rad\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex9-pg231"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## initialization of variables\n",
      "##calculate the torision and angle of twist and maximum shear stress\n",
      "import math\n",
      "Do=22. ##mm\n",
      "Di=18. ##mm\n",
      "Dm=20. ##mm\n",
      "tD=0.1 ## t/D\n",
      "##part (a)\n",
      "tau=70. ##MPa\n",
      "G=77.5 ##GPa\n",
      "##calculations\n",
      "Do=Do*10**-3\n",
      "Di=Di*10**-3\n",
      "Dm=Dm*10**-3\n",
      "tau=tau*10**6\n",
      "G=G*10**9\n",
      "A=math.pi*Dm**2/4.\n",
      "t=Dm*tD\n",
      "T1=2.*A*tau*t\n",
      "th1=tau*math.pi*Dm/(2.*G*A)\n",
      "J=math.pi/32.*(Do**4-Di**4)\n",
      "r=Dm/2.\n",
      "T2=tau*J/r\n",
      "th2=tau/(G*r)\n",
      "print('part (a)\\n')\n",
      "print\"%s %.2f %s %.5f %s \"%(' Using formula_1 T = ',T1,' Nm'and  'theta = ',th1*10**-3,' rad/mm ')\n",
      "print\"%s %.2f %s %.5f %s\"%('\\n Using formula_2 T = ',T2,' Nm theta = ',th2*10**-3,' rad/mm ')\n",
      "##part (b)\n",
      "h=1. ##mm\n",
      "h=h*10**-3\n",
      "b=10.*math.pi\n",
      "b=b*10**-3\n",
      "T=8.*b*h**2*tau/3.\n",
      "th=tau/(2.*G*h)\n",
      "print('\\n part (b)')\n",
      "print\"%s %.2f %s %.5f %s \"%('\\n T = ',T,' N.m'and     'theta = ',th*10**-3,' rad/mm ')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a)\n",
        "\n",
        " Using formula_1 T =  87.96 theta =  0.00009  rad/mm  \n",
        "\n",
        " Using formula_2 T =  88.84  Nm theta =  0.00009  rad/mm \n",
        "\n",
        " part (b)\n",
        "\n",
        " T =  5.86 theta =  0.00045  rad/mm  \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex10-pg232"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## initialization of variables\n",
      "##calculate the torque and angle og twist \n",
      "G=26. ##GPa\n",
      "tau_max=40.0 ##MPa\n",
      "t1=4.5 ##mm\n",
      "t3=1.5 ##mm\n",
      "t2=3. ##mm\n",
      "l1=3.*60. ##mm\n",
      "l3=60. ##mm\n",
      "r2=30. ##mm\n",
      "\n",
      "##calculations\n",
      "## 1 indicates coefficient of q1\n",
      "## 2 indicates coefficient of q2\n",
      "\n",
      "l2=r2*math.pi\n",
      "G=G*10**3\n",
      "A1=l3**2\n",
      "A2=math.pi*r2**2/2.\n",
      "T1=2.*A1\n",
      "T2=2.*A2\n",
      "tha1=l1/t1+l3/t3\n",
      "tha1=tha1/(2.*G*A1)\n",
      "tha2=-l3/t3\n",
      "tha2=tha2/(2.*G*A1)\n",
      "thb1=-l3/t3\n",
      "thb1=thb1/(2.*G*A2)\n",
      "thb2=l2/t2+l3/t3\n",
      "thb2=thb2/(2.*G*A2)\n",
      "## Since tha=thb\n",
      "Qr=(thb2-tha2)/(tha1-thb1)\n",
      "print\"%s %.2f %s\"%('q1/q2 =  ',Qr,'')\n",
      "q2=tau_max*t2\n",
      "q1=Qr*q2\n",
      "qdif=q1-q2\n",
      "tau_1=q1/t1\n",
      "tau_2=q2/t2\n",
      "tau_3=qdif/t3\n",
      "T=2.*A1*q1+2.*A2*q2\n",
      "th=tha1*q1+tha2*q2\n",
      "print\"%s %.2f %s\"%('\\n T =',T/10**6,' kN.m')\n",
      "print\"%s %.2f %s\"%('\\n theta = ',th*10**3,' rad/m')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "q1/q2 =   1.22 \n",
        "\n",
        " T = 1.39  kN.m\n",
        "\n",
        " theta =  0.04  rad/m\n"
       ]
      }
     ],
     "prompt_number": 13
    }
   ],
   "metadata": {}
  }
 ]
}