{
 "metadata": {
  "name": "",
  "signature": "sha256:05786e622b820b192f974e7ef748cfea2396e08a32d8eacacaccd134e7dd7e82"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter4-Inelastic Material Behavior"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the constants beta and gamma for annealed high carbon steel and compute the deflection U \n",
      "## initialization of variables\n",
      "import math\n",
      "P=170. ##kN\n",
      "A=645. ## (mm)^2\n",
      "## part (a)\n",
      "E=211.4 ## G Pa (from figure)\n",
      "Y=252.6 ## M Pa (from figure)\n",
      "Beta=0.0799 ## G Pa (from figure)\n",
      "Ey=Y/E\n",
      "## The stress strain law given is\n",
      "## Sigma= E*eps  for eps< Ey\n",
      "## Sigma= (1-Beta)*Y + Beta*E*eps  otherwise\n",
      "\n",
      "## part (b)\n",
      "th=math.atan(1.8/2.4)## radians\n",
      "F=P/(2.*math.cos(th))\n",
      "F=F*10**3 ##N\n",
      "A=A*10**-6 ##m^2\n",
      "E=E*10**9 ##Pa\n",
      "Y=Y*10**6 ##Pa\n",
      "L=3.0 ##m\n",
      "Sigma=F/A\n",
      "if(Sigma<Y):\n",
      "    eps=Sigma/E\n",
      "else:\n",
      "   eps=(Sigma-(1-Beta)*Y )/(Beta*E) \n",
      "\n",
      "u=eps*L/math.cos(th)\n",
      "u=u*10**3 ##mm\n",
      "## results\n",
      "print('part (b)\\n')\n",
      "print\"%s %.2f %s\"%(' Deflection = ',u,' mm')\n",
      "\n",
      "## part (c)\n",
      "P=270. ##kN\n",
      "F=P/(2.*math.cos(th))\n",
      "F=F*10**3 ##N\n",
      "Sigma=F/A\n",
      "if(Sigma<Y):\n",
      "    eps=Sigma/E\n",
      "else:\n",
      "   eps=(Sigma-(1-Beta)*Y )/(Beta*E) \n",
      "u=eps*L/math.cos(th)\n",
      "u=u*10**3 ##mm\n",
      "## results\n",
      "print('\\n part (c)\\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' Deflection = ',u,' mm'and  'for P = ',P,'kN')\n",
      "\n",
      "P=300. ##kN\n",
      "F=P/(2.*math.cos(th))\n",
      "F=F*10**3 ##N\n",
      "Sigma=F/A\n",
      "if(Sigma<Y):\n",
      "    eps=Sigma/E\n",
      "else:\n",
      "   eps=(Sigma-(1-Beta)*Y )/(Beta*E) \n",
      "\n",
      "u=eps*L/math.cos(th)\n",
      "u=u*10**3 ##mm\n",
      "## results\n",
      "print\"%s %.2f %s %.2f %s\"%('\\n Deflection = ',u,' mm'and  'for P = ',P,' kN')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (b)\n",
        "\n",
        " Deflection =  2.92  mm\n",
        "\n",
        " part (c)\n",
        "\n",
        " Deflection =  6.49 for P =  270.00 kN \n",
        "\n",
        " Deflection =  12.94 for P =  300.00  kN\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the load parameter and residual forces and fully plastic load \n",
      "## initialization of variables\n",
      "import math\n",
      "## Material properties\n",
      "E=200. ##GPa\n",
      "A=100. ##mm^2\n",
      "Y1=500. ##M Pa\n",
      "Y2=250. ## MPa\n",
      "## calculations\n",
      "E=E*10**9 ## Pa\n",
      "A=A*10**-6 ##m^2\n",
      "Y1=Y1*10**6 ## Pa\n",
      "Y2=Y2*10**6 ##Pa\n",
      "L_FG=1. ##m\n",
      "L_CD=2. ## m\n",
      "P1=Y2*A\n",
      "e=P1*L_FG/(E*A)\n",
      "e_FG=e\n",
      "e_CD=e\n",
      "P2=E*A*e_FG/L_FG\n",
      "P3=E*A*e_CD/L_CD\n",
      "Py=2.*P1+2.*P2+P3\n",
      "##results\n",
      "print('part (a) \\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' Yield Load Py = ',Py/10**3,' kN' and 'the displacement is ',e*10**3,' mm')\n",
      "\n",
      "## part(b)\n",
      "P4=Y1*A\n",
      "e=P4*L_FG/(E*A)\n",
      "P5=E*A*e/L_CD\n",
      "P=2.*P1+2.*P4+P5\n",
      "print('\\n part (b) \\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' Yield Load P = ',P/10**3,' kN' and 'the displacement is ',e*10**3,' mm')\n",
      "## Fully plastic load\n",
      "P6=Y2*A*2.\n",
      "Pp=2.*P1+2.*P4+P6\n",
      "e_CD=P6*L_CD/(E*A)\n",
      "print\"%s %.2f %s %.2f %s \"%('\\n Fully Plastic Load Pp = ',Pp/10**3,' kN' and 'the displacement is ',e_CD*10**3,' mm')\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a) \n",
        "\n",
        " Yield Load Py =  112.50 the displacement is  1.25  mm \n",
        "\n",
        " part (b) \n",
        "\n",
        " Yield Load P =  175.00 the displacement is  2.50  mm \n",
        "\n",
        " Fully Plastic Load Pp =  200.00 the displacement is  5.00  mm \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the determine factor of safety SF against yeild and determine which criterion tersca or vonmises and illustrate stress state\n",
      "## initialization of variables\n",
      "import math\n",
      "## Stresses\n",
      "import numpy\n",
      "Sxx=100. ## MPa\n",
      "Syy=-14. ## MPa\n",
      "Sxy=50. ## MPa\n",
      "Y=300. ## MPa\n",
      "## part (a)\n",
      "Szz=0. ## MPa\n",
      "Syz=0. ##MPa\n",
      "Sxz=0. ## MPa\n",
      "## To calculate principal stresses\n",
      "I1=Sxx+Syy+Szz\n",
      "I2=Sxx*Syy-Sxy**2+Szz*Sxx-Sxz**2+Szz*Syy-Syz**2\n",
      "M=([[Sxx, Sxy, Sxz],\n",
      "   [Sxy ,Syy, Syz],\n",
      "   [Sxz, Syz, Szz]])\n",
      "I3=numpy.linalg.det(M)   \n",
      "p=([1, -I1, I2 ,-I3])\n",
      "Sigma=numpy.roots(p)\n",
      "Smax=Sigma[0]\n",
      "Smin=Sigma[1]\n",
      "## Smax=max(Sigma)\n",
      "## Smin=min(Sigma)\n",
      "tau_max=Y/2.\n",
      "SF=tau_max*2./(Smax-Smin)\n",
      "print('part (a)\\n')\n",
      "print\"%s %.2f %s\"%(' SF = ',SF,' if the material obeys Tresca criterion')\n",
      "\n",
      "## part (b)\n",
      "SF=math.sqrt(2)*Y/math.sqrt((Smax**2)+(Smin**2)+(Smin-Smax)**2)\n",
      "print('\\n part (b)')\n",
      "print\"%s %.2f %s\"%('\\n SF = ',SF,' if the material obeys von Mises criterion')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part (a)\n",
        "\n",
        " SF =  1.98  if the material obeys Tresca criterion\n",
        "\n",
        " part (b)\n",
        "\n",
        " SF =  2.17  if the material obeys von Mises criterion\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}