{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#12: Mechanical Behaviour of Materials"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.1, Page number 12.115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "yield strength is 86.026 kg/mm**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "sigma0=8.55;\n",
    "K=2.45;      \n",
    "sigma=10**-3;      #steel size(mm)\n",
    "\n",
    "#Calculation\n",
    "sigma=sigma0+(K/math.sqrt(sigma));      #yield strength\n",
    "\n",
    "#Result\n",
    "print \"yield strength is\",round(sigma,3),\"kg/mm**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.2, Page number 12.115"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fracture strength is 0.211 GPa\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "E=70*10**9;     #young's modulus(Pa)\n",
    "gama=1;     #surface energy(joule/m**2)\n",
    "C=1*10**-6;    #depth(m)\n",
    "\n",
    "#Calculation\n",
    "sigma_f=math.sqrt(2*E*gama/(math.pi*C));      #fracture strength(GPa)\n",
    "\n",
    "#Result\n",
    "print \"fracture strength is\",round(sigma_f/10**9,3),\"GPa\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.3, Page number 12.116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ultimate tensile strength is 736.0 MPa\n",
      "ductility % of elongation is 10.0 %\n",
      "ductility % of reduction is 75.0 %\n",
      "modulus of toughness is 49 *10**6 Pa\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "ml=57800;     #load(N)\n",
    "d=10*10**-3;    #diameter(m)\n",
    "D=5;      #diameter after fracture(mm)\n",
    "l=50;    #guage length(mm)\n",
    "L=55;    #length after fracture(mm)\n",
    "\n",
    "#Calculation\n",
    "ts=ml/(math.pi*(d/2)**2);    #ultimate tensile strength(MPa)\n",
    "de=(L-l)*100/l;          #ductility % of elongation(%)\n",
    "dr=((2*D)**2-D**2)*100/(2*D)**2;      #ductility % of reduction(%)\n",
    "t=(2/3)*ts*de/100;        #modulus of toughness(Pa)\n",
    "\n",
    "#Result\n",
    "print \"ultimate tensile strength is\",round(ts/10**6),\"MPa\"\n",
    "print \"ductility % of elongation is\",de,\"%\"\n",
    "print \"ductility % of reduction is\",dr,\"%\"\n",
    "print \"modulus of toughness is\",int(t/10**6),\"*10**6 Pa\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.4, Page number 12.116"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "elastic strain in 1st case is 0.001\n",
      "ratio of elastic and plastic strain in 2nd case is 2.5 %\n",
      "ratio of elastic and plastic strain in 3rd case is 1.0 %\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "pl1=206850*10**3;     #proportional limit(Pa)\n",
    "pl2=310275*10**3;     #proportional limit(Pa)\n",
    "pl3=413700*10**3;     #proportional limit(Pa)\n",
    "s2=0.0615;      #strain\n",
    "s3=0.2020;      #strain\n",
    "Y=2.0685*10**11;    #young's modulus(Pa)\n",
    "\n",
    "#Calculation\n",
    "e1=pl1/Y;     #elastic strain in 1st case\n",
    "e2=pl2/Y;     #elastic strain in 2nd case\n",
    "p2=s2-e2;     #plastic strain in 2nd case\n",
    "r2=e2*100/p2;   #ratio of elastic and plastic strain in 2nd case\n",
    "e3=pl3/Y;     #elastic strain in 2nd case   \n",
    "p3=s3-e3;     #plastic strain in 2nd case \n",
    "r3=e3*100/p3;   #ratio of elastic and plastic strain in 3rd case\n",
    "\n",
    "#Result\n",
    "print \"elastic strain in 1st case is\",e1\n",
    "print \"ratio of elastic and plastic strain in 2nd case is\",r2,\"%\"\n",
    "print \"ratio of elastic and plastic strain in 3rd case is\",r3,\"%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.5, Page number 12.117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "effective modulus is 738750.0 *10**3 Pa\n",
      "cross sectional area is 1.0831 *10**-4 m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "s=12411*10**3;      #stress(Pa)\n",
    "t=0.0168;     #tension\n",
    "e=0.127;     #elongation(cm)\n",
    "l=15.24;     #length(cm)\n",
    "g=9.8;\n",
    "L=68.04;     #load(kg)\n",
    "\n",
    "#Calculation\n",
    "E_eff=s/t;     #effective modulus(Pa)\n",
    "S=e/l;      \n",
    "W=E_eff*S;\n",
    "A=L*g/W;       #cross sectional area(m**2)\n",
    "\n",
    "#Result\n",
    "print \"effective modulus is\",E_eff/10**3,\"*10**3 Pa\"\n",
    "print \"cross sectional area is\",round(A*10**4,4),\"*10**-4 m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.6, Page number 12.117"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transition temperature is 229.0 K\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "E=35*10**10;     #youngs modulus(Pa)\n",
    "gama=2;     #specific surface energy(J/m**2)\n",
    "C=2*10**-6;    #length(m)\n",
    "x=17700;    \n",
    "y=2.1;\n",
    "z=31.25;\n",
    "\n",
    "#Calculation\n",
    "sigma_f=math.sqrt(2*E*gama/(math.pi*C));     #fracture stress(Pa)\n",
    "T=x/((sigma_f/(9.8*10**6))-y+z);    #transition temperature(K)\n",
    "\n",
    "#Result\n",
    "print \"transition temperature is\",round(T),\"K\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.7, Page number 12.118"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "critical resolved shear stress is 0.898 MPa\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h1=1;\n",
    "h2=1;\n",
    "k1=1;\n",
    "k2=1;\n",
    "l1=1;\n",
    "l2=1;\n",
    "l3=0;\n",
    "s=3.5*10**6;      #stress(Pa)\n",
    "\n",
    "#Calculation\n",
    "x=math.sqrt(h1**2+k1**2+l1**2);\n",
    "y=math.sqrt(h2**2+k2**2+l2**2);\n",
    "z=math.sqrt(h2**2+k2**2+l3**2);\n",
    "cos_phi=((h1*h2)-(k1*k2)+(l1*l2))/(x*y);\n",
    "sin_phi=math.sqrt(1-(cos_phi)**2);\n",
    "cos_theta=((h1*h2)+(k1*k2)+(l1*l3))/(x*z);\n",
    "ss=s*cos_theta*cos_phi*sin_phi;        #critical resolved shear stress(Pa)\n",
    "\n",
    "#Result\n",
    "print \"critical resolved shear stress is\",round(ss/10**6,3),\"MPa\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.8, Page number 12.119"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "activation energy is 192.393 kJ/mol\n",
      "answer varies due to rounding off errors\n",
      "diffusion coefficient is 0.394 *10**-4 m**2/s\n",
      "diffusivity at 300 C is 11.37 *10**-23 m**2/s\n",
      "diffusivity at 700 C is 1.846 *10**-15 m**2/s\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "dz1=4*10**-18;    #diffusivity(m**2/s)\n",
    "dz2=5*10**-13;    #diffusivity(m**2/s)\n",
    "T1=773;    #temperature(K)\n",
    "T2=1273;   #temperature(K)\n",
    "T3=573;   #temperature(K)\n",
    "T4=973;   #temperature(K)\n",
    "\n",
    "#Calculation\n",
    "x1=round(math.log(dz1),2);\n",
    "y1=round(math.log(dz2),3);\n",
    "x2=round(-1/(8.314*T1),7);\n",
    "y2=round(-1/(8.314*T2),7);\n",
    "x=round((x1-y1),3);\n",
    "y=round((x2-y2),6);\n",
    "Q=x/y;      #activation energy(J/mol)\n",
    "z=round(y1-(y2*Q),4);\n",
    "D0=math.exp(z);          #diffusion coefficient(m**2/Vs)\n",
    "D1=D0*math.exp(-Q/(8.314*T3));    #diffusivity at 300 C(m**2/s)\n",
    "D2=D0*math.exp(-Q/(8.314*T4));    #diffusivity at 700 C(m**2/s)\n",
    "\n",
    "#Result\n",
    "print \"activation energy is\",round(Q/10**3,3),\"kJ/mol\"\n",
    "print \"answer varies due to rounding off errors\"\n",
    "print \"diffusion coefficient is\",round(D0*10**4,3),\"*10**-4 m**2/s\"\n",
    "print \"diffusivity at 300 C is\",round(D1*10**23,2),\"*10**-23 m**2/s\"\n",
    "print \"diffusivity at 700 C is\",round(D2*10**15,3),\"*10**-15 m**2/s\"\n",
    "print \"answer given in the book is wrong\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 12.9, Page number 12.119"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "diffusion is 4.9 *10**-15 m**2/s\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "D0=0.73*10**-4;     #diffusion coefficient(m**2/s)\n",
    "Q=170*10**3;     #activation energy(J/mol)\n",
    "R=8.314; \n",
    "T=873;    #temperature(K)\n",
    "\n",
    "#Calculation\n",
    "D=D0*math.exp(-Q/(R*T));     #diffusion(m**2/s)\n",
    "\n",
    "#Result\n",
    "print \"diffusion is\",round(D*10**15,1),\"*10**-15 m**2/s\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}