{
 "metadata": {
  "name": "",
  "signature": "sha256:9192ef8aa28e4e5c3605b5f9963d537f83bd70931cce6349f37ee7655e275acf"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Distrubuted forces centroids and centers of gravity"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1  Page No : 228"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Given Data\n",
      "n = 4; \t\t\t# no of component\n",
      "A = [120*80,120*60/2,math.pi*60*60/2,-math.pi*40*40];\t\t\t#mm**2, Areas of Recmath.tangle, triangle, Semicircle, and Circle respectively\n",
      "x = [60,40,60,60];\t\t\t#mm, x components of centroids of Recmath.tangle, triangle, Semicircle, and Circle respectively\n",
      "y = [40,-20,105.46,80];\t\t\t#mm, y components of centroids of Recmath.tangle, triangle, Semicircle, and Circle respectively\n",
      "\n",
      "sumA = 0;\n",
      "sumxA = 0;\n",
      "sumyA = 0;\n",
      "\n",
      "# Calculations and Results\n",
      "for i in range(n):\n",
      "    sumA = sumA+A[i];\n",
      "    sumxA = sumxA+x[i]*A[i];\n",
      "    sumyA = sumyA+y[i]*A[i];\n",
      "\n",
      "# First Moment of area\n",
      "Qx = sumyA;\t\t\t# About X axis\n",
      "Qy = sumxA;\t\t\t#About Yaxis\n",
      "print \"First moments of the area are Qx =  %.0f mm**3 and Qy = %.0f mm**3 \"%(Qx,Qy);\n",
      "\n",
      "#Location of centroid\n",
      "X = sumxA/sumA;\t\t\t# X co-ordinate\n",
      "Y = sumyA/sumA;\t\t\t# Y co = ordinate\n",
      "print \"Co-ordinates of centroid are X =  %.1f mm and Y =  %.1f mm \"%(X,Y);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "First moments of the area are Qx =  506238 mm**3 and Qy = 757699 mm**3 \n",
        "Co-ordinates of centroid are X =  54.8 mm and Y =  36.6 mm \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2  Page No : 229"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Given Data\n",
      "n = 3; \t\t\t# no of segment\n",
      "L = [600,650,250];\t\t\t#mm, Lengths of segment AB , BC and CA respectively\n",
      "x = [300,300,0];\t\t\t#mm, x components of centroids of segment AB , BC and CA respectively\n",
      "y = [0,125,125];\t\t\t#mm, y components of centroids of segment AB , BC and CA respectively\n",
      "\n",
      "sumL = 0;\n",
      "sumxL = 0;\n",
      "sumyL = 0;\n",
      "\n",
      "# Calculations\n",
      "for i in range(n):\n",
      "    sumL = sumL+L[i];\n",
      "    sumxL = sumxL+x[i]*L[i];\n",
      "    sumyL = sumyL+y[i]*L[i];\n",
      "\n",
      "#Location of centre of gravity\n",
      "X = sumxL/sumL;\t\t\t# X co-ordinate\n",
      "Y = sumyL/sumL;\t\t\t# Y co = ordinate\n",
      "\n",
      "# Results\n",
      "print \"Co-ordinates of centroid are X =  %.0f mm and Y =  %.0f mm \"%(X,Y);\n",
      "#There is variation because of roundoff"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Co-ordinates of centroid are X =  250 mm and Y =  75 mm \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7  Page No : 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Given Data\n",
      "p = 7850.;\t\t\t#kg/m**3, density of steel rim\n",
      "n = 2; \t\t\t# no of component\n",
      "A = [(20+60+20)*(30+20),-60*30];\t\t\t#mm**2,Cross section Areas of recmath.tangle I and II\n",
      "\n",
      "y = [375,365];\t\t\t#mm, y components of centroids of Recmath.tangles I and II respectively\n",
      "sumV = 0;\n",
      "\n",
      "C = [0,0]\n",
      "V = [0,0]\n",
      "# Calculations\n",
      "for i in range(n):\n",
      "    C[i] = 2*math.pi*y[i];\t\t\t#mm, Dismath.tance travelled by C\n",
      "    V[i] = A[i]*C[i];\t\t\t#mm**3, Volume of 1 component\n",
      "    sumV = sumV+V[i];\t\t\t# mm**3, Total volume of rim\n",
      "\n",
      "sumV = sumV*10**(-9);\t\t\t#Conversion into m**3\n",
      "g = 9.81;\t\t\t#m/s**2, acceleration due to gravity\n",
      "m = p*sumV;\t\t\t#kg, mass\n",
      "W = m*g;\t\t\t#N, Weight\n",
      "\n",
      "# Results\n",
      "print \"mass of steel is m =  %.0f kg and Wight is W =  %.0f N\"%(m,W);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass of steel is m =  60 kg and Wight is W =  589 N\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.9  Page No : 250"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data\n",
      "n = 2; \t\t\t# no of triangle\n",
      "A = [4.5,13.5];\t\t\t#kN, loads\n",
      "x = [2.,4.];\t\t\t#mm, dismath.tances of centroid from point A\n",
      "\n",
      "# Calculations and Results\n",
      "sumA = 0;\n",
      "sumxA = 0;\n",
      "for i in range(n):\n",
      "    sumA = sumA+A[i];\n",
      "    sumxA = sumxA+x[i]*A[i];\n",
      "\n",
      "#Location of centroid\n",
      "X = sumxA/sumA;\t\t\t# X co-ordinate\n",
      "W = sumA;\t\t\t#kN, Concentrated load\n",
      "print \"The equivalent concentrated mass is W =  %.0f kN and its line of action is located at a\\\n",
      "\\n distance X =  %.1f m to the right of A \"%(W,X);\n",
      "\n",
      "# Reactions\n",
      "# Applying sum(F_x) = 0\n",
      "Bx = 0.;\t\t\t#N\n",
      "#Applying sum(M_A) = 0\n",
      "By = W*X/6.;\t\t\t#kN, Reaction at B in Y direction\n",
      "#Applying sum(M_B) = 0\n",
      "A = W*(6-X)/6;\t\t\t#kN, Reaction at B in Y direction\n",
      "\n",
      "print \"The rection at A = %.1f kN, At Bx = %.1f kN and By = %.1f kN \"%(A,Bx,By);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equivalent concentrated mass is W =  18 kN and its line of action is located at a\n",
        " distance X =  3.5 m to the right of A \n",
        "The rection at A = 7.5 kN, At Bx = 0.0 kN and By = 10.5 kN \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.10  Page No : 251"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given Data\n",
      "t = 0.3;\t\t\t#m thickness of dam\n",
      "g = 9.81;\t\t\t# m/s**2, acceleration due to gravity\n",
      "p1 = 2400.;\t\t\t#kg/m**3, density of concrete\n",
      "p2 = 1000.;\t\t\t#kg/m**3, density of water\n",
      "W1 = 0.5*2.7*6.6*t*p1*g/1000;\t\t\t#kN, Weight of concrete component 1\n",
      "W2 = 1.5*6.6*t*p1*g/1000;\t\t\t#kN, Weight of concrete component 2\n",
      "W3 = 1./3*3*5.4*t*p1*g/1000;\t\t\t#kN, Weight of concrete component 3\n",
      "W4 = 2./3*3*5.4*t*p2*g/1000;\t\t\t#kN, Weight of water\n",
      "P = 0.5*2.7*6.6*t*p1*g/1000;\t\t\t#kN, pressure force exerted by water\n",
      "\n",
      "# Calculations and Results\n",
      "# Applying sum(F_x) = 0\n",
      "H = 42.9;\t\t\t#kN, Horizontal reation at A\n",
      "#Applying sum(Fy) = 0\n",
      "V = W1+W2+W3+W4;\t\t\t#kN, Vertical Reaction at A \n",
      "print \"The horizontal reaction is H = %.1f kN \\\n",
      "\\nVertical rection at A V = %.1f kN \"%(H,V);\n",
      "#Applying sum(M_A) = 0\n",
      "M = W1*1.8+W2*3.45+W3*5.1+W4*6-P*1.8;\t\t\t#kN.m, Moment at A\n",
      "\n",
      "# We can replace force couple system by math.single force acting at dismath.tance right to A\n",
      "d = M/V;\t\t\t# m Dismath.tance of resultant force from A\n",
      "\n",
      "print \"The moment about A is M = %.1f kN.m anticlockwise and  \\\n",
      "\\nif we replace it by force couple system resultant, s distance from A is d =  %0.2f m  \"%(M,d);\n",
      "#Difference is because of round off"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The horizontal reaction is H = 42.9 kN \n",
        "Vertical rection at A V = 202.8 kN \n",
        "The moment about A is M = 626.5 kN.m anticlockwise and  \n",
        "if we replace it by force couple system resultant, s distance from A is d =  3.09 m  \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.11  Page No : 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Given Data\n",
      "n = 3; \t\t\t# no of component\n",
      "r = 60.;\t\t\t#mm, radius\n",
      "l = 100.;\t\t\t#mm length of cylinder\n",
      "V = [0.5*4./3*math.pi*(r)**3,math.pi*r*r*l,-math.pi/3*r*r*l];\t\t\t#mm**3, Volumes of Hemisphere, cylinder and cone respectively\n",
      "x = [-3./8*r,l/2.,3./4*l];\t\t\t#mm, x components of centroids of Hemisphere, cylinder and cone respectively\n",
      "\n",
      "sumV = 0;\n",
      "sumxV = 0;\n",
      "\n",
      "# Calculations\n",
      "for i in range(n):\n",
      "    sumV = sumV+V[i];\n",
      "    sumxV = sumxV+x[i]*V[i];\n",
      "\n",
      "#Location of centre of gravity\n",
      "X = sumxV/sumV;\t\t\t# X co-ordinate\n",
      "\n",
      "# Results\n",
      "print \"Co-ordinates of centroid are X =  %.0f mm \"%(X);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Co-ordinates of centroid are X =  15 mm \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.12  Page No : 264"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Given Data\n",
      "l = 4.5; \t\t\t# in in\n",
      "b = 2.;\t\t\t#in\n",
      "h = .5;\t\t\t#in\n",
      "a_I = l*b*h\n",
      "a_II = ((1./4)*math.pi*b**2*h)\n",
      "a_III = -math.pi*(h**2)*h\n",
      "a_IV = -math.pi*(h**2)*h\n",
      "V = [a_I, a_II, a_III, a_IV]\n",
      "#print (V)\n",
      "\n",
      "x = [.25,1.3488,.25,.25];\t\t\t#in, x components of centroids of part I,II , III and IV respectively\n",
      "y = [-1,-0.8488,-1,-1];\t\t\t#in, y components of centroids of part I,II , III and IV respectively\n",
      "z = [2.25,0.25,3.5,1.5];\t\t\t#in, z components of centroids of part I,II , III and IV respectively\n",
      "\n",
      "# Calculations and Results\n",
      "y = [0,0,0,0]\n",
      "for i in range(4):\n",
      "    temp = 0\n",
      "    sum_xV = 0\n",
      "    sum_xV = V[i]*x[i]\n",
      "    y[i] = sum_xV\n",
      "\n",
      "x = sum(y)\n",
      "print \"The sum of x*V = %f  in**4 \"%(x)\n",
      "\n",
      "for i in range(4):\n",
      "    temp = 0\n",
      "    sum_zV = 0\n",
      "    sum_zV = V[i]*z[i]\n",
      "    y[i] = sum_zV\n",
      "\n",
      "z = sum(y)\n",
      "print \"The sum of z*V = %f  in**4 \"%(z)\n",
      "\n",
      "for i in range(4):\n",
      "    temp = 0\n",
      "    sum_yV = 0\n",
      "    sum_yV = V[i]*y[i]\n",
      "    y[i] = sum_yV\n",
      "\n",
      "s = sum(y)\n",
      "print \"The sum of y*V = %f  in**4 \"%(s)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The sum of x*V = 3.047341  in**4 \n",
        "The sum of z*V = 8.554204  in**4 \n",
        "The sum of y*V = 46.950413  in**4 \n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}