diff options
Diffstat (limited to 'Fluid_mechanics/Chapter_2.ipynb')
-rwxr-xr-x | Fluid_mechanics/Chapter_2.ipynb | 406 |
1 files changed, 406 insertions, 0 deletions
diff --git a/Fluid_mechanics/Chapter_2.ipynb b/Fluid_mechanics/Chapter_2.ipynb new file mode 100755 index 00000000..f518cad4 --- /dev/null +++ b/Fluid_mechanics/Chapter_2.ipynb @@ -0,0 +1,406 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:8249f270a6314fb49f84df63266820d87dfa51fe64fed0b9dd11afa539cb500b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 2 - Fluid Statics"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1 - Pg 10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the final pressure and specific weight of the gas\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "gam=0.0765 #lb/ft^3\n",
+ "p=14.7 #psia\n",
+ "dz=10560. #ft\n",
+ "#calculations\n",
+ "pg=p*144./gam\n",
+ "p2=p*math.exp(-dz/pg)\n",
+ "gam2=p2/p*gam\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"Final pressure =\",p2,\"psia\")\n",
+ "print '%s %.4f %s' %(\"\\n Final specific weight =\",gam2,\"lb/ft^3\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final pressure = 10.04 psia\n",
+ "\n",
+ " Final specific weight = 0.0522 lb/ft^3\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2 - Pg 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the final pressure and specific weight\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "gam=0.0765 #lb/ft^3\n",
+ "p=14.7 #psia\n",
+ "dz=10560. #ft\n",
+ "n=1.235\n",
+ "#calculations\n",
+ "pg=p*144./gam\n",
+ "p2=p*math.pow((1- dz/pg *(n-1)/n),(n/(n-1)))\n",
+ "gam2=math.pow((p2/p),(1/n)) *gam\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"Final pressure =\",p2,\"psia\")\n",
+ "print '%s %.4f %s' %(\"\\n Final specific weight =\",gam2,\"lb/ft^3\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Final pressure = 9.89 psia\n",
+ "\n",
+ " Final specific weight = 0.0555 lb/ft^3\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3 - Pg 16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the absolute pressure\n",
+ "#Initialization of variables\n",
+ "pb=28.5 #in mercury\n",
+ "d=13.6 #g/cc\n",
+ "gam=62.4\n",
+ "pobs=-4. #psi\n",
+ "#calculations\n",
+ "patm=pb/12. *gam*d/144.\n",
+ "pabs=patm+pobs\n",
+ "P=pabs*144./gam\n",
+ "#results\n",
+ "print '%s %.1f %s' %(\"Absolute pressure =\",pabs,\"psia\")\n",
+ "print '%s %.1f %s' %(\"\\n Absolute pressure in feet of water =\",P,\"ft of water\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Absolute pressure = 10.0 psia\n",
+ "\n",
+ " Absolute pressure in feet of water = 23.1 ft of water\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4 - Pg 18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the pressure gauge at B and also the absolute pressure of air\n",
+ "#Initialization of variables\n",
+ "pb=28. #in mercury\n",
+ "d=13.6 #g/cc\n",
+ "gam=62.4\n",
+ "xm=15. #in\n",
+ "xw=10. #in\n",
+ "patm=28. #in\n",
+ "#calculations\n",
+ "pB=-xm/12 *gam/144 *d + xw*gam/144\n",
+ "pair=patm/12 *gam/144 *d - xm/12 *gam/144 *d\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"The pressure gauge at B indicates a reading of\",-pB,\"psi vacuum\")\n",
+ "print '%s %.2f %s' %(\"\\n Absolute pressure of Air =\",pair,\"psia\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The pressure gauge at B indicates a reading of 3.03 psi vacuum\n",
+ "\n",
+ " Absolute pressure of Air = 6.38 psia\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5 - Pg 20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the pressure difference and also compare the pressures at A and B\n",
+ "#Initialization of variables\n",
+ "pb=28.5 #in mercury\n",
+ "d=13.6 #g/cc\n",
+ "gam=62.4\n",
+ "xm=10. #in\n",
+ "xw=2. #ft\n",
+ "#calculations\n",
+ "dp= xw*gam/144 - xm/12 *gam/144 + xm/12 *gam/144 *d\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"Pressure difference =\",dp,\"psi\")\n",
+ "if dp>0:\n",
+ " print '%s' %(\"\\n Pressure at A is greater than that at B\")\n",
+ "elif dp==0:\n",
+ " print '%s' %(\"\\n Pressure at both A and B are equal\")\n",
+ "else:\n",
+ " print '%s' %(\"\\n Pressure at A is less than that at B\")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Pressure difference = 5.42 psi\n",
+ "\n",
+ " Pressure at A is greater than that at B\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6 - Pg 24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the magnitude of total force, vertical and horiontal locations of the total force.\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "import scipy\n",
+ "from scipy import integrate\n",
+ "gam=62.4\n",
+ "x1=4. #ft\n",
+ "x2=6. #ft\n",
+ "y1=6. #ft\n",
+ "z=8. #ft\n",
+ "dy=1. #ft\n",
+ "angle=60.*math.pi/180. #radians\n",
+ "#calculations\n",
+ "A1=x1*x2\n",
+ "A2=1/2. *y1*y1\n",
+ "yc = (A1*(x1+x2+dy) + A2*(x1+x2))/(A1+A2)\n",
+ "hc=yc*math.sin(angle)\n",
+ "F=hc*gam*(A1+A2)\n",
+ "ic1=1/12. *x1*y1*y1*y1\n",
+ "ic2=1/36. *y1*x2*x2*x2\n",
+ "ad1=A1*(x1+x2+dy-yc)*(x1+x2+dy-yc)\n",
+ "ad2=A2*(x1+x2-yc)*(x1+x2-yc)\n",
+ "It=ic1+ic2+ad1+ad2\n",
+ "ydc=It/(yc*(A1+A2))\n",
+ "def momen(u):\n",
+ " m= gam*math.sin(angle) *(2*x1+u)*0.5*(x2-u)*(y1-u)\n",
+ " return m;\n",
+ "\n",
+ "MED, err =scipy.integrate.quad( momen,0,y1)\n",
+ "FEDC=gam*math.sin(angle) *A2*(x1+x2)\n",
+ "xed=MED/FEDC\n",
+ "xp= (A1*2*(x1+x2+dy) + (x1+x2)*(A2)*(x1+xed))/(A1*(x1+x2+dy) + A2*(x1+x2))\n",
+ "#results\n",
+ "print '%s %d %s' %(\"Magnitude of total force =\",F,\"lb\")\n",
+ "print '%s %.3f %s' %(\"\\n Vertical location of force =\",ydc,\"ft\")\n",
+ "print '%s %.2f %s' %(\"\\n Horizontal location of force =\",xp,\"ft from AB\")\n",
+ "print '%s' %(\"\\n Direction of force is perpendicular to the plane surface\")\n",
+ "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Magnitude of total force = 23993 lb\n",
+ "\n",
+ " Vertical location of force = 0.266 ft\n",
+ "\n",
+ " Horizontal location of force = 3.58 ft from AB\n",
+ "\n",
+ " Direction of force is perpendicular to the plane surface\n",
+ "The answers are a bit different from textbook due to rounding off error\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7 - Pg 27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate the magnitude of force and the horizontal distance from line of action of Fv\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "gam=62.4\n",
+ "z=10. #ft\n",
+ "z2=5. #ft\n",
+ "z3=4.25 #ft\n",
+ "p=2. #psig\n",
+ "#calculations\n",
+ "h=p*144./gam\n",
+ "Av=z*z\n",
+ "Fh=gam*(z+h)*Av\n",
+ "hpc=1/12. *z*z*z*z /((h+z)*z*z)\n",
+ "Fv=gam*(z2+h) *z*z + gam*math.pi/4. *z*z *z\n",
+ "xp= (gam*(z2+h) *z*z *z2 + gam*math.pi/4. *z*z *z*z3)/(Fv)\n",
+ "F=math.sqrt(Fh*Fh + Fv*Fv)\n",
+ "#results\n",
+ "print '%s %d %s' %(\"Magnitude of force =\",F,\"lb\")\n",
+ "print '%s %.2f %s' %(\"\\n horizontal distance from line of action of Fv =\",xp,\"ft from AG\")\n",
+ "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Magnitude of force = 142127 lb\n",
+ "\n",
+ " horizontal distance from line of action of Fv = 4.66 ft from AG\n",
+ "The answers are a bit different from textbook due to rounding off error\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8 - Pg 33"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#calculate whether the barge is stable and also find the location of the metacenter\n",
+ "#Initialization of variables\n",
+ "import math\n",
+ "gam=0.0765 #lb/ft^3\n",
+ "l=40. #ft\n",
+ "w=16. #ft\n",
+ "d=8. #ft\n",
+ "z=6. #ft\n",
+ "BG=1. #ft\n",
+ "#calculations\n",
+ "I=1/12. *l*w*w*w\n",
+ "V=l*w*z\n",
+ "IVG=I/V - BG\n",
+ "MB=I/V\n",
+ "#results\n",
+ "print '%s %.2f %s' %(\"I/V -BG =\",IVG,\"ft \")\n",
+ "if IVG >0:\n",
+ " print '%s' %(\"\\n Barge is stable\")\n",
+ "else:\n",
+ " print '%s' %(\"\\n The barge is unstable\")\n",
+ "\n",
+ "print '%s %.2f %s' %(\"\\n Location of metacenter =\",MB,\"ft above the center of buoyancy \")\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "I/V -BG = 2.56 ft \n",
+ "\n",
+ " Barge is stable\n",
+ "\n",
+ " Location of metacenter = 3.56 ft above the center of buoyancy \n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |