{
 "metadata": {
  "name": "",
  "signature": "sha256:ee3efcb70c7b8625c2621d2e113f06299bf0d0de2c90519d4a9ec891c7f588ab"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter3-Linear Stress-Strain Temperature Relations"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the maximum circumferential stress\n",
      "## initialization of variables\n",
      "import math\n",
      "## part (a)\n",
      "E=72. ## G Pa\n",
      "v=0.33 ## Poisoon's ratio\n",
      "h=2. ## mm\n",
      "R=600. ## mm\n",
      "##calculations\n",
      "sig_cir=E*h/(2.*(1.-v**2)*R)\n",
      "## results\n",
      "print('\\n part (a) \\n')\n",
      "print\"%s %.2f %s\"%(' The maximum circumferential stress is ',sig_cir*10**3,' M Pa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " part (a) \n",
        "\n",
        " The maximum circumferential stress is  134.67  M Pa\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the stress in aluminum and steel cylinder \n",
      "## initialization of variables\n",
      "import math\n",
      "tR=0.02 ## t/R ration\n",
      "E_A=69. ##G Pa\n",
      "v_A=0.33  ## Poisson's ratio\n",
      "alpha_A=21.6*10**-6 ## /degree Celcius (Coefficient of expansion)\n",
      "E_S=207. ## G Pa\n",
      "v_S=0.280\n",
      "alpha_S=10.8*10**-6 ## /degree Celcius (Coefficient of expansion)\n",
      "## calculations\n",
      "## Sig_LA=a*p+b*delT+c*sig_thS\n",
      "## Sig_LS=v_S*Sig_thS+d*delT\n",
      "E_S=E_S*10**9\n",
      "E_A=E_A*10**9\n",
      "a=1./tR*E_A/E_S\n",
      "b=-2./3.*alpha_S*E_S\n",
      "c=-E_A/E_S\n",
      "d=-alpha_S*E_S\n",
      "## SigthS=e*p+f*delT\n",
      "## SigthA=g*p+h*delT\n",
      "e=37.16\n",
      "f=0.8639*10**6\n",
      "g=1./tR-e\n",
      "h=-f\n",
      "## results\n",
      "p=689.4 ## kPa\n",
      "delT=100. ## degree Celcius\n",
      "p=p*10**3 ## Pa\n",
      "SigthA=g*p+h*delT\n",
      "SigthS=e*p+f*delT\n",
      "Sig_LA=a*p+b*delT+c*SigthS\n",
      "Sig_LS=v_S*SigthS+d*delT\n",
      "print\"%s %.2f %s %.2f %s \"%('Thus, for p = ',p/10**3,' k Pa' and 'delT = ',delT,' degree celcius \\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' SigthA = ',SigthA/10**6,' M Pa'and   'Sig_LA = ',Sig_LA/10**6,' M Pa \\n')\n",
      "print\"%s %.2f %s %.2f %s \"%(' SigthS = ',SigthS/10**6,' M Pa'and    'Sig_LS = ',Sig_LS/10**6,' M Pa')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thus, for p =  689.40 delT =  100.00  degree celcius \n",
        " \n",
        " SigthA =  -77.54 Sig_LA =  -174.89  M Pa \n",
        " \n",
        " SigthS =  112.01 Sig_LS =  -192.20  M Pa \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##calculate the  orientation of the principal stress and deterimine stress components and orientation of the principal axes of strain\n",
      "## initialization of variables\n",
      "import math\n",
      "import numpy\n",
      "## Material constants\n",
      "Ex=14700. ## M Pa\n",
      "Ey=1000. ## M Pa\n",
      "Ez=735. ## M Pa\n",
      "Gxy=941. ## M Pa\n",
      "Gxz=1147. ## M Pa\n",
      "Gyz=103. ## M pa\n",
      "Vxy=0.292\n",
      "Vxz=0.449\n",
      "Vyz=0.39\n",
      "## Stresses at a point\n",
      "Sxx=7. ## M pa\n",
      "Syy=2.1 ## M Pa\n",
      "Szz=-2.8 ##M Pa\n",
      "Sxy=1.4 ## M Pa\n",
      "Sxz=0. ##M Pa\n",
      "Syz=0. ## M Pa\n",
      "## part (a)\n",
      "th=1/2.*math.atan(2.*Sxy/(Sxx-Syy))*180./math.pi\n",
      "I1=Sxx+Syy+Szz\n",
      "I2=Sxx*Syy-Sxy**2+Szz*Sxx-Sxz**2+Szz*Syy-Syz**2\n",
      "M=numpy.matrix([[Sxx, Sxy, Sxz],\n",
      "   [Sxy, Syy, Syz],\n",
      "   [Sxz, Syz, Szz]])\n",
      "I3=numpy.linalg.det(M)   \n",
      "p=([1, -I1, I2 ,-I3])\n",
      "S=numpy.roots(p)\n",
      "## results\n",
      "print('Part (a) \\n')\n",
      "print\"%s %.2f %s\"%('The maximum principal stress is S1 = ',S[0],' M Pa')\n",
      "print\"%s %.2f %s\"%('\\n and occurs in direction th = ',th,' degrees')\n",
      "print\"%s %.2f %s %.2f %s \"%('\\n and the intermediate principal stress S2 = ',S[2],' M Pa'and 'occurs in the direction th = ',th+90,' degrees \\n')\n",
      "print\"%s %.2f %s\"%(' The minimum principal stress is S3 = Szz = ',S[1],' M Pa')\n",
      "Ex=Ex*10**6\n",
      "Ey=Ey*10**6\n",
      "Ez=Ez*10**6\n",
      "Gxy=Gxy*10**6\n",
      "Gxz=Gxz*10**6\n",
      "Gyz=Gyz*10**6\n",
      "## part (b) is to find strains\n",
      "Exx=Sxx/Ex-Vxy*Syy/Ey-Vxz*Szz/Ez\n",
      "Eyy=-Vxy*Sxx/Ex+Syy/Ey-Vyz*Szz/Ez\n",
      "Ezz=-Vxz*Sxx/Ex-Vyz*Syy/Ey+Szz/Ez\n",
      "Exy=Sxy/Gxy\n",
      "Exz=Sxz/Gxz\n",
      "Eyz=Syz/Gyz\n",
      "print('\\n Part (b)')\n",
      "print('\\n The srains are')\n",
      "print\"%s %.2e %s %.2e %s %.2e %s\"%('\\n Exx = ',Exx,'' and'Eyy =',Eyy,''and 'Ezz = ',Ezz,'')\n",
      "print\"%s %.2e %s %.2d %s %.2d %s\"%('\\n Exy = ',Exy,''and '  Exz = ',Exz,''and  'Eyz = ',Eyz,'')\n",
      "## Wrong Exx value in the textbook\n",
      "th=1/2.*math.atan(Exy/(Exx-Eyy))\n",
      "th=th*180./math.pi\n",
      "th2=th+90.\n",
      "print('\\n part (c)')\n",
      "print\"%s %.2f %s %.2f %s \"%('\\n theta = ',th,'' and 'or theta=',th2,'degrees')\n",
      "## Wrong theta too since Example  given in textbook is wrong\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part (a) \n",
        "\n",
        "The maximum principal stress is S1 =  7.37  M Pa\n",
        "\n",
        " and occurs in direction th =  14.87  degrees\n",
        "\n",
        " and the intermediate principal stress S2 =  1.73 occurs in the direction th =  104.87  degrees \n",
        " \n",
        " The minimum principal stress is S3 = Szz =  -2.80  M Pa\n",
        "\n",
        " Part (b)\n",
        "\n",
        " The srains are\n",
        "\n",
        " Exx =  1.57e-09  3.45e-09  -4.84e-09 \n",
        "\n",
        " Exy =  1.49e-09  00  00 \n",
        "\n",
        " part (c)\n",
        "\n",
        " theta =  -19.23  70.77 degrees \n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}