{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.7 Laminar flow in Valves, Fittings, and Pipe - System from Example 7.6"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "SAE oil is discharged at 15 degrees Celsius from a tank with 7 m of head to atmosphere through:\n",
    "\n",
    "* 60 meters of 80 mm schedule 40 pipe\n",
    "* Six 80 mm standard 90 degree threaded elbows\n",
    "* One 80 mm flanged ball valve, with a 60 mm diameter seat, 16 degree conical inlet and 30 degree conival outlet.\n",
    "* The entrance is sharp-edged and flush with the tank\n",
    "\n",
    "This is the same problem as 7.6, except the properties of the fluid are sufficiently viscous to put it into the laminar regime although not by much."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flow rate = 792.547439913 liter / minute, Reynolds number = 100000.0\n",
      "Flow rate = 428.461048981 liter / minute, Reynolds number = 2421.30022376 dimensionless\n",
      "Flow rate = 485.75141276 liter / minute, Reynolds number = 1308.98515537 dimensionless\n",
      "Flow rate = 515.733166793 liter / minute, Reynolds number = 1484.01211735 dimensionless\n",
      "Flow rate = 530.620769781 liter / minute, Reynolds number = 1575.60894058 dimensionless\n",
      "Flow rate = 537.828263434 liter / minute, Reynolds number = 1621.0918412 dimensionless\n",
      "Flow rate = 541.275603892 liter / minute, Reynolds number = 1643.11135084 dimensionless\n",
      "Flow rate = 542.915000096 liter / minute, Reynolds number = 1653.64327082 dimensionless\n",
      "Flow rate = 543.692496106 liter / minute, Reynolds number = 1658.65176646 dimensionless\n",
      "Flow rate = 544.060753053 liter / minute, Reynolds number = 1661.02708328 dimensionless\n",
      "Flow rate = 544.23506934 liter / minute, Reynolds number = 1662.15213975 dimensionless\n",
      "Flow rate = 544.317558945 liter / minute, Reynolds number = 1662.68469092 dimensionless\n",
      "Flow rate = 544.356589163 liter / minute, Reynolds number = 1662.93670372 dimensionless\n",
      "Flow rate = 544.375055237 liter / minute, Reynolds number = 1663.05594438 dimensionless\n",
      "Flow rate = 544.383791685 liter / minute, Reynolds number = 1663.11235981 dimensionless\n",
      "Flow rate = 544.387924908 liter / minute, Reynolds number = 1663.13905041 dimensionless\n",
      "Flow rate = 544.389880327 liter / minute, Reynolds number = 1663.15167776 dimensionless\n",
      "Flow rate = 544.390805428 liter / minute, Reynolds number = 1663.15765173 dimensionless\n",
      "Flow rate = 544.39124309 liter / minute, Reynolds number = 1663.16047799 dimensionless\n",
      "Flow rate = 544.391450145 liter / minute, Reynolds number = 1663.16181509 dimensionless\n"
     ]
    }
   ],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "rho = 875.*u.kg/u.m**3\n",
    "mu = 78*u.cP\n",
    "\n",
    "H = 7*u.m\n",
    "L = 60*u.m\n",
    "NPS, D_pipe, Do_pipe, t = nearest_pipe(Do=80*u.mm)\n",
    "\n",
    "fd = 0.017\n",
    "Re = 1E5\n",
    "for i in range(20):\n",
    "    K = K_from_f(fd=fd, L=L, D=D_pipe)\n",
    "    K += entrance_sharp()\n",
    "    K += exit_normal()\n",
    "    K += 6*bend_rounded(D_pipe, angle=90*u.degrees, fd=fd, bend_diameters=0.65)\n",
    "    ball_valve_angle = 0.5*(15+30)*u.degrees # use the average angle\n",
    "    K += K_ball_valve_Crane(D1=D_pipe, D2=60*u.mm, angle=ball_valve_angle, fd=fd)\n",
    "\n",
    "    v = (2*u.gravity*H/K)**0.5\n",
    "    Q = v*pi/4*D_pipe**2\n",
    "    print('Flow rate = %s, Reynolds number = %s' %(Q.to(u.L/u.min), Re))\n",
    "    Re = Reynolds(D=D_pipe, rho=rho, mu=mu, V=v)\n",
    "    fd = friction_factor(Re=Re, eD=0.0018*u.inch/D_pipe)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "No solution is actually presented in the example; but the result of their initial guess of a velocity of 1.5 m/s gives 511.2 L/min."
   ]
  }
 ],
 "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.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
