{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 10: Columns"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.01, Page number 638"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Size of cross section if the column is to safetly support 100 kN = 0.100000 psi \n",
      "Case(b): Size of cross section if the column is to safetly support 200 kN = 129 psi \n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "L=2                                                                         # Length(m)\n",
    "E=13*(pow(10,9))                                                            # Modulus of elasticity(GPa)   \n",
    "Sall=12                                                                     # Stress(MPa)\n",
    "FS=2.5                                                                      # Factor of safety(2.5)\n",
    "Ld1=100                                                                     # Load force(kN)     \n",
    "Ld2=200                                                                     # Load force(kN)  \n",
    "\n",
    "\n",
    "#Calculation         \n",
    "#(a) For the 100-kN Load\n",
    "Pcr=FS*Ld1*(1000.0)                                                           # Pressure(kN) \n",
    "I=(Pcr*(L**2))/(((math.pi)**2)*E)                                           # Moment of inertia(m**4)   \n",
    "a1=round((I*12)**(1/4.0),1)                                                   # Side of square(mm)\n",
    "S=(100)/((0.1)**2)                                                          # Normal stress in column(MPa) \n",
    "\n",
    "#(b) For the 200-kN Load \n",
    "Pcr=FS*(Ld2)*(1000.0)                                                         # Pressure(kN)\n",
    "I=(Pcr*(L**2))/(((math.pi)**2)*E)                                           # Moment of inertia(m**4)\n",
    "a=((I)*12)**(1/4.0)                                                           # Side of square(mm)\n",
    "S=(200/(0.11695)**2)                                                        # Normal stress(MPa)\n",
    "A=(200/12.0)*(pow(10,-3))                                                     # Area of cross section(m**2)\n",
    "a2=(A)**(1/2.0)*(1000)                                                        # Side of square(mm)\n",
    "\n",
    "#Result\n",
    "print('Case(a): Size of cross section if the column is to safetly support 100 kN = %lf psi '%a1)\n",
    "print('Case(b): Size of cross section if the column is to safetly support 200 kN = %.lf psi '%a2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.1, Page number 643"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Ratio for most efficient design = 0.350000  \n",
      "Case(b): Design for given data breadth = 1.619708 in \n",
      "Case(b): Design for given data length = 0.566898 in \n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "L=20                                                                             # Length of aluminium column(in)\n",
    "E=10.1*(pow(10,6))                                                               # Modulus of elasticity(psi)\n",
    "P=5                                                                              # Stress(kips) \n",
    "L=symbols('L')                                                                   # Variable declaration\n",
    "Le=symbols('Le')                                                                 # Variable declaration  \n",
    "Le=0.7*L                                                                         # Effective length of column\n",
    "a=symbols('a')                                                                   # Variable declaration  \n",
    "b=symbols('b')                                                                   # Variable declaration  \n",
    "Scr=symbols('Scr')                                                               # Variable declaration\n",
    "ry=(b)/(math.sqrt(12))                                                                # Radius of gyration \n",
    "FS=2.5                                                                           # Factor of safety\n",
    "\n",
    "#Calculation         \n",
    "#Buckling in xy Plane\n",
    "Ix=(1/12.0)*(a**3)*b                                                               # Moment of inertia\n",
    "A=a*b                                                                            # Area of cross section\n",
    "rz=(((1/12.0)*b*(a**3))/(a*b))**(1/2.0)                                                 # Radius of gyration\n",
    "ESRxy=(Le)/(rz)                                                                  # Effective slenderness ratio \n",
    "\n",
    "\n",
    "#Buckling in xz Plane \n",
    "ESRxz=(Le)/(ry)                                                                  # Effective slenderness ratio\n",
    "\n",
    "# Case(a) Most Efficient Design\n",
    "Ans=((0.7*L)*(math.sqrt(12.0)))/((2.0*L)*(math.sqrt(12.0)))                                      # Most efficient design \n",
    "\n",
    "# Case(b) Design for Given Data.\n",
    "Pcr=(FS)*(P)                                                                     # Pressure(kips)\n",
    "a=0.35*b                                                                         # Distance \n",
    "A=a*b                                                                            # Area\n",
    "Scr=(Pcr/A)                                                                      # Stress\n",
    "b=(((12500)*((138.6)**2))/(0.35*10.1*(pow(10.0,6))*((math.pi)**2.0)))**(1/4.0)         # Distance(in)\n",
    "\n",
    "\n",
    "#Result\n",
    "print('Case(a): Ratio for most efficient design = %lf  '%Ans)\n",
    "print('Case(b): Design for given data breadth = %lf in '%b)\n",
    "print('Case(b): Design for given data length = %lf in '%(0.35*b))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.2, Page number 654 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Case(a): Allowable load = 31.056698 kips\n",
      "Case(a): Allowable stress = 8.773078 ksi \n",
      "Case(b): The horizontal deflection of the top of the column = 0.939000 in \n",
      "Case(b): Maximum normal stress in the column = 21.981585 ksi \n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "E=(29*(pow(10,6)))                                                              # Modulus of elasticity(psi)\n",
    "FS=2                                                                            # Factor of safety  \n",
    "A=3.54                                                                          # Area of cross section(in**2) \n",
    "I=8.00                                                                          # Moment of inertia(in**4)\n",
    "r=1.50                                                                          # Radius(in)\n",
    "c=2.00                                                                          # Distance(in) \n",
    "Lab=8\n",
    "\n",
    "#Calculation         \n",
    "# Effective Length\n",
    "Le=2*(Lab)                                                                      # Effective length(in)\n",
    "# Critical Load\n",
    "Pcr=((((math.pi)**2)*E*(8.0))/(192.0)**2)/(1000.0)                                    # Critical load(kips)\n",
    "\n",
    "#Case(a) Allowable Load and Stress\n",
    "Pall=Pcr/FS                                                                     # Allowable load(kips)\n",
    "S=Pall/A                                                                        # Allowable Stress(ksi)\n",
    "\n",
    "#Case(b) Eccentric Load\n",
    "ym=(0.75)*(2.252-1)                                                             # Distance(in)\n",
    "Sm=(31.1/3.54)*(1+(0.667)*(2.252))                                              # Distance(in)\n",
    "\n",
    "#Result\n",
    "print('Case(a): Allowable load = %lf kips'%Pall)\n",
    "print('Case(a): Allowable stress = %lf ksi '%S)\n",
    "print('Case(b): The horizontal deflection of the top of the column = %lf in '%ym)\n",
    "print('Case(b): Maximum normal stress in the column = %lf ksi '%Sm)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.02, Page number 664"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The longest unsupported length L = 2.318480 m\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "A=1460*(pow(10,-6))                                                       # Area of cross section(m**2)\n",
    "rx=41.7                                                                   # Radius of gyration(mm)\n",
    "ry=14.6                                                                   # Radius of gyration(mm)\n",
    "P=60*(pow(10,3))                                                          # Force(N)\n",
    "E=200*(pow(10,9))                                                         # Modulus of elasticity(GPa)\n",
    "L=symbols('L')                                                            # Variable Declaration\n",
    "r=symbols('r')                                                            # Variable Declaration\n",
    "Scr=symbols('Scr')\n",
    "\n",
    "#Calculation         \n",
    "Sall=(P/A)                                                                # Stress of all(Pa)\n",
    "Scr=0.8778*((((math.pi)**2)*(E))/(L/r)**2)                                # Critical stress\n",
    "Sall=Scr/1.67                                                             # Stress of all(Pa)\n",
    "R1=((1.037*(pow(10,12)))/(1.41*(pow(10,6))))**(1/2)                       # Slenderness ratio\n",
    "R1l=(4.71)*((200*(pow(10,9)))/(250*(pow(10,6))))**(1/2)                   # Slenderness ratio\n",
    "L=158.8*(14.6*(pow(10,-3)))                                               # Choosing the smaller of the two radii of gyration\n",
    "\n",
    "#Result\n",
    "print('The longest unsupported length L = %lf m'%L)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.3, Page number 668 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Effective centric load P if the effective length of the column is 24 = 81.649348 kips\n",
      "Effective centric load P if bracing is provided to prevent the movement of the midpoint C in the xz plane = 187.639873 ksi\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "Sy=36                                                                       # Stress(ksi)\n",
    "E=(29*(pow(10,6)))                                                          # Modulus of elasticity(psi)\n",
    "A=11.5                                                                      # Area(in**2) \n",
    "FS=2                                                                        # Factor of safety\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "ratio=(4.71)*(E/(36*(pow(10,3))))                                           # Value of the slenderness ratio\n",
    "\n",
    "#Case(a) Effective Length\n",
    "Sr=(24*12)/(1.98)                                                           # Value of the slenderness ratio\n",
    "Scr=((0.877)*((math.pi)**2)*(29*(pow(10,3))))/(145.5)**2                    # Value of the slenderness ratio\n",
    "Sall=(Scr/1.67)                                                             # Allowable stress(ksi)\n",
    "Pall1=Sall*A                                                                 # Pressure(kips)\n",
    "#Case(b) Bracing at Midpoint C                                                 \n",
    "#xz Plane\n",
    "Elxz=(144)/(1.98)                                                           # Slenderness ratio\n",
    "#yz Plane\n",
    "Elyz=(288)/(4.27)                                                           # Slenderness ratio\n",
    "\n",
    "Se=(((math.pi)**2)*(E))/(72.7)**2                                           # Stress(ksi)\n",
    "Scr=(0.658)**(36/54.1)*(36)                                                 # Stress(ksi) \n",
    "\n",
    "Sall=(Scr)/(1.67)                                                           # Allowable load(ksi)\n",
    "Pall2=Sall*A                                                                 # Force(ksi) \n",
    "\n",
    "#Result\n",
    "print('Effective centric load P if the effective length of the column is 24 = %lf kips'%Pall1)\n",
    "print('Effective centric load P if bracing is provided to prevent the movement of the midpoint C in the xz plane = %lf ksi'%Pall2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.4, Page number 669 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The smallest diameter rod that can be used to support the centric load P=60 kN if L=750 mm = 0.036628 \n",
      "The smallest diameter rod that can be used to support the centric load P=60 kN if L=300 mm = 0.023900 \n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols\n",
    "\n",
    "#Variable declaration\n",
    "P=60                                                                                # Centric load(kN)\n",
    "c=symbols('c')                                                                      # Variable declaration\n",
    "I=((math.pi)/4.0)*(c**4)                                                              # Moment of inertia\n",
    "A=(math.pi)*(c**2)                                                                  # Area of cross section \n",
    "\n",
    "#Calculation         \n",
    "r=(I/A)**(1/2.0)                                                                         # Radius\n",
    "\n",
    "#Case(a) Length of 750 mm\n",
    "c=((60*(pow(10,3))*((0.75)**2)*4)/((math.pi)*(382.0)*(pow(10.0,9))))**(1/4.0)\n",
    "Sr=(750)/(18.31/2.0)\n",
    "d1=2*c\n",
    "\n",
    "#Case(b) Length of 300 mm\n",
    "c=11.95                                                                             # Radius(mm)\n",
    "\n",
    "Sr=((300)*(2))/(11.95)                                                              # Slenderness ratio\n",
    "d2=(2*c)/(1000.0)                                                                     # Required diamter(mm)\n",
    "\n",
    "#Result\n",
    "print('The smallest diameter rod that can be used to support the centric load P=60 kN if L=750 mm = %lf '%d1)\n",
    "print('The smallest diameter rod that can be used to support the centric load P=60 kN if L=300 mm = %lf '%d2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.04, Page number 676"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum load that can be safely applied is = 23.278244 kips\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,solve\n",
    "\n",
    "#Variable declaration\n",
    "L=28                                                                           # Effective length(in)\n",
    "P=symbols('P')\n",
    "\n",
    "#Calculation         \n",
    "A=2**2                                                                         # Area of cross ection(in**2)\n",
    "I=(1/12.0)*(2**4)                                                                # Moment of inertia(in**4)\n",
    "r=(I/A)**(1/2.0)                                                                 # Radius(in)\n",
    "R1=(28/0.5774)                                                                 # Ratio\n",
    "Sall=(30.9-(0.229*48.5))                                                       # Stress for the aluminum column(ksi)  \n",
    "P=solve((P/4.0)+((P*0.8*1)/(1.333))-19.79,P)                                     # Maximum load that can be safely applied(kips)\n",
    "\n",
    "#Result\n",
    "print('The maximum load that can be safely applied is = %lf kips'%P[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 10.05, Page number 677"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The maximum load that can be safely applied is = 26.568262 kips\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,solve\n",
    "\n",
    "#Variable declaration\n",
    "Sallcentric=19.79                                                              # Stress all centric(ksi) \n",
    "Sallbending=24                                                                 # Stress all bending(ksi)\n",
    "P=symbols('P')\n",
    "\n",
    "#Calculation         \n",
    "P=solve((P/4.0)/(19.79) + ((P*0.8*1)/(1.333*24))-1,P)\n",
    "\n",
    "#Result\n",
    "print('The maximum load that can be safely applied is = %lf kips'%P[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.5, Page number 678"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The largest allowable load P is thus = 327.340184 kN\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,solve\n",
    "\n",
    "#Variable declaration\n",
    "E=200                                                                           # Modulus of elasticity(GPa)\n",
    "Sy=250                                                                          # Stress(MPa)\n",
    "P=symbols('P')                                                                  # Variable declaration\n",
    "\n",
    "#Calculation         \n",
    "Sall=162.2/1.67                                                                 # Allowable stress(MPa)\n",
    "\n",
    "P=solve(P*((1/(9.42*(pow(10,-3))))+(0.200/(1.050*(pow(10,-3)))))-97.1,P)        # Largest load P(kN)\n",
    "\n",
    "#Result\n",
    "print('The largest allowable load P is thus = %lf kN'%(P[0]*1000))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SAMPLE PROBLEM 10.6, Page number 678"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The largest allowable load P is thus = 423.169834 kN\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,solve\n",
    "\n",
    "#Variable declaration\n",
    "E=200                                                                           # Modulus of elasticity(GPa)\n",
    "Sy=150                                                                          # Stress(MPa)\n",
    "P=symbols('P')                                                                  # Variable declaration\n",
    "\n",
    "\n",
    "#Calculation         \n",
    "P=solve(P*((1/(97.1*9.42*(pow(10,3))))+(0.200/(150*1.050*(pow(10,3)))))-1,P)    # Largest allowable load(kN)\n",
    "\n",
    "#Result\n",
    "print('The largest allowable load P is thus = %lf kN'%(P[0]/1000))              "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## SAMPLE PROBLEM 10.7, Page number 679"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Selection of Shape. The shape to be used is W8*48\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from sympy import symbols,solve\n",
    "\n",
    "#Variable declaration\n",
    "A=symbols('A')                                                                # Variable declaration                                                                       \n",
    "E=29*(pow(10,6))                                                              # Modulus of elasticity(psi) \n",
    "Sy=36                                                                         # Stress(ksi) \n",
    "SR=133.7                                                                      # Slenderness ratio\n",
    "Scr=22.5                                                                      # Slenderness ratio\n",
    "\n",
    "#Calculation         \n",
    "A=solve(22-(85/A)-((425*4)/(A*(pow(3.5,2)))),A)                               # Area of cross section(in**2) \n",
    "\n",
    "#Trial 1: W8*35\n",
    "#Allowable Bending Stress\n",
    "Sall=22                                                                       # Allowable bending stress(ksi) \n",
    "#Allowable Concentric Stress\n",
    "Ratio1=(8.25/13.46)+(13.62/22.0)                                                # Allowable concentric stress(ksi) \n",
    "#Since 1.232 > 1.000, the requirement expressed by the interaction formula is not satisfied; we must select a larger trial shape.\n",
    "\n",
    "#Trial 2: W8*48\n",
    "Ratio2=(6.03/13.76)+(9.82/22.0)                                                 # Allowable concentric stress(ksi)\n",
    "#The W8*48 shape is satisfactory but may be unnecessarily large\n",
    "\n",
    "#Trial 3: W8*40\n",
    "#Following again the same procedure, we find that the interaction formula is not satisfied.\n",
    "\n",
    "print ('Selection of Shape. The shape to be used is W8*48')"
   ]
  }
 ],
 "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
}
