{
 "metadata": {
  "name": "chapter21.ipynb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 21: Kinematics Of Rigid Body"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-1,Page No:536"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "N=1800 # r.p.m # Speed of the shaft\n",
      "t=5 # seconds # time taken to attain the rated speed # case (a)\n",
      "T=90 # seconds # time taken by the unit to come to rest # case (b)\n",
      "pi=3.14 # constant\n",
      "\n",
      "# Calculations\n",
      "\n",
      "omega=(2*pi*N)/(60)\n",
      "\n",
      "# (a)\n",
      "# we take alpha_1,theta_1 & n_1 for case (a)\n",
      "alpha_1=omega/t # rad/s^2 #\n",
      "theta_1=(omega**2)/(2*alpha_1) # radian\n",
      "# Let n_1 be the number of revolutions turned,\n",
      "n_1=theta_1*(1/(2*pi))\n",
      "\n",
      "# (b)\n",
      "# similarly we take alpha_1,theta_1 & n_1 for case (b)\n",
      "alpha_2=(omega/T) # rad/s^2 # However here alpha_2 is -ve\n",
      "theta_2=(omega**2)/(2*alpha_2) # radians\n",
      "# Let n_2 be the number of revolutions turned,\n",
      "n_2=theta_2*(1/(2*pi))\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"(a) The no of revolutions the unit turns to attain the rated speed is \",round(n_1)\n",
      "print\"(b) The no of revolutions the unit turns to come to rest is \",round(n_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The no of revolutions the unit turns to attain the rated speed is  75.0\n",
        "(b) The no of revolutions the unit turns to come to rest is  1350.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-2,Page No:540"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "r=1 # m # radius of the cylinder\n",
      "v_c=20 # m/s # velocity of the cylinder at its centre\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# The velocity of point E is given by using the triangle law as,\n",
      "v_e=(2)**0.5*v_c # m/s \n",
      "\n",
      "# Similarly the velocity at point F is given as,\n",
      "v_f=2*v_c # m/s \n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The velocity of point E is \",round(v_e,2),\"m/s\"\n",
      "print\"The velocity of point F is \",round(v_f),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of point E is  28.28 m/s\n",
        "The velocity of point F is  40.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-3,Page No:541"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of Variables\n",
      "\n",
      "v_1=3 # m/s # uniform speed of the belt at top\n",
      "v_2=2 # m/s # uniform speed of the belt at the bottom\n",
      "r=0.4 # m # radius of the roller\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# equating eq'ns 2 & 4 and solving for v_c & theta' (angular velocity). We use matrix to solve the eqn's\n",
      "A=[1 r;1 -r]\n",
      "B=[v_1;v_2]\n",
      "C=inv(A)*B\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The linear velocity (v_c) at point C is \",round(C(1)),\"m/s\"\n",
      "print\"The angular velocity at point C is \" round(C(2)),\"radian/second\"\n",
      "# NOTE: The answer of angular velocity is incorrect in the book\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "SyntaxError",
       "evalue": "invalid syntax (<ipython-input-4-f6df08d07dba>, line 12)",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-4-f6df08d07dba>\"\u001b[1;36m, line \u001b[1;32m12\u001b[0m\n\u001b[1;33m    A=[1 r;1 -r]\u001b[0m\n\u001b[1;37m         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-4,Page No:542"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of Variables\n",
      "\n",
      "l=1 # m # length of bar AB\n",
      "v_a=5 # m/s # velocity of A\n",
      "theta=30 # degree # angle made by the bar with the horizontal\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# From the vector diagram linear velocity of end B is given as,\n",
      "v_b=v_a/tan(theta*(pi/180)) # m/s \n",
      "\n",
      "# Now let the relative velocity be v_ba which is given as,\n",
      "v_ba=v_a/sin(theta*(pi/180)) # m/s\n",
      "\n",
      "# Now let the angular velocity of the bar be theta_a which is given as,\n",
      "theta_a=(v_ba)/l # radian/second\n",
      "\n",
      "# Velocity of point A\n",
      "v_a=(0.5)*theta_a # m/s\n",
      "\n",
      "# Magnitude of velocity at point C is,\n",
      "v_c=v_a # m/s # from the vector diagram\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"(a) The angular velocity of the bar is \",round(theta_a),\"radian/second\"\n",
      "print\"(b) The velocity of end B is \",round(v_b,2),\"m/s\"\n",
      "print\"(c) The velocity of mid point C is \",round(v_c),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The angular velocity of the bar is  10.0 radian/second\n",
        "(b) The velocity of end B is  8.67 m/s\n",
        "(c) The velocity of mid point C is  5.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-5,Page No:544"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of Variables\n",
      "\n",
      "r=0.12 # m # length of the crank\n",
      "l=0.6 # m # length of the connecting rod\n",
      "N=300 # r.p.m # angular velocity of the crank\n",
      "theta=30 # degree # angle made by the crank with the horizontal\n",
      "pi=3.14\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# Now let the angle between the connecting rod and the horizontal rod be phi\n",
      "phi=arcsin(r*sin(theta*(pi/180))/(l))*(180/pi) # degree\n",
      "\n",
      "# Now let the angular velocity of crank OA be omega_oa, which is given by eq'n\n",
      "omega_oa=(2*pi*N)/(60) # radian/second\n",
      "\n",
      "# Linear velocity at A is given as,\n",
      "v_a=r*omega_oa # m/s\n",
      "\n",
      "# Now using the sine rule linear velocity at B can be given as,\n",
      "v_b=v_a*sin(35.7*(pi/180))/sin(84.3*(pi/180)) # m/s\n",
      "\n",
      "# Similarly the relative velocity (assume v_ba) is given as,\n",
      "v_ba=v_a*sin(60*(pi/180))/sin(84.3*(pi/180))\n",
      "\n",
      "# Angular velocity (omega_ab) is given as,\n",
      "omega_ab=v_ba/l # radian/second\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"(a) The angular velocity of the connecting rod is \",round(omega_ab,2),\"radian/second\"\n",
      "print\"(b) The velocity of the piston when the crank makes an angle of 30 degree is \",round(v_b,2),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) The angular velocity of the connecting rod is  5.46 radian/second\n",
        "(b) The velocity of the piston when the crank makes an angle of 30 degree is  2.21 m/s\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-6,Page No:548"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initiization of variables\n",
      "\n",
      "r=1 # m # radius of the cylinder\n",
      "v_c=20 # m/s # velocity at the centre\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# Angular velocity is given as,\n",
      "omega=v_c/r # radian/second\n",
      "\n",
      "# Velocity at point D is\n",
      "v_d=omega*(2)**0.5*r # m/s # from eq'n 1\n",
      "\n",
      "# Now, the velocity at point E is,\n",
      "v_e=omega*2*r # m/s \n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The velocity at point D is \",round(v_d,2),\"m/s\"\n",
      "print\"The velocity at point E is \",round(v_e),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at point D is  28.28 m/s\n",
        "The velocity at point E is  40.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-7,Page No:548"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of Variables\n",
      "\n",
      "r=5 # cm # radius of the roller\n",
      "AB=0.1 # m\n",
      "v_a=3 # m/s # velocity at A\n",
      "v_b=2 # m/s # velocity at B\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# Solving eqn's 1 & 2 using matrix for IA & IB we get,\n",
      "A=[-2 3;1 1]\n",
      "B=[0;AB]\n",
      "C=inv(A)*B\n",
      "d1=C(2)*10**2 # cm # assume d1 for case 1\n",
      "\n",
      "# Similary solving eqn's 3 & 4 again for IA & IB we get,\n",
      "P=[-v_b v_a;1 -1]\n",
      "Q=[0;AB]\n",
      "R=inv(P)*Q\n",
      "d2=R(2)*10**2 # cm # assume d2 for case 2\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The distance d when the bars move in the opposite directions are \",round(d1),\"cm\"\n",
      "print\"The distance d when the bars move in the same directions are \",round(d2),\"cm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "SyntaxError",
       "evalue": "invalid syntax (<ipython-input-21-6e389b1a0870>, line 13)",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-21-6e389b1a0870>\"\u001b[1;36m, line \u001b[1;32m13\u001b[0m\n\u001b[1;33m    A=[-2 3;1 1]\u001b[0m\n\u001b[1;37m          ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-8,Page No:550"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of Variables\n",
      "\n",
      "v_c=1 # m/s # velocity t the centre\n",
      "r1=0.1 # m \n",
      "r2=0.20 # m\n",
      "EB=0.1 # m\n",
      "EA=0.3 # m\n",
      "ED=(r1**2+r2**2)**0.5 # m\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# angular velocity is given as,\n",
      "omega=v_c/r1 # radian/seconds\n",
      "\n",
      "# Velocit at point B\n",
      "v_b=omega*EB # m/s \n",
      "\n",
      "# Velocity at point A\n",
      "v_a=omega*EA # m/s\n",
      "\n",
      "# Velocity at point D\n",
      "v_d=omega*ED # m/s\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The velocity at point A is \",round(v_a),\"m/s\"\n",
      "print\"The velocity at point B is \",round(v_b),\"m/s\"\n",
      "print\"The velocity at point D is \",round(v_d,2),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at point A is  3.0 m/s\n",
        "The velocity at point B is  1.0 m/s\n",
        "The velocity at point D is  2.24 m/s\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-9,Page No:551"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "l=1 # m # length of bar AB\n",
      "v_a=5 # m/s # velocity at A\n",
      "theta=30 # degree # angle made by the bar with the horizontal\n",
      "\n",
      "# Calculations\n",
      "\n",
      "IA=l*sin(theta*(pi/180)) # m\n",
      "IB=l*cos(theta*(pi/180)) # m\n",
      "IC=0.5 # m # from triangle IAC\n",
      "\n",
      "# Angular veocity is given as,\n",
      "omega=v_a/(IA) # radian/second\n",
      "v_b=omega*IB # m/s\n",
      "v_c=omega*IC # m/s\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The velocity at point B is \",round(v_b,2),\"m/s\"\n",
      "print\"The velocity at point C is \",round(v_c),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at point B is  8.67 m/s\n",
        "The velocity at point C is  5.0 m/s\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-11,Page No:552"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "v_a=2 # m/s # velocity at end A\n",
      "r=0.05 # m # radius of the disc\n",
      "alpha=30 # degree # angle made by the bar with the horizontal\n",
      "\n",
      "# Calculations \n",
      "\n",
      "# Soving eqn's 1 & 2 and substuting eqn 1 in it we get eq'n for omega as,\n",
      "omega=(v_a*(sin(alpha*(pi/180)))**2)/(r*cos(alpha*(pi/180))) # radian/second\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The anguar veocity of the bar is \",round(omega,2),\"radian/second\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The anguar veocity of the bar is  11.53 radian/second\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-12,Page No:553"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "l=0.6 # m \n",
      "r=0.12 # m \n",
      "theta=30 # degree # angle made by OA with the horizontal\n",
      "phi=5.7 # degree # from EX 21.5\n",
      "N=300\n",
      "pi=3.14\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# Let the angular velocity of the connecting rod be (omega_ab) which is given from eqn's 1 & 4 as,\n",
      "omega_oa=(2*pi*N)/(60) # radian/ second\n",
      "\n",
      "# Now,in triangle IBO.\n",
      "IB=(l*cos(phi*(pi/180))*tan(theta*(pi/180)))+(r*sin(theta*(pi/180))) # m\n",
      "IA=(l*cos(phi*(pi/180)))/(cos(theta*(pi/180))) # m\n",
      "\n",
      "# from eq'n 5\n",
      "v_b=(r*omega_oa*IB)/(IA) # m/s\n",
      "\n",
      "# From eq'n 6\n",
      "omega_ab=(r*omega_oa)/(IA) # radian/second\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The velocity at B is \",round(v_b,2),\"m/s\"\n",
      "print\"The angular velocity of the connecting rod is \",round(omega_ab,2),\"radian/second\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at B is  2.21 m/s\n",
        "The angular velocity of the connecting rod is  5.47 radian/second\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 21.21-13,Page No:555"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Initilization of variables\n",
      "\n",
      "omega_ab=5 # rad/s # angular veocity of the bar\n",
      "AB=0.20 # m\n",
      "BC=0.15 # m\n",
      "CD=0.3 # m\n",
      "theta=30 # degree # where theta= angle made by AB with the horizontal\n",
      "alpha=60 # degree # where alpha=angle made by CD with the horizontal\n",
      "\n",
      "# Calculations\n",
      "\n",
      "# Consider triangle BIC\n",
      "IB=sin(alpha*(pi/180))*BC*1 # m\n",
      "IC=sin(theta*(pi/180))*BC*1 # m\n",
      "v_b=omega_ab*AB # m/s\n",
      "\n",
      "# let the angular velocity of the bar BC be omega_bc\n",
      "omega_bc=v_b/IB # radian/second\n",
      "v_c=omega_bc*IC # m/s\n",
      "\n",
      "# let the angular velocity of bar DC be omega_dc\n",
      "omega_dc=v_c/CD # radian/second\n",
      "\n",
      "# Results\n",
      "\n",
      "print\"The angular velocity of bar BC is \",round(omega_bc,3),\"rad/s\"\n",
      "print\"The angular velocity of bar CD is \",round(omega_dc,2),\"rad/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The angular velocity of bar BC is  7.7 rad/s\n",
        "The angular velocity of bar CD is  1.92 rad/s\n"
       ]
      }
     ],
     "prompt_number": 34
    }
   ],
   "metadata": {}
  }
 ]
}