{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Friction"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Experimental friction factors"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "from fluids.friction import friction_factor, oregon_Res, oregon_fd_smooth\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "Res = np.logspace(np.log10(oregon_Res[0]), np.log10(oregon_Res[-1]), 500)\n",
    "fds_calc = [friction_factor(Re) for Re in Res]\n",
    "plt.loglog(oregon_Res, oregon_fd_smooth, 'x', label='Oregon Data')\n",
    "plt.loglog(Res, fds_calc, label='Colebrook')\n",
    "plt.xlabel('Reynolds number')\n",
    "plt.ylabel('Darcy friction factor')\n",
    "plt.title(\"Experimental friction factor data for smooth pipe\")\n",
    "plt.legend()\n",
    "plt.plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[11.21, 20.22, 29.28, 43.19, 57.73, 64.58, 86.05, 113.3, 135.3, 157.5, 179.4, 206.4, 228.0, 270.9, 315.2, 358.9, 402.9, 450.2, 522.5, 583.1, 671.8, 789.8, 891.0, 1013.0, 1197.0, 1300.0, 1390.0, 1669.0, 1994.0, 2227.0, 2554.0, 2868.0, 2903.0, 2926.0, 2955.0, 2991.0, 2997.0, 3047.0, 3080.0, 3264.0, 3980.0, 4835.0, 5959.0, 8162.0, 10900.0, 13650.0, 18990.0, 29430.0, 40850.0, 59220.0, 84760.0, 120000.0, 176000.0, 237700.0, 298200.0, 467800.0, 587500.0, 824200.0, 1050000.0]\n",
      "[5.537, 3.492, 2.329, 1.523, 1.173, 0.9863, 0.7826, 0.5709, 0.4815, 0.4182, 0.3655, 0.3237, 0.2884, 0.2433, 0.2077, 0.1834, 0.1656, 0.1475, 0.1245, 0.1126, 0.09917, 0.08501, 0.07722, 0.06707, 0.0588, 0.05328, 0.04815, 0.04304, 0.03739, 0.03405, 0.03091, 0.02804, 0.03182, 0.03846, 0.03363, 0.04124, 0.035, 0.03875, 0.04285, 0.0426, 0.03995, 0.03797, 0.0361, 0.03364, 0.03088, 0.02903, 0.0267, 0.02386, 0.02086, 0.02, 0.01805, 0.01686, 0.01594, 0.01511, 0.01462, 0.01365, 0.01313, 0.01244, 0.01198]\n"
     ]
    }
   ],
   "source": [
    "print(oregon_Res)\n",
    "print(oregon_fd_smooth)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Roughness data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Brass': 1.52e-06,\n",
       " 'Lead': 1.52e-06,\n",
       " 'Glass': 1.52e-06,\n",
       " 'Steel': 1.52e-06,\n",
       " 'Asphalted cast iron': 0.000122,\n",
       " 'Galvanized iron': 0.000152,\n",
       " 'Cast iron': 0.000259,\n",
       " 'Wood stave': 0.000183,\n",
       " 'Rough wood stave': 0.000914,\n",
       " 'Concrete': 0.000305,\n",
       " 'Rough concrete': 0.00305,\n",
       " 'Riveted steel': 0.000914,\n",
       " 'Rough riveted steel': 0.00914}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from fluids.friction import _roughness\n",
    "# Material from Perry's handbook; roughness in meters.\n",
    "_roughness"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Really good table from Idelʹchik, I. E, and A. S Ginevskiĭ. Handbook of Hydraulic \n",
    "Resistance. Redding, CT: Begell House, 2007.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Rough channels in rock, Blast-hewed, little jointing': (0.1, 0.14, None),\n",
       " 'Rough channels in rock, Blast-hewed, substantial jointing': (0.13,\n",
       "  0.5,\n",
       "  None),\n",
       " 'Rough channels in rock, Roughly cut or very uneven surface': (0.5,\n",
       "  1.5,\n",
       "  None),\n",
       " 'Unlined tunnels, Rocks, gneiss, diameter 3-13.5 m': (0.3, 0.7, None),\n",
       " 'Unlined tunnels, Rocks, granite, diameter 3-9 m': (0.2, 0.7, None),\n",
       " 'Unlined tunnels, Shale, diameter, diameter 9-12 m': (0.25, 0.65, None),\n",
       " 'Unlined tunnels, Shale, quartz, quartzile, diameter 7-10 m': (0.2,\n",
       "  0.6,\n",
       "  None),\n",
       " 'Unlined tunnels, Shale, sedimentary, diameter 4-7 m': (None, None, 0.4),\n",
       " 'Unlined tunnels, Shale, nephrite bearing, diameter 3-8 m': (None, None, 0.2),\n",
       " 'Wood tubes, Boards, thoroughly dressed': (None, None, 0.00015),\n",
       " 'Wood tubes, Boards, well dressed': (None, None, 0.0003),\n",
       " 'Wood tubes, Boards, undressed but fitted': (None, None, 0.0007),\n",
       " 'Wood tubes, Boards, undressed': (None, None, 0.001),\n",
       " 'Wood tubes, Staved': (None, None, 0.0006),\n",
       " 'Plywood tubes, Birch plywood, transverse grain, good quality': (None,\n",
       "  None,\n",
       "  0.00012),\n",
       " 'Plywood tubes, Birch plywood, longitudal grain, good quality': (3e-05,\n",
       "  5e-05,\n",
       "  None),\n",
       " 'Glass tubes, Glass': (1.5e-06, 1e-05, None),\n",
       " 'Concrete water conduits, no finish, New and finished with plater; excellent manufacture (joints aligned, prime coated and smoothed)': (5e-05,\n",
       "  0.00015,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Used and corroded; with a wavy surface and wood framework': (0.001,\n",
       "  0.004,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Old, poor fitting and manufacture; with an overgrown surface and deposits of sand and gravel': (0.001,\n",
       "  0.004,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Very old; damaged surface, very overgrown': (0.005,\n",
       "  None,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Water conduit, finished with smoothed plaster': (0.005,\n",
       "  None,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, New, very well manufactured, hand smoothed, prime-coated joints': (0.0001,\n",
       "  0.0002,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Hand-smoothed cement finish and smoothed joints': (0.00015,\n",
       "  0.00035,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Used, no deposits, moderately smooth, steel or wooden casing, joints prime coated but not smoothed': (0.0003,\n",
       "  0.0006,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Used, prefabricated monoliths, cement plaster (wood floated), rough joints': (0.0005,\n",
       "  0.001,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Conduits for water, sprayed surface of concrete': (0.0005,\n",
       "  0.001,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Smoothed air-placed, either sprayed concrete or concrete on more concrete': (0.006,\n",
       "  0.017,\n",
       "  None),\n",
       " 'Concrete water conduits, no finish, Brushed air-placed, either sprayed concrete or concrete on more concrete': (None,\n",
       "  None,\n",
       "  0.0023),\n",
       " 'Concrete water conduits, no finish, Non-smoothed air-placed, either sprayed concrete or concrete on more concrete': (0.003,\n",
       "  0.006,\n",
       "  None),\n",
       " 'Reinforced concrete tubes, New': (0.00025, 0.00034, None),\n",
       " 'Reinforced concrete tubes, Nonprocessed': (0.0025, None, None),\n",
       " 'Asbestos cement tubes, New': (5e-05, 0.0001, None),\n",
       " 'Asbestos cement tubes, Average': (0.0006, None, None),\n",
       " 'Cement tubes, Smoothed': (0.0003, 0.0008, None),\n",
       " 'Cement tubes, Non processed': (0.001, 0.002, None),\n",
       " 'Cement tubes, Joints, non smoothed': (0.0019, 0.0064, None),\n",
       " 'Cement-mortar plaster channels, Plaster, cement, smoothed joints and protrusions, and a casing': (5e-05,\n",
       "  0.00022,\n",
       "  None),\n",
       " 'Cement-mortar plaster channels, Steel trowled': (None, None, 0.0005),\n",
       " 'Other, Plaster over a screen': (0.01, 0.015, None),\n",
       " 'Other, Salt-glazed ceramic': (None, None, 0.0014),\n",
       " 'Other, Slag-concrete': (None, None, 0.0015),\n",
       " 'Other, Slag and alabaster-filling': (0.001, 0.0015, None),\n",
       " 'Seamless tubes made from brass, copper, lead, aluminum, Commercially smooth': (1.5e-06,\n",
       "  1e-05,\n",
       "  None),\n",
       " 'Seamless steel tubes, New and unused': (2e-05, 0.0001, None),\n",
       " 'Seamless steel tubes, Cleaned, following years of use': (None, 4e-05, None),\n",
       " 'Seamless steel tubes, Bituminized': (None, 4e-05, None),\n",
       " 'Seamless steel tubes, Heating systems piping; either superheated steam pipes, or just water pipes of systems with deaerators and chemical treatment': (None,\n",
       "  None,\n",
       "  0.0001),\n",
       " 'Seamless steel tubes, Following one year as a gas pipeline': (None,\n",
       "  None,\n",
       "  0.00012),\n",
       " 'Seamless steel tubes, Following multiple year as a gas pipeline': (4e-05,\n",
       "  0.0002,\n",
       "  None),\n",
       " 'Seamless steel tubes, Casings in gas wells, different conditions, several years of use': (6e-05,\n",
       "  0.00022,\n",
       "  None),\n",
       " 'Seamless steel tubes, Heating systems, saturated steam ducts or water pipes (with minor water leakage < 0.5%, and balance water deaerated)': (None,\n",
       "  None,\n",
       "  0.0002),\n",
       " 'Seamless steel tubes, Water heating system pipelines, any source': (None,\n",
       "  None,\n",
       "  0.0002),\n",
       " 'Seamless steel tubes, Oil pipelines, intermediate operating conditions ': (None,\n",
       "  None,\n",
       "  0.0002),\n",
       " 'Seamless steel tubes, Corroded, moderately ': (None, None, 0.0004),\n",
       " 'Seamless steel tubes, Scale, small depositions only ': (None, None, 0.0004),\n",
       " 'Seamless steel tubes, Condensate pipes in open systems or periodically operated steam pipelines': (None,\n",
       "  None,\n",
       "  0.0005),\n",
       " 'Seamless steel tubes, Compressed air piping': (None, None, 0.0008),\n",
       " 'Seamless steel tubes, Following multiple years of operation, generally corroded or with small amounts of scale': (0.00015,\n",
       "  0.001,\n",
       "  None),\n",
       " 'Seamless steel tubes, Water heating piping without deaeration but with chemical treatment of water; leakage up to 3%; or condensate piping operated periodically': (None,\n",
       "  None,\n",
       "  0.001),\n",
       " 'Seamless steel tubes, Used water piping': (0.0012, 0.0015, None),\n",
       " 'Seamless steel tubes, Poor condition': (0.005, None, None),\n",
       " 'Welded steel tubes, Good condition': (4e-05, 0.0001, None),\n",
       " 'Welded steel tubes, New and covered with bitumen': (None, None, 5e-05),\n",
       " 'Welded steel tubes, Used and covered with partially dissolved bitumen; corroded': (None,\n",
       "  None,\n",
       "  0.0001),\n",
       " 'Welded steel tubes, Used, suffering general corrosion': (None,\n",
       "  None,\n",
       "  0.00015),\n",
       " 'Welded steel tubes, Surface looks like new, 10 mm lacquer inside, even joints': (0.0003,\n",
       "  0.0004,\n",
       "  None),\n",
       " 'Welded steel tubes, Used Gas mains': (None, None, 0.0005),\n",
       " 'Welded steel tubes, Double or simple transverse riveted joints; with or without lacquer; without corrosion': (0.0006,\n",
       "  0.0007,\n",
       "  None),\n",
       " 'Welded steel tubes, Lacquered inside but rusted': (0.00095, 0.001, None),\n",
       " 'Welded steel tubes, Gas mains, many years of use, with layered deposits': (None,\n",
       "  None,\n",
       "  0.0011),\n",
       " 'Welded steel tubes, Non-corroded and with double transverse riveted joints': (0.0012,\n",
       "  0.0015,\n",
       "  None),\n",
       " 'Welded steel tubes, Small deposits': (None, None, 0.0015),\n",
       " 'Welded steel tubes, Heavily corroded and with  double transverse riveted joints': (None,\n",
       "  None,\n",
       "  0.002),\n",
       " 'Welded steel tubes, Appreciable deposits': (0.002, 0.004, None),\n",
       " 'Welded steel tubes, Gas mains, many years of use, deposits of resin/naphthalene': (None,\n",
       "  None,\n",
       "  0.0024),\n",
       " 'Welded steel tubes, Poor condition': (0.005, None, None),\n",
       " 'Riveted steel tubes, Riveted laterally and longitudinally with one line; lacquered on the inside': (0.0003,\n",
       "  0.0004,\n",
       "  None),\n",
       " 'Riveted steel tubes, Riveted laterally and longitudinally with two lines; with or without lacquer on the inside and without corrosion': (0.0006,\n",
       "  0.0007,\n",
       "  None),\n",
       " 'Riveted steel tubes, Riveted laterally with one line and longitudinally with two lines; thickly lacquered or torred on the inside': (0.0012,\n",
       "  0.0014,\n",
       "  None),\n",
       " 'Riveted steel tubes, Riveted longitudinally with six lines, after extensive use': (None,\n",
       "  None,\n",
       "  0.002),\n",
       " 'Riveted steel tubes, Riveted laterally with four line and longitudinally with six lines; overlapping joints inside': (None,\n",
       "  None,\n",
       "  0.004),\n",
       " 'Riveted steel tubes, Extremely poor surface; overlapping and uneven joints': (0.005,\n",
       "  None,\n",
       "  None),\n",
       " 'Roofing steel sheets, Oiled': (0.00015, 0.0011, None),\n",
       " 'Roofing steel sheets, Not Oiled': (2e-05, 4e-05, None),\n",
       " 'Galzanized steel tubes, Bright galvanization; new': (7e-05, 0.0001, None),\n",
       " 'Galzanized steel tubes, Ordinary galvanization': (0.0001, 0.00015, None),\n",
       " 'Galzanized sheet steel, New': (None, None, 0.00015),\n",
       " 'Galzanized sheet steel, Used previously for water': (None, None, 0.00018),\n",
       " 'Steel tubes, Glass enamel coat': (1e-06, 1e-05, None),\n",
       " 'Steel tubes, New': (0.00025, 0.001, None),\n",
       " 'Cast-iron tubes, New, bituminized': (0.0001, 0.00015, None),\n",
       " 'Cast-iron tubes, Coated with asphalt': (0.00012, 0.0003, None),\n",
       " 'Cast-iron tubes, Used water pipelines': (None, None, 0.0014),\n",
       " 'Cast-iron tubes, Used and corroded': (0.001, 0.0015, None),\n",
       " 'Cast-iron tubes, Deposits visible': (0.001, 0.0015, None),\n",
       " 'Cast-iron tubes, Substantial deposits': (0.002, 0.004, None),\n",
       " 'Cast-iron tubes, Cleaned after extensive use': (0.0003, 0.0015, None),\n",
       " 'Cast-iron tubes, Severely corroded': (None, 0.003, None),\n",
       " 'Steel water conduits in generating stations, New, clean, seamless (without joints), well fitted': (1.5e-05,\n",
       "  4e-05,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, welded lengthwise and well fitted': (1.2e-05,\n",
       "  3e-05,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, welded lengthwise and well fitted, with transverse welded joints': (8e-05,\n",
       "  0.00017,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, coated, bituminized when manufactured': (1.4e-05,\n",
       "  1.8e-05,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, coated, bituminized when manufactured, with transverse welded joints': (0.0002,\n",
       "  0.0006,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, coated, galvanized': (0.0001,\n",
       "  0.0002,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, coated, roughly galvanized': (0.0004,\n",
       "  0.0007,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, New, clean, coated, bituminized, curved': (0.0001,\n",
       "  0.0014,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, Used, clean, slight corrosion': (0.0001,\n",
       "  0.0003,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, Used, clean, moderate corrosion or slight deposits': (0.0003,\n",
       "  0.0007,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, Used, clean, severe corrosion': (0.0008,\n",
       "  0.0015,\n",
       "  None),\n",
       " 'Steel water conduits in generating stations, Used, clean, previously cleaned of either deposits or rust': (0.00015,\n",
       "  0.0002,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, all welded, <2 years use, no deposits': (0.00012,\n",
       "  0.00024,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, all welded, <20 years use, no deposits': (0.0006,\n",
       "  0.005,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, iron-bacterial corrosion': (0.003,\n",
       "  0.004,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, heavy corrosion, or with incrustation (deposit 1.5 - 9 mm deep)': (0.003,\n",
       "  0.005,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, heavy corrosion, or with incrustation (deposit 3 - 25 mm deep)': (0.006,\n",
       "  0.0065,\n",
       "  None),\n",
       " 'Used steel water conduits in generating stations, Used, inside coating, bituminized, < 2 years use': (0.0001,\n",
       "  0.00035,\n",
       "  None)}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from fluids.friction import HHR_roughness\n",
    "HHR_roughness"
   ]
  }
 ],
 "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.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
