{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6 : Shearing Stresses in Beams and Thin-Walled Members"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.01, Page number 386"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shearing force in each nail is = 92.592593 N\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "#Variable declaration\n",
    "l=0.020                                                                           # Length(m)\n",
    "b=0.100                                                                           # Breadth(m)\n",
    "V=500                                                                             # Vertical shear(N)\n",
    "y=0.060                                                                           # Distance(m)\n",
    "\n",
    "#Calculation         \n",
    "A=l*b                                                                             # Area(m**2)\n",
    "Q=A*y                                                                             # First moment of an area with respect to a given axis\n",
    "I=(1/12.0)*(0.020)*(0.1**3) + 2*((1/12.0)*(0.1)*(0.02**3) + (0.020*0.1)*(0.06**2))    # Moment of inertia(m**4)    \n",
    "q=(V*Q)/(I)                                                                       \n",
    "F=(0.025)*q                                                                       # Shearing force in each nail(N)\n",
    "\n",
    "# Result\n",
    "print ('Shearing force in each nail is = %lf N' %F)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.02, Page number 389"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum shearing stress in a narrow rectangular beam = 0.132548 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "#Variable declaration\n",
    "Vmax=4.50                                                                           # Force maximum(kips)\n",
    "b=3.5                                                                               # Actual width of beam(in)\n",
    "h=14.55                                                                             # Depth(in)\n",
    "\n",
    "#Calculation         \n",
    "Tmax=(3/2.0)*(Vmax/(b*h))                                                             # Maximum shearing stress(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Maximum shearing stress in a narrow rectangular beam = %lf ksi' %Tmax)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.03, Page number 389"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum allowable shearing stress for steel beam = 28.653295 MPa\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "#Variable declaration\n",
    "tw=5.8                                                     # Distance(mm)\n",
    "d=349                                                      # Distance(mm)\n",
    "Vmax=58                                                    # Force(kN)\n",
    "\n",
    "#Calculation         \n",
    "Aweb=d*tw                                                  # Area(mm*2)\n",
    "Tmax=(Vmax/Aweb)*(1000)                                    # Maximum shearing stress(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Maximum allowable shearing stress for steel beam = %lf MPa' %Tmax)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.1, Page number 392"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shearing stress in joint a = 725.000000 kPa\n",
      "Shearing stress in joint b = 608.000000 kPa\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "A=B=1.5                                                                       # Force(kN)\n",
    "V=1.5                                                                         # Force(kN)\n",
    "y1=0.0417                                                                     # Distance(m)\n",
    "y2=0.0583                                                                     # Distance(m)\n",
    "AreaA=0.100*0.020                                                             # Area(m**2)\n",
    "AreaB=0.060*0.020                                                             # Area(m**2)\n",
    "I=8.63*(pow(10,-6))                                                           # Moment of inertia(m**2) \n",
    "t=0.020                                                                       # Distance(m)\n",
    "\n",
    "#Calculation         \n",
    "#Shearing Stress in Joint a\n",
    "Qa=AreaA*y1                                                                   \n",
    "taweA=round((V*Qa)/(I*t),0)                                                   # Shearing stress in joint a(kPa)\n",
    "\n",
    "#Shearing Stress in Joint b\n",
    "Qb=AreaB*y2\n",
    "taweB=round((V*Qb)/(I*t),0)                                                   # Shearing stress in joint b(kPa)\n",
    "\n",
    "# Result\n",
    "print ('Shearing stress in joint a = %lf kPa' %taweA)            \n",
    "print ('Shearing stress in joint b = %lf kPa' %taweB)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.2, Page number 393"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum required depth d of beam = 10.710000 in\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "#Maximum Shear and Bending Moment\n",
    "I=symbols('I')                                                             # Variable declaration\n",
    "b=symbols('b')                                                             # Variable declaration \n",
    "d=symbols('d')                                                             # Variable declaration\n",
    "c=symbols('c')                                                             # Variable declaration\n",
    "S=symbols('S')                                                             # Variable declaration  \n",
    "Mmax=90                                                                    # Maximum bending moment(kip.in) \n",
    "Vmax=3                                                                     # Force(kips)\n",
    "sall=1800                                                                  # Stress all(psi)\n",
    "tall=120                                                                   # Shearing stress(psi) \n",
    "b=3.5                                                                      # Width(in)\n",
    "\n",
    "#Calculation         \n",
    "#Design Based on Allowable Normal Stress\n",
    "I=(1/12.0)*(b)*(d**3)                                                        # Moment of inertia(m**4)\n",
    "S=round((1/6.0)*(b),4)*(d**2)                                                # Section modulus\n",
    "d=round(sqrt(((90*(pow(10,3)))/(1800))*(1/0.5833)),2)                      # Distance(in)\n",
    "\n",
    "#Check Shearing Stress\n",
    "Area=(b)*(d)                                                               # Area(in**2)\n",
    "tm=round((3/2.0)*((Vmax*1000)/Area),1)                                       # Allowable shearing stress(psi)\n",
    "\n",
    "#Design Based on Allowable Shearing Stress\n",
    "d=round((3*3000)/(2*3.5*120),2)                                            # Distance(in)\n",
    "\n",
    "# Result\n",
    "print ('Minimum required depth d of beam = %lf in' %d)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.04, Page number 401"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shearing force in each nail = 80.762500 lb\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "l=0.75                                                     # Distance(in)\n",
    "b=3                                                        # Breadth(in)  \n",
    "V=600                                                      # Vertical shear(lb)\n",
    "y=1.875                                                    # Distance(in)\n",
    "\n",
    "#Calculation         \n",
    "Q=l*b*y                                                    \n",
    "I=(1/12.0)*((4.5**4)-(3**4))                                 # Moment of inertia(in**4)\n",
    "q=(V*Q)/(I)                                                \n",
    "F=(1.75)*(46.15)                                           # Shearing force(lb)\n",
    "\n",
    "# Result\n",
    "print ('Shearing force in each nail = %lf lb' %F)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.3, Page number 406"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Horizontal shearing stress = 2.630000 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "#Variable declaration\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "Q=round((4.31)*(0.770)*(4.815),2)\n",
    "t=round(((50)*(15.98))/(394*0.770),2)                                             # Normal shearing stress(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Horizontal shearing stress = %lf ksi' %t)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.4, Page number 406"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Horizontal shearing stress = 2.790000 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "tf=0.770                                                                      # Distance(in)\n",
    "\n",
    "#Calculation         \n",
    "I=round(394 + 2*((1/12)*(12)*pow(0.75,3) + (12)*(0.75)*(pow(5.575,2))),0)     # Centroidal moment of inertia(in**4)\n",
    "t=2*tf                                                                        # Distance(in)  \n",
    "Q=round(2*(4.31*0.770*4.815) + (12)*(0.75)*(5.575),1)                         \n",
    "t=round(((50)*(82.1))/((954)*(1.54)),2)                                       # Shearing stress(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Horizontal shearing stress = %lf ksi' %t)            "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.5, Page number 407"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a) Shearing stress at A = 0.000000 ksi\n",
      "Case(a) Maximum shearing stress = 18.540000 MPa\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#Variable declaration\n",
    "AB=AD=65                                                                             # Distance AB(mm)\n",
    "cosB=12/13.0                                                                            \n",
    "\n",
    "#Calculation         \n",
    "#Centroid\n",
    "Y=round((2*65*3*30)/((2*65*3)+((50)*(3))),2)                                         # Distance y(mm)\n",
    "#Centroidal Moment of Inertia\n",
    "b=(3)/(cosB)                                                                         # Distance(mm) \n",
    "I=2*((1/12.0)*(3.25)*(pow(60,3)) + (3.25)*(60)*(pow(8.33,2))) +  ((1/12.0)*(50)*(pow(3,3)) + (50)*(3)*(pow(21.67,2)))# Moment of inertia(mm**4)\n",
    "I=(I/(pow(10,12)))                                                                   # Moment of inertia(m**4) \n",
    "#Shearing Stress at A\n",
    "ta=0\n",
    "#Maximum Shearing Stress\n",
    "Q=round(3.25*38.33*(38.33/2.0),0)\n",
    "tE=((5)*(2.387*(pow(10,-6))))/((0.2146*(pow(10,-6)))*(0.003))                        \n",
    "tE=round(tE/1000.0,2)                                                                  # Largest shearing stress\n",
    "\n",
    "# Result\n",
    "print ('Case(a) Shearing stress at A = %lf ksi' %ta)\n",
    "print ('Case(a) Maximum shearing stress = %lf MPa' %tE)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.05, Page number 417"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shear center O of a channel section of uniform thickness = 1.600000 in\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "#Variable declaration\n",
    "b=4                                                                                      # Distance(in)\n",
    "h=6                                                                                      # Distance(in)\n",
    "t=0.15                                                                                   # Thickness(in)  \n",
    "s=symbols('s')                                                                           # Variable declaration\n",
    "V=symbols('V')                                                                           # Variable declaration \n",
    "I=symbols('I')                                                                           # Variable declaration\n",
    "b=symbols('b')                                                                           # Variable declaration\n",
    "\n",
    "#Calculation         \n",
    "q=(V*s*t*h)/(2.0*I)                                                                        # First moment\n",
    "F=integrate(q,(s,0,b))                                                                   # Magnitude of shearing force\n",
    "e=(F*h)/(V)                                                                              # Distance e from the center line of the web BD to the shear center O\n",
    "I=((1/12.0)*t*(h**3)) + 2*(((1/12.0)*b*(t**3)) + (b*t*((h/2)**2)))                           # Moment of inertia\n",
    "e=(4)/(2+0.5)                                                                            # Distance(in)\n",
    "\n",
    "# Result\n",
    "print ('Shear center O of a channel section of uniform thickness = %lf in' %e)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.06, Page number 418"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shearing stress in flanges = 2.222222 ksi\n",
      "Shearing stress in web = 3.055556 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "V=2.5                                                                             # Force(kips)\n",
    "b=4                                                                               # Distance(in)\n",
    "t=0.15                                                                            # Thickness(in)\n",
    "h=6                                                                               # Height(in)\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "tB=(6*V*b)/((t*h)*(6.0*b+h))                                                        # Horizontal shearing stress(ksi)\n",
    "tMAX=(3*(V)*(4*b+h))/(2.0*t*h*(6.0*b+h))                                              # Shearing stress in web(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Shearing stress in flanges = %lf ksi' %tB)\n",
    "print ('Shearing stress in web = %lf ksi' %tMAX)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 6.07, Page number 419"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Maximum shearing stress = 68.860000 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import Symbol\n",
    "#Variable declaration\n",
    "V=2.5                                                              # Force(kip)\n",
    "OC=1.6+1.143                                                       # Distance(in)\n",
    "a=4+6+4.0                                                            # Distance(in)\n",
    "b=0.15                                                             # Distance(in)\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "T=V*OC                                                             # Torque(kip.in)\n",
    "TmaxBend=3.06                                                      # Maximum value of stress(ksi)\n",
    "c1=(1/3.0)*(1-(0.630*(b/a)))                                          \n",
    "tmaxTwist=(T/(c1*a*(b**2)))                                        # Stress due to twisting(ksi)  \n",
    "tmax=3.06 + 65.8                                                   # Combined stress(ksi)\n",
    "\n",
    "# Result\n",
    "print ('Maximum shearing stress = %lf ksi' %tmax)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 6.6, Page number 422"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Combined stress along the vertical leg :-\n",
      "-3.0*P*(-0.25*a + 0.25*y)*(0.25*a + 1.25*y)/(a**3*t)\n",
      "Combined stress along the horizontal leg :-\n",
      "3.0*P*(-0.25*a + 0.25*y)*(-0.25*a + 0.75*y)/(a**3*t)\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,cos,factor\n",
    "\n",
    "#Variable declaration\n",
    "b=symbols('b')                                                               # Variable declaration\n",
    "h=symbols('h')                                                               # Variable declaration  \n",
    "t=symbols('t')                                                               # Variable declaration\n",
    "a=symbols('a')                                                               # Variable declaration\n",
    "y=symbols('y')                                                               # Variable declaration \n",
    "P=symbols('P')                                                               # Variable declaration\n",
    "t1=symbols('t1')                                                             # Variable declaration\n",
    "\n",
    "#Calculation         \n",
    "#Principal Axes\n",
    "Inn=(1/12.0)*(b)*(pow(h,3))                                                    # Moment of inertia\n",
    "Imm=(1/3.0)*(b)*(pow(h,3))                                                     # Moment of inertia \n",
    "Iy=(2)*(1/3.0)*(t/cos((math.pi)/4.0))*(pow((a*cos((math.pi)/4.0)),3))              # Centroidal moment of inertia at y   \n",
    "Iz=(2)*(1/12.0)*(t/cos((math.pi)/4.0))*(pow((a*cos((math.pi)/4.0)),3))             # Centroidal moment of inertia at z\n",
    "\n",
    "#Shearing Stresses Due to Vy\n",
    "Y=(1/2.0)*(a+y)*(cos((math.pi)/4.0))-(1/2.0)*(a)*(cos((math.pi)/4.0))                # Distance\n",
    "Q=(1/2.0)*(t)*(a-y)*(y)*cos((math.pi)/4.0)\n",
    "Vy=P*(cos((math.pi)/4.0))\n",
    "t1=(Vy*Q)/(Iz*t)                                                             # Stress\n",
    "\n",
    "\n",
    "#Shearing Stresses Due to Vz\n",
    "Z=(1/2.0)*(a+y)*cos((math.pi)/4.0)\n",
    "Q=(1/2.0)*(a**2-y**2)*(t)*(cos((math.pi)/4.0))\n",
    "Vz=P*(cos((math.pi)/4.0))\n",
    "t2=(Vz*Q)/(Iy*t)                                                             # Stress\n",
    "\n",
    "#Combined Stresses. \n",
    "#Along the Vertical Leg\n",
    "te=factor(t1+t2)                                                             # Stress \n",
    "\n",
    "#Along the Horizontal Leg.\n",
    "tf=factor(t2-t1)                                                             # Stress\n",
    "\n",
    "# Result\n",
    "print ('Combined stress along the vertical leg :-' )\n",
    "print(te)\n",
    "print ('Combined stress along the horizontal leg :-')\n",
    "print(tf)"
   ]
  }
 ],
 "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
}
