{
 "metadata": {
  "name": "",
  "signature": "sha256:aaf5a5f62a391d916c40aa2d720de6a3e7681d1c9c64ec2fdbeff148819b3c75"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Chapter 12:Energy and Virtual-work Methods"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.1 page number 645 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#Virtual loading\n",
      "p_ab = -0.833   #lb The recorded virtual loading\n",
      "p_bc = + 0.833  #lb The recorded virtual loading\n",
      "F_ab = 2500     #lb\n",
      "F_bc = -2500    #lb\n",
      "l_ab = 60       #in - The length of the rod\n",
      "l_bc = 60       #in - The length of the rod\n",
      "A_ab = 0.15     #in2 the areaof ab\n",
      "A_bc = 0.25     #in2 the areaof bc\n",
      "E = 30*(10**6)  #psi The youngs modulus of the material\n",
      "#Part_a\n",
      "e_a =p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E) #in the deflection\n",
      "if e_a<0:\n",
      "    print \"a) The deflection is downwards\",round(-e_a,3),\"in\"\n",
      "else:\n",
      "    print \"a) The deflection is upwards\",round(e_a,3),\"in\"\n",
      "#part-b\n",
      "x = 0.125 #Shortening of member Ab\n",
      "e_b = p_ab*(-x) + p_bc*0 #in - in\n",
      "if e_b<0:\n",
      "    print \"b) The deflection is downwards\",round(-e_b,3),\"in\"\n",
      "else:\n",
      "    print \"b) The deflection is upwards\",round(e_b,3),\"in\"\n",
      "#Part-c\n",
      "S = 6.5*(10**-6) #Thermal specific heat\n",
      "T = 120 #F - The cahnge in temperature\n",
      "e_t = -S*T*l_ab #in - The change in length of member\n",
      "e_c = p_bc*e_t #in the deflection\n",
      "if e_c<0:\n",
      "    print \"c) The deflection is downwards\",round(-e_c,3),\"in\"\n",
      "else:\n",
      "    print \"c) The deflection is upwards\",round(e_c,3),\"in\"\n",
      "\n",
      "\n",
      "   \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a) The deflection is downwards 0.044 in\n",
        "b) The deflection is upwards 0.104 in\n",
        "c) The deflection is downwards 0.039 in\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.3 page number 648"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#Virtual loading\n",
      "#Two parts \n",
      "#Part -1 \n",
      "p_ab = 5     #KN The recorded virtual loading\n",
      "p_bc = -4    #KN The recorded virtual loading\n",
      "F_ab = 10    #KN\n",
      "F_bc = -8    #KN\n",
      "l_ab = 2.5           #mt - The length of the rod\n",
      "l_bc = 2             #mt - The length of the rod\n",
      "A_ab = 5*(10**-4)    #mt2 the areaof ab\n",
      "A_bc = 5*(10**-3)    #mt2 the areaof bc\n",
      "E = 70 #Gpa The youngs modulus of the material\n",
      "e_a =(p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E))*(10**-6) #KN-m\n",
      "#Part -2 due to flexure\n",
      "I = 60*10**6    #mm4 - the moment of inertia \n",
      "#After solving the integration \n",
      "e_b = 0.01525 #KN-m\n",
      "#Total\n",
      "e = (e_a+e_b)*1 #m\n",
      "print \"The point C deflects\",round(e,3),\"mt down\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The point C deflects 0.019 mt\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.5 page number 651"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#Virtual loading Without f_d\n",
      "p_ab = -0.833   #lb The recorded virtual loading\n",
      "p_bc = + 0.833  #lb The recorded virtual loading\n",
      "F_ab = 2500     #lb\n",
      "F_bc = -2500    #lb\n",
      "l_ab = 60       #in - The length of the rod\n",
      "l_bc = 60       #in - The length of the rod\n",
      "A_ab = 0.15     #in2 the areaof ab\n",
      "A_bc = 0.25     #in2 the areaof bc\n",
      "E = 30*(10**6)  #psi The youngs modulus of the material\n",
      "#Part_a\n",
      "e_a =p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E) #lb-in the deflection\n",
      "#With f_d\n",
      "p_bd = 1       #lb The recorded virtual loading \n",
      "F_bd = 1       #lb\n",
      "l_bd = 40      #in - The length of the rod\n",
      "A_bd = 0.1     #in2 the areaof ab\n",
      "e_a_1 =p_ab*p_ab*l_ab/(A_ab*E) + p_bc*p_bc*l_bc/(A_bc*E) +p_bd*p_bd*l_bd/(A_bd*E) #lb-in the deflection\n",
      "#Since the produced defelection should compensate the other one\n",
      "x_d = e_a/e_a_1\n",
      "print \"The reaction force at D is\",round(-x_d,2),\"lb\"\n",
      "\n",
      "#Part - B\n",
      "e_b = -x_d*l_bd/(A_bd*E ) #in - The deflection of nodal point B\n",
      "print\"The deflection of nodal point B\",round(e_b,4),\"in\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reaction force at D is 1578.98 lb\n",
        "The deflection of nodal point B 0.0211 in\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.6 page number 655"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#Virtual loading\n",
      "p_ab = -0.833   #lb The recorded virtual loading\n",
      "p_bc = + 0.833  #lb The recorded virtual loading   \n",
      "l_ab = 60       #in - The length of the rod\n",
      "l_bc = 60       #in - The length of the rod\n",
      "A_ab = 0.15     #in2 the areaof ab\n",
      "A_bc = 0.25     #in2 the areaof bc\n",
      "E = 30*(10**6)  #psi The youngs modulus of the material\n",
      "K_1 = A_ab*E/l_ab  #k/in - Stiffness\n",
      "K_2 = A_bc*E/l_bc  #k/in - Stiffness\n",
      "#soving for e_1 and e_2 gives a liner euations to solve\n",
      "# 128*e_1  + 24*e_2 = 0\n",
      "#24*e_1  + 72*e_2 = -3\n",
      "#Solving for e_1,e_2\n",
      "a = np.array([[128,24], [24,72]])\n",
      "b = np.array([0,-3])\n",
      "x = np.linalg.solve(a, b)\n",
      "e_1 = x[0] #in\n",
      "e_2 = x[1] #in\n",
      "u_1 = 0.8*e_1 - 0.6*e_2 #Taking each components\n",
      "F_1 = K_1*u_1*(10**-3)  #k The reaction at A Force = stiffness x dislacement \n",
      "u_2 = 0.8*e_1 + 0.6*e_2 #Taking each components\n",
      "F_2 = K_2*u_2*(10**-3) #k The reaction at B Force\n",
      "print \"The reaction at A \",F_1,\"k\"\n",
      "print \"The reaction at B \",F_2,\"k\"\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reaction at A  2.5 k\n",
        "The reaction at B  -2.5 k\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.7 page number 655"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Virtual loading\n",
      "p_ab = -0.833   #lb The recorded virtual loading\n",
      "p_bc = + 0.833  #lb The recorded virtual loading   \n",
      "l_ab = 60       #in - The length of the rod\n",
      "l_bc = 60       #in - The length of the rod\n",
      "A_ab = 0.15     #in2 the areaof ab\n",
      "A_bc = 0.25     #in2 the areaof bc\n",
      "E = 30*(10**6)  #psi The youngs modulus of the material\n",
      "K_1 = A_ab*E/l_ab  #k/in - Stiffness\n",
      "K_2 = A_bc*E/l_bc  #k/in - Stiffness\n",
      "p_bd = 1    #lb The recorded virtual loading \n",
      "F_bd = 1    #lb\n",
      "l_bd = 40       #in - The length of the rod\n",
      "A_bd = 0.1      #in2 the areaof ab\n",
      "K_3 =  A_ab*E/l_ab #k/in - Stiffness\n",
      "#soving for e_1 and e_2 gives a liner euations to solve\n",
      "# 128*e_1  + 24*e_2 = 0\n",
      "#24*e_1  + 72*e_2 = -3\n",
      "#Solving for e_1,e_2\n",
      "a = np.array([[128,24], [24,147]])\n",
      "b = np.array([0,-3])\n",
      "x = np.linalg.solve(a, b)\n",
      "e_1 = x[0] #in\n",
      "e_2 = x[1] #in\n",
      "u_1 = 0.8*e_1 - 0.6*e_2 #Taking each components\n",
      "F_1 = K_1*u_1*(10**-3)  #k The reaction at A Force = stiffness x dislacement \n",
      "u_2 = 0.8*e_1 + 0.6*e_2 #Taking each components\n",
      "F_2 = K_2*u_2*(10**-3) #k The reaction at B Force\n",
      "u_3 = e_2 #Taking each components\n",
      "F_3 = K_3*u_3*(10**-3) #k The reaction at D Force\n",
      "print \"The reaction at A \",round(F_1,2),\"k\"\n",
      "print \"The reaction at B \",round(F_2,2),\"k\"\n",
      "print \"The reaction at D \",round(F_3,2),\"k\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The reaction at A  1.18 k\n",
        "The reaction at B  -1.18 k\n",
        "The reaction at D  -1.58 k\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.8 page number 659"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "#First we will solve part B\n",
      "u_1 =5 #L/AE, elastic elongation\n",
      "u_2 =25 #L/AE,elastic elongation\n",
      "f_1 = u_1#, Units got neutralized , Constitutive relation for elastic bars\n",
      "f_2 = u_2# Units got neutralized\n",
      "#u_1 = 0.8*e_1 - 0.6*e_2\n",
      "#u_2 = 0.8*e_1 + 0.6*e_2\n",
      "#u = A*e Matric multiplication \n",
      "A = np.array([[0.8,-0.6],[0.8,0.6]]) #The matrix form of A\n",
      "F = np.array([[f_1],[f_2]])\n",
      "P = np.dot((A.T),F) #Nodal forces matrix\n",
      "print \"b) The vertical component of the nodal force is\",P[1],\"\"\n",
      "print \"b) The vertical component of the nodal force is\",P[0],\"\"\n",
      "#Part A\n",
      "#F_1 = (5/8.0)*P_1 - (5/6.0)*p_2 , From statics\n",
      "#F_1 = (5/8.0)*P_1 + (5/6.0)*p_2\n",
      "#F = BP ,Matric multiplication \n",
      "B = np.array([[(5/8.0),-(5/6.0)],[(5/8.0),(5/6.0)]]) #The matrix form of A\n",
      "U   = np.array([[u_1],[u_2]])\n",
      "e = P = np.dot((B.T),U) #L/AE, Nodal forces matrix\n",
      "print \"a) The components of displacement of point B are\",round(e[0],2),\"L/AE and\",round(e[1],2),\"L/AE\" \n",
      "\n",
      "\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "b) The vertical component of the nodal force is [ 12.] \n",
        "b) The vertical component of the nodal force is [ 24.] \n",
        "a) The components of displacement of point B are 18.75 L/AE and 16.67 L/AE\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.10 page number 667"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "A_1 = 0.125         #in2 , The area of the crossection of AB\n",
      "A_2 = 0.219         #in2 , The area of the crossection of BC\n",
      "l_1 = 3*(5**0.5)    #in , The length of AB\n",
      "l_2 = 6*(2**0.5)    #in , The length of BC\n",
      "p = 3               #k , Force acting on the system \n",
      "E = 10.6*(10**3)    #Ksi - youngs modulus of the material\n",
      "p_1 = (5**0.5)*p/3  #P, The component of p on AB\n",
      "p_2 = -2*(2**0.5)*p/3 #P, The component of p on AB\n",
      "\n",
      "e = p_1*l_1*p_1/(p*E*A_1) + p_2*l_2*p_2/(p*E*A_2) #in, By virtual deflection method  \n",
      "print \"The deflection is\",round(e,3),\"in\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The deflection is 0.018 in\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}