{ "metadata": { "name": "chapter10.ipynb" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 10: First Moments and Centroids" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-5, Page no 160" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "import numpy as np\n", "\n", "#Initilization of variables\n", "r=50 #mm\n", "L1=75 #mm\n", "L2=pi*r #mm\n", "L3=61.2 #mm\n", "# as theta1=45 degrees & theta2=60 degrees\n", "sintheta1=sqrt(2)**-1\n", "costheta1=sqrt(2)**-1\n", "sintheta2=sqrt(3)*2**-1\n", "costheta2=2**-1\n", "\n", "#Calculations\n", "x_bar=np.array([(L1/2)*costheta1,L1*costheta1+r,L1*costheta1+100+(L3/2)*costheta2]) #mm\n", "y_bar=np.array([(L1/2)*sintheta1,L1*sintheta1+(2*r)/pi,(L3/2)*sintheta2]) #mm\n", "#Centroid Calculations\n", "x=(L1*x_bar[0]+L2*x_bar[1]+L3*x_bar[2])/(L1+L2+L3) #mm\n", "y=(L1*y_bar[0]+L2*y_bar[1]+L3*y_bar[2])/(L1+L2+L3) #mm\n", "\n", "#Result\n", "print'The centroid is as follows:'\n", "print'x=',round(x,1),\"mm\"\n", "print'y=',round(y,1),\"mm\"\n", "\n", "# The answer may wary due to decimal point descrepancy" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The centroid is as follows:\n", "x= 97.0 mm\n", "y= 57.7 mm\n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-6, Page no 160" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Initilization of variables\n", "theta=75 #degrees\n", "theta1=30 #degrees\n", "sintheta=0.96\n", "costheta=0.25\n", "sintheta1=2**-1\n", "costheta1=sqrt(3)*2**-1\n", "alpha=(150*pi)/180 #rad\n", "r=1\n", "lhor=14 #in\n", "\n", "#calculations\n", "a=((2*r)/alpha)*sintheta #in\n", "p=90-theta\n", "sinp=0.259\n", "y=-a*sinp #in\n", "#Length of arc\n", "l=r*alpha #in\n", "#Slope length calculations\n", "DF=7 #in\n", "AB=DF #in\n", "BC=1 #in\n", "BF=BC*costheta1 #in\n", "FC=BC*sintheta1 #in\n", "DC=DF+FC #in\n", "EC=DC/costheta1 #in\n", "#Centroid of EC is at G\n", "yslope=0.5*EC*sintheta1+BF #in\n", "#Y of composite figure\n", "Y=((2*l*y)+14*-1+(2*EC*yslope))/(2*l+lhor+2*EC) #in\n", "\n", "#Result\n", "print'The centroid is at Y=',round(Y,2),\"in\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The centroid is at Y= 1.03 in\n" ] } ], "prompt_number": 13 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-11, Page no 163" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Initilization of variables\n", "a=100 #mm\n", "b=150 #mm\n", "A1=2*10**4 #mm**2\n", "A2=5*10**3 #mm**2\n", "A3=(pi*(a/2)**2)/2 #mm**2\n", "\n", "#Calculations\n", "x=(A1*a+A2*(133.3)-A3*b)/(A1+A2-A3) #mm\n", "y=(A1*a*0.5+A2*(116.66)-A3*((4*a*0.5)/(3*pi)))/(A1+A2-A3) #mm\n", "\n", "#Result\n", "print'The centroidal distances are'\n", "print'x=',round(x,1),\"mm\"\n", "print'y=',round(y,1),\"mm\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The centroidal distances are\n", "x= 98.6 mm\n", "y= 71.2 mm\n" ] } ], "prompt_number": 14 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-16, Page no 166" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Initilization of variables\n", "V=np.array([1728*10**3,432*10**3,7.54*10**3])\n", "x_bar=np.array([60,140,60]) #mm\n", "y_bar=np.array([30,20,30]) #mm\n", "\n", "#Calculations\n", "x=(V[0]*x_bar[0]+V[1]*x_bar[1]+V[2]*x_bar[2])/(V[0]+V[1]+V[2]) #mm\n", "y=(V[0]*y_bar[0]+V[1]*y_bar[1]+V[2]*y_bar[2])/(V[0]+V[1]+V[2]) #mm\n", "z=120 #mm from symmetry\n", "\n", "#Result\n", "print'The centroid is at'\n", "print'x=',round(x,1),\"mm\"\n", "print'y=',round(y,1),\"mm\"\n", "print'z=',round(z,1),\"mm\"\n", "\n", "#Decimal accuracy causes discrepancy in answers\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The centroid is at\n", "x= 75.9 mm\n", "y= 28.0 mm\n", "z= 120.0 mm\n" ] } ], "prompt_number": 17 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-17, Page no 166" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Initilization of variables\n", "# Here tx=30 degrees,ty=45 degrees& tz=60 degrees,, thus\n", "sintx=2**-1\n", "costx=sqrt(3)*2**-1\n", "sinty=sqrt(2)**-1\n", "costy=sqrt(2)**-1\n", "sintz=sqrt(3)*2**-1\n", "costz=2**-1\n", "\n", "#Calculations\n", "V=np.array([10,15,25]) #in**3\n", "x_bar=np.array([4,12,24]) #in\n", "y_bar=np.array([4*costx,-6*costy,-4*costz])\n", "z_bar=np.array([-4*sintx,6*sinty,-4*sintz])\n", "#Centroid calculations\n", "x=(V[0]*x_bar[0]+V[1]*x_bar[1]+V[2]*x_bar[2])/(V[0]+V[1]+V[2]) #in\n", "y=(V[0]*y_bar[0]+V[1]*y_bar[1]+V[2]*y_bar[2])/(V[0]+V[1]+V[2]) #in\n", "z=(V[0]*z_bar[0]+V[1]*z_bar[1]+V[2]*z_bar[2])/(V[0]+V[1]+V[2]) #in\n", "\n", "#Result\n", "print'The centroid of three volumes is at'\n", "print'x=',round(x,1),\"in\"\n", "print'y=',round(y,2),\"in\"\n", "print'z=',round(z,2),\"in\"\n", "\n", "# The ans for x is off by 0.4 in" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The centroid of three volumes is at\n", "x= 16.0 in\n", "y= -1.58 in\n", "z= -0.86 in\n" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-26, Page no 171" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Part a\n", "# Pefer textbook for part a.\n", "\n", "# Part b\n", "\n", "# Initilization of variables\n", "w=150 #lb/ft**2\n", "h=2 #ft height of the load\n", "s=8 #ft span\n", "b=2 #ft\n", "\n", "import math\n", "from scipy.integrate import quad\n", "def integrand(x, a, b):\n", " return x*(150*(x/4)*2)\n", "a=1\n", "b=1\n", "M=quad(integrand, 0, s, args=(a,b))\n", "Rr=M[0]/(2*s) #lb\n", "\n", "# Results\n", "print'The value of M is',round(M[0]),\"lb-ft\"\n", "print'The value of Rr is',round(Rr),\"lb\"\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The value of M is 12800.0 lb-ft\n", "The value of Rr is 800.0 lb\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-27, Page no 172" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Initilization of variables\n", "\n", "rho_m=1000 # kg/m**3\n", "h=0.3 # m height of hole\n", "b=0.6 # m width of hole\n", "\n", "import math\n", "from scipy.integrate import quad\n", "def integrand(y, a, b):\n", " return y*9.8*rho_m*(1.2-y)*(0.6)\n", "a=1\n", "b=1\n", "I=quad(integrand, 0, h, args=(a,b))\n", "B=I[0]/(2*(0.3))\n", "\n", "# Results\n", "print'The value of B is',round(B),\"N\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The value of B is 441.0 N\n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10.10-28, Page no 172" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Initilization of variables\n", "l=62.4 #lb/ft**3\n", "h=12 #ft\n", "f=105 #lb/ft**3\n", "\n", "#Calculations\n", "p1=l*h #lb/ft**2\n", "#Total force on left side\n", "#Simplfying the equation we get a three degree equation in d\n", "#solving for d\n", "p=np.array([3**-1,0,-144,467])\n", "r=roots(p)\n", "d=r[2] #ft\n", "\n", "#Result\n", "print'The value of d is',round(d,2),\"feet\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The value of d is 3.33 feet\n" ] } ], "prompt_number": 24 } ], "metadata": {} } ] }