{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch:5 Introduction to pressure vessels"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 5-1 - Page 138"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t1 is 3.83 mm \n",
      "\n",
      "t2 is 3.894 mm \n"
     ]
    }
   ],
   "source": [
    "p=2#\n",
    "Rm=220#\n",
    "#tensile hoop or circumferential stress= sigt\n",
    "sigr=-2#\n",
    "#sigt=(p*Rm)/t#\n",
    "Sa=230/2#\n",
    "#t1=thickness according to maximum principal stress theory\n",
    "#t2=thickness according to maximum shear stress theory\n",
    "t1=(p*Rm)/Sa#\n",
    "t2=(p*Rm)/(Sa+sigr)#\n",
    "print \"t1 is %0.2f mm \"%(t1)#\n",
    "print \"\\nt2 is %0.3f mm \"%(t2)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 5-2 - Page 139"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t is 17.0mm \n",
      "\n",
      "M is 2295.0mm \n",
      "\n",
      "sigb is 47.6mm \n",
      "sigb is below allowable sigd.\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "from __future__ import division\n",
    "#Elastic limit=sige\n",
    "sige=310#\n",
    "#inside diameter=di\n",
    "di=300#\n",
    "p=1.8#\n",
    "FOS=2#\n",
    "#design stress=sigd#\n",
    "sigd=sige/2#\n",
    "c=0.162#\n",
    "d=380#\n",
    "#cover plate thickness=t#\n",
    "t=d*sqrt(c*p/sigd)#\n",
    "t=17#\n",
    "M=di*p*t/4#\n",
    "\n",
    "z=(1/6)*1*t**2#\n",
    "#bending stress=sigb#\n",
    "sigb=M/z#\n",
    "print \"t is %0.1fmm \"%(t)#\n",
    "print \"\\nM is %0.1fmm \"%(M)#\n",
    "print \"\\nsigb is %0.1fmm \"%(sigb)#\n",
    "if (sigb<=sigd):\n",
    "    print 'sigb is below allowable sigd.'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 5-3 - Page 140"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t1 is 24.0mm \n",
      "\n",
      "t2 is 30.206mm \n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "sige=220#\n",
    "v=0.29#\n",
    "Ri=175#\n",
    "FOS=3#\n",
    "Sa=sige/3#\n",
    "p=10#\n",
    "#t1=thickness according to maximum principal stress theory\n",
    "#t2=thickness according to maximum shear stress theory\n",
    "x=Sa+(p*(1-(2*v)))#\n",
    "y=Sa-(p*(1+v))#\n",
    "t1=(sqrt(x/y)-1)*Ri#\n",
    "t1=24#\n",
    "#t1=((sqrt((Sa+(p*(1-(2*v)))))/(Sa-(p*(1+v))))-1)*Ri#\n",
    "t2=Ri*((sqrt(Sa/(Sa-(2*p))))-1)#\n",
    "# printing data in scilab o/p window\n",
    "print \"t1 is %0.1fmm \"%(t1)#\n",
    "print \"\\nt2 is %0.3fmm \"%(t2)#\n",
    "#The answer to t2 is not calculated in the book."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 5-4 - Page 141"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "t is 50.0mm \n"
     ]
    }
   ],
   "source": [
    "p=16#\n",
    "Ri=250#\n",
    "#Yield strength =sigy#\n",
    "sigy=330#\n",
    "v=0.3#\n",
    "FOS=3#\n",
    "Sa=sigy/3#\n",
    "t=Ri*((sqrt(Sa/(Sa-(2*p))))-1)#\n",
    "t=50#\n",
    "\n",
    "print \"t is %0.1fmm \"%(t)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 5-5 - Page 141"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "kb is 1546.253 N/mm \n",
      "\n",
      "The combines stiffness of bolt and gasket is 84.823 kN/mm\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "d=15#\n",
    "Eg=480#\n",
    "t=3#\n",
    "#flange thickness=ft#\n",
    "ft=12#\n",
    "A=pi*d**2/4#\n",
    "l=d+t+(ft/2)#\n",
    "E=210#\n",
    "kb=A*E/l#\n",
    "#effective area of gasket=Ag#\n",
    "Ag=pi*(((ft+t+d)**2)-(d**2))/4#\n",
    "kg=Ag*Eg/t#\n",
    "# printing data in scilab o/p window\n",
    "print \"kb is %0.3f N/mm \"%(kb)#\n",
    "kb=kb*10**-3#\n",
    "kg=kg*10**-3#\n",
    "if (kb<=kg):\n",
    "    print \"\\nThe combines stiffness of bolt and gasket is %0.3f kN/mm\"%(kg)\n",
    "\n",
    "\n",
    "#The difference in the value of kb is due to rounding-off the value of 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
}