{
 "metadata": {
  "name": "",
  "signature": "sha256:e94e252902947538e327888c054726e4c87fafcbcff4841a5585391ce610b765"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Chapter 03:Torsion"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.1, Page No:79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "P=20*10**3 #Power in W\n",
      "f=2 #Frequency in Hz\n",
      "t_max=40*10**6 #Maximum shear stress in Pa\n",
      "G=83*10**9 #Bulk modulus in Pa\n",
      "theta=(6*pi)/180 #Angle of twist in radians\n",
      "L=3 #Length in m\n",
      "\n",
      "#Calculations\n",
      "#Strength condition\n",
      "T=P/(2*pi*f) #Torque in N.m\n",
      "d1=((16*T)/(pi*t_max))**0.333 #Max allowable diameter in mm\n",
      "\n",
      "#Applying torque-twist relationship\n",
      "d2=((32*T*L)/(G*theta*pi))**0.25 #Diameter in mm\n",
      "\n",
      "d=max(d1,d2)\n",
      "\n",
      "print \"To satisfy both strength and rigidity conditions d=\",round(d*1000,1),\"mm\"\n",
      "\n",
      "#NOTE:The fractional power leads to the discrepancy in the answer\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "To satisfy both strength and rigidity conditions d= 58.9 mm\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.2, Page No:79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "Ga=4*10**6 #Bulk modulus of Aluminium in psi\n",
      "Gs=12*10**6 #Bulk Modulus of Steel in psi\n",
      "T=10**4 #Torque in lb.in\n",
      "L1=3 #Length in ft of the Steel bar\n",
      "L2=6 #Length in ft of the Aluminium bar\n",
      "d1=3 #Diameter of the Aluminium bar in inches\n",
      "d2=2 #Diameter of the Steel bar in inches\n",
      "\n",
      "#Calculations\n",
      "#Using Compatibility and equlibrium conditions\n",
      "a=np.array([[1,1],[(L1*32)/(Gs*pi*d2**4),-((L2*32)/(Ga*d1**4*pi))]])\n",
      "b=np.array([T,0])\n",
      "y=np.linalg.solve(a,b)\n",
      "\n",
      "#Stresses\n",
      "t_max_st=(16*y[0])/(pi*d2**3) #Max shear Stress in Steel in psi\n",
      "t_max_al=(16*y[1])/(pi*d1**3) #Max shear stress in aluminium in psi\n",
      "\n",
      "print \"The maximum values of Shear Stresses are as flollows\"\n",
      "print round(t_max_st),\"psi in Steel and \",round(t_max_al),\"psi in Aluminium\"\n",
      "#NOTE:The shear stress for steel in the txtbook is off by 3psi"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum values of Shear Stresses are as flollows\n",
        "3453.0 psi in Steel and  863.0 psi in Aluminium\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.3, Page No:80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "d=2 #Diameter in ft\n",
      "G=12*10**6 #Bulk Modulus in psi\n",
      "#Torque in lb.ft\n",
      "T1=500 #Torque 1 \n",
      "T2=900 #Torque 2\n",
      "T3=1000 #Torque 3\n",
      "#Length in ft\n",
      "L1=4 \n",
      "L2=3\n",
      "L3=5\n",
      "\n",
      "#Calculations\n",
      "#Applying the sum of torques we get\n",
      "Tab=T1 #Torque at section AB in lb.ft\n",
      "Tbc=-T2+T1 #Torque at section BC in lb.ft\n",
      "Tcd=T3-T2+T1 #Torque at Section CD in lb.ft\n",
      "\n",
      "#Summing the angle of twists\n",
      "theta_r=(((Tab*12*L3*12)+(Tbc*12*L2*12)+(Tcd*12*L1*12))*32)/(pi*2**4*G)\n",
      "theta=(theta_r*180)/pi #Angle in degrees\n",
      "\n",
      "print \"The angle of twist is\",round(theta,3),\"degrees\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The angle of twist is 1.62 degrees\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.4, Page No:81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "L=1.5 #Length of the shaft in m\n",
      "t_B=200 #Torque per unit length in N.m/m\n",
      "d=0.025 #Diameter of the shaft in m\n",
      "G=80*10**9 #Bulk Modulus for steel in Pa\n",
      "\n",
      "\n",
      "#Calculations\n",
      "#Part(1)\n",
      "#After carrying out the variable integration\n",
      "T_A=0.5*t_B*L #Torque about point A in N.m\n",
      "#Using equation of max stress\n",
      "tau_Max=(16*T_A)*(pi*d**3)**-1 #Maximum stress in the shaft in Pa\n",
      "\n",
      "#Part(2)\n",
      "J=(pi*d**4)*32**-1 #Polar moment of inertia in m^4\n",
      "#After carrying out the computation for angle of twist we get\n",
      "theta_r=(t_B*L**2)*(3*G*J)**-1 #Angle of twist in radians\n",
      "theta=theta_r*(180*pi**-1) #Angle of twist in degrees\n",
      "\n",
      "#Result\n",
      "print \"Result for part (1)\"\n",
      "print \"Maximum Shear Stress in the shaft is\",round(tau_Max/10**6,1),\"MPa\"\n",
      "print \"Result for part (2)\"\n",
      "print \"The angle of twist in the shaft is\",round(theta,2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Result for part (1)\n",
        "Maximum Shear Stress in the shaft is 48.9 MPa\n",
        "Result for part (2)\n",
        "The angle of twist in the shaft is 2.8 degrees\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.5, Page No:91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "L=6 #Length of the tube in ft\n",
      "t=3*8**-1 #Constant wall thickness in inches\n",
      "G=12*10**6 #Bulk modulus of the tube in psi\n",
      "w1=6 #Width on the top in inches\n",
      "w2=4 #Width at the bottom in inches\n",
      "h=5 #Height in inches\n",
      "theta=0.5 #Angle of twist in radians\n",
      "\n",
      "#Calculations\n",
      "#Part(1)\n",
      "Ao=(w1+w2)*2**-1*h #Area enclosed by the median line in sq.in\n",
      "S=w1+w2+2*(sqrt(1**2+h**2)) #Length of the median line in inches\n",
      "#Using the torsional stifness formula we get\n",
      "k=4*G*Ao**2*t*(L*12*S)**-1*(pi*180**-1) #tortional Stiffness  in lb.in/rad\n",
      "\n",
      "#Part(2)\n",
      "T=k*theta #Torque required to produce an angle of twist of theta in lb.in\n",
      "q=T*(2*Ao)**-1 #Shear flow in lb/in\n",
      "tau=q/t #Shear stress in the wall in psi\n",
      "\n",
      "\n",
      "#Result \n",
      "print \"Part(1) results\"\n",
      "print \"Torsional stiffness is\",round(k),\"lb.in/deg\"\n",
      "print \"Part(2) results\"\n",
      "print \"The shear stress in the wall is\", round(tau),\"psi\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part(1) results\n",
        "Torsional stiffness is 135017.0 lb.in/deg\n",
        "Part(2) results\n",
        "The shear stress in the wall is 3600.0 psi\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3.6, Page No:92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "L=1.2 #Length of the tube in m\n",
      "tau=40*10**6 #MAximum shear stress  in MPa\n",
      "t=0.002 #Thickness in m\n",
      "r=0.025 #Radius of the semicircle in m\n",
      "G=28*10**9 #Bulk Modulus in Pa\n",
      "t1=2 #Thickness in mm\n",
      "t2=3 #thickness in mm\n",
      "\n",
      "#Calculations\n",
      "#Part(1)\n",
      "q=tau*t #Shear flow causing the stress in N/m\n",
      "Ao=pi*r**2*0.5 #Area of the semi-circle in m^2\n",
      "T=2*Ao*q #Torque causing the shear stress in N.m\n",
      "\n",
      "#Part(2)\n",
      "#After computing the median lines integration we get\n",
      "S=(pi*25*t1**-1)+(2*25*t2**-1) #Length of median line \n",
      "theta_r=T*L*S*(4*G*Ao**2)**-1 #Angle of twist in radians\n",
      "theta=theta_r*(180*pi**-1) #Angle of twist in degrees\n",
      "\n",
      "#Result\n",
      "print \"Result for part(1)\"\n",
      "print \"The torque causing the stress of 40MPa is\",round(T,2),\"N.m\"\n",
      "print \"Result for part (2)\"\n",
      "print \"The angle of twist is\",round(theta,1),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Result for part(1)\n",
        "The torque causing the stress of 40MPa is 157.08 N.m\n",
        "Result for part (2)\n",
        "The angle of twist is 5.6 degrees\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}