diff options
author | tslee | 2014-11-27 17:17:59 +0530 |
---|---|---|
committer | tslee | 2014-11-27 17:17:59 +0530 |
commit | 6e3407ba85ae84e1cee1ae0c972fd32c5504d827 (patch) | |
tree | b89808101c39b1db1e3793eada2c8b702f856606 /Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb | |
parent | 36a03d6d76bac315dba73b2ba9555c7e3fe0234f (diff) | |
download | Python-Textbook-Companions-6e3407ba85ae84e1cee1ae0c972fd32c5504d827.tar.gz Python-Textbook-Companions-6e3407ba85ae84e1cee1ae0c972fd32c5504d827.tar.bz2 Python-Textbook-Companions-6e3407ba85ae84e1cee1ae0c972fd32c5504d827.zip |
added books
Diffstat (limited to 'Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb')
-rw-r--r-- | Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb | 398 |
1 files changed, 398 insertions, 0 deletions
diff --git a/Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb b/Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb new file mode 100644 index 00000000..6c605e78 --- /dev/null +++ b/Fluid_Mechanics_With_Engineering_Applications/ch2.ipynb @@ -0,0 +1,398 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dcc8f42948d54861c1b3938fe3127fa1812368cca6f5d25f547cacd56a9fddb2" + }, + "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 2.1 Page No : 24" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#Initialization of variables\n", + "z = 20000. \t#ft\n", + "rate = -0.00356 \t#F/ft\n", + "T = 59. \t#F\n", + "P = 14.7 \t#psia\n", + "gamma = 0.076 \t#lb/ft**3\n", + "\t\n", + "#calculations\n", + "P2 = P*144 - gamma*(z)\n", + "P2f = P2/144\n", + "P3 = P*math.exp(-gamma*z/(P*144))\n", + "P4 = ((P*144)**0.285 -0.285*gamma*z*(P*144)**(-0.715))**(1/0.285)\n", + "P4f = P4/144.\n", + "P5 = P*((460+T)/(460+T+rate*z))**(gamma*(T+460)/(P*144*rate))\n", + "\t\n", + "#Results\n", + "print ' Constant density'\n", + "print ' Final pressure = %.2f psia'%(P2f)\n", + "print ' \\nIsothermal'\n", + "print ' Final pressure = %.2f psia'%(P3)\n", + "print ' \\nIsentropic'\n", + "print ' Final pressure = %.1f psia'%(P4f)\n", + "print ' \\nLinear decrease'\n", + "print ' Final pressure = %.1f psia'%(P5)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Constant density\n", + " Final pressure = 4.14 psia\n", + " \n", + "Isothermal\n", + " Final pressure = 7.17 psia\n", + " \n", + "Isentropic\n", + " Final pressure = 6.6 psia\n", + " \n", + "Linear decrease\n", + " Final pressure = 6.8 psia\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 Page No : 37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#Initialization of variables\n", + "wA = 53.5 \t#weight of A - lb/ft**3\n", + "wA2 = 8.4 \t#kN/m**3\n", + "wB = 78.8 \t#weight of B - lb/ft**3\n", + "wB2 = 12.3 \t#kN/m**3\n", + "PB = 30. \t#pressure at B - psi\n", + "PB2 = 200. \t#kN/m**2\n", + "AB = 1.3 \t#ft\n", + "AB2 = 40./100 \t#m\n", + "BC = 6.5 \t#ft\n", + "BC2 = 2. \t#m\n", + "CD = 10. \t#ft\n", + "CD2 = 3. \t#m\n", + "\t\n", + "#calculations\n", + "PAbyGB = PB*144/wB - AB*13.55*62.4/wB - (BC+CD) + (AB+BC)*wA/wB\n", + "PA = PAbyGB*wB/144.\n", + "PAbyGB2 = PB2/wB2 - AB2*13.55*9.81/wB2 - (BC2+CD2) + (AB2+BC2)*wA2/wB2\n", + "PA2 = PAbyGB2*wB2\n", + "\t\n", + "#Results\n", + "print ' English units'\n", + "print \" Final pressure = %.1f psi\"%(PA)\n", + "print ' \\n SI Units'\n", + "print \" Final pressure = %d kPa\"%(PA2+1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " English units\n", + " Final pressure = 16.2 psi\n", + " \n", + " SI Units\n", + " Final pressure = 106 kPa\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page No : 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy import *\n", + "\n", + "#Initialization of variables\n", + "W = 500. \t#weight of gate - lb\n", + "width = 2. \t#ft\n", + "len1 = 4. \t#ft\n", + "CGx = 1.2 \t#ft\n", + "CGy = 0.9 \t#ft\n", + "theta = 30. \t#degrees\n", + "gam = 62.4 \t#lb/ft**3\n", + "\n", + "#calculations\n", + "Fv = width*len1 \t#multiply by gam*x\n", + "F = width/(2*math.cos(math.radians(theta))) \t#multiply by gam*x*x\n", + "vector = roots([F*gam*0.770/2,0, - Fv*gam*width,W*CGx])\n", + "\n", + "#Result\n", + "print 'The gate will remain closed between %.2f ft and %.2f ft'%(vector[2],vector[1])\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The gate will remain closed between 0.61 ft and 5.67 ft\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page No : 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#Initialization of variables\n", + "z1 = 1. \t#in\n", + "z2 = 2. \t#in\n", + "z3 = 2. \t#in\n", + "sOil = 0.8 \n", + "sWater = 1.\n", + "Pa = 3. \t#psi\n", + "\t\n", + "#calculations\n", + "Pd = (Pa) + (z2+z1)*sOil*62.4/144 + 62.4*z3/144\n", + "Fa = Pa*144*math.pi*z3**2\n", + "Fb = sOil*62.4*(z2+z1-(z2+z3)*z2/((z2+z1)*math.pi))*(math.pi*z3**2 /2)\n", + "Fc = sOil*62.4*(z2+z1)*(math.pi*z3**2 /2)\n", + "Fd = 62.4*(z2+z3)*z2/((z2+z1)*math.pi)*(math.pi*z3**2 /2)\n", + "F = Fa+Fb+Fc+Fd\n", + "yPa = z2+z1\n", + "yCb = z2+z1-(z2+z3)*z2/((z2+z1)*math.pi) \n", + "ICb = math.pi*(z2+z3)**4 /128 -0.5*math.pi*z2**2 *((z2+z3)*z2/((z2+z1)*math.pi))**2\n", + "yPb = yCb+ICb/(yCb*0.5*math.pi*z2**2)\n", + "yPc = z2+z1+ (z2+z3)*z2/((z2+z1)*math.pi) \n", + "ICd = ICb\n", + "yPd = z2+z1 + (z2+z3)*z2/((z2+z1)*math.pi) + ICb/((z2+z3)*z2/((z2+z1)*math.pi)*0.5*math.pi*z3**2 )\n", + "yP = (Fa*yPa+Fb*yPb+Fc*yPc+Fd*yPd)/F\n", + "\t\n", + "#Results\n", + "print ' case 1'\n", + "print ' Pressure at the bottom = %.1f psi'%(Pd)\n", + "print ' \\n case 2'\n", + "print ' Net force = %d lb'%( F+3)\n", + "print ' Location of net force = %.2f ft'%( yP)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " case 1\n", + " Pressure at the bottom = 4.9 psi\n", + " \n", + " case 2\n", + " Net force = 7380 lb\n", + " Location of net force = 3.10 ft\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page No : 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#Initialization of variables\n", + "dia = 4. \t#m\n", + "P = 35. \t#kN/m**2\n", + "theta = 30. #degrees\n", + "\t\n", + "#calculations\n", + "Fx = P*(dia-dia*(1-math.cos(math.radians(theta)))/2.)\n", + "Fz = P*dia*math.sin(math.radians(theta))/2\n", + "dist = (dia-dia*(1-math.cos(math.radians(theta)))/2.)\n", + "Fxb = 9.81*dist*dist/2 \n", + "Fzb = 9.81*((180+theta)*math.pi*(dia/2)**2/360 + math.sqrt(3) /2 + dia/2)\n", + "\t\n", + "#Results\n", + "print ' part a'\n", + "print ' Horizontal force = %.1f kN/m to the right'%( Fx)\n", + "print ' Vertical force = %.1f kN/m upward' %( Fz)\n", + "print ' \\n part b'\n", + "print ' force by the fluid = %.1f kN/m to the right'%(Fxb)\n", + "print ' weight of the cross-hatched volume of liquid = %.1f kN/m Upward'%(Fzb )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " part a\n", + " Horizontal force = 130.6 kN/m to the right\n", + " Vertical force = 35.0 kN/m upward\n", + " \n", + " part b\n", + " force by the fluid = 68.3 kN/m to the right\n", + " weight of the cross-hatched volume of liquid = 100.0 kN/m Upward\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page No : 49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy.linalg import solve\n", + "from numpy import *\n", + "\n", + "#Initialization of variables\n", + "d1 = 4. \t#diameter - in\n", + "h1 = 3.75 \t#in\n", + "w1 = 0.85 \t#weight of cylinder - lb\n", + "gamma = 52. #lb/ft**3\n", + "d2 = 5. \t#in\n", + "depth = 3. \t#in\n", + "\t\n", + "#calculations\n", + "A = array([[(d1/2)*(d1/2), -(d2/2)*(d2/2)+(d1/2)*(d1/2)],[ 1,1]])\n", + "b = array([[0],[w1*12*(12*2/d1)**2 /(gamma*math.pi)]])\n", + "C = solve(A,b)\n", + "x = C[0]\n", + "y = C[1]\n", + "height = depth-x\n", + "\t\n", + "#Results\n", + "print 'Bottom of the cylinder will be %.2f in above the bottom of hollow cylinder'%(height)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Bottom of the cylinder will be 2.19 in above the bottom of hollow cylinder\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page No : 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#Initialization of variables\n", + "v = 180. \t#velocity - m/s\n", + "angle = 40. #degrees\n", + "a = 4. \t#m/s**2\n", + "r = 2600. \t#radius - m\n", + "g = 9.81 \t#m/s**2\n", + "\t\n", + "#calculations\n", + "#Assume outward and right as positive\n", + "an = round(-v*v/r,1)\n", + "at = -a\n", + "ax = at*math.cos(math.radians(angle)) +an*math.sin(math.radians(angle))\n", + "az = at*math.sin(math.radians(angle)) -an*math.cos(math.radians(angle))\n", + "tangent = ax/(az+g)\n", + "theta = math.degrees(math.atan(tangent))\n", + "\n", + "\n", + "#Results\n", + "print 'Angle made by the free liquid = %.1f degrees'%(-theta)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Angle made by the free liquid = 33.4 degrees\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |