{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 8: The Tension Test"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### Example 8.1, Standard properties of the material, Page No. 281"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Ultimate Tensile Strength = 92363.2 psi\n",
      "0.2 percent offset yield strength = 74889.1 psi\n",
      "Breaking Stress = 80880.2 psi\n",
      "Elongation = 26.5 percent\n",
      "Reduction of Area = 61.092 percent\n",
      "\n",
      "\n",
      "Note: Slight Computational Errors in book\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from math import pi\n",
    "\n",
    "#variable declaration\n",
    "D=0.505;\n",
    "Lo=2;\n",
    "Lf=2.53;\n",
    "Py=15000;\n",
    "Pmax=18500;\n",
    "Pf=16200;\n",
    "D_f=0.315;\n",
    "\n",
    "#calculation\n",
    "A0=pi*D**2/4;\n",
    "Af=pi*D_f**2/4;\n",
    "s_u=Pmax/A0;\n",
    "s0=Py/A0;\n",
    "s_f=Pf/A0;\n",
    "e_f=(Lf-Lo)/Lo;\n",
    "q=(A0-Af)/A0;\n",
    "\n",
    "#result\n",
    "print('\\nUltimate Tensile Strength = %g psi\\n0.2 percent offset yield strength = %g psi\\nBreaking Stress = %g psi\\nElongation = %g percent\\nReduction of Area = %g percent\\n\\n\\nNote: Slight Computational Errors in book')%(s_u,s0,s_f,e_f*100,q*100);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 8.2, True Strain, Page No. 288"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "True Strain to fracture using changes in length = 0.405465\n",
      "True Strain to fracture using changes in area = 0.405465\n",
      "\n",
      "\n",
      "\n",
      "For More ductile metals\n",
      "True Strain to fracture using changes in length = 0.729961\n",
      "True Strain to fracture using changes in diameter = 0.940007\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from math import log\n",
    "\n",
    "#case 1\n",
    "#variable declaration\n",
    "Af=100.0;\n",
    "Lf1=60.0;\n",
    "A0=150.0;\n",
    "L01=40.0;\n",
    "Lf=83.0;\n",
    "L0=40.0;\n",
    "Df=8.0;\n",
    "D0=12.8;\n",
    "\n",
    "#calculation\n",
    "L1=float (Lf1/L01);\n",
    "A1=float (A0/Af);\n",
    "ef11=log(L1);\n",
    "ef21=log(A1);\n",
    "L2=(Lf/L0);\n",
    "D2=D0/Df;5\n",
    "ef12=log(L2);\n",
    "ef22=2*log(D2);\n",
    "\n",
    "#result\n",
    "print('\\nTrue Strain to fracture using changes in length = %g\\nTrue Strain to fracture using changes in area = %g')%(ef11,ef21);\n",
    "print('\\n\\n\\nFor More ductile metals\\nTrue Strain to fracture using changes in length = %g\\nTrue Strain to fracture using changes in diameter = %g')%(ef12,ef22);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 8.3, Ultimate Tensile Strength, Page No. 290"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Ultimate Tensile Strength = 99729.2 psi\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "from math import exp\n",
    "\n",
    "#variable declaration\n",
    "def sigma(e):\n",
    "    return 200000*e**0.33;\n",
    "E_u=0.33;\n",
    "\n",
    "#calculation\n",
    "sigma_u=sigma(E_u);\n",
    "s_u=sigma_u/exp(E_u);\n",
    "\n",
    "#result\n",
    "print('Ultimate Tensile Strength = %g psi')%(s_u);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 8.4, Effect of Strain Rate, Page No. 298"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "At 70deg F\n",
      "\n",
      "sigma_a = 10.2 ksi\n",
      "sigma_b = 13.8229 ksi\n",
      "sigma_b/sigma_a = 1.35519\n",
      "\n",
      "\n",
      "\n",
      "At 825deg F\n",
      "\n",
      "sigma_a = 2.1 ksi\n",
      "sigma_b = 5.54906 ksi\n",
      "sigma_b/sigma_a = 2.64241\n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "#variable declaration\n",
    "C_70=10.2;\n",
    "C_825=2.1;\n",
    "m_70=0.066;\n",
    "m_825=0.211;\n",
    "e1=1;\n",
    "e2=100;\n",
    "\n",
    "#calculation 1\n",
    "print('\\nAt 70deg F\\n');\n",
    "sigma_a=C_70*e1**m_70;\n",
    "sigma_b=C_70*e2**m_70;\n",
    "\n",
    "#result 1\n",
    "print('sigma_a = %g ksi\\nsigma_b = %g ksi\\nsigma_b/sigma_a = %g\\n')%(sigma_a,sigma_b,sigma_b/sigma_a);\n",
    "\n",
    "\n",
    "#calculation 2\n",
    "print('\\n\\nAt 825deg F\\n');\n",
    "sigma_a=C_825*e1**m_825;\n",
    "sigma_b=C_825*e2**m_825;\n",
    "\n",
    "#result 2\n",
    "print('sigma_a = %g ksi\\nsigma_b = %g ksi\\nsigma_b/sigma_a = %g\\n')%(sigma_a,sigma_b,sigma_b/sigma_a);\n"
   ]
  }
 ],
 "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
}