1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187
|
r"""Chemical Engineering Design Library (ChEDL). Utilities for process modeling.
Copyright (C) 2016, 2017, 2018, 2019, 2020 Caleb Bell <Caleb.Andrew.Bell@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This module contains correlations for the loss coefficient of various types
of pipe fittings. Whether you are designing a network or modeling a single
element, the correlations here cover most cases.
For reporting bugs, adding feature requests, or submitting pull requests,
please use the `GitHub issue tracker <https://github.com/CalebBell/fluids/>`_
or contact the author at Caleb.Andrew.Bell@gmail.com.
.. contents:: :local:
Entrances
---------
.. autofunction:: entrance_sharp
.. autofunction:: entrance_distance
.. autofunction:: entrance_angled
.. autofunction:: entrance_rounded
.. autofunction:: entrance_beveled
.. autofunction:: entrance_beveled_orifice
.. autofunction:: entrance_distance_45_Miller
Exits
-----
.. autofunction:: exit_normal
Bends
-----
.. autofunction:: bend_rounded
.. autofunction:: bend_rounded_Miller
.. autofunction:: bend_rounded_Crane
.. autofunction:: bend_miter
.. autofunction:: bend_miter_Miller
.. autofunction:: helix
.. autofunction:: spiral
Contractions/Reducers
---------------------
.. autofunction:: contraction_sharp
.. autofunction:: contraction_round
.. autofunction:: contraction_round_Miller
.. autofunction:: contraction_conical
.. autofunction:: contraction_conical_Crane
.. autofunction:: contraction_beveled
Expansions/Diffusers
--------------------
.. autofunction:: diffuser_sharp
.. autofunction:: diffuser_conical
.. autofunction:: diffuser_conical_staged
.. autofunction:: diffuser_curved
.. autofunction:: diffuser_pipe_reducer
Tees
----
.. autofunction:: K_branch_converging_Crane
.. autofunction:: K_run_converging_Crane
.. autofunction:: K_branch_diverging_Crane
.. autofunction:: K_run_diverging_Crane
Valves
------
.. autofunction:: K_gate_valve_Crane
.. autofunction:: K_angle_valve_Crane
.. autofunction:: K_globe_valve_Crane
.. autofunction:: K_swing_check_valve_Crane
.. autofunction:: K_lift_check_valve_Crane
.. autofunction:: K_tilting_disk_check_valve_Crane
.. autofunction:: K_globe_stop_check_valve_Crane
.. autofunction:: K_angle_stop_check_valve_Crane
.. autofunction:: K_ball_valve_Crane
.. autofunction:: K_diaphragm_valve_Crane
.. autofunction:: K_foot_valve_Crane
.. autofunction:: K_butterfly_valve_Crane
.. autofunction:: K_plug_valve_Crane
Hooper 2K fittings
------------------
.. autofunction:: Hooper2K
.. autodata:: Hooper
Darby 3K fittings
------------------
.. autofunction:: Darby3K
.. autodata:: Darby
Loss Coefficient Converters
---------------------------
.. autofunction:: Cv_to_K
.. autofunction:: Kv_to_K
.. autofunction:: K_to_Cv
.. autofunction:: K_to_Kv
.. autofunction:: Cv_to_Kv
.. autofunction:: Kv_to_Cv
Miscellaneous
-------------
.. autofunction:: v_lift_valve_Crane
Sources
-------
The main sources for these correlations are as follows [100]_ [101]_ [102]_ [103]_ [104]_:
.. [100] Crane Co. TP 410 Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [101] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [102] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [103] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [104] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
"""
from math import atan, cos, degrees, log, log10, pi, radians, sin, sqrt, tan
from fluids.constants import deg2rad, rad2deg
from fluids.friction import Clamond, friction_factor, friction_factor_curved, ft_Crane
from fluids.numerics import bisplev, horner, implementation_optimize_tck, interp, splev, tck_interp2d_linear
from fluids.piping import NPS40, S40i
__all__ = ['contraction_sharp', 'contraction_round',
'contraction_round_Miller',
'contraction_conical', 'contraction_conical_Crane', 'contraction_beveled', 'diffuser_sharp',
'diffuser_conical', 'diffuser_conical_staged', 'diffuser_curved',
'diffuser_pipe_reducer',
'entrance_sharp', 'entrance_distance', 'entrance_angled',
'entrance_rounded', 'entrance_beveled', 'entrance_beveled_orifice',
'entrance_distance_45_Miller',
'exit_normal', 'bend_rounded', 'bend_rounded_Miller', 'bend_rounded_Crane', 'bend_miter',
'bend_miter_Miller', 'helix', 'spiral','Darby3K', 'Hooper2K', 'Kv_to_Cv', 'Cv_to_Kv',
'Kv_to_K', 'K_to_Kv', 'Cv_to_K', 'K_to_Cv', 'change_K_basis', 'Darby',
'Hooper', 'K_gate_valve_Crane', 'K_angle_valve_Crane', 'K_globe_valve_Crane',
'K_swing_check_valve_Crane', 'K_lift_check_valve_Crane',
'K_tilting_disk_check_valve_Crane', 'K_globe_stop_check_valve_Crane',
'K_angle_stop_check_valve_Crane', 'K_ball_valve_Crane',
'K_diaphragm_valve_Crane', 'K_foot_valve_Crane', 'K_butterfly_valve_Crane',
'K_plug_valve_Crane', 'K_branch_converging_Crane', 'K_run_converging_Crane',
'K_branch_diverging_Crane', 'K_run_diverging_Crane', 'v_lift_valve_Crane',
'Crane_loss_coefficient',
'CRANE_VALVES', 'DARBY_VALVES', 'HOOPER_VALVES']
def change_K_basis(K1, D1, D2):
r'''Converts a loss coefficient `K1` from the basis of one diameter `D1`
to another diameter, `D2`. This is necessary when dealing with pipelines
of changing diameter.
.. math::
K_2 = K_1\frac{D_2^4}{D_1^4} = K_1 \frac{A_2^2}{A_1^2}
Parameters
----------
K1 : float
Loss coefficient with respect to diameter `D`, [-]
D1 : float
Diameter of pipe for which `K1` has been calculated, [m]
D2 : float
Diameter of pipe for which `K2` will be calculated, [m]
Returns
-------
K2 : float
Loss coefficient with respect to the second diameter, [-]
Notes
-----
This expression is shown in [1]_ and can easily be derived:
.. math::
\frac{\rho V_{1}^{2}}{2} \cdot K_{1} = \frac{\rho V_{2}^{2} }{2}
\cdot K_{2}
Substitute velocities for flow rate divided by area:
.. math::
\frac{8 K_{1} Q^{2} \rho}{\pi^{2} D_{1}^{4}} = \frac{8 K_{2} Q^{2}
\rho}{\pi^{2} D_{2}^{4}}
From here, simplification and rearrangement is all that is required.
Examples
--------
>>> change_K_basis(K1=32.68875692997804, D1=.01, D2=.02)
523.020110879
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
r = D2/D1
r *= r
return K1*r*r
### Entrances
entrance_sharp_methods = ['Rennels', 'Swamee', 'Blevins', 'Idelchik', 'Crane',
'Miller']
entrance_sharp_method_missing = (f'Specified method not recognized; methods are {entrance_sharp_methods}')
def entrance_sharp(method='Rennels'):
r'''Returns loss coefficient for a sharp entrance to a pipe.
Six sources are available; four of them recommending K = 0.5,
the most recent 'Rennels', method recommending K = 0.57, and the
'Miller' method recommending ~0.51 as read from a graph.
.. figure:: fittings/flush_mounted_sharp_edged_entrance.png
:scale: 30 %
:alt: flush mounted sharp edged entrance; after [1]_
Parameters
----------
method : str, optional
The method to use; one of 'Rennels', 'Swamee', 'Blevins',
'Idelchik', 'Crane', or 'Miller, [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
0.5 is the result for 'Swamee', 'Blevins', 'Idelchik', and 'Crane';
'Miller' returns 0.5093, and 'Rennels' returns 0.57.
Examples
--------
>>> entrance_sharp()
0.57
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [3] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [4] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
.. [5] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [6] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply
Pipe Networks. John Wiley & Sons, 2008.
'''
if method is None:
method = 'Rennels'
if method in ('Swamee', 'Blevins', 'Crane', 'Idelchik'):
return 0.50
elif method == 'Miller':
# From entrance_rounded(Di=0.9, rc=0.0, method='Miller'); Not saying it's right
return 0.5092676683721356
elif method == 'Rennels':
return 0.57
else:
raise ValueError(entrance_sharp_method_missing)
entrance_distance_Miller_coeffs = [3.5979871366071166, -2.735407311020481, -14.08678246875138,
10.637236472292983, 21.99568490754116, -16.38501138746954,
-17.62779826803278, 12.945551397987447, 7.715463242992863,
-5.850893341031715, -1.3809402870404826, 1.179637166644488,
0.08781141316107932, -0.09751968111743672, 0.00501792061942849,
0.0026378278251172615, 0.5309019247035696]
entrance_distance_Idelchik_l_Di = [0.0, 0.002, 0.005, 0.01, 0.02, 0.05, 0.1,
0.2, 0.3, 0.5, 10.0] # last point infinity
entrance_distance_Idelchik_t_Di = [0.0, 0.004, 0.008, 0.012, 0.016, 0.02, 0.024,
0.03, 0.04, 0.05, 1.0] # last point infinity
entrance_distance_Idelchik_dat = [
[0.5, 0.57, 0.63, 0.68, 0.73, 0.8, 0.86, 0.92, 0.97, 1, 1],
[0.5, 0.54, 0.58, 0.63, 0.67, 0.74, 0.8, 0.86, 0.9, 0.94, 0.94],
[0.5, 0.53, 0.55, 0.58, 0.62, 0.68, 0.74, 0.81, 0.85, 0.88, 0.88],
[0.5, 0.52, 0.53, 0.55, 0.58, 0.63, 0.68, 0.75, 0.79, 0.83, 0.83],
[0.5, 0.51, 0.51, 0.53, 0.55, 0.58, 0.64, 0.7, 0.74, 0.77, 0.77],
[0.5, 0.51, 0.51, 0.52, 0.53, 0.55, 0.6, 0.66, 0.69, 0.72, 0.72],
[0.5, 0.5, 0.5, 0.51, 0.52, 0.53, 0.58, 0.62, 0.65, 0.68, 0.68],
[0.5, 0.5, 0.5, 0.51, 0.52, 0.52, 0.54, 0.57, 0.59, 0.61, 0.61],
[0.5, 0.5, 0.5, 0.51, 0.51, 0.51, 0.51, 0.52, 0.52, 0.54, 0.54],
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
[0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]]
entrance_distance_Idelchik_tck = tck_interp2d_linear(entrance_distance_Idelchik_l_Di,
entrance_distance_Idelchik_t_Di,
entrance_distance_Idelchik_dat,
kx=1, ky=1)
entrance_distance_Idelchik_obj = lambda x, y: float(bisplev(x, y, entrance_distance_Idelchik_tck))
entrance_distance_Idelchik_obj = lambda x, y: bisplev(x, y, entrance_distance_Idelchik_tck)
entrance_distance_Harris_t_Di = [0.00322, 0.007255, 0.01223, 0.018015,
0.021776, 0.029044, 0.039417, 0.049519, 0.058012, 0.066234,
0.076747, 0.088337, 0.098714, 0.109497, 0.121762, 0.130655, 0.14036,
0.148986, 0.159902, 0.17149, 0.179578, 0.189416, 0.200602, 0.208148,
0.217716, 0.228232, 0.239821, 0.250063, 0.260845, 0.270818,
0.280116, 0.289145]
entrance_distance_Harris_Ks = [0.894574, 0.832435, 0.749768, 0.671543,
0.574442, 0.508432, 0.476283, 0.430261, 0.45027, 0.45474, 0.461993,
0.457042, 0.458745, 0.464889, 0.471594, 0.461638, 0.467778,
0.475024, 0.474509, 0.456239, 0.466258, 0.467959, 0.466336,
0.459705, 0.454746, 0.478092, 0.468701, 0.467074, 0.468779,
0.467151, 0.46441, 0.458894]
entrance_distance_Harris_tck = implementation_optimize_tck([
[0.00322, 0.00322, 0.00322, 0.00322, 0.01223, 0.018015, 0.021776, 0.029044,
0.039417, 0.049519, 0.058012, 0.066234, 0.076747, 0.088337, 0.098714,
0.109497, 0.121762, 0.130655, 0.14036, 0.148986, 0.159902, 0.17149,
0.179578, 0.189416, 0.200602, 0.208148, 0.217716, 0.228232, 0.239821,
0.250063, 0.260845, 0.270818, 0.289145, 0.289145, 0.289145, 0.289145],
[0.894574, 0.8607821362959746, 0.7418364422223542, 0.7071594764719331,
0.5230593641637336, 0.5053866365045014, 0.4869380604512194,
0.40993425463761973, 0.4588732899536263, 0.45115886608796796,
0.4672085434114074, 0.45422360120010624, 0.45882234693051327,
0.4633823025024543, 0.4785594597978615, 0.45603301615693537,
0.46825191653436804, 0.4759245648612374, 0.4816400424293727,
0.4467699156979281, 0.4713316096394432, 0.4667017151264001,
0.4686302748435692, 0.4597796190662107, 0.445267522727416,
0.491034205369033, 0.4641178520412072, 0.46721810151497395,
0.46958841021674314, 0.4664976446563455, 0.46420067427943945,
0.458894, 0.0, 0.0, 0.0, 0.0],
3])
entrance_distance_Harris_obj = lambda x : float(splev(x, entrance_distance_Harris_tck))
entrance_distance_methods = ['Rennels', 'Miller', 'Idelchik', 'Harris',
'Crane']
entrance_distance_unrecognized_msg = f'Specified method not recognized; methods are {entrance_distance_methods}'
def entrance_distance(Di, t=None, l=None, method='Rennels'):
r'''Returns the loss coefficient for a sharp entrance to a pipe at a distance
from the wall of a reservoir. This calculation has five methods available;
all but 'Idelchik' require the pipe to be at least `Di/2` into the
reservoir.
The most conservative formulation is that of Rennels; with Miller being
almost identical until `t/Di` reaches 0.05, when it continues settling to
K = 0.53 compared to K = 0.57 for 'Rennels'. 'Idelchik' is offset lower
by about 0.03 and settles to 0.50. The 'Harris' method is a straight
interpolation from experimental results with smoothing, and it is the
lowest at all points. The 'Crane' [6]_ method returns 0.78 for all cases.
The Rennels [1]_ formula is:
.. math::
K = 1.12 - 22\frac{t}{d} + 216\left(\frac{t}{d}\right)^2 +
80\left(\frac{t}{d}\right)^3
.. figure:: fittings/sharp_edged_entrace_extended_mount.png
:scale: 30 %
:alt: sharp edged entrace, extended mount; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
t : float, optional
Thickness of pipe wall, used in all but 'Crane' method, [m]
l : float, optional
The distance the pipe extends into the reservoir; used only in the
'Idelchik' method, defaults to `Di`, [m]
method : str, optional
One of 'Rennels', 'Miller', 'Idelchik', 'Harris', 'Crane', [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
This type of inlet is also known as a Borda's mouthpiece.
It is not of practical interest according to [1]_.
The 'Idelchik' [3]_ data is recommended in [5]_; it also provides rounded
values for the 'Harris. method.
.. plot:: plots/entrance_distance_plot.py
Examples
--------
>>> entrance_distance(Di=0.1, t=0.0005)
1.0154100000000001
>>> entrance_distance(Di=0.1, t=0.0005, method='Idelchik')
0.9249999999999999
>>> entrance_distance(Di=0.1, t=0.0005, l=.02, method='Idelchik')
0.8474999999999999
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [3] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [4] Harris, Charles William. The Influence of Pipe Thickness on
Re-Entrant Intake Losses. Vol. 48. University of Washington, 1928.
.. [5] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
.. [6] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if method is None:
method = 'Rennels'
if method == 'Rennels':
t_Di = t/Di
if t_Di > 0.05:
t_Di = 0.05
return 1.12 + t_Di*(t_Di*(80.0*t_Di + 216.0) - 22.0)
elif method == 'Miller':
t_Di = t/Di
if t_Di > 0.3:
t_Di = 0.3
return horner(entrance_distance_Miller_coeffs, 20.0/3.0*(t_Di - 0.15))
elif method == 'Idelchik':
if l is None:
l = Di
t_Di = min(t/Di, 1.0)
l_Di = min(l/Di, 10.0)
K = float(entrance_distance_Idelchik_obj(l_Di, t_Di))
if K < 0.0:
K = 0.0
return K
elif method == 'Harris':
ratio = min(t/Di, 0.289145) # max value for interpolation - extrapolation looks bad
K = float(entrance_distance_Harris_obj(ratio))
return K
elif method == 'Crane':
return 0.78
else:
raise ValueError(entrance_distance_unrecognized_msg)
entrance_distance_45_Miller_coeffs = [1.866792110435199, -2.8873199398381075, -4.814715029513536,
10.49562589373457, 1.40401776402922, -14.035912282651882,
6.576826918678071, 7.854645523152614, -8.044860164646053,
-1.1515885154512326, 4.145420152553604, -0.7994793202964967,
-1.1034822877774095, 0.32764916637953573, 0.367065452438954,
-0.2614447909010587, 0.29084476697430256]
def entrance_distance_45_Miller(Di, Di0):
r'''Returns loss coefficient for a sharp entrance to a pipe at a distance
from the wall of a reservoir with an initial 45 degree slope conical
section of diameter `Di0` added to reduce the overall loss coefficient.
This method is as shown in Miller's Internal Flow Systems
[1]_. This method is a curve fit to a graph in [1]_ which was digitized.
Parameters
----------
Di : float
Inside diameter of pipe, [m]
Di0 : float
Initial inner diameter of the welded conical section of the entrance
of the distant (re-entrant) pipe, [m]
Returns
-------
K : float
Loss coefficient with respect to the main pipe diameter `Di`, [-]
Notes
-----
The graph predicts an almost constant loss coefficient once the thickness
of pipe wall to pipe diameter ratio becomes ~0.02.
Examples
--------
>>> entrance_distance_45_Miller(Di=0.1, Di0=0.14)
0.24407641818143339
References
----------
.. [1] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
'''
t = 0.5*(Di0 - Di)
t_Di = t/Di
if t_Di > 0.3:
t_Di = 0.3
return horner(entrance_distance_45_Miller_coeffs, 6.66666666666666696*(t_Di-0.15))
entrance_angled_methods = ['Idelchik']
entrance_angled_methods_missing = (f'Specified method not recognized; methods are {entrance_angled_methods}')
def entrance_angled(angle, method='Idelchik'):
r'''Returns loss coefficient for a sharp, angled entrance to a pipe
flush with the wall of a reservoir. First published in [2]_, it has been
recommended in [3]_ as well as in [1]_.
.. math::
K = 0.57 + 0.30\cos(\theta) + 0.20\cos(\theta)^2
.. figure:: fittings/entrance_mounted_at_an_angle.png
:scale: 30 %
:alt: entrace mounted at an angle; after [1]_
Parameters
----------
angle : float
Angle of inclination (90° = straight, 0° = parallel to pipe wall),
[degrees]
method : str, optional
The method to use; only 'Idelchik' is supported
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Not reliable for angles under 20 degrees.
Loss coefficient is the same for an upward or downward angled inlet.
Examples
--------
>>> entrance_angled(30)
0.9798076211353315
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [3] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
'''
if method == 'Idelchik' or method is None:
cos_term = cos(deg2rad*angle)
return 0.57 + cos_term*(0.2*cos_term + 0.3)
else:
raise ValueError(entrance_angled_methods_missing)
entrance_rounded_Miller_coeffs = [1.3127209945178038, 0.19963046592715727, -6.49081916725612,
-0.10347409377743588, 12.68369791325003, -0.9435681020599904
, -12.44320584089916, 1.328251365167716, 6.668390027065714,
-0.4356382649470076, -2.209229212394282, -0.07222448354500295,
0.6786898049825905, -0.18686362789567468, 0.020064570486606065,
-0.013120241146656442, 0.061951596342059975]
entrance_rounded_ratios_Idelchik = [0, .01, .02, .03, .04, .05, .06, .08, .12,
.16, .2]
entrance_rounded_Ks_Idelchik = [.5, .44, .37, .31, .26, .22, .2, .15, .09, .06,
.03]
entrance_rounded_Idelchik_tck = implementation_optimize_tck([[0.0, 0.0, 0.0, 0.015, 0.025, 0.035, 0.045, 0.055,
0.07, 0.1, 0.14, 0.2, 0.2, 0.2],
[0.5, 0.46003224474143023, 0.3682580956033294, 0.30877401146621397, 0.2590978355993873,
0.2166389749374616, 0.19717564973543905, 0.1332971654240214, 0.08659056691519569,
0.05396118560777325, 0.03, 0.0, 0.0, 0.0],
2])
entrance_rounded_Idelchik = lambda x : float(splev(x, entrance_rounded_Idelchik_tck))
entrance_rounded_ratios_Crane = [0.0, .02, .04, .06, .1, .15]
entrance_rounded_Ks_Crane = [.5, .28, .24, .15, .09, .04]
entrance_rounded_ratios_Harris = [0.0, .01, .02, .03, .04, .05, .06, .08, .12,
.16]
entrance_rounded_Ks_Harris = [.44, .35, .28, .22, .17, .13, .1, .07, .03, 0.0]
entrance_rounded_Harris_tck = implementation_optimize_tck([[0.0, 0.0, 0.0, 0.015, 0.025, 0.035, 0.045,
0.055, 0.07, 0.1, 0.16, 0.16, 0.16],
[0.44, 0.36435669860605086, 0.2790010365858813, 0.2187082142826953, 0.16874967771794716,
0.1287937194096216, 0.09091157742799895, 0.06354756460434334, 0.01885121769782832,
0.0, 0.0, 0.0, 0.0],
2])
entrance_rounded_Harris = lambda x : float(splev(x, entrance_rounded_Harris_tck))
entrance_rounded_methods = ['Rennels', 'Crane', 'Miller', 'Idelchik', 'Harris',
'Swamee']
entrance_rounded_methods_error = (f'Specified method not recognized; methods are {entrance_rounded_methods}')
def entrance_rounded(Di, rc, method='Rennels'):
r'''Returns loss coefficient for a rounded entrance to a pipe
flush with the wall of a reservoir. This calculation has six methods
available.
The most conservative formulation is that of Rennels; with the Swammee
correlation being 0.02-0.07 lower. They were published in 2012 and 2008
respectively, and for this reason could be regarded as more reliable.
The Idel'chik correlation appears based on the Hamilton data; and the
Miller correlation as well, except a little more conservative. The Crane
model trends similarly but only has a few points. The Harris data set is
the lowest.
The Rennels [1]_ formulas are:
.. math::
K = 0.0696\left(1 - 0.569\frac{r}{d}\right)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622\left(1 - 0.30\sqrt{\frac{r}{d}}
- 0.70\frac{r}{d}\right)^4
The Swamee [5]_ formula is:
.. math::
K = 0.5\left[1 + 36\left(\frac{r}{D}\right)^{1.2}\right]^{-1}
.. figure:: fittings/flush_mounted_rounded_entrance.png
:scale: 30 %
:alt: rounded entrace mounted straight and flush; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
rc : float
Radius of curvature of the entrance, [m]
method : str, optional
One of 'Rennels', 'Crane', 'Miller', 'Idelchik', 'Harris', or 'Swamee'.
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
For generously rounded entrance (rc/Di >= 1), the loss coefficient
converges to 0.03 in the Rennels method.
The Rennels formulation was derived primarily from data and theoretical
analysis from different flow scenarios than a rounded pipe entrance; the
only available data in [2]_ is quite old and [1]_ casts doubt on it.
The Hamilton data set is available in [1]_ and [6]_.
.. plot:: plots/entrance_rounded_plot.py
Examples
--------
Point from Diagram 9.2 in [1]_, which was used to confirm the Rennels
model implementation:
>>> entrance_rounded(Di=0.1, rc=0.0235)
0.09839534618360923
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Hamilton, James Baker. Suppression of Pipe Intake Losses by Various
Degrees of Rounding. Seattle: Published by the University of Washington,
1929. https://search.library.wisc.edu/catalog/999823652202121.
.. [3] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [4] Harris, Charles William. Elimination of Hydraulic Eddy Current Loss
at Intake, Agreement of Theory and Experiment. University of Washington,
1930.
.. [5] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply
Pipe Networks. John Wiley & Sons, 2008.
.. [6] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [7] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
.. [8] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
'''
if method is None:
method = 'Rennels'
ratio = rc/Di
if method == 'Rennels':
if ratio > 1.0:
return 0.03
lbd = (1.0 - 0.30*sqrt(ratio) - 0.70*ratio)
lbd *= lbd
lbd = 1.0 + 0.622*lbd*lbd
return 0.0696*(1.0 - 0.569*ratio)*lbd*lbd + (lbd - 1.0)*(lbd - 1.0)
elif method == 'Swamee':
return 0.5/(1.0 + 36.0*(ratio)**1.2)
elif method == 'Crane':
if ratio < 0:
return 0.5
elif ratio > 0.15:
return 0.04
else:
return interp(ratio, entrance_rounded_ratios_Crane,
entrance_rounded_Ks_Crane)
elif method == 'Miller':
if ratio > 0.3:
ratio = 0.3
return horner(entrance_rounded_Miller_coeffs, (20.0/3.0)*(ratio - 0.15))
elif method == 'Harris':
if ratio > .16:
return 0.0
return float(splev(ratio, entrance_rounded_Harris_tck))
elif method == 'Idelchik':
if ratio > .2:
return entrance_rounded_Ks_Idelchik[-1]
return float(splev(ratio, entrance_rounded_Idelchik_tck))
else:
raise ValueError(entrance_rounded_methods_error)
entrance_beveled_methods = ['Rennels', 'Idelchik']
entrance_beveled_methods_unknown_msg = f'Specified method not recognized; methods are {entrance_beveled_methods}'
entrance_beveled_Idelchik_l_Di = [0.025, 0.05, 0.075, 0.1, 0.15, 0.6]
entrance_beveled_Idelchik_angles = [0.0, 10.0, 20.0, 30.0, 40.0, 60.0, 100.0,
140.0, 180.0]
entrance_beveled_Idelchik_dat = [
[0.5, 0.47, 0.45, 0.43, 0.41, 0.4, 0.42, 0.45, 0.5],
[0.5, 0.45, 0.41, 0.36, 0.33, 0.3, 0.35, 0.42, 0.5],
[0.5, 0.42, 0.35, 0.3, 0.26, 0.23, 0.3, 0.4, 0.5],
[0.5, 0.39, 0.32, 0.25, 0.22, 0.18, 0.27, 0.38, 0.5],
[0.5, 0.37, 0.27, 0.2, 0.16, 0.15, 0.25, 0.37, 0.5],
[0.5, 0.27, 0.18, 0.13, 0.11, 0.12, 0.23, 0.36, 0.5]]
entrance_beveled_Idelchik_tck = tck_interp2d_linear(entrance_beveled_Idelchik_angles,
entrance_beveled_Idelchik_l_Di,
entrance_beveled_Idelchik_dat,
kx=1, ky=1)
entrance_beveled_Idelchik_obj = lambda x, y : float(bisplev(x, y, entrance_beveled_Idelchik_tck))
def entrance_beveled(Di, l, angle, method='Rennels'):
r'''Returns loss coefficient for a beveled or chamfered entrance to a pipe
flush with the wall of a reservoir. This calculation has two methods
available.
The 'Rennels' and 'Idelchik' methods have similar trends, but the 'Rennels'
formulation is centered around a straight loss coefficient of 0.57, so it
is normally at least 0.07 higher.
The Rennels [1]_ formulas are:
.. math::
K = 0.0696\left(1 - C_b\frac{l}{d}\right)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622\left[1-1.5C_b\left(\frac{l}{d}
\right)^{\frac{1-(l/d)^{1/4}}{2}}\right]
.. math::
C_b = \left(1 - \frac{\theta}{90}\right)\left(\frac{\theta}{90}
\right)^{\frac{1}{1+l/d}}
.. figure:: fittings/flush_mounted_beveled_entrance.png
:scale: 30 %
:alt: Beveled entrace mounted straight; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
l : float
Length of bevel measured parallel to the pipe length, [m]
angle : float
Angle of bevel with respect to the pipe length, [degrees]
method : str, optional
One of 'Rennels', or 'Idelchik', [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
A cheap way of getting a lower pressure drop.
Little credible data is available.
The table of data in [2]_ uses the angle for both bevels, so it runs from 0
to 180 degrees; this function follows the convention in [1]_ which uses
only one angle, with the angle varying from 0 to 90 degrees.
.. plot:: plots/entrance_beveled_plot.py
Examples
--------
>>> entrance_beveled(Di=0.1, l=0.003, angle=45)
0.450868642219
>>> entrance_beveled(Di=0.1, l=0.003, angle=45, method='Idelchik')
0.399500000000
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
'''
if method is None:
method = 'Rennels'
if method == 'Rennels':
Cb = (1-angle/90.)*(angle/90.)**(1./(1 + l/Di ))
lbd = 1 + 0.622*(1 - 1.5*Cb*(l/Di)**((1 - sqrt(sqrt(l/Di)))/2.))
return 0.0696*(1 - Cb*l/Di)*lbd**2 + (lbd - 1.)**2
elif method == 'Idelchik':
return float(bisplev(angle*2.0, l/Di, entrance_beveled_Idelchik_tck))
else:
raise ValueError(entrance_beveled_methods_unknown_msg)
def entrance_beveled_orifice(Di, do, l, angle):
r'''Returns loss coefficient for a beveled or chamfered orifice entrance to
a pipe flush with the wall of a reservoir, as shown in [1]_.
.. math::
K = 0.0696\left(1 - C_b\frac{l}{d_o}\right)\lambda^2 + \left(\lambda
-\left(\frac{d_o}{D_i}\right)^2\right)^2
.. math::
\lambda = 1 + 0.622\left[1-C_b\left(\frac{l}{d_o}\right)^{\frac{1-
(l/d_o)^{0.25}}{2}}\right]
.. math::
C_b = \left(1 - \frac{\Psi}{90}\right)\left(\frac{\Psi}{90}
\right)^{\frac{1}{1+l/d_o}}
.. figure:: fittings/flush_mounted_beveled_orifice_entrance.png
:scale: 30 %
:alt: Beveled orifice entrace mounted straight; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
do : float
Inside diameter of orifice, [m]
l : float
Length of bevel measured parallel to the pipe length, [m]
angle : float
Angle of bevel with respect to the pipe length, [degrees]
Returns
-------
K : float
Loss coefficient [-]
Examples
--------
>>> entrance_beveled_orifice(Di=0.1, do=.07, l=0.003, angle=45)
1.2987552913818574
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
Cb = (1-angle/90.)*(angle/90.)**(1./(1 + l/do ))
lbd = 1 + 0.622*(1 - Cb*(l/do)**((1 - sqrt(sqrt(l/do)))/2.))
return 0.0696*(1 - Cb*l/do)*lbd**2 + (lbd - (do/Di)**2)**2
### Exits
def exit_normal():
r'''Returns loss coefficient for any exit to a pipe
as shown in [1]_ and in other sources.
.. math::
K = 1
.. figure:: fittings/flush_mounted_exit.png
:scale: 28 %
:alt: Exit from a flush mounted wall; after [1]_
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
It has been found on occasion that K = 2.0 for laminar flow, and ranges
from about 1.04 to 1.10 for turbulent flow.
Examples
--------
>>> exit_normal()
1.0
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
return 1.0
### Bends
tck_bend_rounded_Miller = implementation_optimize_tck([[0.500967, 0.500967, 0.500967, 0.500967, 0.5572659504420276, 0.6220535279438968, 0.6876695918008857,
0.8109956990835443, 0.8966138996017785, 1.0418136796591293, 1.2129808986390955, 1.4328097893561944,
2.684491977649823, 3.496050493509287, 4.245254058334557, 10.0581, 10.0581, 10.0581, 10.0581],
[10.0022, 10.0022, 10.0022, 10.0022, 26.661576730080427, 35.71142422728946, 46.22896414495794, 54.476944091380965,
67.28681897720492, 79.96560467244989, 88.89484575805731, 104.37345376723293, 113.75217318286595, 121.36638011164008,
139.53481668808192, 180.502, 180.502, 180.502, 180.502],
[0.02844925354339322, 0.032368056788003474, 0.06341726367587057, 0.18372991235687228, 0.27828335685928296,
0.4184452895626468, 0.5844709012848479, 0.8517327028006999, 1.0883889837806633, 1.003595822015052, 1.2959349743905006,
1.3631701864169843, 3.2579960738248563, 8.188259745620396, 6.370167194425542, 0.026614405579949103, 0.03578575879432178,
0.05399131725104529, 0.17357295746658216, 0.2597698136964017, 0.384398460262134, 0.5537955210508835, 0.842964805734998,
1.1076060802420074, 1.0500502914944205, 1.2160489773171173, 1.2940140217639442, 2.5150913200614293, 5.987790923112488,
4.791049223949247, 0.026866783841898684, 0.03061409809632371, 0.054698306220358, 0.14037162784411245, 0.23981090432386729,
0.31617091309760137, 0.47435842573782666, 0.7484605121106159, 0.9223888516911868, 1.0345139221619066, 1.0709769967277933,
1.1489283659291687, 1.4249255928619116, 2.6908421883082823, 2.3898833324508804, 0.019707980719056793, 0.03350958504709355,
0.0457699204936841, 0.1180773988295937, 0.18163838540491214, 0.2955424583244998, 0.3178086095370295, 0.54907384767895,
0.7497276995283433, 0.8353766950608585, 0.8907203653185313, 0.941376749552297, 0.8755423259796333, 0.8987849646797164,
0.9905785504810203, 0.018632197087313764, 0.0275473376021632, 0.046686663726990756, 0.09334625398868963,
0.15009471210360348, 0.21438462374865175, 0.310541469358518, 0.27652184608845864, 0.4703245212932829,
0.5612926929410017, 0.6344189573543495, 0.6897616299237337, 0.8553230255854581, 0.8050040042565408,
0.7800498994134173, 0.017040716941189974, 0.027163747207842776, 0.04233976165781228, 0.08546809847236579,
0.11872359104267481, 0.1748602349243538, 0.248787221592314, 0.3166892465009758, 0.2894990945943436,
0.35635089905047324, 0.3942719381041552, 0.4019846022857163, 0.4910888827789205, 0.4424331343990761,
0.5367477778555589, 0.017232689797500957, 0.024595005629126976, 0.04235982677436609, 0.0748705682747817,
0.11096283696103083, 0.13900984487771062, 0.18773056195495877, 0.2400721832034611, 0.28581377924973544,
0.282839816159864, 0.2907117502580411, 0.3035848810896592, 0.31268019467513564, 0.3365050687225188, 0.2836774098946595,
0.017462451480157917, 0.02373981127475937, 0.04248526591300313, 0.07305722078054935, 0.09424065630357203,
0.13682400355164548, 0.15020534827616405, 0.2100221959547714, 0.23136495625582817, 0.24417894312621574,
0.2505645472554214, 0.24143469557592281, 0.24722191256497117, 0.2195110087547775, 0.29557609063213136,
0.017605444779345832, 0.026265210174737128, 0.0445497171166642, 0.07254637551095446, 0.08779690828578819,
0.11992614224260065, 0.14501268843599757, 0.17386066713179812, 0.21657094190224363, 0.21594544490951023, 0.22661999176624517,
0.23759356544596819, 0.23887614636323537, 0.25802515101229484, 0.20566480389514516, 0.01928450591486404, 0.03264367752872495,
0.05391006363370407, 0.07430728218140033, 0.08818045730326454, 0.09978389535000864, 0.12544634357734885, 0.13365159719049172,
0.15802979203343911, 0.17543365869590444, 0.17531453508236272, 0.1706085325985479, 0.15983319357859727, 0.16872558079206196,
0.19799750352823683, 0.020835891827102552, 0.047105767455498285, 0.05307639179638059, 0.07839236342751181, 0.09519829368423402,
0.10189528661430994, 0.12852821694010982, 0.13195311029179943, 0.1594822363328695, 0.15660304273110143, 0.15934161651984413,
0.17702957118830723, 0.1892675345030034, 0.19710951153945122, 0.1897835097361326, 0.031571285288316195, 0.04810266172763896,
0.05660304311192384, 0.09317293919692342, 0.08967028392412497, 0.12028974875677166, 0.1182836264474129, 0.13845925262729528,
0.15739100571169004, 0.17649056196464383, 0.20171423738165223, 0.20947832805305883, 0.22837004534830094, 0.23661874048689152,
0.24537433391842686, 0.042992073811512765, 0.045958026954244176, 0.08988351069774198, 0.08320361205549355, 0.1253881915447805,
0.12765039447605908, 0.1632907944306065, 0.17922551055575348, 0.20436939408609628, 0.23133806857897737, 0.22837190631962206,
0.2611718034649056, 0.30462224139228183, 0.3277471634644065, 0.3595577208662931, 0.042671097083349346, 0.06027193387363409,
0.07182684474072856, 0.12072547771177115, 0.1331787059163636, 0.16137414417679433, 0.1780034002291815, 0.19820571860540606,
0.2294059556234193, 0.23221403415772682, 0.2697708431035234, 0.2813760107306456, 0.28992333749905363, 0.3650401400682786,
0.8993207970132076, 0.045660964207664585, 0.06299599466264151, 0.09193684371316964, 0.12747145786167088, 0.14606550538249963,
0.172664884028299, 0.19152378303841075, 0.2212007207927944, 0.23752800077573005, 0.26289800433018995, 0.2772198641539113,
0.2995308585350757, 0.3549459028594012, 0.8032461437896778, 3.330618601208751],
3, 3])
bend_rounded_Miller_Kb = lambda rc_D, angle : float(bisplev(rc_D, angle, tck_bend_rounded_Miller))
tck_bend_rounded_Miller_C_Re = implementation_optimize_tck([[4.0, 4.0, 4.0, 4.0, 8.0, 8.0, 8.0, 8.0],
[1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0],
[2.177340320782947, 2.185952396281732, 2.185952396281732, 2.1775876405173977,
0.6513348082098823, 0.7944713057222101, 0.7944713057222103, 1.0526247737400114,
0.6030278030721317, 1.3741240162063968, 1.3741240162063992, 0.7693594604301893,
-2.1663631289607883, -1.9474318981548622, -1.9474318981548622, 0.4196741237602154],
3, 3])
bend_rounded_Miller_C_Re = lambda Re, rc_D : float(bisplev(log10(Re), rc_D, tck_bend_rounded_Miller_C_Re))
bend_rounded_Miller_C_Re_limit_1 = [2428087.757821312, -13637184.203693766, 28450331.830760233, -25496945.91463643, 8471761.477755375]
tck_bend_rounded_Miller_C_o_0_1 = implementation_optimize_tck([[9.975803953769495e-06, 9.975803953769495e-06, 9.975803953769495e-06,
9.975803953769495e-06, 0.5259485989276764, 1.3157845547408782, 3.220104449183945, 6.133677908951886,
30.260656153593906, 30.260656153593906, 30.260656153593906, 30.260656153593906],
[0.6179524338907976, 0.6000479624108129, 0.49299050530751654, 0.4820011733402483, 0.5584830305084972,
0.7496716557444135, 0.8977538553873484, 0.9987218804089956, 0.0, 0.0, 0.0, 0.0],
3])
tck_bend_rounded_Miller_C_o_0_15 = implementation_optimize_tck([[0.0025931401409935687, 0.0025931401409935687, 0.0025931401409935687,
0.0025931401409935687, 0.26429667728434275, 0.5188174292838083, 1.469212480387932, 4.269571348168375,
13.268280073552294, 26.28093462852014, 26.28093462852014, 26.28093462852014, 26.28093462852014],
[0.8691924906711972, 0.8355177386350426, 0.7617588987656675, 0.5853012015918869, 0.5978128647571033,
0.7366100253604377, 0.8229203841913866, 0.9484887080989913, 1.0003643259424702, 0.0, 0.0, 0.0, 0.0],
3])
tck_bend_rounded_Miller_C_o_0_2 = implementation_optimize_tck([[-0.001273275512351991, -0.001273275512351991, -0.001273275512351991, -
0.001273275512351991, 0.36379835796750504, 0.7789151587713531, 1.7319487323386349, 3.559883175039053,
22.10600230228466, 22.10600230228466, 22.10600230228466, 22.10600230228466],
[1.2055892891232, 1.1810797953131011, 0.8556056552110055, 0.6595884323229468, 0.6669634037761268,
0.8636791463334055, 0.8855712717206472, 0.9992625616471772, 0.0, 0.0, 0.0, 0.0],
3])
tck_bend_rounded_Miller_C_o_0_25 = implementation_optimize_tck([[0.0025931401409935687, 0.0025931401409935687, 0.0025931401409935687,
0.0025931401409935687, 0.2765978180291006, 0.5010875816968301, 0.6395222359284018, 0.661563946104784,
0.6887462820881093, 0.7312909084975013, 0.7605490601821624, 0.8078652661481783, 0.8553090397903271,
1.024376958429362, 1.4748577103270428, 2.052843716337269, 3.9670225184835175, 6.951737782758053,
16.770001745987884, 16.770001745987884, 16.770001745987884, 16.770001745987884],
[2.7181584441006414, 2.6722855229796196, 2.510271857479865, 2.162580617260359, 1.8234805515473758,
1.5274137403431902, 1.3876379087140025, 1.2712745614209848, 1.1478416325256429, 1.015542018903243,
0.8445749706812837, 0.7368799268423506, 0.7061205857035833, 0.7381928947255646, 0.7960778489514514,
0.878729192230999, 0.9281388590439098, 0.9825611959699471, 0.0, 0.0, 0.0, 0.0],
3])
tck_bend_rounded_Miller_C_o_1_0 = implementation_optimize_tck([[0.0025931401409935687, 0.0025931401409935687, 0.0025931401409935687,
0.0025931401409935687, 0.4940382602529053, 0.7383107558560895, 0.8929948619544391, 0.9910262538499016,
1.1035407055233972, 1.2685727302009009, 2.190931635360523, 3.718073594472333, 6.026458907878363,
13.268280073552294, 13.268280073552294, 13.268280073552294, 13.268280073552294],
[2.713127433391318, 2.6799201583608965, 2.4446034702691906, 2.0505313661892837, 1.7853408404592677,
1.5802763594858027, 1.395503315683405, 1.0504150726350026, 0.9294800209596744, 0.8937523212160566,
0.9339124388590752, 0.9769117997985829, 0.9948478073955791, 0.0, 0.0, 0.0, 0.0],
3])
tck_bend_rounded_Miller_C_os = (tck_bend_rounded_Miller_C_o_0_1, tck_bend_rounded_Miller_C_o_0_15,
tck_bend_rounded_Miller_C_o_0_2, tck_bend_rounded_Miller_C_o_0_25,
tck_bend_rounded_Miller_C_o_1_0)
bend_rounded_Miller_C_o_Kbs = [.1, .15, .2, .25, 1]
bend_rounded_Miller_C_o_limits = [30.260656153593906, 26.28093462852014, 22.10600230228466, 16.770001745987884, 13.268280073552294]
bend_rounded_Miller_C_o_limit_0_01 = [0.6169055099514943, 0.8663244713199465, 1.2029584898712695, 2.7143438886138744, 2.7115417734646114]
def Miller_bend_roughness_correction(Re, Di, roughness):
# Section 9.2.4 - Roughness correction
# Re limited to under 1E6 in friction factor falculations
# Use a cached smooth fd value if Re too high
Re_fd_min = min(1E6, Re)
if Re_fd_min < 1E6:
fd_smoth = friction_factor(Re=Re_fd_min, eD=0.0)
else:
fd_smoth = 0.011645040997991626
fd_rough = friction_factor(Re=Re_fd_min, eD=roughness/Di)
C_roughness = fd_rough/fd_smoth
return C_roughness
def Miller_bend_unimpeded_correction(Kb, Di, L_unimpeded):
"""Limitations as follows:
* Ratio not over 30
* If ratio under 0.01, tabulated values are used near the limits
(discontinuity in graph anyway)
* If ratio for a tried curve larger than max value, max value is used
instead of calculating it
* Kb limited to between 0.1 and 1.0
* When between two Kb curves, interpolate linearly after evaluating both
splines appropriately
"""
if Kb < 0.1:
Kb_C_o = 0.1
elif Kb > 1:
Kb_C_o = 1.0
else:
Kb_C_o = Kb
L_unimpeded_ratio = L_unimpeded/Di
if L_unimpeded_ratio > 30:
L_unimpeded_ratio = 30.0
for i in range(len(bend_rounded_Miller_C_o_Kbs)):
Kb_low, Kb_high = bend_rounded_Miller_C_o_Kbs[i], bend_rounded_Miller_C_o_Kbs[i+1]
if Kb_low <= Kb_C_o <= Kb_high:
if L_unimpeded_ratio >= bend_rounded_Miller_C_o_limits[i]:
Co_low = 1.0
elif L_unimpeded_ratio <= 0.01:
Co_low = bend_rounded_Miller_C_o_limit_0_01[i]
else:
Co_low = float(splev(L_unimpeded_ratio, tck_bend_rounded_Miller_C_os[i]))
if L_unimpeded_ratio >= bend_rounded_Miller_C_o_limits[i+1]:
Co_high = 1.0
elif L_unimpeded_ratio <= 0.01:
Co_high = bend_rounded_Miller_C_o_limit_0_01[i+1]
else:
Co_high = float(splev(L_unimpeded_ratio, tck_bend_rounded_Miller_C_os[i+1]))
C_o = Co_low + (Kb_C_o - Kb_low)*(Co_high - Co_low)/(Kb_high - Kb_low)
return C_o
def bend_rounded_Miller(Di, angle, Re, rc=None, bend_diameters=None,
roughness=0.0, L_unimpeded=None):
r'''Calculates the loss coefficient for a rounded pipe bend according to
Miller [1]_. This is a sophisticated model which uses corrections for
pipe roughness, the length of the pipe downstream before another
interruption, and a correction for Reynolds number. It interpolates several
times using several corrections graphs in [1]_.
Parameters
----------
Di : float
Inside diameter of pipe, [m]
angle : float
Angle of bend, [degrees]
Re : float
Reynolds number of the pipe (no specification if inlet or outlet
properties should be used), [m]
rc : float, optional
Radius of curvature of the entrance, [m]
bend_diameters : float, optional
Number of diameters of pipe making up the bend radius (used if rc not
provided; defaults to 5), [-]
roughness : float, optional
Roughness of bend wall, [m]
L_unimpeded : float, optional
The length of unimpeded pipe without any fittings, instrumentation,
or flow disturbances downstream (assumed 20 diameters if not
specified), [m]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
When inputting bend diameters, note that manufacturers often specify
this as a multiplier of nominal diameter, which is different than actual
diameter. Those require that rc be specified.
`rc` is limited to 0.5 or above; which represents a sharp, square, inner
edge - and an outer bend radius of 1.0. Losses are at a minimum when this
value is large.
This was developed for bend angles between 10 and 180 degrees; and r/D
ratios between 0.5 and 10. Both smooth and rough data was used in its
development from several sources.
Note the loss coefficient includes the surface friction of the pipe as if
it was straight.
Examples
--------
>>> bend_rounded_Miller(Di=.6, bend_diameters=2, angle=90, Re=2e6,
... roughness=2E-5, L_unimpeded=30*.6)
0.15261820705145895
References
----------
.. [1] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
'''
if rc is None:
if bend_diameters is None:
bend_diameters = 5.0
rc = Di*bend_diameters
radius_ratio = rc/Di
if L_unimpeded is None:
# Assumption - smooth outlet
L_unimpeded = 20.0*Di
# Graph is defined for angles 10 to 180 degrees, ratios 0.5 to 10
if radius_ratio < 0.5:
radius_ratio = 0.5
if radius_ratio > 10.0:
radius_ratio = 10.0
if angle < 10.0:
angle = 10.0
# Curve fit in terms of degrees
# Caching could work here - angle, radius ratio does not change often
Kb = bend_rounded_Miller_Kb(radius_ratio, angle)
C_roughness = Miller_bend_roughness_correction(Re=Re, Di=Di,
roughness=roughness)
"""Section 9.2.2 - Reynolds Number Correction
Allow some extrapolation up to 1E8 (1E7 max in graph but the trend looks good)
"""
Re_C_Re = min(max(Re, 1E4), 1E8)
if radius_ratio >= 2.0:
if Re_C_Re == 1E8:
C_Re = 0.4196741237602154 # bend_rounded_Miller_C_Re(1e8, 2.0)
elif Re_C_Re == 1E4:
C_Re = 2.1775876405173977 # bend_rounded_Miller_C_Re(1e4, 2.0)
else:
C_Re = bend_rounded_Miller_C_Re(Re_C_Re, 2.0)
elif radius_ratio <= 1.0:
# newton(lambda x: bend_rounded_Miller_C_Re(x, 1.0)-1, 2e5) to get the boundary value
C_Re_1 = bend_rounded_Miller_C_Re(Re_C_Re, 1.0) if Re_C_Re < 207956.58904584477 else 1.0
if radius_ratio > 0.7 or Kb < 0.4:
C_Re = C_Re_1
else:
C_Re = Kb/(Kb - 0.2*C_Re_1 + 0.2)
if C_Re > 2.2 or C_Re < 0:
C_Re = 2.2
else:
# regardless of ratio - 1
if Re_C_Re > 1048884.4656835075:
C_Re = 1.0
elif Re_C_Re > horner(bend_rounded_Miller_C_Re_limit_1, radius_ratio):
C_Re = 1.0
# ps = np.linspace(1, 2)
# qs = [secant(lambda x: bend_rounded_Miller_C_Re(x, i)-1, 2e5) for i in ps]
# np.polyfit(ps, qs, 4).tolist()
# Line of C_Re=1 as a function of r_d between 0 and 1
else:
C_Re = bend_rounded_Miller_C_Re(Re_C_Re, radius_ratio)
C_o = Miller_bend_unimpeded_correction(Kb=Kb, Di=Di, L_unimpeded=L_unimpeded)
# print('Kb=%g, C Re=%g, C rough =%g, Co=%g' %(Kb, C_Re, C_roughness, C_o))
return Kb*C_Re*C_roughness*C_o
bend_rounded_Crane_ratios = [1.0, 1.5, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 12.0,
14.0, 16.0, 20.0]
bend_rounded_Crane_fds = [20.0, 14.0, 12.0, 12.0, 14.0, 17.0, 24.0, 30.0, 34.0,
38.0, 42.0, 50.0]
bend_rounded_Crane_coeffs = [111.75011378177442, -331.89911345404107, -27.841951521656483,
1066.8916917931147, -857.8702190626232, -1151.4621655498092,
1775.2416673594603, 216.37911821941805, -1458.1661519377653,
447.169127650163, 515.361158769082, -322.58377486107577,
-38.38349416327068, 71.12796602489138, -16.198233745350535,
19.377150177339015, 31.107110520349494]
def bend_rounded_Crane(Di, angle, rc=None, bend_diameters=None):
r'''Calculates the loss coefficient for any rounded bend in a pipe
according to the Crane TP 410M [1]_ method. This method effectively uses
an interpolation from tabulated values in [1]_ for friction factor
multipliers vs. curvature radius.
.. figure:: fittings/bend_rounded.png
:scale: 30 %
:alt: rounded bend; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
angle : float
Angle of bend, [degrees]
rc : float, optional
Radius of curvature of the entrance; specify either `rc` or
`bend_diameters`, optional [m]
bend_diameters : float, optional
Number of diameters of pipe making up the bend radius; specify either
`rc` or `bend_diameters`, [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
The Crane method does match the trend of increased pressure drop as
roughness increases.
The points in [1]_ are extrapolated to other angles via a well-fitting
Chebyshev approximation, whose accuracy can be seen in the below plot.
.. plot:: plots/bend_rounded_Crane_plot.py
Examples
--------
>>> bend_rounded_Crane(Di=.4020, rc=.4*5, angle=30)
0.09321910015613409
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if (rc is not None and bend_diameters is not None): # numba: delete
if abs(Di*bend_diameters/rc - 1.0) > 1e-12: # numba: delete
raise ValueError("Cannot specify both `rc` and `bend_diameters`") # numba: delete
if rc is None:
if bend_diameters is None:
bend_diameters = 5.0
rc = Di*bend_diameters
fd = ft_Crane(Di)
radius_ratio = rc/Di
if radius_ratio < 1.0:
radius_ratio = 1.0
elif radius_ratio > 20.0:
radius_ratio = 20.0
factor = horner(bend_rounded_Crane_coeffs, 0.105263157894736836*(radius_ratio - 10.5))
K = fd*factor
K = (angle/90.0 - 1.0)*(0.25*pi*fd*radius_ratio + 0.5*K) + K
return K
_Ito_angles = [45.0, 90.0, 180.0]
def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None,
roughness=0.0):
"""Ito method as shown in Blevins.
Curved friction factor as given in Blevins, with minor tweaks to be more
accurate to the original methods.
"""
if not rc:
if bend_diameters is None:
bend_diameters = 5.0
rc = Di*bend_diameters
radius_ratio = rc/Di
angle_rad = radians(angle)
De2 = Re*(Di/rc)**2.0
if rc > 50.0*Di:
alpha = 1.0
else:
# Alpha is up to 6, as ratio gets higher, can go down to 1
alpha_45 = 1.0 + 5.13*(Di/rc)**1.47
alpha_90 = 0.95 + 4.42*(Di/rc)**1.96 if rc/Di < 9.85 else 1.0
alpha_180 = 1.0 + 5.06*(Di/rc)**4.52
alpha = interp(angle, _Ito_angles, [alpha_45, alpha_90, alpha_180])
if De2 <= 360.0:
fc = friction_factor_curved(Re=Re, Di=Di, Dc=2.0*rc,
roughness=roughness,
Rec_method='Srinivasan',
laminar_method='White',
turbulent_method='Srinivasan turbulent')
K = 0.0175*alpha*fc*angle*rc/Di
else:
K = 0.00431*alpha*angle*Re**-0.17*(rc/Di)**0.84
return K
crane_standard_bend_angles = [45.0, 90.0, 180.0]
crane_standard_bend_losses = [16.0, 30.0, 50.0]
bend_rounded_methods = ['Rennels', 'Crane', 'Crane standard', 'Miller', 'Swamee', 'Ito']
bend_rounded_method_unknown = f'Specified method not recognized; methods are {bend_rounded_methods}'
def bend_rounded(Di, angle, fd=None, rc=None, bend_diameters=None,
Re=None, roughness=0.0, L_unimpeded=None, method='Rennels'):
r'''Returns loss coefficient for rounded bend in a pipe of diameter `Di`,
`angle`, with a specified either radius of curvature `rc` or curvature
defined by `bend_diameters`, Reynolds number `Re` and optionally pipe
roughness, unimpeded length downstrean, and with the specified method.
This calculation has six methods available.
It is hard to describe one method as more conservative than another as
depending on the conditions, the relative results change significantly.
The 'Miller' method is the most complicated and slowest method; the 'Ito'
method comprehensive as well and a source of original data, and the primary
basis for the 'Rennels' method. The 'Swamee' method is very simple and
generally does not match the other methods. The 'Crane' method may match
or not match other methods depending on the inputs. There is also a
'Crane standard' method for use with threaded fittings which have higher
pressure drops. It is a linear interpolation of values at angles of
45, 90, and 180 degrees.
The Rennels [1]_ formula is:
.. math::
K = f\alpha\frac{r}{d} + (0.10 + 2.4f)\sin(\alpha/2)
+ \frac{6.6f(\sqrt{\sin(\alpha/2)}+\sin(\alpha/2))}
{(r/d)^{\frac{4\alpha}{\pi}}}
The Swamee [5]_ formula is:
.. math::
K = \left[0.0733 + 0.923 \left(\frac{d}{rc}\right)^{3.5} \right]
\theta^{0.5}
.. figure:: fittings/bend_rounded.png
:scale: 30 %
:alt: rounded bend; after [1]_
Parameters
----------
Di : float
Inside diameter of pipe, [m]
angle : float
Angle of bend, [degrees]
fd : float, optional
Darcy friction factor; used only in Rennels method; calculated if not
provided from Reynolds number, diameter, and roughness [-]
rc : float, optional
Radius of curvature of the entrance, optional [m]
bend_diameters : float, optional (used if rc not provided)
Number of diameters of pipe making up the bend radius [-]
Re : float, optional
Reynolds number of the pipe (used in Miller, Ito methods primarily, and
Rennels method if no friction factor given), [-]
roughness : float, optional
Roughness of bend wall (used in Miller, Ito methods primarily, and
Rennels method if no friction factor given), [m]
L_unimpeded : float, optional
The length of unimpeded pipe without any fittings, instrumentation,
or flow disturbances downstream (assumed 20 diameters if not
specified); used only in Miller method, [m]
method : str, optional
One of 'Rennels', 'Miller', 'Crane', 'Crane standard', 'Ito', or
'Swamee', [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
When inputting bend diameters, note that manufacturers often specify
this as a multiplier of nominal diameter, which is different than actual
diameter. Those require that rc be specified.
In the 'Rennels' method, `rc` is limited to 0.5 or above; which represents
a sharp, square, inner edge - and an outer bend radius of 1.0. Losses are
at a minimum when this value is large. Its first term represents surface
friction loss; the second, secondary flows; and the third, flow separation.
It encompasses the entire range of elbow and pipe bend configurations.
It was developed for bend angles between 0 and 180 degrees; and r/D
ratios above 0.5. Only smooth pipe data was used in its development.
Note the loss coefficient includes the surface friction of the pipe as if
it was straight.
Examples
--------
>>> bend_rounded(Di=4.020, rc=4.0*5, angle=30, Re=1E5)
0.11519070808085191
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [3] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [4] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply
Pipe Networks. John Wiley & Sons, 2008.
.. [5] Itō, H."Pressure Losses in Smooth Pipe Bends." Journal of Fluids
Engineering 82, no. 1 (March 1, 1960): 131-40. doi:10.1115/1.3662501
.. [6] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
'''
if method is None:
method = 'Rennels'
if bend_diameters is None and rc is None:
bend_diameters = 5.0
if rc is None:
rc = Di*bend_diameters
if method == 'Rennels':
angle = radians(angle)
if fd is None:
if Re is None:
raise ValueError("The `Rennels` method requires either a "
"specified friction factor or `Re`")
fd = Clamond(Re=Re, eD=roughness/Di, fast=False)
sin_term = sin(0.5*angle)
return (fd*angle*rc/Di + (0.10 + 2.4*fd)*sin_term
+ 6.6*fd*(sqrt(sin_term) + sin_term)/(rc/Di)**(4.*angle/pi))
elif method == 'Miller':
if Re is None:
raise ValueError('Miller method requires Reynolds number')
return bend_rounded_Miller(Di=Di, angle=angle, Re=Re, rc=rc,
bend_diameters=bend_diameters,
roughness=roughness,
L_unimpeded=L_unimpeded)
elif method == 'Crane':
return bend_rounded_Crane(Di=Di, angle=angle, rc=rc,
bend_diameters=bend_diameters)
elif method == 'Crane standard':
return ft_Crane(Di)*interp(angle, crane_standard_bend_angles, crane_standard_bend_losses, extrapolate=True)
elif method == 'Ito':
if Re is None:
raise ValueError("The `Iso` method requires`Re`")
return bend_rounded_Ito(Di=Di, angle=angle, Re=Re, rc=rc, bend_diameters=bend_diameters,
roughness=roughness)
elif method == 'Swamee':
return (0.0733 + 0.923*(Di/rc)**3.5)*sqrt(radians(angle))
else:
raise ValueError(bend_rounded_method_unknown)
bend_miter_Miller_coeffs = [-12.050299402650126, -4.472433689233185, 50.51478860493546, 18.246302079077196,
-84.61426660754049, -28.9340865412371, 71.07345367553872, 21.354010992349565,
-30.239604839338, -5.855129345095336, 5.465131779316523, -1.0881363712712555,
-0.3635431075401224, 0.5120065303391261, 0.46818214491579246, 0.9789177645343993,
0.5080285124448385]
def bend_miter_Miller(Di, angle, Re, roughness=0.0, L_unimpeded=None):
r'''Calculates the loss coefficient for a single miter bend according to
Miller [1]_. This is a sophisticated model which uses corrections for
pipe roughness, the length of the pipe downstream before another
interruption, and a correction for Reynolds number. It interpolates several
times using several corrections graphs in [1]_.
Parameters
----------
Di : float
Inside diameter of pipe, [m]
angle : float
Angle of miter bend, [degrees]
Re : float
Reynolds number of the pipe (no specification if inlet or outlet
properties should be used), [m]
roughness : float, optional
Roughness of bend wall, [m]
L_unimpeded : float, optional
The length of unimpeded pipe without any fittings, instrumentation,
or flow disturbances downstream (assumed 20 diameters if not
specified), [m]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Note the loss coefficient includes the surface friction of the pipe as if
it was straight.
Examples
--------
>>> bend_miter_Miller(Di=.6, angle=90, Re=2e6, roughness=2e-5,
... L_unimpeded=30*.6)
1.1921574594947664
References
----------
.. [1] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
'''
if L_unimpeded is None:
L_unimpeded = 20.0*Di
if angle > 120.0:
angle = 120.0
Kb = horner(bend_miter_Miller_coeffs, 1.0/60.0*(angle-60.0))
C_o = Miller_bend_unimpeded_correction(Kb=Kb, Di=Di, L_unimpeded=L_unimpeded)
C_roughness = Miller_bend_roughness_correction(Re=Re, Di=Di,
roughness=roughness)
Re_C_Re = min(max(Re, 1E4), 1E8)
C_Re_1 = bend_rounded_Miller_C_Re(Re_C_Re, 1.0) if Re_C_Re < 207956.58904584477 else 1.0
C_Re = Kb/(Kb - 0.2*C_Re_1 + 0.2)
if C_Re > 2.2 or C_Re < 0:
C_Re = 2.2
return Kb*C_Re*C_roughness*C_o
bend_miter_Crane_angles = [0.0, 15.0, 30.0, 45.0, 60.0, 75.0, 90.0]
bend_miter_Crane_fds = [2.0, 4.0, 8.0, 15.0, 25.0, 40.0, 60.0]
bend_miter_Blevins_angles = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 120.0]
bend_miter_Blevins_Ks = [0.0, .025, .055, .1, .2, .35, .5, .7, .9, 1.1, 1.5]
bend_miter_methods = ['Rennels', 'Miller', 'Crane', 'Blevins']
bend_miter_method_unknown_msg = f'Specified method not recognized; methods are {bend_miter_methods}'
def bend_miter(angle, Di=None, Re=None, roughness=0.0, L_unimpeded=None,
method='Rennels'):
r'''Returns loss coefficient for any single-joint miter bend in a pipe
of angle `angle`, diameter `Di`, Reynolds number `Re`, roughness
`roughness` unimpeded downstream length `L_unimpeded`, and using the
specified method. This calculation has four methods available.
The 'Rennels' method is based on a formula and extends to angles up to
150 degrees. The 'Crane' method extends only to 90 degrees; the 'Miller'
and 'Blevins' methods extend to 120 degrees.
The Rennels [1]_ formula is:
.. math::
K = 0.42\sin(\alpha/2) + 2.56\sin^3(\alpha/2)
The 'Crane', 'Miller', and 'Blevins' methods are all in part graph or
tabular based and do not have straightforward formulas.
.. figure:: fittings/bend_miter.png
:scale: 25 %
:alt: Miter bend, one joint only; after [1]_
Parameters
----------
angle : float
Angle of bend, [degrees]
Di : float, optional
Inside diameter of pipe, [m]
Re : float, optional
Reynolds number of the pipe (no specification if inlet or outlet
properties should be used), [-]
roughness : float, optional
Roughness of bend wall, [m]
L_unimpeded : float, optional
The length of unimpeded pipe without any fittings, instrumentation,
or flow disturbances downstream (assumed 20 diameters if not
specified), [m]
method : str, optional
The specified method to use; one of 'Rennels', 'Miller', 'Crane',
or 'Blevins', [-]
Returns
-------
K : float
Loss coefficient with respect to either upstream or downstream
diameter, [-]
Notes
-----
This method is designed only for single-jointed miter bends. It is common
for miter bends to have two or three sections, to further reduce the loss
coefficient. Some methods exist in [2]_ for taking this into account.
Because the additional configurations reduce the pressure loss, it is
"common practice" to simply ignore their effect and accept the slight
overdesign.
The following figure illustrates the different methods.
.. plot:: plots/bend_miter_plot.py
Examples
--------
>>> bend_miter(150)
2.7128147734758103
>>> bend_miter(Di=.6, angle=45, Re=1e6, roughness=1e-5, L_unimpeded=20,
... method='Miller')
0.2944060416245169
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [3] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [4] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
'''
if method is None:
method = 'Rennels'
if method == 'Rennels':
angle_rad = radians(angle)
sin_half_angle = sin(angle_rad*0.5)
return 0.42*sin_half_angle + 2.56*sin_half_angle*sin_half_angle*sin_half_angle
elif method == 'Crane':
factor = interp(angle, bend_miter_Crane_angles, bend_miter_Crane_fds)
return ft_Crane(Di)*factor
elif method == 'Miller':
return bend_miter_Miller(Di=Di, angle=angle, Re=Re, roughness=roughness, L_unimpeded=L_unimpeded)
elif method == 'Blevins':
# data from Idelchik, Miller, an earlier ASME publication
# For 90-120 degrees, a polynomial/spline would be better than a linear fit
K_base = interp(angle, bend_miter_Blevins_angles, bend_miter_Blevins_Ks)
return K_base*(2E5/Re)**0.2
else:
raise ValueError(bend_miter_method_unknown_msg)
def helix(Di, rs, pitch, N, fd):
r'''Returns loss coefficient for any size constant-pitch helix
as shown in [1]_. Has applications in immersed coils in tanks.
.. math::
K = N \left[f\frac{\sqrt{(2\pi r)^2 + p^2}}{d} + 0.20 + 4.8 f\right]
Parameters
----------
Di : float
Inside diameter of pipe, [m]
rs : float
Radius of spiral, [m]
pitch : float
Distance between two subsequent coil centers, [m]
N : float
Number of coils in the helix [-]
fd : float
Darcy friction factor [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Formulation based on peak secondary flow as in two 180 degree bends per
coil. Flow separation ignored. No f, Re, geometry limitations.
Source not compared against others.
Examples
--------
>>> helix(Di=0.01, rs=0.1, pitch=.03, N=10, fd=.0185)
14.525134924495514
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
return N*(fd*sqrt((2*pi*rs)**2 + pitch**2)/Di + 0.20 + 4.8*fd)
def spiral(Di, rmax, rmin, pitch, fd):
r'''Returns loss coefficient for any size constant-pitch spiral
as shown in [1]_. Has applications in immersed coils in tanks.
.. math::
K = \frac{r_{max} - r_{min}}{p} \left[ f\pi\left(\frac{r_{max}
+r_{min}}{d}\right) + 0.20 + 4.8f\right]
+ \frac{13.2f}{(r_{min}/d)^2}
Parameters
----------
Di : float
Inside diameter of pipe, [m]
rmax : float
Radius of spiral at extremity, [m]
rmin : float
Radius of spiral at end near center, [m]
pitch : float
Distance between two subsequent coil centers, [m]
fd : float
Darcy friction factor [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Source not compared against others.
Examples
--------
>>> spiral(Di=0.01, rmax=.1, rmin=.02, pitch=.01, fd=0.0185)
7.950918552775473
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
return (rmax-rmin)/pitch*(fd*pi*(rmax+rmin)/Di + 0.20 + 4.8*fd) + 13.2*fd/(rmin/Di)**2
### Contractions
tck_contraction_abrupt_Miller = implementation_optimize_tck([
[0.0, 0.0, 0.0, 0.0, 0.5553844358576507, 0.7193937784550933, 0.8144518359319883, 1.0, 1.0, 1.0, 1.0],
[0.0, 0.0, 0.0, 0.0, 0.008318525134414716, 0.03421785904690331, 0.1, 0.1, 0.1, 0.1],
[0.4994829280256306, 0.4879234090312588, 0.4255534701302917, 0.13986792857000196, 0.18065199312360336,
0.08701863105570044, 0.440886271558411, 0.4243716649409474, 0.36030826702480984, 0.2117960027770777,
0.11248601502220595, 0.08616608643911047, 0.4018850813314268, 0.3706136100344715, 0.26368725187530173,
0.15316562777200723, 0.09856904494833027, 0.08399367477431015, 0.17005190739488515, 0.16023910724406945,
0.1242906181281536, 0.06137573180850665, 0.05726821990215439, 0.04684229988854647, 0.03922553704852396,
0.036955938945600654, 0.029450340285188167, 0.028656302938315878, 0.019588760093397686, 0.01950497484044149,
0.006447273360860872, 0.006569278508667471, 0.0053786079483153885, -0.013158950566037957,
0.010870991979047888, 0.0015100946100218284, -0.0005221250682760256, -0.0006447517875307877,
-0.0007846123907797336, 0.0024459067063225485, -0.0019102888752274472, -0.0001356300464508266],
3, 3])
def contraction_round_Miller(Di1, Di2, rc):
r'''Returns loss coefficient for any round edged pipe contraction
using the method of Miller [1]_. This method uses a spline fit to a graph
with area ratios 0 to 1, and radius ratios (rc/Di2) from 0.1 to 0.
Parameters
----------
Di1 : float
Inside diameter of original pipe, [m]
Di2 : float
Inside diameter of following pipe, [m]
rc : float
Radius of curvature of the contraction, [m]
Returns
-------
K : float
Loss coefficient in terms of the following pipe, [-]
Notes
-----
This method normally gives lower losses than the Rennels formulation.
Examples
--------
>>> contraction_round_Miller(Di1=1, Di2=0.4, rc=0.04)
0.08565953051298639
References
----------
.. [1] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
'''
A_ratio = Di2*Di2/(Di1*Di1)
radius_ratio = rc/Di2
if radius_ratio > 0.1:
radius_ratio = 0.1
Ks = float(bisplev(A_ratio, radius_ratio, tck_contraction_abrupt_Miller))
# For some near-1 ratios, can get negative Ks due to the spline.
if Ks < 0.0:
Ks = 0.0
return Ks
contraction_sharp_methods = ['Rennels', 'Hooper', 'Crane']
contraction_sharp_method_unknown = f'Specified method not recognized; methods are {contraction_sharp_methods}'
def contraction_sharp(Di1, Di2, fd=None, Re=None, roughness=0.0,
method='Rennels'):
r'''Returns loss coefficient for a sharp edged pipe contraction.
This calculation has two methods available. The 'Rennels' [2]_ method is a
fit for turbulent regimes, while the `Hooper` method is more complicated
and claims to have full dependence on `Re` including a laminar transition
at `Re` of 2500 (based on the original pipe diameter).
The Rennels [1]_ formulas are:
.. math::
K_1 = 0.0696(1-\beta^5)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622(1-0.215\beta^2 - 0.785\beta^5)
.. math::
\beta = d_2/d_1
The Hooper [1]_ formulas are:
If :math:`{Re}_1 \le 2500`:
.. math::
K_1 = \left[1.2 + \frac{160}{\text{Re}_1}\right]
\left[ \left(\frac{D_1} {D_2} \right)^4 -1 \right]
If :math:`{Re}_1 > 2500`:
.. math::
K_1 = \left[0.6 + 0.48f_1\right] \left(\frac{D_1} {D_2} \right)^2
\left[ \left(\frac{D_1} {D_2} \right)^2 -1 \right]
Converting the loss coefficient to a consistent basis:
.. math::
K_2 = K_1\frac{D_2^4}{D_1^4}
For the Crane formula see `contraction_conical_Crane` with a length of zero.
.. figure:: fittings/contraction_sharp.png
:scale: 40 %
:alt: Sharp contraction
Parameters
----------
Di1 : float
Inside diameter of original (larger) pipe, [m]
Di2 : float
Inside diameter of following (smaller) pipe, [m]
fd : float, optional
Darcy friction factor in original pipe; used only in the Hooper method
and will be calculated from `Re` if not given, [-]
Re : float, optional
Reynolds number of the pipe (used in Hooper method, [m]
roughness : float, optional
Roughness of original pipe (used in Hooper method only if no friction
factor given), [m]
method : str
The calculation method to use; one of 'Hooper', 'Rennels', or 'Crane' [-]
Returns
-------
K : float
Loss coefficient in terms of the following pipe [-]
Notes
-----
A value of 0.506 or simply 0.5 is often used.
Examples
--------
>>> contraction_sharp(Di1=1, Di2=0.4)
0.5301269161
>>> contraction_sharp(Di1=1, Di2=0.4, Re=1e5, method='Hooper')
0.5112534765
The Hooper method supports laminar flow, while `Rennels` is not even `Re`
aware.
>>> contraction_sharp(Di1=1, Di2=0.4, Re=1e3, method='Hooper')
1.325184
Crane offers similar results:
>>> contraction_sharp(3.0, 2.0, method='Crane')
0.2777777
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Hooper, William B. "Calculate Head Loss Caused by Change in Pipe
Size." Chemical Engineering 95, no. 16 (November 7, 1988): 89.
'''
if method == 'Rennels':
beta = Di2/Di1
beta2 = beta*beta
beta5 = beta2*beta2*beta
lbd = 1.0 + 0.622*(1.0 - 0.215*beta2 - 0.785*beta5)
return 0.0696*(1.0 - beta5)*lbd*lbd + (lbd - 1.0)*(lbd - 1.0)
elif method == 'Hooper':
if Re is None:
raise ValueError("Hooper method requires `Re`")
D1_D2 = Di1/Di2
D1_D2_2 = D1_D2*D1_D2
if Re <= 2500.0:
K = (1.2 + 160.0/Re)*(D1_D2_2*D1_D2_2 - 1.0)
else:
if fd is None:
fd = Clamond(Re=Re, eD=roughness/Di1)
K = (0.6 + 0.48*fd)*D1_D2_2*(D1_D2_2 - 1.0)
K = change_K_basis(K, Di1, Di2)
return K
elif method == 'Crane':
return contraction_conical_Crane(Di1, Di2, l=0.0)
else:
raise ValueError(contraction_sharp_method_unknown)
contraction_round_Idelchik_ratios = [0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06,
0.08, 0.12, 0.16, 0.2]
contraction_round_Idelchik_factors = [0.5, 0.43, 0.37, 0.31, 0.26, 0.22, 0.20,
0.15, 0.09, 0.06, 0.03]
# Third factor is 0.36 in 1960 edition, 0.37 in Design Guide
contraction_round_methods = ['Rennels', 'Miller', 'Idelchik']
contraction_round_unknown_method = f'Specified method not recognized; methods are {contraction_round_methods}'
def contraction_round(Di1, Di2, rc, method='Rennels'):
r'''Returns loss coefficient for any any round edged pipe contraction.
This calculation has three methods available. The 'Miller' [2]_ method is a
bivariate spline digitization of a graph; the 'Idelchik' [3]_ method is an
interpolation using a formula and a table of values.
The most conservative formulation is that of Rennels; with fairly similar.
The 'Idelchik' method is more conservative and less complex; it offers a
straight-line curve where the others curves are curved.
The Rennels [1]_ formulas are:
.. math::
K = 0.0696\left(1 - 0.569\frac{r}{d_2}\right)\left(1-\sqrt{\frac{r}
{d_2}}\beta\right)(1-\beta^5)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622\left(1 - 0.30\sqrt{\frac{r}{d_2}}
- 0.70\frac{r}{d_2}\right)^4 (1-0.215\beta^2-0.785\beta^5)
.. math::
\beta = d_2/d_1
.. figure:: fittings/contraction_round.png
:scale: 30 %
:alt: Circular round contraction; after [1]_
Parameters
----------
Di1 : float
Inside diameter of original pipe, [m]
Di2 : float
Inside diameter of following pipe, [m]
rc : float
Radius of curvature of the contraction, [m]
method : str
The calculation method to use; one of 'Rennels', 'Miller', or
'Idelchik', [-]
Returns
-------
K : float
Loss coefficient in terms of the following pipe [-]
Notes
-----
Rounding radius larger than 0.14Di2 prevents flow separation from the wall.
Further increase in rounding radius continues to reduce loss coefficient.
.. plot:: plots/contraction_round_plot.py
Examples
--------
>>> contraction_round(Di1=1, Di2=0.4, rc=0.04)
0.1783332490866574
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [3] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
'''
beta = Di2/Di1
if method is None:
method = 'Rennels'
if method == 'Rennels':
lbd = 1.0 + 0.622*(1.0 - 0.30*sqrt(rc/Di2) - 0.70*rc/Di2)**4*(1.0 - 0.215*beta**2 - 0.785*beta**5)
return 0.0696*(1.0 - 0.569*rc/Di2)*(1.0 - sqrt(rc/Di2)*beta)*(1.0 - beta**5)*lbd*lbd + (lbd - 1.0)**2
elif method == 'Miller':
return contraction_round_Miller(Di1=Di1, Di2=Di2, rc=rc)
elif method == 'Idelchik':
# Di2, ratio defined in terms over diameter
K0 = interp(rc/Di2, contraction_round_Idelchik_ratios,
contraction_round_Idelchik_factors)
return K0*(1.0 - beta*beta)
else:
raise ValueError(contraction_round_unknown_method)
def contraction_conical_Crane(Di1, Di2, l=None, angle=None):
r'''Returns loss coefficient for a conical pipe contraction
as shown in Crane TP 410M [1]_ between 0 and 180 degrees.
If :math:`\theta < 45^{\circ}`:
.. math::
K_2 = {0.8 \sin \frac{\theta}{2}(1 - \beta^2)}
otherwise:
.. math::
K_2 = {0.5\sqrt{\sin \frac{\theta}{2}} (1 - \beta^2)}
.. math::
\beta = d_2/d_1
Parameters
----------
Di1 : float
Inside pipe diameter of the larger, upstream, pipe, [m]
Di2 : float
Inside pipe diameter of the smaller, downstream, pipe, [m]
l : float, optional
Length of the contraction [m]
angle : float, optional
Angle of contraction [degrees]
Returns
-------
K : float
Loss coefficient in terms of the following (smaller) pipe [-]
Notes
-----
Cheap and has substantial impact on pressure drop. Note that the
nomenclature in [1]_ is somewhat different - the smaller pipe is called 1,
and the larger pipe is called 2; and so the beta ratio is reversed, and the
fourth power of beta used in their equation is not necessary.
Examples
--------
>>> contraction_conical_Crane(Di1=0.0779, Di2=0.0525, l=0)
0.2729017979998056
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if l is not None:
if l == 0.0:
angle_rad = pi
else:
angle_rad = 2.0*atan((Di1-Di2)/(2.0*l))
elif angle is not None:
angle_rad = deg2rad*angle
#l = (Di1 - Di2)/(2.0*tan(0.5*angle)) # L is not needed in this calculation
else:
raise ValueError('One of `l` or `angle` must be specified')
beta = Di2/Di1
beta2 = beta*beta
if angle_rad < 0.25*pi:
# Formula 1
K2 = 0.8*sin(0.5*angle_rad)*(1.0 - beta2)
else:
# Formula 2
K2 = 0.5*(sqrt(sin(0.5*angle_rad))*(1.0 - beta2))
return K2
contraction_conical_angles_Idelchik = [2, 3, 6, 8, 10, 12, 14, 16, 20]
contraction_conical_A_ratios_Idelchik = [0.05, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6]
contraction_conical_friction_Idelchik = [
[0.14, 0.1, 0.05, 0.04, 0.03, 0.03, 0.02, 0.02, 0.01],
[0.14, 0.1, 0.05, 0.04, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.14, 0.1, 0.05, 0.04, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.14, 0.1, 0.05, 0.04, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.14, 0.1, 0.05, 0.03, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.14, 0.1, 0.05, 0.03, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.13, 0.09, 0.04, 0.03, 0.03, 0.02, 0.02, 0.02, 0.01],
[0.12, 0.08, 0.04, 0.03, 0.02, 0.02, 0.02, 0.02, 0.01],
[0.11, 0.07, 0.04, 0.03, 0.02, 0.02, 0.02, 0.02, 0.01],
[0.09, 0.06, 0.03, 0.02, 0.02, 0.02, 0.02, 0.02, 0.01]]
contraction_conical_frction_Idelchik_tck = tck_interp2d_linear(contraction_conical_angles_Idelchik,
contraction_conical_A_ratios_Idelchik,
contraction_conical_friction_Idelchik,
kx=1, ky=1)
contraction_conical_frction_Idelchik_obj = lambda x, y : float(bisplev(x, y, contraction_conical_frction_Idelchik_tck))
contraction_conical_l_ratios_Blevins = [0.0, 0.05, 0.1, 0.15, 0.6]
contraction_conical_A_ratios_Blevins = [1.2, 1.5, 2.0, 3.0, 5.0, 10.0]
contraction_conical_Ks_Blevins = [[.08, .06, .04, .03, .03],
[.17, .12, .09, .07, .06],
[.25, .23, .17, .14, .06],
[.33, .31, .27, .23, .08],
[.4, .38, .35, .31, .18],
[.45, .45, .41, .39, .27]]
contraction_conical_Blevins_tck = tck_interp2d_linear(contraction_conical_l_ratios_Blevins,
contraction_conical_A_ratios_Blevins,
contraction_conical_Ks_Blevins, kx=1, ky=1)
contraction_conical_Blevins_obj = lambda x, y: float(bisplev(x, y, contraction_conical_Blevins_tck))
contraction_conical_Miller_tck = implementation_optimize_tck([
[
-2.2990613088204293, -2.2990613088204293, -2.2990613088204293, -2.2990613088204293, -1.9345621970869704,
-1.404550366067981, -1.1205580332553446, -0.7202074014540876, -0.18305354619604816, 0.5791478950190209,
1.2576636025381396, 2.2907351590368092, 2.2907351590368092, 2.2907351590368092, 2.2907351590368092],
[
0.09564194294666524, 0.09564194294666524, 0.17553288711543455, 0.263895293813645, 0.3890819147022019,
0.46277323951998217, 0.5504296236707121, 0.7265657737596892, 1.0772357648098938, 1.2566022106161683,
1.3896885941879062, 1.3896885941879062],
[
-0.019518693251672135, 0.04439613867473242, 0.11549650174721836, 0.21325506677861075, 0.268179723158688,
0.31125301421509866, 0.38394595875289805, 0.4808287074532006, 0.5205981039085685, 0.5444079315893322,
-0.016435668699253902, 0.036132755789022385, 0.09344296094392814, 0.18264727448046977, 0.23460506265914166,
0.2772896726095435, 0.3475409775384636, 0.45339837219176454, 0.49766916609817535, 0.533981552804865,
-0.006524265764454468, 0.024107195694715193, 0.05862956870028131, 0.12122104285943507, 0.17207312024278762,
0.2175356288866053, 0.282297563080016, 0.3995008583081823, 0.4563724107887528, 0.5175856070810377,
0.00971345082784277, 0.025981390544674948, 0.0438578322196561, 0.08103403101086341, 0.11351528283253318,
0.16873088559958743, 0.2347695003589526, 0.3428907161435351, 0.42017998591926276, 0.49784770602295325,
0.022572122504756167, 0.0277671279384801, 0.033512283408629495, 0.05470423531298454, 0.06485563480390757,
0.10483763206962131, 0.1802208799223503, 0.29075723837012296, 0.35502824385155335, 0.4460106883062252,
0.030312717163327077, 0.03080869253188484, 0.03583128286874324, 0.04627567520803308, 0.050501484562613955,
0.05683263025468022, 0.12297253802915259, 0.2415222338797251, 0.3025777968736861, 0.3724407040165538,
0.03115993727503623, 0.03443665864698284, 0.03574452046031886, 0.03995718256281492, 0.04759698369059247,
0.050404788737262694, 0.052375330859925545, 0.1356057568743366, 0.20463667731329582, 0.26043914743762864,
0.02844193432840707, 0.0219797618956514, 0.013352154001094038, 0.018393840217638825, 0.02448602185526976,
0.038812331325140816, 0.0522197430071833, 0.057132169238281294, 0.06871138075102912, 0.09334527259294226,
0.04089985439478869, 0.07148502476706058, 0.06750266344761692, 0.038560772865945815, 0.020172054809734774,
0.01596047961326318, 0.033338955878272625, 0.058808731166289874, 0.055802602927507314, 0.025265841939291166,
0.11200365568168691, 0.11945663812857424, 0.10673570013847415, 0.07758458179796549, 0.055266607234870514,
0.03072901347153607, 0.025790727504652375, 0.037031664564632104, 0.0601306808668177, 0.07612350738135039,
0.0964900248905913, 0.11088549072803407, 0.10778442024110846, 0.09386482850507959, 0.06940476627270852,
0.04434507143623664, 0.03331958878624311, 0.01854072032522763, 0.027553821071285824, 0.045426686375783926],
3, 1])
contraction_conical_Miller_obj = lambda l_r2, A_ratio: max(min(float(bisplev(log(l_r2), log(A_ratio), contraction_conical_Miller_tck)), .5), 0)
contraction_conical_methods = ['Rennels', 'Idelchik', 'Crane', 'Swamee',
'Blevins', 'Miller', 'Hooper']
contraction_conical_method_unknown = f'Specified method not recognized; methods are {contraction_conical_methods}'
def contraction_conical(Di1, Di2, fd=None, l=None, angle=None,
Re=None, roughness=0.0, method='Rennels'):
r'''Returns the loss coefficient for any conical pipe contraction.
This calculation has five methods available. The 'Idelchik' [2]_ and
'Blevins' [3]_ methods use interpolation among tables of values; 'Miller'
uses a 2d spline representation of a graph; and the
'Rennels' [1]_, 'Crane' [4]_, 'Swamee' [5]_ and 'Hooper' methods use
formulas for their calculations.
The 'Rennels' [1]_ formulas are:
.. math::
K_2 = K_{fr,2} + K_{conv,2}
.. math::
K_{fr,2} = \frac{f_d ({1 - \beta^4})}{8\sin(\theta/2)}
.. math::
K_{conv,2} = 0.0696[1+C_B(\sin(\alpha/2)-1)](1-\beta^5)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622(\alpha/180)^{0.8}(1-0.215\beta^2-0.785\beta^5)
.. math::
\beta = d_2/d_1
The 'Swamee' [5]_ formula is:
.. math::
K = 0.315 \theta^{1/3}
The Hooper [7]_ formulas are:
If :math:`{Re}_1 \le 2500`:
.. math::
K_{1,sharp} = \left[1.2 + \frac{160}{\text{Re}_1}\right]
\left[ \left(\frac{D_1} {D_2} \right)^4 -1 \right]
If :math:`{Re}_1 > 2500`:
.. math::
K_{1,sharp} = \left[0.6 + 0.48f_1\right] \left(\frac{D_1} {D_2} \right)^2
\left[ \left(\frac{D_1} {D_2} \right)^2 -1 \right]
In both cases, a multiplier is added for the angle:
For angles between 45 and 180 degrees:
.. math::
K_1 = K_{1,sharp} \sqrt{\sin \frac{\theta}{2}}
For angles between 0 and 45 degrees:
.. math::
K_1 = K_{1,sharp} 1.6 \sin \frac{\theta}{2}
Converting the Hooper loss coefficient to a consistent basis:
.. math::
K_2 = K_1\frac{D_2^4}{D_1^4}
.. figure:: fittings/contraction_conical.png
:scale: 30 %
:alt: contraction conical; after [1]_
Parameters
----------
Di1 : float
Inside pipe diameter of the larger, upstream, pipe, [m]
Di2 : float
Inside pipe diameter of the smaller, downstream, pipe, [m]
fd : float, optional
Darcy friction factor; used only in the `Rennels` and `Hooper` method
and will be calculated from `Re` and `roughness` if not given, [-]
l : float, optional
Length of the contraction, optional [m]
angle : float, optional
Angle of contraction (180 = sharp, 0 = infinitely long contraction),
optional [degrees]
Re : float, optional
Reynolds number of the pipe (used in `Rennels` and `Hooper` method only
if no friction factor given), [m]
roughness : float, optional
Roughness of bend wall (used in Rennel method if no friction factor
given), [m]
method : str, optional
The method to use for the calculation; one of 'Rennels', 'Idelchik',
'Crane', 'Swamee' 'Hooper', 'Miller', or 'Blevins', [-]
Returns
-------
K : float
Loss coefficient in terms of the following pipe [-]
Notes
-----
Cheap and has substantial impact on pressure drop.
The 'Idelchik' method includes two tabular interpolations; its friction
term is limited to angles between 2 and 20 degrees and area ratios 0.05 to
0.6, while its main term is limited to length over diameter ratios 0.025 to
0.6. This seems to give it high results for angles < 25 degrees.
The 'Blevins' method is based on Idelchik data; it should not be used,
because its data jumps around and its data is limited to area ratios .1 to
0.83, and length over diameter ratios 0 to 0.6. The 'Miller' method jumps
around as well. Unlike most of Miller's method, there is no correction for
Reynolds number.
There is quite a bit of variance in the predictions of the methods, as
demonstrated by the following figure.
.. plot:: plots/contraction_conical_plot.py
Examples
--------
>>> contraction_conical(Di1=0.1, Di2=0.04, l=0.04, Re=1E6)
0.15639885880609544
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [3] Blevins, Robert D. Applied Fluid Dynamics Handbook. New York, N.Y.:
Van Nostrand Reinhold Co., 1984.
.. [4] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [5] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply
Pipe Networks. John Wiley & Sons, 2008.
.. [6] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [7] Hooper, William B. "Calculate Head Loss Caused by Change in Pipe
Size." Chemical Engineering 95, no. 16 (November 7, 1988): 89.
'''
beta = Di2/Di1
if angle is not None:
angle_rad = angle*deg2rad
l = (Di1 - Di2)/(2.0*tan(0.5*angle_rad))
elif l is not None:
if l != 0.0:
angle_rad = 2.0*atan((Di1-Di2)/(2.0*l))
else:
angle_rad = pi
else:
raise ValueError('Either l or angle is required')
if method == 'Rennels':
if fd is None:
if Re is None:
raise ValueError("The `Rennels` method requires either a "
"specified friction factor or `Re`")
fd = Clamond(Re=Re, eD=roughness/Di2, fast=False)
beta2 = beta*beta
beta4 = beta2*beta2
beta5 = beta4*beta
lbd = 1.0 + 0.622*(angle_rad/pi)**0.8*(1.0 - 0.215*beta2 - 0.785*beta5)
sin_half_angle = sin(0.5*angle_rad)
K_fr2 = fd*(1.0 - beta4)/(8.0*sin_half_angle)
K_conv2 = 0.0696*sin_half_angle*(1.0 - beta5)*lbd*lbd + (lbd - 1.0)**2
return K_fr2 + K_conv2
elif method == 'Crane':
return contraction_conical_Crane(Di1=Di1, Di2=Di2, l=l, angle=angle_rad*rad2deg)
elif method == 'Swamee':
return 0.315*angle_rad**(1.0/3.0)
elif method == 'Idelchik':
# Diagram 3-6; already digitized for beveled entrance
K0 = float(bisplev(angle_rad*rad2deg, l/Di2, entrance_beveled_Idelchik_tck))
# Angles 0 to 20, ratios 0.05 to 0.06
if angle_rad > 20.0*deg2rad:
angle_fric = 20.0
elif angle_rad < 2.0*deg2rad:
angle_fric = 2.0
else:
angle_fric = angle_rad*rad2deg
A_ratio = A_ratio_fric = Di2*Di2/(Di1*Di1)
if A_ratio_fric < 0.05:
A_ratio_fric = 0.05
elif A_ratio_fric > 0.6:
A_ratio_fric = 0.6
K_fr = float(contraction_conical_frction_Idelchik_obj(angle_fric, A_ratio_fric))
return K0*(1.0 - A_ratio) + K_fr
elif method == 'Blevins':
A_ratio = Di1*Di1/(Di2*Di2)
if A_ratio < 1.2:
A_ratio = 1.2
elif A_ratio > 10.0:
A_ratio = 10.0
l_ratio = l/Di2
if l_ratio > 0.6:
l_ratio = 0.6
return float(contraction_conical_Blevins_obj(l_ratio, A_ratio))
elif method == 'Miller':
A_ratio = Di1*Di1/(Di2*Di2)
if A_ratio > 4.0:
A_ratio = 4.0
elif A_ratio < 1.1:
A_ratio = 1.1
l_ratio = l/(Di2*0.5)
if l_ratio < 0.1:
l_ratio = 0.1
elif l_ratio > 10.0:
l_ratio = 10.0
# Turning on ofr off the limits - little difference in plot
return contraction_conical_Miller_obj(l_ratio, A_ratio)
elif method == 'Hooper':
if Re is None:
raise ValueError("Hooper method requires `Re`")
D1_D2 = Di1/Di2
D1_D2_2 = D1_D2*D1_D2
if Re <= 2500.0:
K = (1.2 + 160.0/Re)*(D1_D2_2*D1_D2_2 - 1.0)
else:
if fd is None:
fd = Clamond(Re=Re, eD=roughness/Di1)
K = (0.6 + 0.48*fd)*D1_D2_2*(D1_D2_2 - 1.0)
if angle_rad > 0.25*pi:
K *= sqrt(sin(0.5*angle_rad))
else:
K *= 1.6*sin(0.5*angle_rad)
K = change_K_basis(K, Di1, Di2)
return K
else:
raise ValueError(contraction_conical_method_unknown)
def contraction_beveled(Di1, Di2, l=None, angle=None):
r'''Returns loss coefficient for any sharp beveled pipe contraction
as shown in [1]_.
.. math::
K = 0.0696[1+C_B(\sin(\alpha/2)-1)](1-\beta^5)\lambda^2 + (\lambda-1)^2
.. math::
\lambda = 1 + 0.622\left[1+C_B\left(\left(\frac{\alpha}{180}
\right)^{0.8}-1\right)\right](1-0.215\beta^2-0.785\beta^5)
.. math::
C_B = \frac{l}{d_2}\frac{2\beta\tan(\alpha/2)}{1-\beta}
.. math::
\beta = d_2/d_1
.. figure:: fittings/contraction_beveled.png
:scale: 30 %
:alt: contraction beveled; after [1]_
Parameters
----------
Di1 : float
Inside diameter of original pipe, [m]
Di2 : float
Inside diameter of following pipe, [m]
l : float
Length of the bevel along the pipe axis ,[m]
angle : float
Angle of bevel, [degrees]
Returns
-------
K : float
Loss coefficient in terms of the following pipe [-]
Notes
-----
Examples
--------
>>> contraction_beveled(Di1=0.5, Di2=0.1, l=.7*.1, angle=120)
0.40946469413070485
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
angle = radians(angle)
beta = Di2/Di1
CB = l/Di2*2.0*beta*tan(0.5*angle)/(1.0 - beta)
beta2 = beta*beta
beta5 = beta2*beta2*beta
lbd = 1.0 + 0.622*(1.0 + CB*((angle/pi)**0.8 - 1.0))*(1.0 - 0.215*beta2 - 0.785*beta5)
return 0.0696*(1.0 + CB*(sin(0.5*angle) - 1.0))*(1.0 - beta5)*lbd*lbd + (lbd-1.0)**2
### Expansions (diffusers)
diffuser_sharp_methods = ['Rennels', 'Hooper']
diffuser_sharp_method_unknown = f'Specified method not recognized; methods are {diffuser_sharp_methods}'
def diffuser_sharp(Di1, Di2, Re=None, fd=None, roughness=0.0, method='Rennels'):
r'''Returns loss coefficient for any sudden pipe diameter expansion
according to the specified method.
The main theoretical formula is as follows, in [1]_ and in other sources
and is implemented under the name `Rennels`.
.. math::
K_2 = (1-\beta^2)^2
The Hooper [2]_ formulas are:
If :math:`{Re}_1 \le 4000`:
.. math::
K_1 = 2 \left[1 - \left( \frac{D_1}{D_2} \right)^4 \right]
else:
.. math::
K_1 = \left[1 + 0.8 f_{d,1}\right] \left\{
\left[1 - \left( \frac{D_1}{D_2}\right)^2
\right]^2 \right\}
Parameters
----------
Di1 : float
Inside diameter of original pipe (smaller), [m]
Di2 : float
Inside diameter of following pipe (larger), [m]
Re : float, optional
Reynolds number of the pipe for original (smaller) pipe, used in
`Hooper` method [-]
fd : float, optional
Darcy friction factor for original (smaller) pipe [-]
roughness : float, optional
Roughness of pipe wall (used in `Hooper` method if no friction factor
given), [m]
method : str
The method to use for the calculation; one of 'Rennels', 'Hooper' [-]
Returns
-------
K : float
Loss coefficient with respect to the original (smaller) pipe [-]
Notes
-----
Highly accurate.
Examples
--------
>>> diffuser_sharp(Di1=.5, Di2=1)
0.5625
>>> diffuser_sharp(Di1=.5, Di2=1, Re=1e5, fd=1e-7, method='Hooper')
0.562500045
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Hooper, William B. "Calculate Head Loss Caused by Change in Pipe
Size." Chemical Engineering 95, no. 16 (November 7, 1988): 89.
'''
beta = Di1/Di2
if method == 'Rennels':
r = 1.0 - beta*beta
return r*r
elif method == 'Hooper':
if Re is None:
raise ValueError("Method `Hooper` requires Reynolds number")
if Re < 4000.0:
return 2.0*(1.0 - beta*beta*beta*beta) # Not the same formula as Rennels
if fd is None:
fd = Clamond(Re=Re, eD=roughness/Di1)
x = 1.0 - beta*beta
return (1.0 + 0.8*fd)*x*x
else:
raise ValueError(diffuser_sharp_method_unknown)
def diffuser_conical_Crane(Di1, Di2, l=None, angle=None):
beta = Di1/Di2
beta2 = beta*beta
if angle is not None:
angle_rad = radians(angle)
angle_deg = angle
elif l is not None:
if l != 0.0:
angle_rad = 2.0*atan((Di1-Di2)/(2.0*l))
angle_deg = degrees(angle_rad)
else:
angle_rad = pi
angle_deg = 180.0
else:
raise ValueError('Either `l` or `angle` must be specified')
if angle_deg < 45.0:
# Formula 3
K2 = 2.6*sin(0.5*angle_rad)*(1.0 - beta2)**2/(beta2*beta2)
else:
K2 = (1.0 - beta2)**2/(beta2*beta2)
# formula 4
K1 = K2*beta2*beta2 # Standard has become using upstream diameter
return K1
tck_diffuser_conical_Miller = implementation_optimize_tck([
[
-2.307004845727645, -2.307004845727645, -2.307004845727645, -2.307004845727645, -0.852533937110498,
-0.08240363489988907, 0.5915927994712962, 0.8982804334259539, 1.2315822114127628, 1.5343291978351532,
1.9774792041044793, 2.990267368122924, 2.990267368122924, 2.990267368122924, 2.990267368122924
],
[
0.15265175024859737, 0.15265175024859737, 0.15265175024859737, 0.15265175024859737, 0.40701687154729443,
0.6664564516122377, 0.8948974705226967, 1.0144777142876453, 1.0931592421107108, 1.1789561829062467,
1.3141101898631344, 1.4016433190574298, 1.4016433190574298, 1.4016433190574298, 1.4016433190574298
],
[
0.06036297171599943, 0.08322477303304361, 0.1533018560180316, 0.23256231139725417, 0.3176212581983357,
0.40020914174974515, 0.4385944607898857, 0.5200344894492758, 0.6068491969006803, 0.5644812620968174,
0.5206931820307759, 0.05279258341151595, 0.06701886136626269, 0.15460022709300852, 0.22187392289400498,
0.3163189969211137, 0.40236602598664045, 0.44217477520553994, 0.5224439320660155, 0.5978399391103398,
0.6131809640282799, 0.6101286467987195, 0.05708355184742518, 0.06843627744908527, 0.08943713554460665,
0.2666074936578441, 0.3093579837678418, 0.3920305705167829, 0.44503141066730906, 0.5320996705995045,
0.5598015078960548, 0.9045290434928654, 1.1278543134986714, 0.004082132921064788, 0.08726673904790738,
0.05768023021275458, 0.2018006237954987, 0.31496483541908044, 0.3856708355645899, 0.4432173742517448,
0.5150555453757539, 0.5447727935474795, 0.8251456282600432, 0.996071097893787, -0.1110682037244921,
0.07314890991840513, 0.06176280023793122, 0.14210338139570033, 0.221133551530109, 0.34303500384378116,
0.40130996632027693, 0.49982098188910806, 0.5348917607889022, 0.6163719511180222, 0.6823385842053077,
-0.2166378057986125, 0.03883937343819872, 0.06286476564404532, 0.10772310640543344, 0.16931893225970837,
0.22920155110345403, 0.32189134044934775, 0.4091523406543155, 0.5122997879847003, 0.5557259511248352,
0.5834892444785406, -0.2784258718931251, 0.01614983641474248, 0.06657175843926792, 0.06987287339424499,
0.11347683852709868, 0.18271325237542604, 0.24381226992585622, 0.33699751608726225, 0.4328543409526461,
0.4932084120786604, 0.5172902462503076, -0.3110304748285624, -0.02554857636053585, 0.04945754727786904,
0.06935393005092971, 0.05644398696176074, 0.08533241552366327, 0.15458680076525846, 0.24566876577901098,
0.35324686175439035, 0.4095605186012888, 0.4277661722408436, -0.27286175236092153, -0.15488345611240545,
-0.09243246273089455, 0.03455782910023685, 0.0829563174865211, 0.05506682466210118, 0.07027248456489407,
0.13458355260751956, 0.21084209763905942, 0.2971705194724395, 0.3194829528180993, -0.08063077687005854,
-0.4253397307338264, -0.6215191566655465, -0.29467521770312016, 0.018448009119198257, 0.08412326971799582,
0.08337420030229001, 0.131275821589702, 0.1623166890922024, 0.21352111168837065, 0.2394011632386149,
0.14484414802505116, -0.781141319195365, -1.4412452429263252, -0.6266583715858592, 0.019328251090708078,
0.07939124881757918, 0.07570115443982374, 0.10818570632561267, 0.14931529315415798, 0.1845260859797597,
0.1975713897205575
], 3, 3
])
diffuser_conical_Idelchik_angles = [3, 6, 8, 10, 12, 14, 16, 20, 24, 30, 40, 60, 90, 180]
diffuser_conical_Idelchik_A_ratios = [0, 0.05, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6]
diffuser_conical_Idelchik_data = [
[0.03, 0.08, 0.11, 0.15, 0.19, 0.23, 0.27, 0.36, 0.47, 0.65, 0.92, 1.15, 1.1, 1.02],
[0.03, 0.07, 0.1, 0.14, 0.16, 0.2, 0.24, 0.32, 0.42, 0.58, 0.83, 1.04, 0.99, 0.92],
[0.03, 0.07, 0.09, 0.13, 0.16, 0.19, 0.23, 0.3, 0.4, 0.55, 0.79, 0.99, 0.95, 0.88],
[0.03, 0.07, 0.09, 0.12, 0.15, 0.18, 0.22, 0.29, 0.38, 0.52, 0.75, 0.93, 0.89, 0.83],
[0.02, 0.06, 0.08, 0.11, 0.14, 0.17, 0.2, 0.26, 0.34, 0.46, 0.67, 0.84, 0.79, 0.74],
[0.02, 0.05, 0.07, 0.1, 0.12, 0.15, 0.17, 0.23, 0.3, 0.41, 0.59, 0.74, 0.7, 0.65],
[0.02, 0.05, 0.06, 0.08, 0.1, 0.13, 0.15, 0.2, 0.26, 0.35, 0.47, 0.65, 0.62, 0.58],
[0.02, 0.04, 0.05, 0.07, 0.09, 0.11, 0.13, 0.18, 0.23, 0.31, 0.4, 0.57, 0.54, 0.5],
[0.01, 0.03, 0.04, 0.06, 0.07, 0.08, 0.1, 0.13, 0.17, 0.23, 0.33, 0.41, 0.39, 0.37],
[0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.09, 0.12, 0.16, 0.23, 0.29, 0.28, 0.26],
[0.01, 0.01, 0.02, 0.03, 0.03, 0.04, 0.05, 0.06, 0.08, 0.1, 0.15, 0.18, 0.17, 0.16]]
diffuser_conical_Idelchik_tck = implementation_optimize_tck([[0.0, 0.0, 0.0, 0.0, 0.075, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.6, 0.6, 0.6, 0.6],
[3.0, 3.0, 6.0, 8.0, 10.0, 12.0, 14.0, 16.0, 20.0, 24.0, 30.0, 40.0, 60.0, 90.0, 180.0, 180.0],
[0.03, 0.08000000000000002, 0.11, 0.15000000000000002, 0.19, 0.23000000000000004, 0.2700000000000001, 0.36000000000000004,
0.4700000000000001, 0.6500000000000001, 0.9200000000000003, 1.1499999999999997,
1.0999999999999999, 1.02, 0.031285899404876215, 0.06962481602354913, 0.12336980866449107,
0.1503712244832664, 0.14378748320215035, 0.20742060216292338, 0.24836000991873095,
0.35209826742177064, 0.43872500319959085, 0.6090878367568959, 0.8690773980930455,
1.0742803401164671, 1.0021612593588036, 0.9451655708069392, 0.028714100595123804,
0.06926407286533984, 0.08440796911328675, 0.1374065532945115, 0.17287918346451642,
0.19813495339263237, 0.23719554563682488, 0.301235065911563, 0.4134972190226316,
0.5698010521319933, 0.8164781574625106, 1.0379418821057562, 1.0011720739745302,
0.9192788736375066, 0.03171453253983491, 0.07116642136473203, 0.09282641155265463,
0.11549496597768823, 0.14338331093620021, 0.17489413621723082, 0.21614667989164066,
0.28946435656236014, 0.37330000426612064, 0.5104504490091938, 0.7371031974573926,
0.9040404534886205, 0.8645483458117367, 0.810220761075916, 0.01599798425801497,
0.0600112625583925, 0.07849171306072822, 0.11003185192295382, 0.14431407179880976,
0.1740127023740962, 0.20378359569975044, 0.2582633102962821, 0.33980922441927436,
0.45585837012862357, 0.6659720355794456, 0.8470955557688615, 0.7909107314263772,
0.7433823030652078, 0.021150220771741206, 0.04655749664043002, 0.0703397965060472,
0.10328500351954951, 0.11954655404108269, 0.1488787675177576, 0.1662463204709797,
0.231242192999296, 0.3007649420874127, 0.4151976547001982, 0.604782427849235,
0.7361883438919813, 0.6970812056056823, 0.6428823350611119, 0.019401132655020165,
0.053758750879887386, 0.06014910091508289, 0.07682813399884816, 0.09749971203685935,
0.13047222755487306, 0.1512311224163308, 0.19676791770653376, 0.2571310072310745,
0.3433510110705831, 0.45489825302361336, 0.6481510686632118, 0.6207644461508929,
0.5850883566903438, 0.02185995392589747, 0.033290416160064826, 0.045368699473134086,
0.06692723598046114, 0.08810622640302032, 0.10215235383204274, 0.1213618790128196,
0.17665887566391483, 0.2219043695740277, 0.3007473976664318, 0.37586666240054567,
0.5455594857191605, 0.5128931976706977, 0.4673228653399028, 1.2670378191600348e-05,
0.03091333375994541, 0.03916320044367654, 0.06214899426206778, 0.062121072502719726,
0.06871380729933241, 0.09367771591902911, 0.10605919242336995, 0.14532614492011708,
0.196826752842303, 0.32944561762761065, 0.340669205008426, 0.32703730722467556,
0.32918425374885374, 0.014993664810904203, 0.014543333120027308, 0.025418399778161738,
0.026425502868966118, 0.04393946374864015, 0.0556430963503338, 0.05566114204048549,
0.07947040378831506, 0.10483692753994148, 0.13908662357884857, 0.1752771911861948,
0.26216539749578693, 0.2564813463876624, 0.22290787312557322,
0.01, 0.01, 0.02, 0.03, 0.03, 0.04, 0.05, 0.06, 0.08, 0.1, 0.15, 0.18, 0.17, 0.16],
3, 1])
diffuser_conical_Idelchik_obj = lambda x, y : float(bisplev(x, y, diffuser_conical_Idelchik_tck))
diffuser_conical_methods = ['Rennels', 'Crane', 'Miller', 'Swamee', 'Idelchik', 'Hooper']
diffuser_conical_method_unknown = f'Specified method not recognized; methods are {diffuser_conical_methods}'
def diffuser_conical(Di1, Di2, l=None, angle=None, fd=None, Re=None,
roughness=0.0, method='Rennels'):
r'''Returns the loss coefficient for any conical pipe diffuser.
This calculation has six methods available.
The 'Rennels' [1]_ formulas are as follows (three different formulas are
used, depending on the angle and the ratio of diameters):
For 0 to 20 degrees, all aspect ratios:
.. math::
K_1 = 8.30[\tan(\alpha/2)]^{1.75}(1-\beta^2)^2 + \frac{f(1-\beta^4)}{8\sin(\alpha/2)}
For 20 to 60 degrees, beta < 0.5:
.. math::
K_1 = \left\{1.366\sin\left[\frac{2\pi(\alpha-15^\circ)}{180}\right]^{0.5}
- 0.170 - 3.28(0.0625-\beta^4)\sqrt{\frac{\alpha-20^\circ}{40^\circ}}\right\}
(1-\beta^2)^2 + \frac{f(1-\beta^4)}{8\sin(\alpha/2)}
For 20 to 60 degrees, beta >= 0.5:
.. math::
K_1 = \left\{1.366\sin\left[\frac{2\pi(\alpha-15^\circ)}{180}\right]^{0.5}
- 0.170 \right\}(1-\beta^2)^2 + \frac{f(1-\beta^4)}{8\sin(\alpha/2)}
For 60 to 180 degrees, beta < 0.5:
.. math::
K_1 = \left[1.205 - 3.28(0.0625-\beta^4)-12.8\beta^6\sqrt{\frac
{\alpha-60^\circ}{120^\circ}}\right](1-\beta^2)^2
For 60 to 180 degrees, beta >= 0.5:
.. math::
K_1 = \left[1.205 - 0.20\sqrt{\frac{\alpha-60^\circ}{120^\circ}}
\right](1-\beta^2)^2
The Swamee [5]_ formula is:
.. math::
K = \left\{\frac{0.25}{\theta^3}\left[1 + \frac{0.6}{r^{1.67}}
\left(\frac{\pi-\theta}{\theta} \right) \right]^{0.533r - 2.6}
\right\}^{-0.5}
The Hooper [6]_ formulas are:
If :math:`{Re}_1 \le 4000`:
.. math::
K_{sharp} = 2 \left[1 - \left( \frac{D_1}{D_2} \right)^4 \right]
else:
.. math::
K_{sharp} = \left[1 + 0.8 f_{d,1}\right] \left\{
\left[1 - \left( \frac{D_1}{D_2}\right)^2
\right]^2 \right\}
If the angle > 45 degrees, :math:`K = K_{sharp}` otherwise
.. math::
K = 2.6 \sin \left(\frac{\theta}{2} \right)K_{sharp}
.. figure:: fittings/diffuser_conical.png
:scale: 60 %
:alt: diffuser conical; after [1]_
Parameters
----------
Di1 : float
Inside diameter of original pipe (smaller), [m]
Di2 : float
Inside diameter of following pipe (larger), [m]
l : float, optional
Length of the contraction along the pipe axis, optional, [m]
angle : float, optional
Angle of contraction, [degrees]
fd : float, optional
Darcy friction factor [-]
Re : float, optional
Reynolds number of the pipe (used in Rennels method only if no friction
factor given), [m]
roughness : float, optional
Roughness of bend wall (used in Rennel method if no friction factor
given), [m]
method : str
The method to use for the calculation; one of 'Rennels', 'Crane',
'Miller', 'Swamee', 'Idelchik', or 'Hooper' [-]
Returns
-------
K : float
Loss coefficient with respect to smaller, upstream diameter [-]
Notes
-----
The Miller method changes around quite a bit.
There is quite a bit of variance in the predictions of the methods, as
demonstrated by the following figure.
.. plot:: plots/diffuser_conical_plot.py
Examples
--------
>>> diffuser_conical(Di1=1/3., Di2=1.0, angle=50.0, Re=1E6)
0.8027721093415322
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
.. [2] Idel`chik, I. E. Handbook of Hydraulic Resistance: Coefficients of
Local Resistance and of Friction (Spravochnik Po Gidravlicheskim
Soprotivleniyam, Koeffitsienty Mestnykh Soprotivlenii i Soprotivleniya
Treniya). National technical information Service, 1966.
.. [3] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [4] Swamee, Prabhata K., and Ashok K. Sharma. Design of Water Supply
Pipe Networks. John Wiley & Sons, 2008.
.. [5] Miller, Donald S. Internal Flow Systems: Design and Performance
Prediction. Gulf Publishing Company, 1990.
.. [6] Hooper, William B. "Calculate Head Loss Caused by Change in Pipe
Size." Chemical Engineering 95, no. 16 (November 7, 1988): 89.
'''
beta = Di1/Di2
beta2 = beta*beta
if l is not None:
angle_rad = 2.0*atan(0.5*(Di2-Di1)/l)
angle_deg = angle_rad*rad2deg
l_calc = l
elif angle is not None:
angle_rad = angle*deg2rad
angle_deg = angle
l_calc = (Di2 - Di1)/(2.0*tan(0.5*angle_rad))
else:
raise ValueError('Either `l` or `angle` must be specified')
if method is None:
method = 'Rennels'
if method == 'Rennels':
if fd is None:
if Re is None:
raise ValueError("The `Rennels` method requires either a "
"specified friction factor or `Re`")
fd = Clamond(Re=Re, eD=roughness/Di2, fast=False)
if 0.0 < angle_deg <= 20.0:
K = 8.30*tan(0.5*angle_rad)**1.75*(1.0 - beta2)**2 + 0.125*fd*(1.0 - beta2*beta2)/sin(0.5*angle_rad)
elif 20.0 < angle_deg <= 60.0 and 0.0 <= beta < 0.5:
K = (1.366*sqrt(sin(2.0*pi*(angle_deg - 15.0)/180.)) - 0.170
- 3.28*(0.0625-beta**4)*sqrt(0.025*(angle_deg-20.0)))*(1.0 - beta2)**2 + 0.125*fd*(1.0 - beta2*beta2)/sin(0.5*angle_rad)
elif 20.0 < angle_deg <= 60.0 and beta >= 0.5:
K = (1.366*sqrt(sin(2.0*pi*(angle_deg - 15.0)/180.0)) - 0.170)*(1.0 - beta2)**2 + 0.125*fd*(1.0 - beta2*beta2)/sin(0.5*angle_rad)
elif 60.0 < angle_deg <= 180.0 and 0.0 <= beta < 0.5:
beta4 = beta2*beta2
K = (1.205 - 3.28*(0.0625 - beta4) - 12.8*beta4*beta2*sqrt((angle_deg - 60.0)/120.))*(1.0 - beta2)**2
elif 60.0 < angle_deg <= 180.0 and beta >= 0.5:
K = (1.205 - 0.20*sqrt((angle_deg - 60.0)/120.))*(1.0 - beta**2)**2
else:
raise ValueError('Conical diffuser inputs incorrect')
return K
elif method == 'Crane':
return diffuser_conical_Crane(Di1=Di1, Di2=Di2, l=l_calc, angle=angle_deg)
elif method == 'Miller':
A_ratio = 1.0/beta2
if A_ratio > 4.0:
A_ratio = 4.0
elif A_ratio < 1.1:
A_ratio = 1.1
l_R1_ratio = l_calc/(0.5*Di1)
if l_R1_ratio < 0.1:
l_R1_ratio = 0.1
elif l_R1_ratio > 20.0:
l_R1_ratio = 20.0
Kd = max(float(bisplev(log(l_R1_ratio), log(A_ratio), tck_diffuser_conical_Miller)), 0)
return Kd
elif method == 'Idelchik':
A_ratio = beta2
# Angles 0 to 20, ratios 0.05 to 0.06
if angle_deg > 20.0:
angle_fric = 20.0
elif angle_deg < 2.0:
angle_fric = 2.0
else:
angle_fric = angle_deg
A_ratio_fric = A_ratio
if A_ratio_fric < 0.05:
A_ratio_fric = 0.05
elif A_ratio_fric > 0.6:
A_ratio_fric = 0.6
K_fr = float(contraction_conical_frction_Idelchik_obj(angle_fric, A_ratio_fric))
K_exp = float(diffuser_conical_Idelchik_obj(min(0.6, A_ratio), max(3.0, angle_deg)))
return K_fr + K_exp
elif method == 'Swamee':
# Really starting to thing Swamee uses a different definition of loss coefficient!
r = Di2/Di1
K = 1.0/sqrt(0.25*angle_rad**-3*(1.0 + 0.6*r**(-1.67)*(pi-angle_rad)/angle_rad)**(0.533*r - 2.6))
return K
elif method == 'Hooper':
if Re is None:
raise ValueError("Method `Hooper` requires Reynolds number")
if Re < 4000.0:
K_sharp = 2.0*(1.0 - beta*beta*beta*beta) # Not the same formula as Rennels
if angle_rad > 0.25*pi:
return K_sharp
return K_sharp*2.6*sin(0.5*angle_rad)
if fd is None:
fd = Clamond(Re=Re, eD=roughness/Di1)
x = 1.0 - beta*beta
K_sharp = (1.0 + 0.8*fd)*x*x
if angle_rad > 0.25*pi:
return K_sharp
return K_sharp*2.6*sin(0.5*angle_rad)
else:
raise ValueError(diffuser_conical_method_unknown)
def diffuser_conical_staged(Di1, Di2, DEs, ls, fd=None, method='Rennels'):
r'''Returns loss coefficient for any series of staged conical pipe expansions
as shown in [1]_. Five different formulas are used, depending on
the angle and the ratio of diameters. This function calls diffuser_conical.
Parameters
----------
Di1 : float
Inside diameter of original pipe (smaller), [m]
Di2 : float
Inside diameter of following pipe (larger), [m]
DEs : array
Diameters of intermediate sections, [m]
ls : array
Lengths of the various sections, size 1 more than `DEs`, [m]
fd : float
Darcy friction factor [-]
method : str
The method to use for the calculation; one of 'Rennels', 'Crane',
'Miller', 'Swamee', or 'Idelchik' [-]
Returns
-------
K : float
Loss coefficient with respect to smaller, upstream diameter [-]
Notes
-----
Only lengths of sections currently allowed. This could be changed
to understand angles also.
Formula doesn't make much sense, as observed by the example comparing
a series of conical sections. Use only for small numbers of segments of
highly differing angles.
Examples
--------
>>> diffuser_conical_staged(Di1=1., Di2=10., DEs=[2,3,4], ls=[1.1,1.2,1.3,1.4], fd=0.01)
1.9317533188274658
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
K = 0.0
K += diffuser_conical(Di1=Di1, Di2=DEs[0], l=ls[0], fd=fd, method=method)
K += diffuser_conical(Di1=DEs[-1], Di2=Di2, l=ls[-1], fd=fd, method=method)
for i in range(len(DEs)-1):
K += diffuser_conical(Di1=DEs[i], Di2=DEs[i+1], l=ls[i+1], fd=fd, method=method)
return K
def diffuser_curved(Di1, Di2, l):
r'''Returns loss coefficient for any curved wall pipe expansion
as shown in [1]_.
.. math::
K_1 = \phi(1.43-1.3\beta^2)(1-\beta^2)^2
.. math::
\phi = 1.01 - 0.624\frac{l}{d_1} + 0.30\left(\frac{l}{d_1}\right)^2
- 0.074\left(\frac{l}{d_1}\right)^3 + 0.0070\left(\frac{l}{d_1}\right)^4
.. figure:: fittings/curved_wall_diffuser.png
:scale: 25 %
:alt: diffuser curved; after [1]_
Parameters
----------
Di1 : float
Inside diameter of original pipe (smaller), [m]
Di2 : float
Inside diameter of following pipe (larger), [m]
l : float
Length of the curve along the pipe axis, [m]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Beta^2 should be between 0.1 and 0.9.
A small mismatch between tabulated values of this function in table 11.3
is observed with the equation presented.
Examples
--------
>>> diffuser_curved(Di1=.25**0.5, Di2=1., l=2.)
0.2299781250000002
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
beta = Di1/Di2
phi = 1.01 - 0.624*l/Di1 + 0.30*(l/Di1)**2 - 0.074*(l/Di1)**3 + 0.0070*(l/Di1)**4
return phi*(1.43 - 1.3*beta**2)*(1 - beta**2)**2
def diffuser_pipe_reducer(Di1, Di2, l, fd1, fd2=None):
r'''Returns loss coefficient for any pipe reducer pipe expansion
as shown in [1]. This is an approximate formula.
.. math::
K_f = f_1\frac{0.20l}{d_1} + \frac{f_1(1-\beta)}{8\sin(\alpha/2)}
+ f_2\frac{0.20l}{d_2}\beta^4
.. math::
\alpha = 2\tan^{-1}\left(\frac{d_1-d_2}{1.20l}\right)
Parameters
----------
Di1 : float
Inside diameter of original pipe (smaller), [m]
Di2 : float
Inside diameter of following pipe (larger), [m]
l : float
Length of the pipe reducer along the pipe axis, [m]
fd1 : float
Darcy friction factor at inlet diameter [-]
fd2 : float
Darcy friction factor at outlet diameter, optional [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Industry lack of standardization prevents better formulas from being
developed. Add 15% if the reducer is eccentric.
Friction factor at outlet will be assumed the same as at inlet if not specified.
Doubt about the validity of this equation is raised.
Examples
--------
>>> diffuser_pipe_reducer(Di1=.5, Di2=.75, l=1.5, fd1=0.07)
0.06873244301714816
References
----------
.. [1] Rennels, Donald C., and Hobart M. Hudson. Pipe Flow: A Practical
and Comprehensive Guide. 1st edition. Hoboken, N.J: Wiley, 2012.
'''
if fd2 is None:
fd2 = fd1
beta = Di1/Di2
angle = -2*atan((Di1-Di2)/1.20/l)
K = fd1*0.20*l/Di1 + fd1*(1-beta)/8./sin(angle/2) + fd2*0.20*l/Di2*beta**4
return K
### TODO: Tees
DARBY_ANGLE_45DEG_FULL_VALVE = 'Valve, Angle valve, 45°, full line size, β = 1'
DARBY_ANGLE_90DEG_FULL_VALVE = 'Valve, Angle valve, 90°, full line size, β = 1'
DARBY_GLOBE_FULL_VALVE = 'Valve, Globe valve, standard, β = 1'
DARBY_PLUG_VALVE_BRANCH_FLOW = 'Valve, Plug valve, branch flow'
DARBY_PLUG_VALVE_STRAIGHT_THROUGH = 'Valve, Plug valve, straight through'
DARBY_PLUG_VALVE_THREE_WAY_FLOW_THROUGH = 'Valve, Plug valve, three-way (flow through)'
DARBY_GATE_VALVE = 'Valve, Gate valve, standard, β = 1'
DARBY_BALL_VALVE = 'Valve, Ball valve, standard, β = 1'
DARBY_DIAPHRAGM_DAM_VALVE = 'Valve, Diaphragm, dam type'
DARBY_SWING_CHECK_VALVE = 'Valve, Swing check'
DARBY_LIFT_CHECK_VALVE = 'Valve, Lift check'
DARBY_VALVES = [DARBY_ANGLE_45DEG_FULL_VALVE, DARBY_ANGLE_90DEG_FULL_VALVE,
DARBY_GLOBE_FULL_VALVE, DARBY_PLUG_VALVE_BRANCH_FLOW,
DARBY_PLUG_VALVE_STRAIGHT_THROUGH, DARBY_PLUG_VALVE_THREE_WAY_FLOW_THROUGH,
DARBY_GATE_VALVE, DARBY_BALL_VALVE, DARBY_DIAPHRAGM_DAM_VALVE,
DARBY_SWING_CHECK_VALVE, DARBY_LIFT_CHECK_VALVE]
### 3 Darby 3K Method (with valves)
Darby = {}
"""Dictionary of coefficients for Darby's 3K fitting pressure drop method;
the tuple contains :math:`K_1` and :math:`K_i` and :math:`K_d` in that order.
"""
Darby['Elbow, 90°, threaded, standard, (r/D = 1)'] = (800.0, 0.14, 4.0)
Darby['Elbow, 90°, threaded, long radius, (r/D = 1.5)'] = (800.0, 0.071, 4.2)
Darby['Elbow, 90°, flanged, welded, bends, (r/D = 1)'] = (800.0, 0.091, 4.0)
Darby['Elbow, 90°, (r/D = 2)'] = (800.0, 0.056, 3.9)
Darby['Elbow, 90°, (r/D = 4)'] = (800.0, 0.066, 3.9)
Darby['Elbow, 90°, (r/D = 6)'] = (800.0, 0.075, 4.2)
Darby['Elbow, 90°, mitered, 1 weld, (90°)'] = (1000.00, 0.27, 4.0)
Darby['Elbow, 90°, 2 welds, (45°)'] = (800.0, 0.068, 4.1)
Darby['Elbow, 90°, 3 welds, (30°)'] = (800.0, 0.035, 4.2)
Darby['Elbow, 45°, threaded standard, (r/D = 1)'] = (500.0, 0.071, 4.2)
Darby['Elbow, 45°, long radius, (r/D = 1.5)'] = (500.0, 0.052, 4.0)
Darby['Elbow, 45°, mitered, 1 weld, (45°)'] = (500.0, 0.086, 4.0)
Darby['Elbow, 45°, mitered, 2 welds, (22.5°)'] = (500.0, 0.052, 4.0)
Darby['Elbow, 180°, threaded, close-return bend, (r/D = 1)'] = (1000.00, 0.23, 4.0)
Darby['Elbow, 180°, flanged, (r/D = 1)'] = (1000.00, 0.12, 4.0)
Darby['Elbow, 180°, all, (r/D = 1.5)'] = (1000.00, 0.1, 4.0)
Darby['Tee, Through-branch, (as elbow), threaded, (r/D = 1)'] = (500.0, 0.274, 4.0)
Darby['Tee, Through-branch,(as elbow), (r/D = 1.5)'] = (800.0, 0.14, 4.0)
Darby['Tee, Through-branch, (as elbow), flanged, (r/D = 1)'] = (800.0, 0.28, 4.0)
Darby['Tee, Through-branch, (as elbow), stub-in branch'] = (1000.00, 0.34, 4.0)
Darby['Tee, Run-through, threaded, (r/D = 1)'] = (200.0, 0.091, 4.0)
Darby['Tee, Run-through, flanged, (r/D = 1)'] = (150.0, 0.05, 4.0)
Darby['Tee, Run-through, stub-in branch'] = (100.0, 0.0, 0.0)
Darby[DARBY_ANGLE_45DEG_FULL_VALVE] = (950.0, 0.25, 4.0)
Darby[DARBY_ANGLE_90DEG_FULL_VALVE] = (1000.0, 0.69, 4.0)
Darby[DARBY_GLOBE_FULL_VALVE] = (1500.0, 1.7, 3.6)
Darby[DARBY_PLUG_VALVE_BRANCH_FLOW] = (500.0, 0.41, 4.0)
Darby[DARBY_PLUG_VALVE_STRAIGHT_THROUGH] = (300.0, 0.084, 3.9)
Darby[DARBY_PLUG_VALVE_THREE_WAY_FLOW_THROUGH] = (300.0, 0.14, 4.0)
Darby[DARBY_GATE_VALVE] = (300.0, 0.037, 3.9)
Darby[DARBY_BALL_VALVE] = (300.0, 0.017, 3.5)
Darby[DARBY_DIAPHRAGM_DAM_VALVE] = (1000.00, 0.69, 4.9)
Darby[DARBY_SWING_CHECK_VALVE] = (1500.0, 0.46, 4.0)
Darby[DARBY_LIFT_CHECK_VALVE] = (2000.00, 2.85, 3.8)
try:
if IS_NUMBA: # type: ignore # noqa: F821
Darby_keys = tuple(Darby.keys())
Darby_values = tuple(Darby.values())
except:
pass
def Darby3K(NPS=None, Re=None, name=None, K1=None, Ki=None, Kd=None, Di=None):
r'''Returns loss coefficient for any various fittings, depending
on the name input. Alternatively, the Darby constants K1, Ki and Kd
may be provided and used instead. Source of data is [1]_.
Reviews of this model are favorable.
.. math::
K_f = \frac{K_1}{Re} + K_i\left(1 + \frac{K_d}{D_{\text{NPS}}^{0.3}}
\right)
Note this model uses nominal pipe diameter in inches.
Parameters
----------
NPS : float
Nominal diameter of the pipe, [in]
Re : float
Reynolds number, [-]
name : str
String from Darby dict representing a fitting
K1 : float
K1 parameter of Darby model, optional [-]
Ki : float
Ki parameter of Darby model, optional [-]
Kd : float
Kd parameter of Darby model, optional [in]
Di : float
If specified, the NPS will be found by interpolating linearly (with
extrapolation) along the schedule 40 diameters and NPSs;
this will supersede NPS if it is specified, [m]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Also described in Albright's Handbook and Ludwig's Applied Process Design.
Relatively uncommon to see it used.
The possibility of combining these methods with those above are attractive.
Examples
--------
>>> Darby3K(NPS=2., Re=10000., name='Valve, Angle valve, 45°, full line size, β = 1')
1.1572523963562356
>>> Darby3K(Di=.05248, Re=10000., name='Valve, Angle valve, 45°, full line size, β = 1')
1.1572523963562356
>>> Darby3K(NPS=12., Re=10000., K1=950, Ki=0.25, Kd=4)
0.819510280626355
References
----------
.. [1] Silverberg, Peter, and Ron Darby. "Correlate Pressure Drops through
Fittings: Three Constants Accurately Calculate Flow through Elbows,
Valves and Tees." Chemical Engineering 106, no. 7 (July 1999): 101.
.. [2] Silverberg, Peter. "Correlate Pressure Drops Through Fittings."
Chemical Engineering 108, no. 4 (April 2001): 127,129-130.
'''
if Di is not None:
NPS = interp(Di*1000.0, S40i, NPS40, extrapolate=True)
if name is not None:
K1 = None
if name in Darby: # NUMBA: DELETE
K1, Ki, Kd = Darby[name] # NUMBA: DELETE
if K1 is None:
try:
K1, Ki, Kd = Darby_values[Darby_keys.index(name)]
except:
raise ValueError('Name of fitting is not in database')
elif K1 is not None and Ki is not None and Kd is not None:
pass
else:
raise ValueError('Name of fitting or constants are required')
return K1/Re + Ki*(1. + Kd*NPS**-0.3)
### 2K Hooper Method
HOOPER_CHECK_VALVE_TILTING_DISK = 'Valve, Check, Tilting-disc'
HOOPER_CHECK_VALVE_SWING = 'Valve, Check, Swing'
HOOPER_CHECK_VALVE_LIFT = 'Valve, Check, Lift'
HOOPER_BUTTERFLY_VALVE = 'Valve, Butterfly,'
HOOPER_DIAPHRAGM_DAM_VALVE = 'Valve, Diaphragm, Dam type'
HOOPER_GLOBE_ANGLED_OR_Y_VALVE = 'Valve, Globe, Angle or Y-type'
HOOPER_GLOBE_STANDARD_VALVE = 'Valve, Globe, Standard'
HOOPER_PLUG_REDUCED_TRIM_VALVE = 'Valve, Plug, Reduced trim, Beta = 0.8'
HOOPER_BALL_REDUCED_TRIM_VALVE = 'Valve, Ball, Reduced trim, Beta = 0.9'
HOOPER_GATE_FULL_LINE_SIZE_VALVE = 'Valve, Gate, Full line size, Beta = 1'
HOOPER_VALVES = [HOOPER_CHECK_VALVE_TILTING_DISK, HOOPER_CHECK_VALVE_SWING,
HOOPER_CHECK_VALVE_LIFT, HOOPER_BUTTERFLY_VALVE,
HOOPER_DIAPHRAGM_DAM_VALVE, HOOPER_GLOBE_ANGLED_OR_Y_VALVE,
HOOPER_GLOBE_STANDARD_VALVE, HOOPER_PLUG_REDUCED_TRIM_VALVE,
HOOPER_BALL_REDUCED_TRIM_VALVE, HOOPER_GATE_FULL_LINE_SIZE_VALVE]
Hooper = {}
r"""Dictionary of coefficients for Hooper's 2K fitting pressure drop method;
the tuple contains :math:`K_1` and :math:`K_\infty` in that order.
"""
Hooper['Elbow, 90°, Standard (R/D = 1), Screwed'] = (800.0, 0.4)
Hooper['Elbow, 90°, Standard (R/D = 1), Flanged/welded'] = (800.0, 0.25)
Hooper['Elbow, 90°, Long-radius (R/D = 1.5), All types'] = (800.0, 0.2)
Hooper['Elbow, 90°, Mitered (R/D = 1.5), 1 weld (90° angle)'] = (1000.0, 1.15)
Hooper['Elbow, 90°, Mitered (R/D = 1.5), 2 weld (45° angle)'] = (800.0, 0.35)
Hooper['Elbow, 90°, Mitered (R/D = 1.5), 3 weld (30° angle)'] = (800.0, 0.3)
Hooper['Elbow, 90°, Mitered (R/D = 1.5), 4 weld (22.5° angle)'] = (800.0, 0.27)
Hooper['Elbow, 90°, Mitered (R/D = 1.5), 5 weld (18° angle)'] = (800.0, 0.25)
Hooper['Elbow, 45°, Standard (R/D = 1), All types'] = (500.0, 0.2)
Hooper['Elbow, 45°, Long-radius (R/D 1.5), All types'] = (500.0, 0.15)
Hooper['Elbow, 45°, Mitered (R/D=1.5), 1 weld (45° angle)'] = (500.0, 0.25)
Hooper['Elbow, 45°, Mitered (R/D=1.5), 2 weld (22.5° angle)'] = (500.0, 0.15)
Hooper['Elbow, 45°, Standard (R/D = 1), Screwed'] = (1000.0, 0.7)
Hooper['Elbow, 180°, Standard (R/D = 1), Flanged/welded'] = (1000.0, 0.35)
Hooper['Elbow, 180°, Long-radius (R/D = 1.5), All types'] = (1000.0, 0.3)
Hooper['Elbow, Used as, Standard, Screwed'] = (500.0, 0.7)
Hooper['Elbow, Elbow, Long-radius, Screwed'] = (800.0, 0.4)
Hooper['Elbow, Elbow, Standard, Flanged/welded'] = (800.0, 0.8)
Hooper['Elbow, Elbow, Stub-in type branch'] = (1000.0, 1.0)
Hooper['Tee, Run, Screwed'] = (200.0, 0.1)
Hooper['Tee, Through, Flanged or welded'] = (150.0, 0.05)
Hooper['Tee, Tee, Stub-in type branch'] = (100.0, 0.0)
Hooper[HOOPER_GATE_FULL_LINE_SIZE_VALVE] = (300.0, 0.1)
Hooper[HOOPER_BALL_REDUCED_TRIM_VALVE] = (500.0, 0.15)
Hooper[HOOPER_PLUG_REDUCED_TRIM_VALVE] = (1000.0, 0.25)
Hooper[HOOPER_GLOBE_STANDARD_VALVE] = (1500.0, 4.0)
Hooper[HOOPER_GLOBE_ANGLED_OR_Y_VALVE] = (1000.0, 2.0)
Hooper[HOOPER_DIAPHRAGM_DAM_VALVE] = (1000.0, 2.0)
Hooper[HOOPER_BUTTERFLY_VALVE] = (800.0, 0.25)
Hooper[HOOPER_CHECK_VALVE_LIFT] = (2000.0, 10.0)
Hooper[HOOPER_CHECK_VALVE_SWING] = (1500.0, 1.5)
Hooper[HOOPER_CHECK_VALVE_TILTING_DISK] = (1000.0, 0.5)
try:
if IS_NUMBA: # type: ignore # noqa: F821
Hooper_keys = tuple(Hooper.keys())
Hooper_values = tuple(Hooper.values())
except:
pass
def Hooper2K(Di, Re, name=None, K1=None, Kinfty=None):
r'''Returns loss coefficient for any various fittings, depending
on the name input. Alternatively, the Hooper constants K1, Kinfty
may be provided and used instead. Source of data is [1]_.
Reviews of this model are favorable less favorable than the Darby method
but superior to the constant-K method.
.. math::
K = \frac{K_1}{Re} + K_\infty\left(1 + \frac{1\text{ inch}}{D_{in}}\right)
**Note this model uses actual inside pipe diameter in inches.**
Parameters
----------
Di : float
Actual inside diameter of the pipe, [in]
Re : float
Reynolds number, [-]
name : str, optional
String from Hooper dict representing a fitting
K1 : float, optional
K1 parameter of Hooper model, optional [-]
Kinfty : float, optional
Kinfty parameter of Hooper model, optional [-]
Returns
-------
K : float
Loss coefficient [-]
Notes
-----
Also described in Ludwig's Applied Process Design.
Relatively uncommon to see it used.
No actual example found.
Examples
--------
>>> Hooper2K(Di=2., Re=10000., name='Valve, Globe, Standard')
6.15
>>> Hooper2K(Di=2., Re=10000., K1=900, Kinfty=4)
6.09
References
----------
.. [1] Hooper, W. B., "The 2-K Method Predicts Head Losses in Pipe
Fittings," Chem. Eng., p. 97, Aug. 24 (1981).
.. [2] Hooper, William B. "Calculate Head Loss Caused by Change in Pipe
Size." Chemical Engineering 95, no. 16 (November 7, 1988): 89.
.. [3] Kayode Coker. Ludwig's Applied Process Design for Chemical and
Petrochemical Plants. 4E. Amsterdam ; Boston: Gulf Professional
Publishing, 2007.
'''
if name is not None:
K1 = None
if name in Hooper: # NUMBA: DELETE
K1, Kinfty = Hooper[name] # NUMBA: DELETE
if K1 is None:
try:
K1, Kinfty = Hooper_values[Hooper_keys.index(name)]
except:
raise ValueError('Name of fitting is not in database')
elif K1 is not None and Kinfty is not None:
pass
else:
raise ValueError('Name of fitting or constants are required')
return K1/Re + Kinfty*(1. + 1./Di)
### Valves
def Kv_to_Cv(Kv):
r'''Convert valve flow coefficient from imperial to common metric units.
.. math::
C_v = 1.156 K_v
Parameters
----------
Kv : float
Metric Kv valve flow coefficient (flow rate of water at a pressure drop
of 1 bar) [m^3/hr]
Returns
-------
Cv : float
Imperial Cv valve flow coefficient (flow rate of water at a pressure
drop of 1 psi) [gallons/minute]
Notes
-----
Kv = 0.865 Cv is in the IEC standard 60534-2-1.
It has also been said that Cv = 1.17Kv; this is wrong by current standards.
The conversion factor does not depend on the density of the fluid or the
diameter of the valve. It is calculated with the definition of a US gallon
as 231 cubic inches, and a psi as a pound-force per square inch.
The exact conversion coefficient between Kv to Cv is 1.1560992283536566;
it is rounded in the formula above.
Examples
--------
>>> Kv_to_Cv(2)
2.3121984567073133
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
return 1.1560992283536566*Kv
def Cv_to_Kv(Cv):
r'''Convert valve flow coefficient from imperial to common metric units.
.. math::
K_v = C_v/1.156
Parameters
----------
Cv : float
Imperial Cv valve flow coefficient (flow rate of water at a pressure
drop of 1 psi) [gallons/minute]
Returns
-------
Kv : float
Metric Kv valve flow coefficient (flow rate of water at a pressure drop
of 1 bar) [m^3/hr]
Notes
-----
Kv = 0.865 Cv is in the IEC standard 60534-2-1.
It has also been said that Cv = 1.17Kv; this is wrong by current standards.
The conversion factor does not depend on the density of the fluid or the
diameter of the valve. It is calculated with the definition of a US gallon
as 231 cubic inches, and a psi as a pound-force per square inch.
The exact conversion coefficient between Kv to Cv is 1.1560992283536566;
it is rounded in the formula above.
Examples
--------
>>> Cv_to_Kv(2.312)
1.9998283393826013
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
return Cv/1.1560992283536566
def Kv_to_K(Kv, D):
r'''Convert valve flow coefficient from common metric units to regular
loss coefficients.
.. math::
K = 1.6\times 10^9 \frac{D^4}{K_v^2}
Parameters
----------
Kv : float
Metric Kv valve flow coefficient (flow rate of water at a pressure drop
of 1 bar) [m^3/hr]
D : float
Inside diameter of the valve [m]
Returns
-------
K : float
Loss coefficient, [-]
Notes
-----
Crane TP 410 M (2009) gives the coefficient of 0.04 (with diameter in mm).
It also suggests the density of water should be found between 5-40°C.
Older versions specify the density should be found at 60 °F, which is
used here, and the pessure for the appropriate density is back calculated.
.. math::
\Delta P = 1 \text{ bar} = \frac{1}{2}\rho V^2\cdot K
V = \frac{\frac{K_v\cdot \text{ hour}}{3600 \text{ second}}}{\frac{\pi}{4}D^2}
\rho = 999.29744568 \;\; kg/m^3 \text{ at } T=60° F, P = 703572 Pa
The value of density is calculated with IAPWS-95; it is chosen as it makes
the coefficient a very convenient round number. Others constants that have
been used are 1.604E9, and 1.60045E9.
Examples
--------
>>> Kv_to_K(2.312, .015)
15.153374600399898
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
return 1.6E9*D**4*Kv**-2
def K_to_Kv(K, D):
r'''Convert regular loss coefficient to valve flow coefficient.
.. math::
K_v = 4\times 10^4 \sqrt{ \frac{D^4}{K}}
Parameters
----------
K : float
Loss coefficient, [-]
D : float
Inside diameter of the valve [m]
Returns
-------
Kv : float
Metric Kv valve flow coefficient (flow rate of water at a pressure drop
of 1 bar) [m^3/hr]
Notes
-----
Crane TP 410 M (2009) gives the coefficient of 0.04 (with diameter in mm).
It also suggests the density of water should be found between 5-40°C.
Older versions specify the density should be found at 60 °F, which is
used here, and the pessure for the appropriate density is back calculated.
.. math::
\Delta P = 1 \text{ bar} = \frac{1}{2}\rho V^2\cdot K
V = \frac{\frac{K_v\cdot \text{ hour}}{3600 \text{ second}}}{\frac{\pi}{4}D^2}
\rho = 999.29744568 \;\; kg/m^3 \text{ at } T=60° F, P = 703572 Pa
The value of density is calculated with IAPWS-95; it is chosen as it makes
the coefficient a very convenient round number. Others constants that have
been used are 1.604E9, and 1.60045E9.
Examples
--------
>>> K_to_Kv(15.15337460039990, .015)
2.312
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
return D*D*sqrt(1.6E9/K)
def K_to_Cv(K, D):
r'''Convert regular loss coefficient to imperial valve flow coefficient.
.. math::
K_v = 1.156 \cdot 4\times 10^4 \sqrt{ \frac{D^4}{K}}
Parameters
----------
K : float
Loss coefficient, [-]
D : float
Inside diameter of the valve [m]
Returns
-------
Cv : float
Imperial Cv valve flow coefficient (flow rate of water at a pressure
drop of 1 psi) [gallons/minute]
Notes
-----
The conversion factor does not depend on the density of the fluid or the
diameter of the valve. It is calculated with the definition of a US gallon
as 231 cubic inches, and a psi as a pound-force per square inch.
The exact conversion coefficient between Kv to Cv is 1.1560992283536566;
it is rounded in the formula above.
Examples
--------
>>> K_to_Cv(16, .015)
2.601223263795727
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
return 1.1560992283536566*D*D*sqrt(1.6E9/K)
def Cv_to_K(Cv, D):
r'''Convert imperial valve flow coefficient from imperial units to regular
loss coefficients.
.. math::
K = 1.6\times 10^9 \frac{D^4}{\left(\frac{C_v}{1.56}\right)^2}
Parameters
----------
Cv : float
Imperial Cv valve flow coefficient (flow rate of water at a pressure
drop of 1 psi) [gallons/minute]
D : float
Inside diameter of the valve [m]
Returns
-------
K : float
Loss coefficient, [-]
Notes
-----
The exact conversion coefficient between Kv to Cv is 1.1560992283536566;
it is rounded in the formula above.
Examples
--------
>>> Cv_to_K(2.712, .015)
14.719595348352
References
----------
.. [1] ISA-75.01.01-2007 (60534-2-1 Mod) Draft
'''
D2 = D*D
term = (Cv*(1.0/1.1560992283536566))
return 1.6E9*D2*D2/(term*term)
def K_gate_valve_Crane(D1, D2, angle, fd=None):
r'''Returns loss coefficient for a gate valve of types wedge disc, double
disc, or plug type, as shown in [1]_.
If β = 1 and θ = 0:
.. math::
K = K_1 = K_2 = 8f_d
If β < 1 and θ <= 45°:
.. math::
K_2 = \frac{K + \sin \frac{\theta}{2} \left[0.8(1-\beta^2)
+ 2.6(1-\beta^2)^2\right]}{\beta^4}
If β < 1 and θ > 45°:
.. math::
K_2 = \frac{K + 0.5\sqrt{\sin\frac{\theta}{2}}(1-\beta^2)
+ (1-\beta^2)^2}{\beta^4}
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
angle : float
Angle formed by the reducer in the valve, [degrees]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions [2]_.
Examples
--------
Example 7-4 in [1]_; a 150 by 100 mm class 600 steel gate valve, conically
tapered ports, length 550 mm, back of sear ring ~150 mm. The valve is
connected to 146 mm schedule 80 pipe. The angle can be calculated to be
13 degrees. The valve is specified to be operating in turbulent conditions.
>>> K_gate_valve_Crane(D1=.1, D2=.146, angle=13.115)
1.1466029421844073
The calculated result is lower than their value of 1.22; the difference is
due to Crane's generous intermediate rounding. A later, Imperial edition of
Crane rounds differently - and comes up with K=1.06.
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
.. [2] Harvey Wilson. "Pressure Drop in Pipe Fittings and Valves |
Equivalent Length and Resistance Coefficient." Katmar Software. Accessed
July 28, 2017. http://www.katmarsoftware.com/articles/pipe-fitting-pressure-drop.htm.
'''
angle = radians(angle)
beta = D1/D2
if fd is None:
fd = ft_Crane(D2)
K1 = 8.0*fd # This does not refer to upstream loss per se
if beta == 1.0 or angle == 0.0:
return K1 # upstream and down
else:
beta2 = beta*beta
one_m_beta2 = 1.0 - beta2
if angle <= 0.7853981633974483:
K = (K1 + sin(0.5*angle)*(one_m_beta2*(0.8 + 2.6*one_m_beta2)))/(beta2*beta2)
else:
K = (K1 + one_m_beta2*(0.5*sqrt(sin(0.5*angle)) + one_m_beta2))/(beta2*beta2)
return K
def K_globe_valve_Crane(D1, D2, fd=None):
r'''Returns the loss coefficient for all types of globe valve, (reduced
seat or throttled) as shown in [1]_.
If β = 1:
.. math::
K = K_1 = K_2 = 340 f_d
Otherwise:
.. math::
K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4}
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_globe_valve_Crane(.01, .02)
135.9200548324305
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = D1/D2
if fd is None:
fd = ft_Crane(D2)
K1 = 340.0*fd
if beta == 1.0:
return K1 # upstream and down
else:
beta2 = beta*beta
one_m_beta = 1.0 - beta
one_m_beta2 = 1.0 - beta2
return (K1 + beta*(0.5*one_m_beta*one_m_beta
+ one_m_beta2*one_m_beta2))/(beta2*beta2)
def K_angle_valve_Crane(D1, D2, fd=None, style=0):
r'''Returns the loss coefficient for all types of angle valve, (reduced
seat or throttled) as shown in [1]_.
If β = 1:
.. math::
K = K_1 = K_2 = N\cdot f_d
Otherwise:
.. math::
K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4}
For style 0 and 2, N = 55; for style 1, N=150.
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
One of 0, 1, or 2; refers to three different types of angle valves
as shown in [1]_ [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_angle_valve_Crane(.01, .02)
26.597361811128465
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = D1/D2
if style not in (0, 1, 2):
raise ValueError('Valve style should be 0, 1, or 2')
if fd is None:
fd = ft_Crane(D2)
if style in (0, 2):
K1 = 55.0*fd
else:
K1 = 150.0*fd
if beta == 1:
return K1 # upstream and down
else:
return (K1 + beta*(0.5*(1-beta)**2 + (1-beta**2)**2))/beta**4
def K_swing_check_valve_Crane(D=None, fd=None, angled=True):
r'''Returns the loss coefficient for a swing check valve as shown in [1]_.
.. math::
K_2 = N\cdot f_d
For angled swing check valves N = 100; for straight valves, N = 50.
Parameters
----------
D : float, optional
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
angled : bool, optional
If True, returns a value 2x the unangled value; the style of the valve
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_swing_check_valve_Crane(D=.02)
2.3974274785373257
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if D is None and fd is None:
raise ValueError('Either `D` or `fd` must be specified')
if fd is None:
fd = ft_Crane(D)
if angled:
return 100.*fd
return 50.*fd
def K_lift_check_valve_Crane(D1, D2, fd=None, angled=True):
r'''Returns the loss coefficient for a lift check valve as shown in [1]_.
If β = 1:
.. math::
K = K_1 = K_2 = N\cdot f_d
Otherwise:
.. math::
K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4}
For angled lift check valves N = 55; for straight valves, N = 600.
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
angled : bool, optional
If True, returns a value 2x the unangled value; the style of the valve
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_lift_check_valve_Crane(.01, .02)
28.597361811128465
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = D1/D2
if fd is None:
fd = ft_Crane(D2)
if angled:
K1 = 55*fd
if beta == 1:
return K1
else:
return (K1 + beta*(0.5*(1 - beta**2) + (1 - beta**2)**2))/beta**4
else:
K1 = 600.*fd
if beta == 1:
return K1
else:
return (K1 + beta*(0.5*(1 - beta**2) + (1 - beta**2)**2))/beta**4
def K_tilting_disk_check_valve_Crane(D, angle, fd=None):
r'''Returns the loss coefficient for a tilting disk check valve as shown in
[1]_. Results are specified in [1]_ to be for the disk's resting position
to be at 5 or 25 degrees to the flow direction. The model is implemented
here so as to switch to the higher loss 15 degree coefficients at 10
degrees, and use the lesser coefficients for any angle under 10 degrees.
.. math::
K = N\cdot f_d
N is obtained from the following table:
+--------+-------------+-------------+
| | angle = 5 ° | angle = 15° |
+========+=============+=============+
| 2-8" | 40 | 120 |
+--------+-------------+-------------+
| 10-14" | 30 | 90 |
+--------+-------------+-------------+
| 16-48" | 20 | 60 |
+--------+-------------+-------------+
The actual change of coefficients happen at <= 9" and <= 15".
Parameters
----------
D : float
Diameter of the pipe section the valve in mounted in; the
same as the line size [m]
angle : float
Angle of the tilting disk to the flow direction; nominally 5 or 15
degrees [degrees]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_tilting_disk_check_valve_Crane(.01, 5)
1.1626516551826345
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D)
if angle < 10:
# 5 degree case
if D <= 0.2286:
# 2-8 inches, split at 9 inch
return 40*fd
elif D <= 0.381:
# 10-14 inches, split at 15 inch
return 30*fd
else:
# 16-18 inches
return 20*fd
else:
# 15 degree case
if D < 0.2286:
# 2-8 inches
return 120*fd
elif D < 0.381:
# 10-14 inches
return 90*fd
else:
# 16-18 inches
return 60*fd
globe_stop_check_valve_Crane_coeffs = {0: 400.0, 1: 300.0, 2: 55.0}
def K_globe_stop_check_valve_Crane(D1, D2, fd=None, style=0):
r'''Returns the loss coefficient for a globe stop check valve as shown in
[1]_.
If β = 1:
.. math::
K = K_1 = K_2 = N\cdot f_d
Otherwise:
.. math::
K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4}
Style 0 is the standard form; style 1 is angled, with a restrition to force
the flow up through the valve; style 2 is also angled but with a smaller
restriction forcing the flow up. N is 400, 300, and 55 for those cases
respectively.
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
One of 0, 1, or 2; refers to three different types of angle valves
as shown in [1]_ [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_globe_stop_check_valve_Crane(.1, .02, style=1)
4.5235076518969795
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D2)
if style == 0:
K = 400.0*fd
elif style == 1:
K = 300.0*fd
elif style == 2:
K = 55.0*fd
else:
raise ValueError('Accepted valve styles are 0, 1, and 2 only')
beta = D1/D2
if beta == 1.0:
return K
else:
return (K + beta*(0.5*(1 - beta**2) + (1 - beta**2)**2))/beta**4
angle_stop_check_valve_Crane_coeffs = {0: 200.0, 1: 350.0, 2: 55.0}
def K_angle_stop_check_valve_Crane(D1, D2, fd=None, style=0):
r'''Returns the loss coefficient for a angle stop check valve as shown in
[1]_.
If β = 1:
.. math::
K = K_1 = K_2 = N\cdot f_d
Otherwise:
.. math::
K_2 = \frac{K + \left[0.5(1-\beta^2) + (1-\beta^2)^2\right]}{\beta^4}
Style 0 is the standard form; style 1 has a restrition to force
the flow up through the valve; style 2 is has the clearest flow area with
no guides for the angle valve. N is 200, 350, and 55 for those cases
respectively.
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be smaller or equal to `D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
One of 0, 1, or 2; refers to three different types of angle valves
as shown in [1]_ [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_angle_stop_check_valve_Crane(.1, .02, style=1)
4.525425593879809
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D2)
if style == 0:
K = 200.0*fd
elif style == 1:
K = 350.0*fd
elif style == 2:
K = 55.0*fd
else:
raise ValueError('Accepted valve styles are 0, 1, and 2 only')
beta = D1/D2
if beta == 1:
return K
else:
return (K + beta*(0.5*(1.0 - beta**2) + (1.0 - beta**2)**2))/beta**4
def K_ball_valve_Crane(D1, D2, angle, fd=None):
r'''Returns the loss coefficient for a ball valve as shown in [1]_.
If β = 1:
.. math::
K = K_1 = K_2 = 3f_d
If β < 1 and θ <= 45°:
.. math::
K_2 = \frac{K + \sin \frac{\theta}{2} \left[0.8(1-\beta^2)
+ 2.6(1-\beta^2)^2\right]} {\beta^4}
If β < 1 and θ > 45°:
.. math::
K_2 = \frac{K + 0.5\sqrt{\sin\frac{\theta}{2}}(1-\beta^2)
+ (1-\beta^2)^2}{\beta^4}
Parameters
----------
D1 : float
Diameter of the valve seat bore (must be equal to or smaller than
`D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
angle : float
Angle formed by the reducer in the valve, [degrees]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_ball_valve_Crane(.01, .02, 50)
14.051310974926592
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D2)
beta = D1/D2
K1 = 3*fd
angle = radians(angle)
if beta == 1:
return K1
else:
if angle <= pi/4:
return (K1 + sin(angle/2)*(0.8*(1-beta**2) + 2.6*(1-beta**2)**2))/beta**4
else:
return (K1 + 0.5*sqrt(sin(angle/2)) * (1 - beta**2) + (1-beta**2)**2)/beta**4
diaphragm_valve_Crane_coeffs = {0: 149.0, 1: 39.0}
def K_diaphragm_valve_Crane(D=None, fd=None, style=0):
r'''Returns the loss coefficient for a diaphragm valve of either weir
(`style` = 0) or straight-through (`style` = 1) as shown in [1]_.
.. math::
K = K_1 = K_2 = N\cdot f_d
For style 0 (weir), N = 149; for style 1 (straight through), N = 39.
Parameters
----------
D : float, optional
Diameter of the pipe section the valve in mounted in; the
same as the line size [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
Either 0 (weir type valve) or 1 (straight through weir valve) [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_diaphragm_valve_Crane(D=.1, style=0)
2.4269804835982565
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if D is None and fd is None:
raise ValueError('Either `D` or `fd` must be specified')
if fd is None:
fd = ft_Crane(D)
if style == 0:
K = 149.0*fd
elif style == 1:
K = 39.0*fd
else:
raise ValueError('Accepted valve styles are 0 (weir) or 1 (straight through) only')
return K
foot_valve_Crane_coeffs = {0: 420.0, 1: 75.0}
def K_foot_valve_Crane(D=None, fd=None, style=0):
r'''Returns the loss coefficient for a foot valve of either poppet disc
(`style` = 0) or hinged-disk (`style` = 1) as shown in [1]_. Both valves
are specified include the loss of the attached strainer.
.. math::
K = K_1 = K_2 = N\cdot f_d
For style 0 (poppet disk), N = 420; for style 1 (hinged disk), N = 75.
Parameters
----------
D : float, optional
Diameter of the pipe section the valve in mounted in; the
same as the line size [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
Either 0 (poppet disk foot valve) or 1 (hinged disk foot valve) [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_foot_valve_Crane(D=0.2, style=0)
5.912221498436275
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if D is None and fd is None:
raise ValueError('Either `D` or `fd` must be specified')
if fd is None:
fd = ft_Crane(D)
if style == 0:
K = 420.0*fd
elif style == 1:
K = 75.0*fd
else:
raise ValueError('Accepted valve styles are 0 (poppet disk) or 1 (hinged disk) only')
return K
butterfly_valve_Crane_coeffs = {0: (45.0, 35.0, 25.0), 1: (74.0, 52.0, 43.0),
2: (218.0, 96.0, 55.0)}
def K_butterfly_valve_Crane(D, fd=None, style=0):
r'''Returns the loss coefficient for a butterfly valve as shown in
[1]_. Three different types are supported; Centric (`style` = 0),
double offset (`style` = 1), and triple offset (`style` = 2).
.. math::
K = N\cdot f_d
N is obtained from the following table:
+------------+---------+---------------+---------------+
| Size range | Centric | Double offset | Triple offset |
+============+=========+===============+===============+
| 2" - 8" | 45 | 74 | 218 |
+------------+---------+---------------+---------------+
| 10" - 14" | 35 | 52 | 96 |
+------------+---------+---------------+---------------+
| 16" - 24" | 25 | 43 | 55 |
+------------+---------+---------------+---------------+
The actual change of coefficients happen at <= 9" and <= 15".
Parameters
----------
D : float
Diameter of the pipe section the valve in mounted in; the
same as the line size [m]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
Either 0 (centric), 1 (double offset), or 2 (triple offset) [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_butterfly_valve_Crane(D=.1, style=2)
3.5508841974793284
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D)
if style == 0:
c1, c2, c3 = 45.0, 35.0, 25.0
elif style == 1:
c1, c2, c3 = 74.0, 52.0, 43.0
elif style == 2:
c1, c2, c3 = 218.0, 96.0, 55.0
else:
raise ValueError('Accepted valve styles are 0 (centric), 1 (double offset), or 2 (triple offset) only.')
if D <= 0.2286:
# 2-8 inches, split at 9 inch
return c1*fd
elif D <= 0.381:
# 10-14 inches, split at 15 inch
return c2*fd
else:
# 16-18 inches
return c3*fd
plug_valve_Crane_coeffs = {0: 18.0, 1: 30.0, 2: 90.0}
def K_plug_valve_Crane(D1, D2, angle, fd=None, style=0):
r'''Returns the loss coefficient for a plug valve or cock valve as shown in
[1]_.
If β = 1:
.. math::
K = K_1 = K_2 = Nf_d
Otherwise:
.. math::
K_2 = \frac{K + 0.5\sqrt{\sin\frac{\theta}{2}}(1-\beta^2)
+ (1-\beta^2)^2}{\beta^4}
Three types of plug valves are supported. For straight-through plug valves
(`style` = 0), N = 18. For 3-way, flow straight through (`style` = 1)
plug valves, N = 30. For 3-way, flow 90° valves (`style` = 2) N = 90.
Parameters
----------
D1 : float
Diameter of the valve plug bore (must be equal to or smaller than
`D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
angle : float
Angle formed by the reducer in the valve, [degrees]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
style : int, optional
Either 0 (straight-through), 1 (3-way, flow straight-through), or 2
(3-way, flow 90°) [-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
This method is not valid in the laminar regime and the pressure drop will
be underestimated in those conditions.
Examples
--------
>>> K_plug_valve_Crane(D1=.01, D2=.02, angle=50)
19.80513692341617
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fd is None:
fd = ft_Crane(D2)
beta = D1/D2
if style == 0:
K = 18.0*fd
elif style == 1:
K = 30.0*fd
elif style == 2:
K = 90.0*fd
else:
raise ValueError('Accepted valve styles are 0 (straight-through), 1 (3-way, flow straight-through), or 2 (3-way, flow 90°)')
angle = radians(angle)
if beta == 1:
return K
else:
return (K + 0.5*sqrt(sin(angle/2)) * (1 - beta**2) + (1-beta**2)**2)/beta**4
def v_lift_valve_Crane(rho, D1=None, D2=None, style='swing check angled'):
r'''Calculates the approximate minimum velocity required to lift the disk
or other controlling element of a check valve to a fully open, stable,
position according to the Crane method [1]_.
.. math::
v_{min} = N\cdot \text{m/s} \cdot \sqrt{\frac{\text{kg/m}^3}{\rho}}
.. math::
v_{min} = N\beta^2 \cdot \text{m/s} \cdot \sqrt{\frac{\text{kg/m}^3}{\rho}}
See the notes for the definition of values of N and which check valves use
which formulas.
Parameters
----------
rho : float
Density of the fluid [kg/m^3]
D1 : float, optional
Diameter of the valve bore (must be equal to or smaller than
`D2`), [m]
D2 : float, optional
Diameter of the pipe attached to the valve, [m]
style : str
The type of valve; one of ['swing check angled', 'swing check straight',
'swing check UL', 'lift check straight', 'lift check angled',
'tilting check 5°', 'tilting check 15°', 'stop check globe 1',
'stop check angle 1', 'stop check globe 2', 'stop check angle 2',
'stop check globe 3', 'stop check angle 3', 'foot valve poppet disc',
'foot valve hinged disc'], [-]
Returns
-------
v_min : float
Approximate minimum velocity required to keep the disc fully lifted,
preventing chattering and wear [m/s]
Notes
-----
This equation is not dimensionless.
+--------------------------+-----+------+
| Name/string | N | Full |
+==========================+=====+======+
| 'swing check angled' | 45 | No |
+--------------------------+-----+------+
| 'swing check straight' | 75 | No |
+--------------------------+-----+------+
| 'swing check UL' | 120 | No |
+--------------------------+-----+------+
| 'lift check straight' | 50 | Yes |
+--------------------------+-----+------+
| 'lift check angled' | 170 | Yes |
+--------------------------+-----+------+
| 'tilting check 5°' | 100 | No |
+--------------------------+-----+------+
| 'tilting check 15°' | 40 | No |
+--------------------------+-----+------+
| 'stop check globe 1' | 70 | Yes |
+--------------------------+-----+------+
| 'stop check angle 1' | 95 | Yes |
+--------------------------+-----+------+
| 'stop check globe 2' | 75 | Yes |
+--------------------------+-----+------+
| 'stop check angle 2' | 75 | Yes |
+--------------------------+-----+------+
| 'stop check globe 3' | 170 | Yes |
+--------------------------+-----+------+
| 'stop check angle 3' | 170 | Yes |
+--------------------------+-----+------+
| 'foot valve poppet disc' | 20 | No |
+--------------------------+-----+------+
| 'foot valve hinged disc' | 45 | No |
+--------------------------+-----+------+
Examples
--------
>>> v_lift_valve_Crane(rho=998.2, D1=0.0627, D2=0.0779, style='lift check straight')
1.0252301935349286
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
specific_volume = 1./rho
if D1 is not None and D2 is not None:
beta = D1/D2
beta2 = beta*beta
if style == 'swing check angled':
return 45.0*sqrt(specific_volume)
elif style == 'swing check straight':
return 75.0*sqrt(specific_volume)
elif style == 'swing check UL':
return 120.0*sqrt(specific_volume)
elif style == 'lift check straight':
return 50.0*beta2*sqrt(specific_volume)
elif style == 'lift check angled':
return 170.0*beta2*sqrt(specific_volume)
elif style == 'tilting check 5°':
return 100.0*sqrt(specific_volume)
elif style == 'tilting check 15°':
return 40.0*sqrt(specific_volume)
elif style == 'stop check globe 1':
return 70.0*beta2*sqrt(specific_volume)
elif style == 'stop check angle 1':
return 95.0*beta2*sqrt(specific_volume)
elif style in ('stop check globe 2', 'stop check angle 2'):
return 75.0*beta2*sqrt(specific_volume)
elif style in ('stop check globe 3', 'stop check angle 3'):
return 170.0*beta2*sqrt(specific_volume)
elif style == 'foot valve poppet disc':
return 20.0*sqrt(specific_volume)
elif style == 'foot valve hinged disc':
return 45.0*sqrt(specific_volume)
CRANE_GATE_VALVE = 'CRANE_GATE_VALVE'
CRANE_GLOBE_VALVE = 'CRANE_GLOBE_VALVE'
CRANE_ANGLE_VALVE_0 = 'CRANE_ANGLE_VALVE_0'
CRANE_ANGLE_VALVE_1 = 'CRANE_ANGLE_VALVE_1'
CRANE_ANGLE_VALVE_2 = 'CRANE_ANGLE_VALVE_2'
CRANE_SWING_CHECK_VALVE = 'CRANE_SWING_CHECK_VALVE'
CRANE_SWING_CHECK_VALVE_ANGLED = 'CRANE_SWING_CHECK_VALVE_ANGLED'
CRANE_LIFT_CHECK_VALVE = 'CRANE_LIFT_CHECK_VALVE'
CRANE_LIFT_CHECK_VALVE_ANGLED = 'CRANE_LIFT_CHECK_VALVE_ANGLED'
CRANE_TILTING_CHECK_VALVE_5DEG = 'CRANE_TILTING_CHECK_VALVE_5DEG'
CRANE_TILTING_CHECK_VALVE_15DEG = 'CRANE_TILTING_CHECK_VALVE_15DEG'
CRANE_GLOBE_STOP_CHECK_VALVE_0 = 'CRANE_GLOBE_STOP_CHECK_VALVE_0'
CRANE_GLOBE_STOP_CHECK_VALVE_1 = 'CRANE_GLOBE_STOP_CHECK_VALVE_1'
CRANE_GLOBE_STOP_CHECK_VALVE_2 = 'CRANE_GLOBE_STOP_CHECK_VALVE_2'
CRANE_ANGLE_STOP_CHECK_VALVE_0 = 'CRANE_ANGLE_STOP_CHECK_VALVE_0'
CRANE_ANGLE_STOP_CHECK_VALVE_1 = 'CRANE_ANGLE_STOP_CHECK_VALVE_1'
CRANE_ANGLE_STOP_CHECK_VALVE_2 = 'CRANE_ANGLE_STOP_CHECK_VALVE_2'
CRANE_BALL_VALVE = 'CRANE_BALL_VALVE'
CRANE_DIAPHRAGM_VALVE_WEIR = 'CRANE_DIAPHRAGM_VALVE_WEIR'
CRANE_DIAPHRAGM_VALVE_STAIGHT_THROUGH_WEIR = 'CRANE_DIAPHRAGM_VALVE_STAIGHT_THROUGH_WEIR'
CRANE_FOOT_VALVE_POPPET_DISK = 'CRANE_FOOT_VALVE_POPPET_DISK'
CRANE_FOOT_VALVE_HINGED_DISK = 'CRANE_FOOT_VALVE_HINGED_DISK'
CRANE_BUTTERFLY_VALVE_CENTRIC = 'CRANE_BUTTERFLY_VALVE_CENTRIC'
CRANE_BUTTERFLY_VALVE_DOUBLE_OFFSET = 'CRANE_BUTTERFLY_VALVE_DOUBLE_OFFSET'
CRANE_BUTTERFLY_VALVE_TRIPLE_OFFSET = 'CRANE_BUTTERFLY_VALVE_TRIPLE_OFFSET'
CRANE_PLUG_VALVE_STRAIGHT_THROUGH = 'CRANE_PLUG_VALVE_STRAIGHT_THROUGH'
CRANE_PLUG_VALVE_3_WAY_STRAIGHT_THROUGH = 'CRANE_PLUG_VALVE_3_WAY_STRAIGHT_THROUGH'
CRANE_PLUG_VALVE_3_WAY_90_DEG = 'CRANE_PLUG_VALVE_3_WAY_90_DEG'
CRANE_VALVES = [CRANE_GATE_VALVE, CRANE_GLOBE_VALVE, CRANE_ANGLE_VALVE_0,
CRANE_ANGLE_VALVE_1, CRANE_ANGLE_VALVE_2, CRANE_SWING_CHECK_VALVE,
CRANE_SWING_CHECK_VALVE_ANGLED, CRANE_LIFT_CHECK_VALVE,
CRANE_LIFT_CHECK_VALVE_ANGLED, CRANE_TILTING_CHECK_VALVE_5DEG,
CRANE_TILTING_CHECK_VALVE_15DEG, CRANE_GLOBE_STOP_CHECK_VALVE_0,
CRANE_GLOBE_STOP_CHECK_VALVE_1, CRANE_GLOBE_STOP_CHECK_VALVE_2,
CRANE_ANGLE_STOP_CHECK_VALVE_0, CRANE_ANGLE_STOP_CHECK_VALVE_1,
CRANE_ANGLE_STOP_CHECK_VALVE_2, CRANE_BALL_VALVE, CRANE_DIAPHRAGM_VALVE_WEIR,
CRANE_DIAPHRAGM_VALVE_STAIGHT_THROUGH_WEIR, CRANE_FOOT_VALVE_POPPET_DISK,
CRANE_FOOT_VALVE_HINGED_DISK, CRANE_BUTTERFLY_VALVE_CENTRIC,
CRANE_BUTTERFLY_VALVE_DOUBLE_OFFSET, CRANE_BUTTERFLY_VALVE_TRIPLE_OFFSET,
CRANE_PLUG_VALVE_STRAIGHT_THROUGH, CRANE_PLUG_VALVE_3_WAY_STRAIGHT_THROUGH,
CRANE_PLUG_VALVE_3_WAY_90_DEG, ]
def Crane_loss_coefficient(D1, D2, angle, fitting, fd=None):
r'''Returns the loss coefficient for a particular Crane valve fitting.
[1]_. This function is intended for internal use, to test all the
correlations, at this point.
Parameters
----------
D1 : float
Diameter of the valve plug bore (must be equal to or smaller than
`D2`), [m]
D2 : float
Diameter of the pipe attached to the valve, [m]
angle : float
Angle formed by the reducer in the valve, [degrees]
fitting : str
Text strings which represent a fitting, [-]
fd : float, optional
Darcy friction factor calculated for the actual pipe flow in clean
steel (roughness = 0.0018 inch) in the fully developed turbulent
region; do not specify this to use the original Crane friction factor!,
[-]
Returns
-------
K : float
Loss coefficient with respect to the pipe inside diameter [-]
Notes
-----
Examples
--------
>>> Crane_loss_coefficient(D1=.01, D2=.02, fitting=CRANE_SWING_CHECK_VALVE_ANGLED, angle=50)
2.3974274785373257
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
if fitting == CRANE_GATE_VALVE:
return K_gate_valve_Crane(D1, D2, angle, fd=fd)
elif fitting == CRANE_GLOBE_VALVE:
return K_globe_valve_Crane(D1, D2, fd)
elif fitting == CRANE_ANGLE_VALVE_0:
return K_angle_valve_Crane(D1, D2, fd, 0)
elif fitting == CRANE_ANGLE_VALVE_1:
return K_angle_valve_Crane(D1, D2, fd, 1)
elif fitting == CRANE_ANGLE_VALVE_2:
return K_angle_valve_Crane(D1, D2, fd, 2)
elif fitting == CRANE_SWING_CHECK_VALVE:
return K_swing_check_valve_Crane(D2, fd, False)
elif fitting == CRANE_SWING_CHECK_VALVE_ANGLED:
return K_swing_check_valve_Crane(D2, fd, True)
elif fitting == CRANE_LIFT_CHECK_VALVE:
return K_lift_check_valve_Crane(D1, D2, fd, False)
elif fitting == CRANE_LIFT_CHECK_VALVE_ANGLED:
return K_lift_check_valve_Crane(D1, D2, fd, True)
elif fitting == CRANE_TILTING_CHECK_VALVE_5DEG:
return K_tilting_disk_check_valve_Crane(D2, 5.0, fd)
elif fitting == CRANE_TILTING_CHECK_VALVE_15DEG:
return K_tilting_disk_check_valve_Crane(D2, 15.0, fd)
elif fitting == CRANE_GLOBE_STOP_CHECK_VALVE_0:
return K_globe_stop_check_valve_Crane(D1, D2, fd, 0)
elif fitting == CRANE_GLOBE_STOP_CHECK_VALVE_1:
return K_globe_stop_check_valve_Crane(D1, D2, fd, 1)
elif fitting == CRANE_GLOBE_STOP_CHECK_VALVE_2:
return K_globe_stop_check_valve_Crane(D1, D2, fd, 2)
elif fitting == CRANE_ANGLE_STOP_CHECK_VALVE_0:
return K_angle_stop_check_valve_Crane(D1, D2, fd, 0)
elif fitting == CRANE_ANGLE_STOP_CHECK_VALVE_1:
return K_angle_stop_check_valve_Crane(D1, D2, fd, 1)
elif fitting == CRANE_ANGLE_STOP_CHECK_VALVE_2:
return K_angle_stop_check_valve_Crane(D1, D2, fd, 2)
elif fitting == CRANE_BALL_VALVE:
return K_ball_valve_Crane(D1, D2, angle, fd)
elif fitting == CRANE_DIAPHRAGM_VALVE_WEIR:
return K_diaphragm_valve_Crane(D2, fd, 0)
elif fitting == CRANE_DIAPHRAGM_VALVE_STAIGHT_THROUGH_WEIR:
return K_diaphragm_valve_Crane(D2, fd, 1)
elif fitting == CRANE_FOOT_VALVE_POPPET_DISK:
return K_foot_valve_Crane(D2, fd, 0)
elif fitting == CRANE_FOOT_VALVE_HINGED_DISK:
return K_foot_valve_Crane(D2, fd, 1)
elif fitting == CRANE_BUTTERFLY_VALVE_CENTRIC:
return K_butterfly_valve_Crane(D2, fd, 0)
elif fitting == CRANE_BUTTERFLY_VALVE_DOUBLE_OFFSET:
return K_butterfly_valve_Crane(D2, fd, 1)
elif fitting == CRANE_BUTTERFLY_VALVE_TRIPLE_OFFSET:
return K_butterfly_valve_Crane(D2, fd, 2)
elif fitting == CRANE_PLUG_VALVE_STRAIGHT_THROUGH:
return K_plug_valve_Crane(D1, D2, angle, fd, 0)
elif fitting == CRANE_PLUG_VALVE_3_WAY_STRAIGHT_THROUGH:
return K_plug_valve_Crane(D1, D2, angle, fd, 1)
elif fitting == CRANE_PLUG_VALVE_3_WAY_90_DEG:
return K_plug_valve_Crane(D1, D2, angle, fd, 2)
else:
raise ValueError("Unrecognized fitting")
branch_converging_Crane_Fs = [1.74, 1.41, 1.0, 0.0]
branch_converging_Crane_angles = [30.0, 45.0, 60.0, 90.0]
def K_branch_converging_Crane(D_run, D_branch, Q_run, Q_branch, angle=90.0):
r'''Returns the loss coefficient for the branch of a converging tee or wye
according to the Crane method [1]_.
.. math::
K_{branch} = C\left[1 + D\left(\frac{Q_{branch}}{Q_{comb}\cdot
\beta_{branch}^2}\right)^2 - E\left(1 - \frac{Q_{branch}}{Q_{comb}}
\right)^2 - \frac{F}{\beta_{branch}^2} \left(\frac{Q_{branch}}
{Q_{comb}}\right)^2\right]
.. math::
\beta_{branch} = \frac{D_{branch}}{D_{comb}} = \frac{D_{branch}}{D_{run}}
In the above equation, D = 1, E = 2. See the notes for definitions of F and
C. The run and combined diameter are assumed the same in this model.
Parameters
----------
D_run : float
Diameter of the straight-through inlet portion of the tee or wye [m]
D_branch : float
Diameter of the pipe attached at an angle to the straight-through, [m]
Q_run : float
Volumetric flow rate in the straight-through inlet of the tee or wye,
[m^3/s]
Q_branch : float
Volumetric flow rate in the pipe attached at an angle to the straight-
through, [m^3/s]
angle : float, optional
Angle the branch makes with the straight-through (tee=90, wye<90)
[degrees]
Returns
-------
K : float
Loss coefficient of branch with respect to the velocity and inside
diameter of the combined flow outlet [-]
Notes
-----
F is linearly interpolated from the table of angles below. There is no
cutoff to prevent angles from being larger or smaller than 30 or 90
degrees.
+-----------+------+
| Angle [°] | |
+===========+======+
| 30 | 1.74 |
+-----------+------+
| 45 | 1.41 |
+-----------+------+
| 60 | 1 |
+-----------+------+
| 90 | 0 |
+-----------+------+
If :math:`\beta_{branch}^2 \le 0.35`, C = 1
If :math:`\beta_{branch}^2 > 0.35` and :math:`Q_{branch}/Q_{comb} > 0.4`,
C = 0.55.
If neither of the above conditions are met:
.. math::
C = 0.9\left(1 - \frac{Q_{branch}}{Q_{comb}}\right)
Note that there is an error in the text of [1]_; the errata can be obtained
here: http://www.flowoffluids.com/publications/tp-410-errata.aspx
Examples
--------
Example 7-35 of [1]_. A DN100 schedule 40 tee has 1135 liters/minute of
water passing through the straight leg, and 380 liters/minute of water
converging with it through a 90° branch. Calculate the loss coefficient in
the branch. The calculated value there is -0.04026.
>>> K_branch_converging_Crane(0.1023, 0.1023, 0.018917, 0.00633)
-0.0404410851362
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = (D_branch/D_run)
beta2 = beta*beta
Q_comb = Q_run + Q_branch
Q_ratio = Q_branch/Q_comb
if beta2 <= 0.35:
C = 1.
elif Q_ratio <= 0.4:
C = 0.9*(1 - Q_ratio)
else:
C = 0.55
D, E = 1., 2.
F = interp(angle, branch_converging_Crane_angles, branch_converging_Crane_Fs)
K = C*(1. + D*(Q_ratio/beta2)**2 - E*(1. - Q_ratio)**2 - F/beta2*Q_ratio**2)
return K
run_converging_Crane_Fs = [1.74, 1.41, 1.0]
run_converging_Crane_angles = [30.0, 45.0, 60.0]
def K_run_converging_Crane(D_run, D_branch, Q_run, Q_branch, angle=90):
r'''Returns the loss coefficient for the run of a converging tee or wye
according to the Crane method [1]_.
.. math::
K_{branch} = C\left[1 + D\left(\frac{Q_{branch}}{Q_{comb}\cdot
\beta_{branch}^2}\right)^2 - E\left(1 - \frac{Q_{branch}}{Q_{comb}}
\right)^2 - \frac{F}{\beta_{branch}^2} \left(\frac{Q_{branch}}
{Q_{comb}}\right)^2\right]
.. math::
\beta_{branch} = \frac{D_{branch}}{D_{comb}} = \frac{D_{branch}}{D_{run}}
In the above equation, C=1, D=0, E=1. See the notes for definitions of F
and also the special case of 90°. The run and combined diameter are assumed
the same in this model.
Parameters
----------
D_run : float
Diameter of the straight-through inlet portion of the tee or wye
[m]
D_branch : float
Diameter of the pipe attached at an angle to the straight-through, [m]
Q_run : float
Volumetric flow rate in the straight-through inlet of the tee or wye,
[m^3/s]
Q_branch : float
Volumetric flow rate in the pipe attached at an angle to the straight-
through, [m^3/s]
angle : float, optional
Angle the branch makes with the straight-through (tee=90, wye<90)
[degrees]
Returns
-------
K : float
Loss coefficient of run with respect to the velocity and inside
diameter of the combined flow outlet [-]
Notes
-----
F is linearly interpolated from the table of angles below. There is no
cutoff to prevent angles from being larger or smaller than 30 or 60
degrees. The switch to the special 90° happens at 75°.
+-----------+------+
| Angle [°] | |
+===========+======+
| 30 | 1.74 |
+-----------+------+
| 45 | 1.41 |
+-----------+------+
| 60 | 1 |
+-----------+------+
For the special case of 90°, the formula used is as follows.
.. math::
K_{run} = 1.55\left(\frac{Q_{branch}}{Q_{comb}} \right)
- \left(\frac{Q_{branch}}{Q_{comb}}\right)^2
Examples
--------
Example 7-35 of [1]_. A DN100 schedule 40 tee has 1135 liters/minute of
water passing through the straight leg, and 380 liters/minute of water
converging with it through a 90° branch. Calculate the loss coefficient in
the run. The calculated value there is 0.03258.
>>> K_run_converging_Crane(0.1023, 0.1023, 0.018917, 0.00633)
0.32575847854551254
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = (D_branch/D_run)
beta2 = beta*beta
Q_comb = Q_run + Q_branch
Q_ratio = Q_branch/Q_comb
if angle < 75.0:
C = 1.0
else:
return 1.55*(Q_ratio) - Q_ratio*Q_ratio
D, E = 0.0, 1.0
F = interp(angle, run_converging_Crane_angles, run_converging_Crane_Fs)
K = C*(1. + D*(Q_ratio/beta2)**2 - E*(1. - Q_ratio)**2 - F/beta2*Q_ratio**2)
return K
def K_branch_diverging_Crane(D_run, D_branch, Q_run, Q_branch, angle=90):
r'''Returns the loss coefficient for the branch of a diverging tee or wye
according to the Crane method [1]_.
.. math::
K_{branch} = G\left[1 + H\left(\frac{Q_{branch}}{Q_{comb}
\beta_{branch}^2}\right)^2 - J\left(\frac{Q_{branch}}{Q_{comb}
\beta_{branch}^2}\right)\cos\theta\right]
.. math::
\beta_{branch} = \frac{D_{branch}}{D_{comb}} = \frac{D_{branch}}{D_{run}}
See the notes for definitions of H, J, and G. The run and combined diameter
are assumed the same in this model.
Parameters
----------
D_run : float
Diameter of the straight-through inlet portion of the tee or wye [m]
D_branch : float
Diameter of the pipe attached at an angle to the straight-through, [m]
Q_run : float
Volumetric flow rate in the straight-through outlet of the tee or wye,
[m^3/s]
Q_branch : float
Volumetric flow rate in the pipe attached at an angle to the straight-
through, [m^3/s]
angle : float, optional
Angle the branch makes with the straight-through (tee=90, wye<90)
[degrees]
Returns
-------
K : float
Loss coefficient of branch with respect to the velocity and inside
diameter of the combined flow inlet [-]
Notes
-----
If :math:`\beta_{branch} = 1, \theta = 90^\circ`, H = 0.3 and J = 0.
Otherwise H = 1 and J = 2.
G is determined according to the following pseudocode:
.. code-block:: python
if angle < 75:
if beta2 <= 0.35:
if Q_ratio <= 0.4:
G = 1.1 - 0.7*Q_ratio
else:
G = 0.85
else:
if Q_ratio <= 0.6:
G = 1.0 - 0.6*Q_ratio
else:
G = 0.6
else:
if beta2 <= 2/3.:
G = 1
else:
G = 1 + 0.3*Q_ratio*Q_ratio
Note that there are several errors in the text of [1]_; the errata can be
obtained here:
https://web.archive.org/web/20200125134233if_/http://flowoffluids.com:80/media/1002/metric-errata-document-nov2012.pdf
Note that the text specifies three case of behavior but no guidance for the range
60...90 degrees so the gap between tees and wyes is solved by splitting the
different behavior at the angle of 75 degrees.
Examples
--------
Example 7-36 of [1]_. A DN150 schedule 80 wye has 1515 liters/minute of
water exiting the straight leg, and 950 liters/minute of water
exiting it through a 45° branch. Calculate the loss coefficient in
the branch. The calculated value there is 0.4640.
>>> K_branch_diverging_Crane(0.146, 0.146, 0.02525, 0.01583, angle=45)
0.4639895627496694
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = (D_branch/D_run)
beta2 = beta*beta
Q_comb = Q_run + Q_branch
Q_ratio = Q_branch/Q_comb
if angle < 60 or beta <= 2/3.:
H, J = 1., 2.
else:
H, J = 0.3, 0
if angle < 75:
# 75 degree transition chosen instead of 60, splitting the difference
# between behavior at 60 and 90
if beta2 <= 0.35:
if Q_ratio <= 0.4:
G = 1.1 - 0.7*Q_ratio
else:
G = 0.85
else:
if Q_ratio <= 0.6:
G = 1.0 - 0.6*Q_ratio
else:
G = 0.6
else:
if beta2 <= 2/3.:
G = 1
else:
G = 1 + 0.3*Q_ratio*Q_ratio
angle_rad = radians(angle)
K_branch = G*(1 + H*(Q_ratio/beta2)**2 - J*(Q_ratio/beta2)*cos(angle_rad))
return K_branch
def K_run_diverging_Crane(D_run, D_branch, Q_run, Q_branch, angle=90):
r'''Returns the loss coefficient for the run of a converging tee or wye
according to the Crane method [1]_.
.. math::
K_{run} = M \left(\frac{Q_{branch}}{Q_{comb}}\right)^2
.. math::
\beta_{branch} = \frac{D_{branch}}{D_{comb}} = \frac{D_{branch}}{D_{run}}
See the notes for the definition of M. The run and combined diameter are
assumed the same in this model.
Parameters
----------
D_run : float
Diameter of the straight-through inlet portion of the tee or wye [m]
D_branch : float
Diameter of the pipe attached at an angle to the straight-through, [m]
Q_run : float
Volumetric flow rate in the straight-through outlet of the tee or wye,
[m^3/s]
Q_branch : float
Volumetric flow rate in the pipe attached at an angle to the straight-
through, [m^3/s]
angle : float, optional
Angle the branch makes with the straight-through (tee=90, wye<90)
[degrees]
Returns
-------
K : float
Loss coefficient of run with respect to the velocity and inside
diameter of the combined flow inlet [-]
Notes
-----
M is calculated according to the following pseudocode:
.. code-block:: python
if beta*beta <= 0.4:
M = 0.4
elif Q_branch/Q_comb <= 0.5:
M = 2*(2*Q_branch/Q_comb - 1)
else:
M = 0.3*(2*Q_branch/Q_comb - 1)
Examples
--------
Example 7-36 of [1]_. A DN150 schedule 80 wye has 1515 liters/minute of
water exiting the straight leg, and 950 liters/minute of water
exiting it through a 45° branch. Calculate the loss coefficient in
the branch. The calculated value there is -0.06809.
>>> K_run_diverging_Crane(0.146, 0.146, 0.02525, 0.01583, angle=45)
-0.06810067607153049
References
----------
.. [1] Crane Co. Flow of Fluids Through Valves, Fittings, and Pipe. Crane,
2009.
'''
beta = (D_branch/D_run)
beta2 = beta*beta
Q_comb = Q_run + Q_branch
Q_ratio = Q_branch/Q_comb
if beta2 <= 0.4:
M = 0.4
elif Q_ratio <= 0.5:
M = 2.*(2.*Q_ratio - 1.)
else:
M = 0.3*(2.*Q_ratio - 1.)
return M*Q_ratio*Q_ratio
|