{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 1: Introduction—Concept of Stress\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 1.1, Page number 18 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Shearing Stress in Pin A = 6790.6 psi\n",
      "Case(b): Shearing Stress in Pin C = 7639 psi\n",
      "Case(c): Largest Normal Stress in Link ABC = 2286 psi\n",
      "Case(d): Average Shearing Stress at B = 171 psi\n",
      "Case(e): Bearing Stress in Link at C = 6000 psi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "Fac = 750                             #Force on rod AC(lb)\n",
    "D = 0.375                             #Diameter at the upper junction of rod ABC(in)\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "#Case(a)\n",
    "A=(1/4)*((math.pi)*pow(D,2))          #Area at the upper junction of rod ABC(in^2) \n",
    "tA=(Fac/A)                            #Shearing Stress in Pin A(psi)   \n",
    "#Case(b) \n",
    "Ab=(1/4)*((math.pi)*pow(0.25,2))      #Area at the lower junction of rod ABC(in^2)\n",
    "tC=(((1/2)*Fac)/Ab)                   #Shearing Stress in Pin C(psi)\n",
    "#Case(c)\n",
    "Anet=(3/8)*(1.25-0.375)               #Area of cross section at A(in^2)\n",
    "sA=(Fac/Anet)                         #Largest Normal Stress in Link ABC(psi)\n",
    "#Case(d)\n",
    "F1=750/2                              #Force on each side(lb)\n",
    "Ad=(1.25*1.75)                        #Area at junction B(in^2)\n",
    "tB=(F1/Ad)                            #Average Shearing Stress at B\n",
    "#Case(e)\n",
    "Ae=0.25*0.25                          #Area at point C(in^2)\n",
    "sB=(F1/Ae)                            #Bearing Stress in Link at C\n",
    "\n",
    "\n",
    "#Result\n",
    "print('Case(a): Shearing Stress in Pin A = %.1f psi' %tA)\n",
    "print('Case(b): Shearing Stress in Pin C = %.f psi' %tC)\n",
    "print('Case(c): Largest Normal Stress in Link ABC = %.f psi' %sA)\n",
    "print('Case(d): Average Shearing Stress at B = %.f psi' %tB)\n",
    "print('Case(e): Bearing Stress in Link at C = %.f psi' %sB)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 1.2, Page number 19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Diameter of the bolt = 28 mm\n",
      "Case(a): Dimension b at Each End of the Bar = 62 mm\n",
      "Case(a): Dimension h of the Bar = 34.300000 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "P = 120                                             #Maximum allowable tension force \n",
    "s = 175                                             #Maximum allowable stress\n",
    "t = 100                                             #Maximum allowable stress\n",
    "Sb = 350                                            #Maximum allowable stress\n",
    "\n",
    "\n",
    "#Calculation\n",
    "#Case(a)\n",
    "F1=P/2         #Current(A)\n",
    "d=math.sqrt(((P/2)*1000)/((22/(4*7))*(100000000)))  #Diameter of bolt(m)\n",
    "d=d*1000                                            #Diameter of bolt(mm)\n",
    "d=round(d,0)                                        #Rounding of the value of diameter of bolt(mm)\n",
    "Ad=(0.020*0.028)                                    #Area of cross section of plate                                    \n",
    "tb=((P*1000)/Ad)/(1000000)                          #Stress between between the 20-mm-thick plate and the 28-mm-diameter bolt\n",
    "tb=round(tb,0)                                      #Rounding of the above calculated stress to check if it is less than 350\n",
    "a=(P/2)/((0.02)*(175))                              #Dimension of cross section of ring \n",
    "a=round(a,2)                                        #Rounding dimension of cross section of ring to two decimal places\n",
    "b=28 + (2*(a))                                      #Dimension b at Each End of the Bar\n",
    "b=round(b,2)                                        #Rounding the dimension b to two decimal places \n",
    "h=(P)/((0.020)*(175))                               #Dimension h of the Bar\n",
    "h=round(h,1)                                        #Rounding dimension h of bar to 1 decimal place\n",
    "\n",
    "\n",
    "#Result\n",
    "print ('Case(a): Diameter of the bolt = %.f mm' %d)\n",
    "print ('Case(a): Dimension b at Each End of the Bar = %.f mm' %b)\n",
    "print ('Case(a): Dimension h of the Bar = %f mm' %h)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Example 1.3, Page number 34"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Diameter of the bolt =  16.730000 mm\n",
      "Case(a): Dimension b at Each End of the Bar =  22.000000 mm\n",
      "Case(a): Dimension h of the Bar =  6.000000 mm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "Su = 600    #ultimate normal stress(MPa)   \n",
    "FS = 3.3    #Factor of safety with respect to failure\n",
    "tU=350      #Ultimate shearing stress(MPa)\n",
    "Cx=40       #X Component of reaction at C(kN)\n",
    "Cy=65       #Y Component of reaction at C(kN)\n",
    "Smax=300    #Allowable bearing stress of the steel \n",
    "\n",
    "#Calculation\n",
    "C=math.sqrt((math.pow(40,2))+(math.pow(65,2)))\n",
    "\n",
    "#Case(a)\n",
    "P=(15*0.6 + 50*0.3)/(0.6)  #Allowable bearing stress of the steel(MPa)\n",
    "Sall=(Su/FS)               #Allowable Stress(MPa)\n",
    "Sall=round(Sall,1)         #Rounding Allowable stress to 1 decimal place(MPa)\n",
    "Areqa=(P/(Sall*(1000)))    #Cross Sectional area(m^2)\n",
    "Areqa=round(Areqa,5)       #Rounding cross sectional area to 5 decimal places(m^2)\n",
    "dAB=math.sqrt(((Areqa)*(4))/(22/7)) #Diameter of AB(m)\n",
    "dAB=dAB*1000                        #Diameter of AB(mm)\n",
    "dAB=round(dAB,2)                    #Rounding Diameter of AB(mm)\n",
    "\n",
    "#Case(b)\n",
    "tALL=tU/FS                          #Stress(MPa)\n",
    "tALL=round(tALL,1)                  #Rounding of Stress\n",
    "AreqC=((C/2)/tALL)                  #Cross sectional area(m^2)\n",
    "AreqC=AreqC*1000                    \n",
    "AreqC=round(AreqC,0)                #Rounding the cross sectional area\n",
    "dC=math.sqrt((4*AreqC)/(22/7))      #Diameter at point C\n",
    "dC=round((dC+1),0)                  #Rounding of the diameter at C\n",
    "\n",
    "#Case(c)\n",
    "\n",
    "Areq=((C/2)/Smax)                   \n",
    "Areq=Areq*1000                      #Cross sectional area(mm^2)\n",
    "t=(Areq/22)                         #Thickness of the bracket\n",
    "t=round(t,0)\n",
    "\n",
    "#Result\n",
    "print ('Case(a): Diameter of the bolt = % f mm' %dAB)\n",
    "print ('Case(a): Dimension b at Each End of the Bar = % f mm' %dC)\n",
    "print ('Case(a): Dimension h of the Bar = % f mm' %t)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Example 1.4, Page number 35"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Control Rod  =  5.263672 kips\n",
      "Case(b): Bolt at B =  5.156250 kips\n",
      "Case(c): Bolt at D =  6.865179 kips\n",
      "Case(d): Bolt at C =  5.238095 kips\n",
      "Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:=  5.156250 kips\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "tU=40                                     #ultimate tensile stress\n",
    "sU=60                                     #ultimate shearing stress\n",
    "FS=3                                      #Mimnimum factor of safety\n",
    "dA=(7/16)                                 #Diameter of bolt at A(in)\n",
    "dB=3/8                                    #Diameter of bolt at B(in) \n",
    "dD=3/8                                    #Diameter of bolt at D(in)\n",
    "dC=1/2                                    #Diameter of bolt at C(in)\n",
    "\n",
    "\n",
    "#Calculation\n",
    "Sall=(sU/FS)                              #Total tensile stress(kips)\n",
    "B=Sall*((1/4)*(22/7)*(pow((7/16),2)))     #Allowable force in the control rod(kips)\n",
    "C1=1.75*(B)                               #Control Rod(kips)\n",
    "tall=(tU/FS)                              #Total shearing stress\n",
    "B=2*(tall*(1/4)*(22/7)*(3/8)*(3/8))       #Allowable magnitude of the force B exerted on the bolt\n",
    "C2=1.75*B                                 #Bolt at B(kips)                       \n",
    "D=B                                       #Bolt at D. Since this bolt is the same as bolt B, the allowable force is same(kips) \n",
    "C3=2.33*D                                 #Bolt at D(kips)\n",
    "C4=2*(tall*(1/4)*(22/7)*(1/2)*(1/2))      #Bolt at C(kips)      \n",
    "list1=[C1,C2,C3,C4]                       #Adding all the maximum allowable forces on C(kips) \n",
    "\n",
    "\n",
    "#Result\n",
    "print ('Case(a): Control Rod  = % f kips' %C1)\n",
    "print ('Case(b): Bolt at B = % f kips' %C2)\n",
    "print ('Case(c): Bolt at D = % f kips' %C3)\n",
    "print ('Case(d): Bolt at C = % f kips' %C4)\n",
    "print ('Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:= % f kips' %min(list1));"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}