{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7.35 Hydraulic Resistance of a Converging Tee"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A 4\" schedule 40 tee with equal leg diameters has 300 gpm of water at 60 deg F flowing into a straight leg, and 100 gpm converging in from the 90 degree branch leg.\n",
    "\n",
    "Find the loss coefficients for the straight leg and the branch leg, and the head loss across each flow path."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2022-08-22T01:20:09.501010Z",
     "iopub.status.busy": "2022-08-22T01:20:09.500454Z",
     "iopub.status.idle": "2022-08-22T01:20:10.222183Z",
     "shell.execute_reply": "2022-08-22T01:20:10.221288Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The combined velocity is 10.081042597997012 foot / second\n",
      "The branch loss coefficient is -0.0421875 dimensionless\n",
      "The run loss coefficient is 0.325 dimensionless\n",
      "The branch head loss is -0.06662833817657396 foot\n",
      "The run head loss is 0.5132849755824956 foot\n"
     ]
    }
   ],
   "source": [
    "from fluids.units import *\n",
    "from math import pi\n",
    "NPS, Di, Do, t = nearest_pipe(NPS=4, schedule='40')\n",
    "\n",
    "A = 0.25*pi*Di**2\n",
    "beta = 1 # same diameters\n",
    "\n",
    "rho = 998*u.kg/u.m**3\n",
    "\n",
    "Q_tot = 400*u.gal/u.min\n",
    "Q_main = 300*u.gal/u.min\n",
    "Q_leg = 100*u.gal/u.min\n",
    "\n",
    "v_combined = Q_tot/A\n",
    "print('The combined velocity is %s' %(v_combined.to(u.ft/u.s)))\n",
    "branch_flow_ratio = Q_leg/Q_tot\n",
    "\n",
    "v_main = Q_main/A\n",
    "v_leg = Q_leg/A\n",
    "\n",
    "K_branch = K_branch_converging_Crane(D_run=Di, D_branch=Di, Q_run=Q_main, Q_branch=Q_leg, angle=90.0*u.degrees)\n",
    "print('The branch loss coefficient is %s' %(K_branch))\n",
    "K_run = K_run_converging_Crane(D_run=Di, D_branch=Di, Q_run=Q_main, Q_branch=Q_leg, angle=90.0*u.degrees)\n",
    "print('The run loss coefficient is %s' %(K_run))\n",
    "\n",
    "head_loss_branch = 0.5*rho*v_combined**2*K_branch/(1*u.gravity*rho)\n",
    "print('The branch head loss is %s' %(head_loss_branch.to(u.ft)))\n",
    "\n",
    "head_loss_run = 0.5*rho*v_combined**2*K_run/(1*u.gravity*rho)\n",
    "print('The run head loss is %s' %(head_loss_run.to(u.ft)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The values presented in crane match very nearly exactly; this type of a problem does not require any iteration, unless the density of the fluid is variable."
   ]
  }
 ],
 "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
}
