{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.25 Rectangular Duct - Application of Hydraulic Radius to Flow Problems"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Given a rectangular concrete overflow aqueduct is 25 feet high and 16.5 feed wide. Its roughness is 0.01 feet. \n",
    "The height of the water in the reservoir is 200 feet, and the length of the aqueduct is 1000 feet.\n",
    "\n",
    "Find the discharge rate (ft^3/s)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:20.547517Z",
     "iopub.status.busy": "2022-08-22T01:19:20.546922Z",
     "iopub.status.idle": "2022-08-22T01:19:21.200811Z",
     "shell.execute_reply": "2022-08-22T01:19:21.200103Z"
    }
   },
   "outputs": [],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "rho = 62.364*u.lb/u.ft**3\n",
    "mu = 1.1*u.cP\n",
    "\n",
    "W = 16.5*u.foot\n",
    "Hw = 25*u.foot\n",
    "A = W*Hw\n",
    "Pw = Hw*2 + W*2\n",
    "\n",
    "Rh = A/Pw\n",
    "Dh = 4.0*Rh\n",
    "\n",
    "eD = .01*u.foot/Dh\n",
    "H = 200*u.foot\n",
    "L = 1000*u.foot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:21.205862Z",
     "iopub.status.busy": "2022-08-22T01:19:21.205472Z",
     "iopub.status.idle": "2022-08-22T01:19:21.222629Z",
     "shell.execute_reply": "2022-08-22T01:19:21.221473Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Flow rate = 30049.50805498884 foot ** 3 / second\n",
      "Flow rate = 30135.24506735869 foot ** 3 / second\n",
      "Flow rate = 30135.24898850496 foot ** 3 / second\n",
      "Flow rate = 30135.24898868379 foot ** 3 / second\n",
      "Flow rate = 30135.248988683794 foot ** 3 / second\n"
     ]
    }
   ],
   "source": [
    "fd = 0.017 # assumed initial guess\n",
    "Re = 1E5\n",
    "for i in range(5):\n",
    "    K = K_from_f(fd=fd, L=L, D=Dh)\n",
    "    K += entrance_sharp()\n",
    "    K += exit_normal()\n",
    "\n",
    "    v = (2*u.gravity*H/K)**0.5\n",
    "    Q = A*v\n",
    "    print('Flow rate = %s' %(Q.to(u.ft**3/u.s)))\n",
    "    Re = Reynolds(D=Dh, rho=rho, mu=mu, V=v)\n",
    "    fd = friction_factor(Re=Re, eD=eD)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The solution given in Crane is 30600 ft^3/s, without iteration."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can also solve the problem using the manning formula, designed for open flow. Different values of the manning `n` coefficient give different results, but a likely value for concrete yields a surprisingly different answer than the hydraulic radius approach."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:19:21.246490Z",
     "iopub.status.busy": "2022-08-22T01:19:21.246011Z",
     "iopub.status.idle": "2022-08-22T01:19:21.264991Z",
     "shell.execute_reply": "2022-08-22T01:19:21.264089Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "61407.46714336768 foot3/second"
      ],
      "text/latex": [
       "$61407.46714336768\\ \\frac{\\mathrm{foot}^{3}}{\\mathrm{second}}$"
      ],
      "text/plain": [
       "61407.46714336768 <Unit('foot ** 3 / second')>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "S = H/L # slope, m/m\n",
    "# n = 0.0106*u.s/u.m**(1/3) # https://www.usbr.gov/tsc/techreferences/hydraulics_lab/pubs/HYD/HYD-585.pdf\n",
    "n = 0.013*u.s/u.m**(1/3)\n",
    "\n",
    "v = V_Manning(Rh=Rh, S=S, n=n)\n",
    "(v*A).to(u.ft**3/u.s)"
   ]
  }
 ],
 "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
}
