{
 "metadata": {
  "name": "",
  "signature": "sha256:c5e7c024d1eb3a7426e4241fc719f61d59003d11703e75e2542d5874bd3a6f9f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 02:Strain"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Examples No:2.2.1, Page No:36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "#Axial Forces in lb in member AB, BC and CD\n",
      "P_AB=2000 \n",
      "P_BC=2000\n",
      "P_CD=4000\n",
      "#Other Variables\n",
      "E=29*10**6 #Modulus of Elasticity in psi\n",
      "#Length of each member in inches\n",
      "L_AB=5*12\n",
      "L_BC=4*12\n",
      "L_CD=4*12\n",
      "#Diameter of each member in inches\n",
      "D_AB=0.5\n",
      "D_BC=0.75\n",
      "D_CD=0.75\n",
      "\n",
      "#Calculation\n",
      "#Area Calculation of each member in square inches\n",
      "A_AB=(pi*D_AB**2)/4\n",
      "A_BC=(pi*D_BC**2)/4\n",
      "A_CD=(pi*D_CD**2)/4\n",
      "\n",
      "#Using relation delta=(PL/AE) to compute strain\n",
      "#As stress in Member CD is compression\n",
      "delta=(E**-1)*((P_AB*L_AB*A_AB**-1)+(P_BC*L_BC*A_BC**-1)-(P_CD*L_CD*A_CD**-1))\n",
      "\n",
      "#Result\n",
      "print \"The elongation in the total structure is\",round(delta,5),\"in\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The elongation in the total structure is 0.01358 in\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.2, Page No:36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from scipy.integrate import quad\n",
      "\n",
      "#Variable Decleration\n",
      "E=200*10**9 #Modulus of elasticity in Pa\n",
      "P=10**5 #Force acting in N\n",
      "\n",
      "#Calculations\n",
      "#Using quad integration\n",
      "#Area has been defined as a quadratic equation to integrate\n",
      "def integrand(x, a, b):\n",
      "    return 1/(a * x + b)\n",
      "a = 160\n",
      "b = 800\n",
      "I = quad(integrand, 0, 10, args=(a,b))\n",
      "#Using delta=(P/E)*I    where I is the integrand\n",
      "delta=(P*E**-1)*10**6*I[0]\n",
      "\n",
      "#Result\n",
      "print \"The elongation in the member is\",round(delta*1000,2),\"mm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The elongation in the member is 3.43 mm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.3, Page No:37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decelration\n",
      "A_AC=0.25 #Cross Sectional Area in square inch\n",
      "Load=2000 #Load at point C in lb\n",
      "E=29*10**6 #Modulus of elasticity in psi\n",
      "theta=(pi*40)/180 #Angle in radians\n",
      "L_BC=8 #Length in ft\n",
      "\n",
      "#Calculations\n",
      "#Using sum of forces \n",
      "P_AC=Load/sin(theta) #Force in cable AC in lb\n",
      "L_AC=(L_BC*12)/cos(theta) #Length of cable AC in in\n",
      "\n",
      "delta_AC=(P_AC*L_AC)/(E*A_AC) #elongation in inches\n",
      "\n",
      "delta_C=delta_AC/sin(theta) #displacement of point C in inches\n",
      "\n",
      "#Result\n",
      "print \"The displacement of point C is\",round(delta_C,4),\"in\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The displacement of point C is 0.0837 in\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.4, Page No:46"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "d=0.05 #Diameter of the rod in mm\n",
      "P=8000 #Load on the bar in N\n",
      "E=40*10**6 #Modulus of elasticity in Pa\n",
      "v=0.45 #Poisson Ratio\n",
      "L=300 #Length of the rod in mm\n",
      "\n",
      "#Calculation\n",
      "A=((pi*d**2)/4) #Area of the bar in mm^2\n",
      "sigma_x=-P/A #Axial Stress in the bar in Pa\n",
      "#As contact pressure resists the force\n",
      "p=(v*sigma_x)/(1-v)\n",
      "#Using Axial Strain formula\n",
      "e_x=(sigma_x-(v*2*p))/E\n",
      "#Corresponding change in length\n",
      "delta=e_x*L #contraction in mm\n",
      "#Without constrains of the wall\n",
      "delta_w=(-P*(L*10**-3))/(E*A) #Elongation in m\n",
      "\n",
      "#Result\n",
      "print \"The elongation in the bar is\",-round(delta,2),\"mm contraction\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The elongation in the bar is 8.06 mm contraction\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.5, Page No:47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "E=500 #Modulus of elasticity in psi\n",
      "v=0.48 #Poisson ratio\n",
      "V=600 #Force in lb\n",
      "w=5 #Width of the plate in inches\n",
      "l=9 #Length of the plate in inches\n",
      "t=1.75 #Thickness of the rubber layer in inches\n",
      "\n",
      "#Calculations\n",
      "tau=V*(w*l)**-1 #Shear stress in rubber in psi\n",
      "G=E/(2*(1+v)) #Bulk modulus in psi\n",
      "gamma=tau/G #Shear Modulus \n",
      "disp=t*gamma #Diplacement in inches\n",
      "\n",
      "#Result\n",
      "print \"The displacement of the rubber layer is\",round(disp,4),\"in\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The displacement of the rubber layer is 0.1381 in\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.6, Page No:52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "P=10**6 #Force on the member in N\n",
      "Es=200 #Modulus of elasticity of steel in GPa\n",
      "Ec=14 #Modulus of elasticity concrete in GPa\n",
      "As=900*10**-6 #Area of steel in m^2\n",
      "Ac=0.3**2 #Area of concrete block in m^2\n",
      "\n",
      "#Calculation\n",
      "#Cross Sectional Areas\n",
      "Ast=4*As #Cross Sectional Area in m^2 of Steel\n",
      "Act=Ac-Ast #Cross Sectional Area of Concrete in m^2\n",
      "\n",
      "#Applying equilibrium to the structure\n",
      "#Using the ratio of stress and modulii of elasticity we obtain the following eq\n",
      "sigma_ct=P/(((Es*Ec**-1)*Ast)+Act) #Stress in Concrete in Pa\n",
      "sigma_st=sigma_ct*Es*Ec**-1 #Stress in Steel in Pa\n",
      "\n",
      "#Result\n",
      "print \"The stress in steel and concrete is as follows\",round(sigma_st*10**-6,1),\"MPa and\",round(sigma_ct*10**-6,3),\"Mpa respectively\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The stress in steel and concrete is as follows 103.6 MPa and 7.255 Mpa respectively\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.7, Page No:52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "#Say the ratio of stress in steel to concrete is R\n",
      "R=14.286 \n",
      "sigma_co=6*10**6 #Stress in concrete in Pa\n",
      "Ast=3.6*10**-3 #Area of steel in m^2\n",
      "Aco=86.4*10**-3 #Area of Concrete in m^2\n",
      "\n",
      "#Calculation\n",
      "sigma_st=R*sigma_co #Stress in steel in Pa\n",
      "#Here stress is below the allowable hence safe\n",
      "P=sigma_st*Ast+sigma_co*Aco #Allowable force in N\n",
      "\n",
      "#Result\n",
      "print \"The maximum allowable force is\",round(P*10**-3),\"kN\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum allowable force is 827.0 kN\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.8, Page No:53"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#NOTE:The NOtation has been changed to ease coding\n",
      "#Variable Decleration\n",
      "d=0.005 #difference in length in inch\n",
      "L=10 #Length in inch\n",
      "#Area of copper and aluminium in sq.in\n",
      "Ac=2 #Area of copper \n",
      "Aa=3 #Area of aluminium \n",
      "#Modulus of elasticity of copper and aluminium in psi\n",
      "Ec=17000000 #Copper\n",
      "Ea=10**7 #Aluminium\n",
      "#Allowable Stress in psi\n",
      "Sc=20*10**3 #Copper\n",
      "Sa=10*10**3 #Aluminium\n",
      "\n",
      "#Calculation\n",
      "#Equilibrium is Pc+Pa=P\n",
      "#Hookes Law is delta_c=delta_a+0.005\n",
      "#Simplfying the solution we have constants we can directly compute\n",
      "A=d*Ec*(L+d)**-1\n",
      "B=Ec*Ea**-1\n",
      "C=L*B*(L+d)**-1\n",
      "sigma_a=(Sc-A)*C**-1\n",
      "\n",
      "#Using equilibrium equation\n",
      "P=Sc*Ac+sigma_a*Aa #Safe load in lb\n",
      "\n",
      "#Result\n",
      "print \"The safe load on the structure is\",round(P),\"lb\"\n",
      "#NOTE:Answer in the textbook has been rounded off and hence the discrepancy"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The safe load on the structure is 60312.0 lb\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.9, Page No:54"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Variable Decleration\n",
      "P=50*10**3 #Load applied in N\n",
      "x1=0.6 #Length in m\n",
      "x2=1.6 #Length in m\n",
      "L1=1 #Length of steel cable in m\n",
      "L2=2 #Length of bronze cable in m\n",
      "L=2.4 #Length in m\n",
      "#Area in m^2\n",
      "Ast=600*10**-6 #Steel\n",
      "Abr=300*10**-6 #Bronze\n",
      "#Modulus of elasticity in GPa\n",
      "Est=200 #Steel\n",
      "Ebr=83 #Bronze\n",
      "\n",
      "#Calculations\n",
      "#Applying the equilibrium and Hookes law we solve by matrix method\n",
      "a=np.array([[x1,x2],[1,-((x1*Est*Ast*L2)/(x2*Ebr*Abr))]])\n",
      "b=np.array([L*P,0])\n",
      "y=np.linalg.solve(a,b)\n",
      "\n",
      "#Stresses in Pa\n",
      "sigma_st=y[0]*Ast**-1 #Stress in steel\n",
      "sigma_br=y[1]/Abr #Stress in bronze\n",
      "\n",
      "#Result\n",
      "print \"The stresses in steel and bronze are as follows\"\n",
      "print round(sigma_st*10**-6,1),\"MPa and\",round(sigma_br*10**-6,1),\"MPa respectively\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The stresses in steel and bronze are as follows\n",
        "191.8 MPa and 106.1 MPa respectively\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.10, Page No:62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "L=2.5 #Length in m\n",
      "A=1200 #Cross sectional Area in mm^2\n",
      "delta_T=40 #Temperature drop in degree C\n",
      "delta=0.5*10**-3 #Movement of the walls in mm\n",
      "alpha=11.7*10**-6 #Coefficient of thermal expansion in /degreeC\n",
      "E=200*10**9 #Modulus of elasticity in Pa\n",
      "\n",
      "#Calculation\n",
      "#Part(1)\n",
      "sigma_1=alpha*delta_T*E #Stress in the rod in Pa\n",
      "\n",
      "#Part(2)\n",
      "#Using Hookes Law\n",
      "sigma_2=E*((alpha*delta_T)-(delta*L**-1)) #Stress in the rod in Pa\n",
      "\n",
      "print \"The Stress in part 1 in the rod is\",round(sigma_1*10**-6,1),\"MPa\"\n",
      "print \"The Stress in part 2 in the rod is\",round(sigma_2*10**-6,1),\"MPa\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Stress in part 1 in the rod is 93.6 MPa\n",
        "The Stress in part 2 in the rod is 53.6 MPa\n"
       ]
      }
     ],
     "prompt_number": 53
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.11, Page No:63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "delta=100 #Increase in the temperature in degreeF\n",
      "Load=12000 #Load on the beam in lb\n",
      "#Length in inch\n",
      "Ls=2*12 #Steel\n",
      "Lb=3*12 #Bronze\n",
      "#Area in sq.in\n",
      "As=0.75 #Steel\n",
      "Ab=1.5 #Bronze\n",
      "#Modulus of elasticity in psi\n",
      "Es=29*10**6 #Steel\n",
      "Eb=12*10**6 #Bronze\n",
      "#Coefficient of thermal expansion in /degree C\n",
      "alpha_s=6.5*10**-6 #Steel\n",
      "alpha_b=10**-5 #Bronze\n",
      "\n",
      "#Calculations\n",
      "#Applying the Hookes Law and equilibrium we get two equations\n",
      "a=np.array([[Ls*(Es*As)**-1,-Lb*(Eb*Ab)**-1],[2,1]])\n",
      "b=np.array([(alpha_b*delta*Lb-alpha_s*delta*Ls),Load])\n",
      "y=np.linalg.solve(a,b)\n",
      "\n",
      "#Stresses\n",
      "sigma_st=y[0]*As**-1 #Stress in steel in psi (T)\n",
      "sigma_br=y[1]*Ab**-1 #Stress in bronze in psi (C)\n",
      "\n",
      "#Result\n",
      "print \"The Stress in steel and bronze are as follows\"\n",
      "print sigma_st,\"psi (T) and\", -sigma_br,\"psi (C)\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Stress in steel and bronze are as follows\n",
        "11600.0 psi (T) and 3600.0 psi (C)\n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2.12, Page No:64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "P=6000 #Force in lb\n",
      "Est=29*10**6 #Modulus of elasticity of steel in psi\n",
      "L1=24 #Length in inches\n",
      "L2=36 #Length in inches\n",
      "alpha_1=6.5*10**-6 #coefficient of thermal expansion in /degree F of steel\n",
      "alpha_2=10**-5 #coefficient of thermal expansion in /degree F of bronze\n",
      "As=0.75 #Area os steel in sq.in\n",
      "\n",
      "#Calculations\n",
      "delta_T=((P*L1)/(Est*As))/(alpha_2*L2-alpha_1*L1) #Change in temperature in degree F\n",
      "\n",
      "print \"The change in the Temperature is\",round(delta_T,1),\"F\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in the Temperature is 32.5 F\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}