{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.30 Nozzle Sizing Calculations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Objective: Size a long-radius venturi nozzle flow meter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A system is designed with a flow rate of 225 gpm of water at 60 F flowing through 6\" schedule 40 pipe. A long-radius nozzle flow has been requested. A measured head loss of 4 feet is the design measurement, with 1D upstream and 1/2D downstream taps.\n",
    "\n",
    "Find the required diameter of the nozzle."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:50.932222Z",
     "iopub.status.busy": "2022-08-22T01:19:50.931516Z",
     "iopub.status.idle": "2022-08-22T01:19:51.573920Z",
     "shell.execute_reply": "2022-08-22T01:19:51.573184Z"
    }
   },
   "outputs": [],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "\n",
    "mu = 1.1*u.cP\n",
    "rho = 62.364*u.lb/u.ft**3\n",
    "\n",
    "NPS, Di, Do, t = nearest_pipe(NPS=6, schedule='40')\n",
    "A = 0.25*pi*Di*Di\n",
    "\n",
    "dP = 4*u.feet_H2O\n",
    "\n",
    "P1 = 10*u.bar # assumed, not very important\n",
    "P2 = P1 - dP\n",
    "k = 1.3 # not important\n",
    "\n",
    "Q = 225*u.gal/u.min\n",
    "m = Q*rho"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:51.577971Z",
     "iopub.status.busy": "2022-08-22T01:19:51.577467Z",
     "iopub.status.idle": "2022-08-22T01:19:51.587280Z",
     "shell.execute_reply": "2022-08-22T01:19:51.586326Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Nozzle diameter found to be 2.405956560384601 inch.\n"
     ]
    }
   ],
   "source": [
    "Do = differential_pressure_meter_solver(D=Di, rho=rho, mu=mu, k=k, P1=P1, P2=P2, \n",
    "                                   m=m, meter_type='long radius nozzle', \n",
    "                                   taps='D')\n",
    "print('Nozzle diameter found to be %s.' %(Do.to(u.inch)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The solution given in Crane is 2.40 inches after two iterations and has an error of 0.4 gpm, whereas the answer above has almost zero theoretical error."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.31 NPRD Calculations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Non-recoverable pressure drop (NRPD) is the permanent pressure drop associated with the flow through the measurement device.\n",
    "Find the NPRD for example 7.30."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:51.609469Z",
     "iopub.status.busy": "2022-08-22T01:19:51.609123Z",
     "iopub.status.idle": "2022-08-22T01:19:51.622403Z",
     "shell.execute_reply": "2022-08-22T01:19:51.621798Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "0.983900143257091 dimensionless"
      ],
      "text/latex": [
       "$0.983900143257091\\ dimensionless$"
      ],
      "text/plain": [
       "0.983900143257091 <Unit('dimensionless')>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C, epsilon = differential_pressure_meter_C_epsilon(D=Di, D2=Do, m=m, P1=P1, P2=P2, rho=rho, mu=mu, k=k,\n",
    "                                          meter_type='long radius nozzle')\n",
    "C"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:51.626068Z",
     "iopub.status.busy": "2022-08-22T01:19:51.625854Z",
     "iopub.status.idle": "2022-08-22T01:19:51.633655Z",
     "shell.execute_reply": "2022-08-22T01:19:51.632808Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "1.2691031737597416 pound_force_per_square_inch"
      ],
      "text/latex": [
       "$1.2691031737597416\\ \\mathrm{pound\\_force\\_per\\_square\\_inch}$"
      ],
      "text/plain": [
       "1.2691031737597416 <Unit('pound_force_per_square_inch')>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dP = differential_pressure_meter_dP(D=Di, D2=Do, P1=P1, P2=P2, C=C, \n",
    "                                   meter_type='long radius nozzle')\n",
    "\n",
    "dP.to(u.psi)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The solution given in Crane is 1.272 psi."
   ]
  }
 ],
 "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
}
