{
 "metadata": {
  "name": "",
  "signature": "sha256:8153891fd31915fc027b9835e482fe359e89a7a1a683b21a2334c8771f72e58d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter4-Stress-Strain Relations"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## initialization of variables\n",
      "import numpy\n",
      "E=2.*10**6. ## kg/cm^2\n",
      "G=8.*10**5. ## kg/cm^2\n",
      "ep=numpy.matrix([[0.001, 0, -0.002],\n",
      "    [0 ,-0.003, 0.0005],\n",
      "    [-0.002, 0.0005, 0]])\n",
      "## calculations\n",
      "nu=E/(2.*G)-1.\n",
      "D=E*nu/((1.+nu)*(1.-2.*nu))\n",
      "mu=G\n",
      "sigma=2.*mu*ep[0,0]+D*(ep[0,0]+ep[1,1]+ep[2,2])\n",
      "sigma=2.*mu*ep[1,1]+D*(ep[0,0]+ep[1,1]+ep[2,2])\n",
      "sigma=2.*mu*ep[2,2]+D*(ep[0,0]+ep[1,1]+ep[2,2])\n",
      "tau=2.*mu*ep[0,1]\n",
      "tau=2.*mu*ep[0,2]\n",
      "tau=2.*mu*ep[1,2]\n",
      "tau=numpy.matrix([[sigma, tau, tau],\n",
      "     [tau, sigma, tau],\n",
      "     [tau, tau, sigma]])\n",
      "## results\n",
      "print'%s %.2f %s  %.2f %s'%('The lames constants are ',D,' and ',mu,'kg/cm^2')\n",
      "print('\\n The stres tensor is')\n",
      "print(tau)\n",
      "print('in text book calculations are done wrong')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The lames constants are  800000.00  and   800000.00 kg/cm^2\n",
        "\n",
        " The stres tensor is\n",
        "[[-1600.   800.   800.]\n",
        " [  800. -1600.   800.]\n",
        " [  800.   800. -1600.]]\n",
        "in text book calculations are donw wrong\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "## initialization of variables\n",
      "#find the magnitude and direction of all the principal strains\n",
      "sigma_x=1000. ##kg/cm^2\n",
      "sigma_y=-500. ##kg/cm^2\n",
      "sigma_z=0.  ##kg/cm^2\n",
      "tau_xy=500. ##kg/cm^2\n",
      "E=2.*10**6 ## kg/cm^2\n",
      "nu=0.25\n",
      "##calculations\n",
      "ep_x=1./E*(sigma_x-nu*(sigma_y+sigma_z))\n",
      "ep_y=1./E*(sigma_y-nu*(sigma_x+sigma_z))\n",
      "ep_z=1./E*(sigma_z-nu*(sigma_y+sigma_x))\n",
      "J1=ep_x+ep_y+ep_z\n",
      "sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)\n",
      "sigma_2=(sigma_x+sigma_y)/2.-math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)\n",
      "th=1/2.*math.atan(2.*tau_xy/(sigma_x-sigma_y))\n",
      "th=th*180/math.pi\n",
      "ep_1=1./E*(sigma_1-nu*sigma_2)\n",
      "ep_2=1./E*(sigma_2-nu*sigma_1)\n",
      "ep_3=-1./E*nu*(sigma_1+sigma_2)\n",
      "##results\n",
      "print'%s %.5f %s'%('The magnitude of principal strain are ',abs(ep_1),'')\n",
      "print'%s %.5f %s'%('The magnitude of principal strain are ',abs(ep_2),'')\n",
      "print'%s %.5f %s'%('The magnitude of principal strain are ',abs(ep_3),'')\n",
      "print'%s %.2f %s'%('\\n and the diection is given by theta=',th,' degrees')\n",
      "print'%s %.8f %s'%('\\n J1 is ',J1,'')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The magnitude of principal strain are  0.00066 \n",
        "The magnitude of principal strain are  0.00047 \n",
        "The magnitude of principal strain are  0.00006 \n",
        "\n",
        " and the diection is given by theta= 16.85  degrees\n",
        "\n",
        " J1 is  0.00012500 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#findd the value of sigma y and principal stress\n",
      "# initialization of variables\n",
      "\n",
      "sigma_x=1400. ##kg/cm^2\n",
      "tau_xy=400.## kg/cm^2\n",
      "ep_z=-3.6*10**-6\n",
      "nu=1/4.\n",
      "E=2*10**8 ##kg/cm^2\n",
      "## calculations\n",
      "sigma_y=(-ep_z*E/nu)-sigma_x\n",
      "sigma_1=(sigma_x+sigma_y)/2.+math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)\n",
      "sigma_2=(sigma_x+sigma_y)/2-math.sqrt((1/2.*(sigma_x-sigma_y))**2+tau_xy**2)\n",
      "th=0.5*math.atan(2*tau_xy/(sigma_x-sigma_y))\n",
      "th=th*180/math.pi\n",
      "print'%s %.2f %s'%('sigma_y is ',sigma_y,' kg/cm^2')\n",
      "print'%s %.2f %s %.2f %s '%('\\n The principal stresses are',sigma_1,'kg/cm^2 'and '',sigma_2,'kg/cm^2')\n",
      "print'%s %.2f %s'%('\\n The direction is given by theta = ',-th,' degrees')\n",
      "\n",
      "## angle was given wrong in the text\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "sigma_y is  1480.00  kg/cm^2\n",
        "\n",
        " The principal stresses are 1842.00  1038.00 kg/cm^2 \n",
        "\n",
        " The direction is given by theta =  42.14  degrees\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg121"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "##initialization of variables\n",
      "#detemine wheather there is yielding according to tresca and von moises conditions or not\n",
      "C=1000./3. ##kg/cm^2\n",
      "sigma_x=2.*C\n",
      "sigma_y=4.*C\n",
      "tau_xy=4.*C\n",
      "sigma_0=4.*C\n",
      "sigma_1=3.+C*math.sqrt(2.)\n",
      "sigma_2=3.-C*math.sqrt(2.)\n",
      "sigma_3=0.\n",
      "tau_oct=1/3.*math.sqrt((sigma_1-sigma_2)**2+(sigma_2-sigma_3)**2+(sigma_3-sigma_1)**2)\n",
      "tau_max=sigma_1/2.\n",
      "taU=1.885*C\n",
      "tau_y=2.*C\n",
      "print'%s %.2f %s'%('Actual tau is ',taU,'')\n",
      "print'%s %.2f %s'%('\\n tau_max at yield is ',tau_y,'')\n",
      "print('\\n Hence yielding doesn not occur according to Von-Miles condition \\n but it occurs due to Tresca condition')\n",
      "print('\\n In text book C is not multiplied' )\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Actual tau is  628.33 \n",
        "\n",
        " tau_max at yield is  666.67 \n",
        "\n",
        " Hence yielding doesn not occur according to Von-Miles condition \n",
        " but it occurs due to Tresca condition\n",
        "\n",
        " In text book C is not multiplied\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}