{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 21: Machining of Metals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### Example 21.1, Mechanics of Machining, Page No. 685"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Shear Plane Angle for 1040 steel= 22.2946 deg\n",
      "\n",
      "Shear Plane Angle for Copper = 10.6433 deg\n"
     ]
    }
   ],
   "source": [
    "from scipy.optimize import fsolve\n",
    "from math import radians, degrees, pi, cos, sin\n",
    "\n",
    "#variable declaration\n",
    "a=6;\n",
    "sigma_s=60000.0;\n",
    "su_s=91000.0;\n",
    "sigma_c=10000.0;\n",
    "su_c=30000;\n",
    "a=radians(a);\n",
    "\n",
    "\n",
    "#calculation\n",
    "def s(fi):\n",
    "    return cos(fi-a)*sin(fi)-sigma_s/su_s*(cos(pi/4-a/2)*sin(pi/4+a/2))\n",
    "def c(fi):\n",
    "    return cos(fi-a)*sin(fi)-sigma_c/su_c*(cos(pi/4-a/2)*sin(pi/4+a/2))\n",
    "fi1=fsolve(s,0);\n",
    "fi2=fsolve(c,0);\n",
    "fi1=degrees(fi1);\n",
    "fi2=degrees(fi2);\n",
    "\n",
    "#result\n",
    "print('\\nShear Plane Angle for 1040 steel= %g deg')%(fi1);\n",
    "print('\\nShear Plane Angle for Copper = %g deg')%(fi2);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 21.2, Mechanics of Machining, Page No. 687"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Slip plane angle = 33.1927 deg\n",
      "Percentage of total energy that goes into friction = 30.918 percent\n",
      "Percentage of total energy that goes into shear = 69.082 percent\n",
      "Total energy per unit volume = 0.197285 hp min/in^3\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "from math import sin\n",
    "from math import cos\n",
    "from math import tan\n",
    "from math import atan\n",
    "from math import radians\n",
    "from math import sqrt\n",
    "from math import degrees\n",
    "\n",
    "#variable declaration\n",
    "v=500;\n",
    "alpha=6;\n",
    "b=0.4;\n",
    "t=0.008;\n",
    "Fv=100;\n",
    "Fh=250;\n",
    "L=20;\n",
    "rho=0.283;\n",
    "m=13.36;\n",
    "m=m/454;            #conversion to lb\n",
    "\n",
    "#calculation\n",
    "tc=m/(rho*b*L);\n",
    "r=t/tc;\n",
    "alpha=radians(alpha);\n",
    "fi=atan(r*cos(alpha)/(1-r*sin(alpha)));\n",
    "#fi=degrees(fi);\n",
    "mu=(Fv+Fh*tan(alpha))/(Fh-Fv*tan(alpha));\n",
    "be=atan(mu);\n",
    "Pr=sqrt(Fv**2+Fh**2);\n",
    "Ft=Pr*sin(be);\n",
    "p_fe=Ft*r/Fh;\n",
    "Fs=Fh*cos(fi)-Fv*sin(fi);\n",
    "vs=v*cos(alpha)/cos(fi-alpha);\n",
    "p_se=Fs*vs/(Fh*v);\n",
    "U=Fh*v/(b*t*v);\n",
    "U=U/33000;                     #conversion to hp\n",
    "U=U/12;                         #conversion of ft units to in units\n",
    "fi=degrees(fi);\n",
    "\n",
    "#result\n",
    "print('\\nSlip plane angle = %g deg\\nPercentage of total energy that goes into friction = %g percent\\nPercentage of total energy that goes into shear = %g percent\\nTotal energy per unit volume = %g hp min/in^3')%(fi,p_fe*100,p_se*100,U);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 21.3, Tool Materials and Tool Life, Page No. 698"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "For High Speed steel tool, increase in tool life is given by: t2 = 322.54 t1\n",
      "\n",
      "For Cemented carbide tool, increase in tool life is given by: t2 = 10.0794 t1\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "#variable declaration\n",
    "d=0.5;\n",
    "\n",
    "#calculation\n",
    "t1=(1/d)**(1/0.12);\n",
    "t2=(1/d)**(1/0.3);\n",
    "\n",
    "#result\n",
    "print('\\nFor High Speed steel tool, increase in tool life is given by: t2 = %g t1')%(t1);\n",
    "print('\\nFor Cemented carbide tool, increase in tool life is given by: t2 = %g t1')%(t2);\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 21.4, Grinding Processes, Page No. 703"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tangential force = 24 N\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "#variable declaration\n",
    "U=40;\n",
    "uw=0.3;\n",
    "b=1.2;\n",
    "v=30;\n",
    "d=0.05;\n",
    "\n",
    "#calculation\n",
    "b=b*10**-3;                   #conversion to m\n",
    "d=d*10**-3;                     #conversion to m\n",
    "U=U*10**9;                     #conversion to Pa\n",
    "M=uw*b*d;\n",
    "P=U*M;\n",
    "F=P/v;\n",
    "\n",
    "#result\n",
    "print('Tangential force = %g N')%(F);\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "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
}