{
 "metadata": {
  "name": "",
  "signature": "sha256:cff1e23e14e854a300136760b464ae325e3afc2c7094a19b255704b9aeba45ea"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : Simple Harmonic Motion"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 Page No : 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "N = 120. \t\t\t#rpm\n",
      "r = 1.              #m\n",
      "x = 0.75 \t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating Angular Velocity\n",
      "omega = 2*math.pi*N/60 \t\t\t#rad/s\n",
      "#Calculating Velocity of the Piston\n",
      "v = omega*math.sqrt(r**2-x**2) \t\t\t#m/s\n",
      "#Calculating Acceleration of the Piston\n",
      "a = omega**2*x\n",
      "\n",
      "#Results:\n",
      "print \" The Velocity of the Piston, v  =  %.2f m/s.\"%(v)\n",
      "print \" The Acceleration of the Piston, a  =  %.2f m/s**2.\"%(a)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Velocity of the Piston, v  =  8.31 m/s.\n",
        " The Acceleration of the Piston, a  =  118.44 m/s**2.\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 Page No : 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import linalg\n",
      "import math \n",
      "\n",
      "# Variables:\n",
      "x1 = .75\n",
      "x2 = 2. \t\t\t#m\n",
      "v1 = 11.\n",
      "v2 = 3.\t\t\t    #m/s\n",
      "\n",
      "#Solution:\n",
      "#We have11 = omega*math.sqrt(r**2-.75**2) and 3 = omega*math.sqrt(r**2-2**2).\n",
      "#These upon solving yield r**2-(121/omega**2)-0.5625 = 0 and r**2-(9/omega**2)-4 = 0.\n",
      "#Take r**2 = x and (1/omega**2) = y and the equation become x-121y = 0.5625 and x-9y = 4.\n",
      "#Variables Matrix\n",
      "A = [[1, -121],[ 1, -9]]\n",
      "#Constants Matrix\n",
      "B = [.5625, 4]\n",
      "V = linalg.solve(A,B)\n",
      "#Calculating Amplitude of the Particle\n",
      "r = math.sqrt(V[0]) \t    \t\t#m\n",
      "#Calculating Angular Velocity of the Particle\n",
      "omega = math.sqrt(1./V[1]) \t\t\t#rad/s\n",
      "#Calculating Periodic Time\n",
      "tp = 2*math.pi/omega \t\t    \t#seconds\n",
      "#Calculating Maximum Acceleration\n",
      "amax = omega**2*r        \t\t\t#m/s**2\n",
      "\n",
      "#Results:\n",
      "print \" The Angular Velocity omega  =  %.1f rad/s.\"%(omega)\n",
      "print \" The Periodic Time tp  =  %.1f s.\"%(tp)\n",
      "print \" The Maximum Acceleration amax  =  %.2f m/s**2.\"%(amax)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Angular Velocity omega  =  5.7 rad/s.\n",
        " The Periodic Time tp  =  1.1 s.\n",
        " The Maximum Acceleration amax  =  67.38 m/s**2.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 Page No : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "m = 60. \t\t\t#kg\n",
      "r = 0.0125          #m\n",
      "x = 0.005 \t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Extension of the Spring\n",
      "delta = (.25/1.5)*60*10**-3 \t\t\t#m\n",
      "#Calculating the Frequency of the System\n",
      "n = 1./(2*math.pi)*math.sqrt(9.81/delta) \t\t\t#Hz\n",
      "#Calculating the Angular Velocity of the Mass\n",
      "omega = math.sqrt(9.81/delta) \t\t\t#rad/s\n",
      "#Calculating the Linear Velocity of the Mass\n",
      "v = omega*math.sqrt(r**2-x**2)\n",
      "\n",
      "#Results:\n",
      "print \" The Frequency of Natural Vibration n  =  %.2f Hz.\"%(n)\n",
      "print \" The Velocity of the Mass v  =  %.2f m/s.\"%(v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Frequency of Natural Vibration n  =  4.98 Hz.\n",
        " The Velocity of the Mass v  =  0.36 m/s.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 Page No : 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "m = 1.              #kg\n",
      "m1 = 2.5 \t\t\t#kg\n",
      "s = 1.8*10**3 \t\t#N/m\n",
      "l = (300.+300)*10**-3\t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Mass Moment of Inertia of the System\n",
      "IA = (m*l**2/3)+(m1*l**2) \t\t\t#kg-m**2\n",
      "#Calculating the Ratio of Alpha to Theta\n",
      "#delta = 0.3*theta\n",
      "#Restoring Force = s*delta = 540*theta\n",
      "#Restoring torque about A = 540*theta*0.3 = 162*theta N-m ...(i)\n",
      "#Torque about A =  IA*alpha = 1.02*alpha N-m              ...(ii)\n",
      "#Equating (i) and (ii) 1.02*alpha = 162*theta \n",
      "alphabytheta = 162/1.02\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 1/(2*math.pi)*math.sqrt(alphabytheta)\n",
      "\n",
      "#Results:\n",
      "print \" The Frequency of Oscillation n  =  %.2f Hz.\"%(n)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Frequency of Oscillation n  =  2.01 Hz.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 Page No : 83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "m = 85. \t\t\t#kg\n",
      "h = 0.1 \t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 100./145 \t\t\t#Hz\n",
      "#Calculating the Equivalent Length of Simple Pendulum\n",
      "L = (1/(2*math.pi)/.69*math.sqrt(9.81))**2\n",
      "#Calculating the Radius of Gyration\n",
      "kG = math.sqrt((L-h)*h)\n",
      "#Calculating the Moment of Inertia of the Flywheel through the Centre of Gravity\n",
      "I = m*kG**2 \t\t\t#kg-m**2\n",
      "\n",
      "#Results:\n",
      "print \" The Moment of Inertia of the Flywheel Through its c.g. I  =  %.1f kg-m**2.\"%(I)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Moment of Inertia of the Flywheel Through its c.g. I  =  3.6 kg-m**2.\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 Page No : 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\n",
      "# Variables:\n",
      "m = 60. \t\t\t#kg\n",
      "d1 = 75.\n",
      "d2 = 102. \t\t\t#mm\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequencies of Oscillation\n",
      "n1 = 100./190\n",
      "n2 = 100./165 \t\t\t#Hz\n",
      "\n",
      "#Calculating the Equivalent Lengths of Simple Pendulum\n",
      "L1 = 9.81/(2*math.pi*n1)**2 \t\t\t#m\n",
      "L2 = 9.81/(2*math.pi*n2)**2 \t\t\t#m\n",
      "\n",
      "#Calculating Dismath.tance of c.g. from the Small and Big End Centres (h1 and h2)  and the Radius of Gyration\n",
      "def f(x):\n",
      "    h1 = x[0]\n",
      "    h2 = x[1]\n",
      "    kG = x[2]\n",
      "    y = [0,0,0]\n",
      "    y[0] = L1*h1-h1**2-kG**2\n",
      "    y[1] = L2*h2-h2**2-kG**2\n",
      "    y[2] = h1+h2-1\n",
      "    return y\n",
      "\n",
      "z = fsolve(f,[1,1,1])\n",
      "\n",
      "h1 = z[0]\n",
      "h2 = z[1]\n",
      "kG = z[2]\n",
      "\n",
      "#Calculating the Mass Moment of Inertia of the Rod\n",
      "I = m*kG**2 \t\t\t#kg-m**2\n",
      "\n",
      "#Results:\n",
      "print \" The Moment of Inertia of the Rod I  =  %d kg-m**2.\"%(I)\n",
      "print \" The C.G is at a Distance of h1  =  %.3f m from the Small End Centre.\"%(h1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Moment of Inertia of the Rod I  =  6 kg-m**2.\n",
        " The C.G is at a Distance of h1  =  0.759 m from the Small End Centre.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 Page No : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "l = 1.2 \t\t\t#m\n",
      "theta = 3*math.pi/180 \t\t\t#rad\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Distance Between the Knife Edge and C.G. of the Rod\n",
      "h = 1.2/2-.05 \t\t\t#m\n",
      "#Calculating the Radius of Gyration of the Rod About C.G.\n",
      "kG = l/math.sqrt(12) \t\t\t#m\n",
      "#Calculating the Time of Swing of the Rod\n",
      "tp = 2*math.pi*math.sqrt((kG**2+h**2)/(9.81*h)) \t\t\t#seconds\n",
      "#Calculating the Minimum Time of Swing\n",
      "tpmin = 2*math.pi*math.sqrt((2*kG)/9.81) \t\t\t#seconds\n",
      "#Calculating Angular Velocity\n",
      "omega = 2*math.pi/tp \t\t\t#rad/s\n",
      "#Calculating Maximum Angular Velocity\n",
      "omegamax = omega*theta \t\t\t#rad/s\n",
      "#Calculating Maximum Angular Acceleration\n",
      "alphamax = omega**2*theta \t\t\t#rad/s**2\n",
      "\n",
      "#Results:\n",
      "print \" The Time of Swing of the Rod tp  =  %.2f seconds.\"%(tp)\n",
      "print \" The Minimum Time of Swing tpmin  =  %.2f seconds.\"%(tpmin)\n",
      "print \" The Maximum Angular Velocity omegamax  =  %.4f rad/s.\"%(omegamax)\n",
      "print \" The Maximum Angular Acceleration (alphamax)  =  %.3f rad/s**2.\"%( alphamax)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Time of Swing of the Rod tp  =  1.76 seconds.\n",
        " The Minimum Time of Swing tpmin  =  1.67 seconds.\n",
        " The Maximum Angular Velocity omegamax  =  0.1871 rad/s.\n",
        " The Maximum Angular Acceleration (alphamax)  =  0.669 rad/s**2.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8 Page No : 86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import linalg\n",
      "import math \n",
      "\n",
      "# Variables:\n",
      "m = 30. \t\t\t#kg\n",
      "OG = 1.05           #m\n",
      "h = OG              #m\n",
      "AG = 0.15 \t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 20/43.5 \t\t\t#Hz\n",
      "#Calculating the Equivalent Length of Simple Pendulum\n",
      "L = 9.81/(2*math.pi*n)**2 \t\t\t#m\n",
      "#Calculating the Distance of Centre of Percussion (C) from the Centre of Gravity (G)\n",
      "CG = L-OG \t\t\t#m\n",
      "#Calculating the Distance of Centre of Percussion (C) from the Knife Edge A\n",
      "AC = AG-CG \t\t\t#m\n",
      "#Calculating the Radius of Gyration of the Pendulum About O\n",
      "kO = math.sqrt(L*h) \t\t\t#m\n",
      "h1 = h*(1-math.cos(60*math.pi/180)) \t\t\t#m\n",
      "#Calculating the Angular Velocity of the Pendulum\n",
      "omega = math.sqrt(2*m*9.81*h1/(m*kO**2)) \t\t\t#rad/s\n",
      "OA = OG+AG\n",
      "#Calculating the Velocity of Striking\n",
      "v = omega*(OA) \t\t\t#Velocity of Striking\n",
      "#Calculating the Angular Velocity of the Pendulum Immediately After Impact\n",
      "I = m*kO**2\n",
      "LKE = 55. \t\t\t#Loss of Kinetic Energy N-m\n",
      "omega1 = math.sqrt(omega**2-LKE*2/I)\n",
      "#Calculating the Impulses at Knife Edge A and at Pivot O (P and Q)\n",
      "CLM = m*h*(omega-omega1) \t\t\t#Change of Linear Momentum\n",
      "CAM = m*(kO**2-h**2)*(omega-omega1) \t\t\t#Change of Angular Momentum\n",
      "#P+Q = Change of Linear Momentum and  0.15P-1.05Q = Change of Angular Momentum.\n",
      "#i.e. P+Q = CLM and 0.15P-1.05Q = CAM\n",
      "#Variables Matrix\n",
      "A = [[1, 1],[0.15,-1.05]]\n",
      "B = [CLM, CAM]\n",
      "V = linalg.solve(A,B)\n",
      "P = V[0]\n",
      "Q = V[1]\n",
      "#Calculating the Change in Axis Reaction When the Pendulum is Vertical\n",
      "CAR = m*(omega**2-omega1**2)*h \t\t\t#Change in Axis Reaction, N\n",
      "\n",
      "#Results:\n",
      "print \" The Distance of Centre of Percussion, AC  =  %.3f m.\"%(AC)\n",
      "print \" The Velocity of Striking  =  %.2f m/s.\"%(v)\n",
      "print \" The Impulse at the Knife Edge P  =  %.1f N-s.\"%(P)\n",
      "print \" The Impulse at the Pivot Q  =  %.2f N-s.\"%(Q)\n",
      "print \" The Change in Axis Reaction When the Pendulum is Vertical  =  %d N.\"%(CAR)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Distance of Centre of Percussion, AC  =  0.024 m.\n",
        " The Velocity of Striking  =  3.47 m/s.\n",
        " The Impulse at the Knife Edge P  =  17.6 N-s.\n",
        " The Impulse at the Pivot Q  =  0.37 N-s.\n",
        " The Change in Axis Reaction When the Pendulum is Vertical  =  93 N.\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 Page No : 89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "m = 1.5 \t\t\t#kg\n",
      "l = 1.25            #m\n",
      "x = 120.*10**-3     #m\n",
      "y = x \t\t\t    #m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 20./40 \t\t\t#Hz\n",
      "#Calculating the Radius of Gyration of the Connecting Rod\n",
      "kG = 1/(2*math.pi*n)*math.sqrt(9.81*x*y/l) \t\t\t#m\n",
      "#Calculating the Moment of Inertia of the Connecting Rod\n",
      "I = m*kG**2 \t\t\t#kg-m**2\n",
      "\n",
      "#Results:\n",
      "print \" The Radius of Gyration  kG  =  %d mm.\"%(kG*1000)\n",
      "print \" The Mass Moment of Inertia  I  =  %.3f kg-m**2.\"%(I)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Radius of Gyration  kG  =  107 mm.\n",
        " The Mass Moment of Inertia  I  =  0.017 kg-m**2.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10 Page No : 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "l = 2.5\n",
      "r = 250.*10**-3 \t\t\t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 50./170 \t\t\t#Hz\n",
      "#Calculating the Radius of Gyration of the Wheel\n",
      "kG = r/(2*math.pi*n)*math.sqrt(9.81/l) \t\t\t#m\n",
      "\n",
      "#Results:\n",
      "print \" The Radius of Gyration kG  =  %d mm.\"%(kG*10**3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The Radius of Gyration kG  =  267 mm.\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.11 Page No : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables:\n",
      "m1 = 5.5            #kg\n",
      "m2 = 1.5 \t\t\t#kg\n",
      "l = 1.25            #m\n",
      "r = 125.*10**-3 \t#m\n",
      "\n",
      "#Solution:\n",
      "#Calculating the Frequency of Oscillation\n",
      "n = 10./30 \t\t\t#Hz\n",
      "#Calculating the Radius of Gyration About an Axis Through the c.g.\n",
      "kG = r/(2*math.pi*n)*math.sqrt(9.81/l) \t\t\t#m\n",
      "#Calculating the Mass Moment of Inertia About an Axis Through its c.g.\n",
      "m = m1+m2 \t\t\t#Total Mass  kg\n",
      "I = m*kG**2 \t\t\t#kg-m**2\n",
      "\n",
      "#Results:\n",
      "print \"The Mass Moment of Inertia About an Axis Through its c.g.  I  =  %.3f kg-m**2.\"%(I)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Mass Moment of Inertia About an Axis Through its c.g.  I  =  0.196 kg-m**2.\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}