{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.8 Laminar flow in Valves, Fittings, and Pipe - SAE oil through a pipe and globe valve"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "S.A.E. 30 Oil at 40 degrees Celsius and a flow rate of 600 barrels/hour flows in a 60 m long 200mm schedule 40 pipe and passes through a 200 mm globe valve, full area seat.\n",
    "\n",
    "Calculate the pressure drop."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "5781.61276167 pascal"
      ],
      "text/latex": [
       "$5781.61276167\\ \\mathrm{pascal}$"
      ],
      "text/plain": [
       "<Quantity(5781.61276167, 'pascal')>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from fluids.units import *\n",
    "from thermo import Stream\n",
    "from math import *\n",
    "Q = 600*u.barrel/u.hour\n",
    "L = 60*u.m\n",
    "NPS, D_pipe, Do_pipe, t = nearest_pipe(Di=200*u.mm)\n",
    "\n",
    "rho = 869.2*u.kg/u.m**3\n",
    "mu = 130*u.cP\n",
    "\n",
    "V = Q/(pi/4*D_pipe**2)\n",
    "Re = Reynolds(D=D_pipe, V=V, rho=rho, mu=mu)\n",
    "fd = friction_factor(Re=Re)\n",
    "ft = friction_factor(Re=1E6, eD=0.0018*u.inch/D_pipe)\n",
    "K = K_globe_valve_Crane(D1=D_pipe, D2=D_pipe, fd=ft)\n",
    "K += K_from_f(fd=fd, L=L, D=D_pipe)\n",
    "dP_from_K(K=K, V=V, rho=rho)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "The example gives a pressure drop of 6382 Pa."
   ]
  }
 ],
 "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": 0
}
