{
 "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 conical 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,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:20:38.797193Z",
     "iopub.status.busy": "2022-08-22T01:20:38.796510Z",
     "iopub.status.idle": "2022-08-22T01:20:39.576311Z",
     "shell.execute_reply": "2022-08-22T01:20:39.575438Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flow rate = 792.5474399133158 liter / minute, Reynolds number = 100000.0\n",
      "Flow rate = 494.99657487971655 liter / minute, Reynolds number = 2421.3002237645055 dimensionless\n",
      "Flow rate = 520.378830860645 liter / minute, Reynolds number = 1512.2568784652317 dimensionless\n",
      "Flow rate = 532.8826141070547 liter / minute, Reynolds number = 1589.8018416954353 dimensionless\n",
      "Flow rate = 538.9130067993693 liter / minute, Reynolds number = 1628.0019690919053 dimensionless\n",
      "Flow rate = 541.7921133079537 liter / minute, Reynolds number = 1646.4253346091618 dimensionless\n",
      "Flow rate = 543.1601058671454 liter / minute, Reynolds number = 1655.2212512728256 dimensionless\n",
      "Flow rate = 543.8086222080263 liter / minute, Reynolds number = 1659.4005855597939 dimensionless\n",
      "Flow rate = 544.1157293288044 liter / minute, Reynolds number = 1661.3818584555358 dimensionless\n",
      "Flow rate = 544.2610867599517 liter / minute, Reynolds number = 1662.3200969795807 dimensionless\n",
      "Flow rate = 544.3298695405146 liter / minute, Reynolds number = 1662.7641763656693 dimensionless\n",
      "Flow rate = 544.3624136657237 liter / minute, Reynolds number = 1662.9743136439959 dimensionless\n",
      "Flow rate = 544.3778108746269 liter / minute, Reynolds number = 1663.073738730347 dimensionless\n",
      "Flow rate = 544.3850953838348 liter / minute, Reynolds number = 1663.1207785206302 dimensionless\n",
      "Flow rate = 544.388541685874 liter / minute, Reynolds number = 1663.1430333193803 dimensionless\n",
      "Flow rate = 544.3901721223835 liter / minute, Reynolds number = 1663.1535620669079 dimensionless\n",
      "Flow rate = 544.3909434755569 liter / minute, Reynolds number = 1663.1585431899127 dimensionless\n",
      "Flow rate = 544.3913083992766 liter / minute, Reynolds number = 1663.1608997398391 dimensionless\n",
      "Flow rate = 544.3914810429436 liter / minute, Reynolds number = 1663.1620146130185 dimensionless\n",
      "Flow rate = 544.3915627198137 liter / minute, Reynolds number = 1663.162542054189 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 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
