{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch:8 Springs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-1 - Page 224"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Ks is 1.0000 \n",
      "\n",
      " Kw is 1.1025 \n",
      "\n",
      " Kc is 1.103 \n",
      "\n",
      " The Spring Stiffness is 16.0 N/mm\n",
      "\n",
      " The Axial deflection is 18.000 mm\n"
     ]
    }
   ],
   "source": [
    "d=5#\n",
    "D=30#\n",
    "G=84*(10**3)#\n",
    "Na=15#\n",
    "#Axial Load W\n",
    "W=300#\n",
    "#Spring index C\n",
    "C=30/5#\n",
    "#Shear stress Augmentation factor Ks\n",
    "Ks=((2*C)+1)/(2*C)#\n",
    "#Wahl's factor Kw\n",
    "Kw=(((4*C)-1)/((4*C)-4))+(0.615/C)#\n",
    "#Curvature correction factor Kc\n",
    "Kc=Kw/Ks#\n",
    "#Spring stiffness k\n",
    "k=(G*(d**4))/(8*(D**3)*Na)#\n",
    "#Axial deflection delta\n",
    "delta=W/k#\n",
    "print \" Ks is %0.4f \"%(Ks)#\n",
    "print \"\\n Kw is %0.4f \"%(Kw)#\n",
    "print \"\\n Kc is %0.3f \"%(Kc)#\n",
    "print \"\\n The Spring Stiffness is %0.1f N/mm\"%(k)#\n",
    "print \"\\n The Axial deflection is %0.3f mm\"%(delta)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-2 - Page 224"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " wire diameter is 2.314 mm \n",
      "\n",
      " mean diameter is 18.516 mm \n",
      "\n",
      " Number of acting coils are 11.117 \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "W=196.2#\n",
    "lenthofscale=50#\n",
    "k=196.2/50#\n",
    "C=8#\n",
    "Ks=(1+(0.5/C))#\n",
    "\n",
    "# Let us choose oil tempered wire 0.6-0.7 %C. Refer to Table 8-4 for constants A and m, relating strength wire \n",
    "#diameter.\n",
    "G=77.2*(10**3)#\n",
    "A=1855#\n",
    "m=0.187#\n",
    "# equating Tmax=0.5*sig(ut).\n",
    "# Ks*(8*W*D/(pi*(d**3)))=0.5*A/(d**2)\n",
    "d1=(Ks*(8*W*C/(pi*A*0.5)))#\n",
    "d=d1**(1/1.813)#\n",
    "D=C*d#\n",
    "Na=G*(d**4)/(8*(D**3)*k)#\n",
    "#Solid length = SL\n",
    "SL=(Na-1)*d\n",
    "\n",
    "print \" wire diameter is %0.3f mm \"%(d)#\n",
    "print \"\\n mean diameter is %0.3f mm \"%(D)#\n",
    "print \"\\n Number of acting coils are %0.3f \"%(Na)#\n",
    "\n",
    "#The difference in the values of d,D and Na is due to rounding-off the digits."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-3 - Page 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Ultimate tensile Strength is 2060.5 MPa \n",
      "\n",
      " Force at which the spring hook fails is 211.3 N \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "d=1.626#\n",
    "A=2211#\n",
    "m=0.145#\n",
    "rm=3#\n",
    "ri=(rm-(d/2))#\n",
    "sigma=A/(d**m)#\n",
    "W=(sigma*pi*(d**3)*ri)/(32*(rm**2))#\n",
    "print \" Ultimate tensile Strength is %0.1f MPa \"%(sigma)#\n",
    "print \"\\n Force at which the spring hook fails is %0.1f N \"%(W)#\n",
    "\n",
    "#The difference in the values of sigma and W is due to rounding-off the digits."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-4 - Page 226"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " d is 2.337mm \n",
      "\n",
      " D is 22.20 mm\n",
      "\n",
      " Ls is 26.18 mm\n",
      "\n",
      " Lo is 83.68 mm\n",
      "\n",
      "The diameter is within space constraints\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "Do=25#\n",
    "# mean coil diameter D=25-d\n",
    "W=150#\n",
    "T=800#\n",
    "G=81000#\n",
    "# Substituting values in equation T=8*W*D/(pi*(d**3))\n",
    "# therefore, the equation becomes d**3 + 0.477*d = 11.936\n",
    "#consider d=2.2mm, (d can be taken between 2.2-2.3mm)\n",
    "d=2.337# #(nearest available wire gauge)\n",
    "C=9.5#\n",
    "D=22.2# \n",
    "Do=D+d#\n",
    "Ks=1+(0.5/C)#\n",
    "Tmax=Ks*8*W*D/(pi*(d**3))#\n",
    "# check for safety- Tmax<T#\n",
    "Lo=100#\n",
    "Ls=40#\n",
    "#Lo=Ls+delta+0.15*delta\n",
    "delta=(Lo-Ls)/1.15#\n",
    "delta=50#\n",
    "k=150/50#\n",
    "Na=(G*d**4)/(8*(D**3)*k)#\n",
    "\n",
    "N=Na+2#\n",
    "Ls=N*d#\n",
    "Lo=Ls+(1.15*delta)#\n",
    "print  \" d is %0.3fmm \"%(d)#\n",
    "print  \"\\n D is %0.2f mm\"%(D)#\n",
    "print  \"\\n Ls is %0.2f mm\"%(Ls)#\n",
    "print  \"\\n Lo is %0.2f mm\"%(Lo)#\n",
    "if (Do<=25):\n",
    "    print '\\nThe diameter is within space constraints'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-5A - Page 227"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " d is 2.3mm \n",
      "\n",
      " C is 7.6 \n",
      "\n",
      " Na is 17.6 \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "Di=15#\n",
    "Do=20#\n",
    "d=2.3#\n",
    "D=17.5#\n",
    "C=D/d#\n",
    "Ks=1+(0.5/C)#\n",
    "Wmax=100#\n",
    "Tmax=Ks*8*Wmax*D/(pi*(d**3))#\n",
    "G=81000#\n",
    "delmax=67.7/2.366#\n",
    "k=100/28#\n",
    "Na=G*(d**4)/(8*k*(D**3))#\n",
    "Ls=Na+1# #(for plain ends)\n",
    "delmax=28#\n",
    "#TL= total working length\n",
    "TL=Ls+delmax+(0.15*delmax)#\n",
    "print  \" d is %0.1fmm \"%(d)#\n",
    "print  \"\\n C is %0.1f \"%(C)#\n",
    "print  \"\\n Na is %0.1f \"%(Na)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-6 - Page- 228"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Tys is 686.9 MPa \n",
      "\n",
      " W is 41.1 N \n",
      "\n",
      " del is 30.457 mm \n",
      "\n",
      " Ls is 15.2375 mm \n",
      "\n",
      " Lo is 50.26 mm \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "# 18 SWG=1.219MM in dia\n",
    "d=1.219#\n",
    "E=198.6*10**3#\n",
    "G=80.7*10**3#\n",
    "m=0.19#\n",
    "A=1783#\n",
    "sig=A/(d**m)#\n",
    "Tys=(0.4*sig)#\n",
    "Do=12.5#\n",
    "D=Do-d#\n",
    "C=D/d#\n",
    "Ks=((2*C)+1)/(2*C)#\n",
    "W=(Tys*pi*(d**3))/(8*D*Ks)#\n",
    "Nt=13.5#\n",
    "Na=Nt-2#\n",
    "Del=(8*W*(D**3)*Na)/(G*(d**4))#\n",
    "Ls=(Nt-1)*d#\n",
    "Lo=Ls+Del+(0.15*Del)#\n",
    "print  \" Tys is %0.1f MPa \"%(Tys)#\n",
    "print  \"\\n W is %0.1f N \"%(W)#\n",
    "print  \"\\n del is %0.3f mm \"%(Del)#\n",
    "print  \"\\n Ls is %0.4f mm \"%(Ls)#\n",
    "print  \"\\n Lo is %0.2f mm \"%(Lo)#\n",
    "  \n",
    "#Answers in the book for Torsional yeild strength have been rounded-off to the nearest whole number."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-7 - Page 228"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tys is 992.7 MPa \n",
      "\n",
      " Do is 12.6 N \n",
      "\n",
      " W is 33.8 N \n",
      "\n",
      " k is 0.496 N \n",
      "\n",
      " del is 68.20 mm \n",
      "\n",
      " Ls is 15.24 mm \n",
      "\n",
      " Lo is 93.669 mm \n",
      "The spring will fail under buckling\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "d=1.016#\n",
    "A=2211#\n",
    "m=0.145#\n",
    "G=81000#\n",
    "Nt=16#\n",
    "Na=16-2#\n",
    "sig=A/(d**m)#\n",
    "Tys=0.45*sig#\n",
    "Do=12.6#\n",
    "D=Do-d#\n",
    "C=D/d#\n",
    "Ks=1+(0.5/C)#\n",
    "W=(Tys*pi*(d**3))/(8*D*Ks)#\n",
    "k=(G*(d**4))/(8*(D**3)*Na)#\n",
    "Del=W/k#\n",
    "Ls=(Nt-1)*d#\n",
    "Lo=Ls+(1.15*Del)#\n",
    "\n",
    "print  \"Tys is %0.1f MPa \"%(Tys)#\n",
    "print  \"\\n Do is %0.1f N \"%(Do)#\n",
    "print  \"\\n W is %0.1f N \"%(W)#\n",
    "print  \"\\n k is %0.3f N \"%(k)#\n",
    "print  \"\\n del is %0.2f mm \"%(Del)#\n",
    "print  \"\\n Ls is %0.2f mm \"%(Ls)#\n",
    "print  \"\\n Lo is %0.3f mm \"%(Lo)#\n",
    "  \n",
    "if ((Lo/D)>=5.26):\n",
    "    print 'The spring will fail under buckling'\n",
    "\n",
    "\n",
    "#Values after the decimal point has not been considered for answer of Torsional yeild strength in the book, whereas answers for deflection and free-length is different as entire value of variables is taken for calculation in the code."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-8 - Page 229"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "k is 3.000 N/mm \n",
      "\n",
      " W is 77.5 N \n",
      "\n",
      " Lo is 49.720 mm \n",
      "\n",
      " p is 5.302 mm \n",
      "The spring will fail under buckling\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "d=2#\n",
    "Do=20#\n",
    "D=Do-d#\n",
    "C=D/d#\n",
    "Na=9#\n",
    "#Material hard drawn spring steel\n",
    "A=1783#\n",
    "m=0.19#\n",
    "G=81000#\n",
    "sig=A/(d**m)#\n",
    "Tys=0.45*sig\n",
    "Kf=1.5#\n",
    "Ta=Tys/Kf#\n",
    "Ks=1+(0.5/C)#\n",
    "W=(Ta*pi*(d**3))/(8*D*Ks)#\n",
    "k=(G*(d**4))/(8*(D**3)*Na)#\n",
    "Del=W/k#\n",
    "Lo=((Na+1)*d)+(1.15*Del)#\n",
    "p=(Lo-d)/Na#\n",
    "print  \"k is %0.3f N/mm \"%(k)#\n",
    "print  \"\\n W is %0.1f N \"%(W)#\n",
    "print  \"\\n Lo is %0.3f mm \"%(Lo)#\n",
    "print  \"\\n p is %0.3f mm \"%(p)\n",
    "  \n",
    "  \n",
    "if ((Lo)>=47.34):\n",
    "    print 'The spring will fail under buckling'\n",
    "\n",
    "#The answer for value of spring rate 'k' is misprinted in the book. Due to this all subsequent values of del,Lo,p is calucated incorrectly in the book."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-9 - Page 230"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Maximum Torque is 497.25 Nmm \n",
      "\n",
      " theta3 is 0.327 turns \n",
      "\n",
      " Ne is 0.293 turns \n",
      "\n",
      " ke is 22089.3 N/mm \n",
      "\n",
      " theta1+theta2 is 0.0225 turns \n",
      "\n",
      " D1 is 13.46 mm \n",
      "\n",
      " IRC is 0.75 mm \n",
      "\n",
      " FRC is 0.23 mm \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "# for music wire\n",
    "d1=11.5#\n",
    "A=2211#\n",
    "d=1.5#\n",
    "m=0.145#\n",
    "sigut=A/(d**m)#\n",
    "sigy=0.78*sigut#\n",
    "Do=16#\n",
    "E=2*(10**5)#\n",
    "Nb=4.25#\n",
    "D=Do-d#\n",
    "C=D/d#\n",
    "Ki=((4*(C**2))-C-1)/(4*C*(C-1))#\n",
    "Mmax=(sigy*pi*(d**3))/(32*Ki)#\n",
    "kc=((d**4)*E)/(10.8*D*Nb)#\n",
    "theta3=Mmax/kc#\n",
    "l1=20#\n",
    "l2=20#\n",
    "Ne=(l1+l2)/(3*pi*D)#\n",
    "Na=Nb+Ne#\n",
    "k=((d**4)*E)/(10.8*Na*D)#\n",
    "thetat=Mmax/k#\n",
    "ke=(3*pi*(d**4)*E)/(10.8*(l1+l2))#\n",
    "# angdisp=theta1+theta2=Mmax/ke#\n",
    "angdisp=Mmax/ke#\n",
    "#D1 is final coil diameter\n",
    "D1=(Nb*D)/(Nb+theta3)#\n",
    "#IRC=Initial radial clearance\n",
    "IRC=((D-d)-d1)/2#\n",
    "#FRC=Final radial clearance\n",
    "FRC=((D1-d)-d1)/2#\n",
    "\n",
    "\n",
    "\n",
    "print \" Maximum Torque is %0.2f Nmm \"%(Mmax)#\n",
    "print \"\\n theta3 is %0.3f turns \"%(theta3)#\n",
    "print \"\\n Ne is %0.3f turns \"%(Ne)#\n",
    "print \"\\n ke is %0.1f N/mm \"%(ke)#\n",
    "print \"\\n theta1+theta2 is %0.4f turns \"%(angdisp)#\n",
    "print \"\\n D1 is %0.2f mm \"%(D1)#\n",
    "print \"\\n IRC is %0.2f mm \"%(IRC)#\n",
    "print \"\\n FRC is %0.2f mm \"%(FRC)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-10 - Page 231"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " d is 2.0 mm \n",
      "\n",
      " D is 15.0 mm \n",
      "\n",
      " Na is 11.00 mm \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "A=1783#\n",
    "m=0.190#\n",
    "d=1.5#\n",
    "D=15#\n",
    "M=300#\n",
    "E=20800#\n",
    "k=30#\n",
    "#sigult= ultimate strength of the material\n",
    "# sigy= yield strength of the material\n",
    "sigult=A/(d**m)#\n",
    "sigy=0.7*sigult#\n",
    "#siga= allowable yield strength of the material\n",
    "siga=sigy/2#\n",
    "C=D/d#\n",
    "Ki=(4*(C**2)-C-1)/(4*C*(C-1))#\n",
    "Z=pi*(d**3)/32#\n",
    "#sigb=bending strength of the material#\n",
    "sigb=Ki*M/Z#\n",
    "while (sigb>=siga) :\n",
    "    d=d+0.15#\n",
    "    D=15#\n",
    "    C=D/d#\n",
    "    sigult=A/(d**m)#\n",
    "    sigy=0.7*sigult#\n",
    "    siga=sigy/2#\n",
    "    Ki=(4*(C**2)-C-1)/(4*C*(C-1))#\n",
    "    Z=pi*(d**3)/32#\n",
    "    sigb=Ki*M/Z#\n",
    "\n",
    "d=2## rounding off the value of the diameter.\n",
    "Na=(d**4)*E/(64*D*k)#\n",
    "print  \" d is %0.1f mm \"%(d)#\n",
    "print  \"\\n D is %0.1f mm \"%(D)#\n",
    "print  \"\\n Na is %0.2f mm \"%(Na)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-11 - Page 231"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " t is 14 mm \n",
      "\n",
      " Wf is 10909 N \n",
      "\n",
      " I is 34300 mm**4 \n",
      "\n",
      " del is 52.0 mm \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "L=1180#\n",
    "W=40*(10**3)#\n",
    "Nf=2#\n",
    "Ng=8#\n",
    "E=207*(10**3)#\n",
    "#sigut is ultimate strength\n",
    "sigut=1400#\n",
    "FOS=2#\n",
    "#siga= allowable yield strength of the material\n",
    "siga=1400/2#\n",
    "#sigbf=bending strength in full length\n",
    "sigbf=700#\n",
    "b=75#\n",
    "t=((4.5*W*L)/(((3*Nf)+(2*Ng))*sigbf))**(0.5)#\n",
    "t=14#\n",
    "I=(Nf*b*(t**3))/12#\n",
    "Wf=(3*Nf*W)/((3*Nf)+(2*Ng))#\n",
    "Del=(Wf*(L**3))/(48*E*I)#\n",
    "print \" t is %0.0f mm \"%(t)#\n",
    "print \"\\n Wf is %0.0f N \"%(Wf)#\n",
    "print \"\\n I is %0.0f mm**4 \"%(I)#\n",
    "print \"\\n del is %0.1f mm \"%(Del)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-12A - Page 232"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " t is 15.0 mm \n",
      "\n",
      " deli is 16.0 mm \n",
      "\n",
      " Wi is 6366 N \n"
     ]
    }
   ],
   "source": [
    "W=80000#\n",
    "sigbfr=500#\n",
    "L=1100#\n",
    "Nf=3#\n",
    "Ng=10#\n",
    "N=Nf+Ng#\n",
    "t=((1.5*W*L)/(N*6*sigbfr))**(1/3)#\n",
    "t=15#\n",
    "b=6*t#\n",
    "E=207*10**3#\n",
    "deli=(W*(L**3))/(8*E*N*b*(t**3))#\n",
    "Wi=(W*Nf*Ng)/(N*((3*Nf)+(2*Ng)))#\n",
    "print \" t is %0.1f mm \"%(t)#\n",
    "print \"\\n deli is %0.1f mm \"%(deli)#\n",
    "print \"\\n Wi is %0.0f N \"%(Wi)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-13 - Page 233"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Tm is 169.77 MPa \n",
      "\n",
      " Ta is 86.2 MPa \n",
      "\n",
      " FOS is 1.548 \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "#ultimate strength=sigut\n",
    "sigut=1500#\n",
    "C=7#\n",
    "d=3#\n",
    "D=C*d#\n",
    "Ks=1+(0.5/C)#\n",
    "Kw=(((4*C)-1)/((4*C)-4))+(0.615/C)#\n",
    "Pmax=120#\n",
    "Pmin=40#\n",
    "Pm=80#\n",
    "Tm=(Ks*8*Pm*D)/(pi*(d**3))#\n",
    "Ta=(Kw*8*Pmin*D)/(pi*(d**3))#\n",
    "Tse=0.22*sigut#\n",
    "Tys=0.45*sigut#\n",
    "x=(Tys-(0.5*Tse))/(0.5*Tse)#\n",
    "y=((x)*Ta)+Tm#\n",
    "FOS=(Tys/y)#\n",
    "print  \" Tm is %0.2f MPa \"%(Tm)#\n",
    "print  \"\\n Ta is %0.1f MPa \"%(Ta)#\n",
    "print  \"\\n FOS is %0.3f \"%(FOS)#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## exa 8-14 - Page 234"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Tm is 186.64 MPa \n",
      "\n",
      " Ta is 126.337 MPa \n",
      "\n",
      " FOS is 1.26 \n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "Tse=360#\n",
    "Tys=660#\n",
    "d=25#\n",
    "P=0.03#\n",
    "m=40#\n",
    "Pmin=((pi*(d**2)*P)/4)+(m*9.81/1000)#\n",
    "k=6#\n",
    "#Additional load= Padd=k*further compression in spring\n",
    "Padd=k*10#\n",
    "Pmax=Padd+Pmin#\n",
    "Pm=(Pmax+Pmin)/2#\n",
    "Pa=(Pmax-Pmin)/2#\n",
    "d=2#\n",
    "D=12#\n",
    "C=6#\n",
    "Ks=1+(0.5/C)#\n",
    "Ks=1.083#\n",
    "Kw=(((4*C)-1)/((4*C)-4))+(0.615/C)#\n",
    "Ta=(Kw*8*Pa*D)/(pi*(d**3))#\n",
    "Tm=(Ks*8*Pm*D)/(pi*(d**3))#\n",
    "x=(Tys-(0.5*Tse))/(0.5*Tse)#\n",
    "y=((x)*Ta)+Tm#\n",
    "FOS=(Tys/y)#\n",
    "print  \" Tm is %0.2f MPa \"%(Tm)#\n",
    "print  \"\\n Ta is %0.3f MPa \"%(Ta)#\n",
    "print  \"\\n FOS is %0.2f \"%(FOS)#"
   ]
  }
 ],
 "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
}