{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 16: Forging"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 16.1, Forging in Plain Strain, Page No. 574"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "At the centerline of the slab = 63044.5 psi\n",
      "\n",
      "\n",
      "Pressure Distributon from the centerline:\n",
      "\n",
      "---------------------------------\n",
      "\n",
      "x\tp (ksi)\t\tt_i (ksi)\n",
      "\n",
      "---------------------------------\n",
      "\n",
      "0\t63.0445\t\t15.7611\n",
      "\n",
      "0.25\t38.2384\t\t9.55961\n",
      "\n",
      "0.5\t23.1928\t\t5.7982\n",
      "\n",
      "0.75\t14.0671\t\t3.51678\n",
      "\n",
      "1\t8.53215\t\t2.13304\n",
      "\n",
      "1.25\t5.17501\t\t1.29375\n",
      "\n",
      "1.5\t3.1388\t\t0.7847\n",
      "\n",
      "1.75\t1.90378\t\t0.475945\n",
      "\n",
      "2\t1.1547\t\t0.288675\n",
      "\n",
      "---------------------------------\n",
      "\n",
      "\n",
      "For sticking friction:\n",
      "p_max = 10.3923 ksi\n",
      "\n",
      "\n",
      "The Forging load = 62.7695 tons\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "from math import exp\n",
    "from math import log\n",
    "\n",
    "#variable declaration\n",
    "sigma=1000;\n",
    "mu=0.25;\n",
    "a=2;\n",
    "b=6;\n",
    "h=0.25;\n",
    "x=0;\n",
    "mu=0.25;\n",
    "\n",
    "#calculation\n",
    "p_max=2*sigma*exp(2*mu*(a-x)/h)/sqrt(3);\n",
    "print('\\nAt the centerline of the slab = %g psi\\n')%(p_max);\n",
    "print('\\nPressure Distributon from the centerline:');\n",
    "print('\\n---------------------------------\\n');\n",
    "print('x\\tp (ksi)\\t\\tt_i (ksi)\\n');\n",
    "print('---------------------------------\\n');\n",
    "while x<=2:\n",
    "    p=2*sigma*exp(2*mu*(a-x)/h)/(1000*sqrt(3));             #in ksi\n",
    "    t_i=mu*p;\n",
    "    print('%g\\t%g\\t\\t%g\\n')%(x,p,t_i);\n",
    "    x+=0.25;\n",
    "print('---------------------------------\\n');\n",
    "k=sigma/sqrt(3);\n",
    "x=0;\n",
    "p_max1=2*sigma*((a-x)/h+1)/sqrt(3);\n",
    "x1=a-h/(2*mu)*log(1/(2*mu));\n",
    "p=2*sigma*(a/(2*h)+1)/sqrt(3);\n",
    "P=2*p*a*b;\n",
    "P=P*0.000453;                      #conversion to metric tons\n",
    "\n",
    "#result\n",
    "print('\\nFor sticking friction:\\np_max = %g ksi')%(p_max1/1000);\n",
    "print('\\n\\nThe Forging load = %g tons')%(P);"
   ]
  }
 ],
 "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
}