forcmain.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | //----------------------------------------------------------------------------- | ||
| 2 | // forcemain.c | ||
| 3 | // | ||
| 4 | // Project: EPA SWMM5 | ||
| 5 | // Version: 5.2 | ||
| 6 | // Date: 11/01/21 (Build 5.2.0) | ||
| 7 | // Author: L. Rossman | ||
| 8 | // | ||
| 9 | // Special Non-Manning Force Main functions | ||
| 10 | //----------------------------------------------------------------------------- | ||
| 11 | #define _CRT_SECURE_NO_DEPRECATE | ||
| 12 | |||
| 13 | #include <math.h> | ||
| 14 | #include "headers.h" | ||
| 15 | |||
| 16 | //----------------------------------------------------------------------------- | ||
| 17 | // Constants | ||
| 18 | //----------------------------------------------------------------------------- | ||
| 19 | static const double VISCOS = 1.1E-5; // Kinematic viscosity of water | ||
| 20 | // @ 20 deg C (sq ft/sec) | ||
| 21 | |||
| 22 | //----------------------------------------------------------------------------- | ||
| 23 | // External functions (declared in funcs.h) | ||
| 24 | //----------------------------------------------------------------------------- | ||
| 25 | // forcemain_getEquivN | ||
| 26 | // forcemain_getRoughFactor | ||
| 27 | // forcemain_getFricSlope | ||
| 28 | |||
| 29 | //----------------------------------------------------------------------------- | ||
| 30 | // Local functions | ||
| 31 | //----------------------------------------------------------------------------- | ||
| 32 | static double forcemain_getFricFactor(double e, double hrad, double re); | ||
| 33 | static double forcemain_getReynolds(double v, double hrad); | ||
| 34 | |||
| 35 | //============================================================================= | ||
| 36 | |||
| 37 | 134 | double forcemain_getEquivN(int j, int k) | |
| 38 | // | ||
| 39 | // Input: j = link index | ||
| 40 | // k = conduit index | ||
| 41 | // Output: returns an equivalent Manning's n for a force main | ||
| 42 | // Purpose: computes a Mannng's n that results in the same normal flow | ||
| 43 | // value for a force main flowing full under fully turbulent | ||
| 44 | // conditions using either the Hazen-Williams or Dary-Weisbach | ||
| 45 | // flow equations. | ||
| 46 | // | ||
| 47 | { | ||
| 48 | 134 | TXsect xsect = Link[j].xsect; | |
| 49 | double f; | ||
| 50 | 134 | double d = xsect.yFull; | |
| 51 |
2/3✓ Branch 0 taken 126 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
134 | switch ( ForceMainEqn ) |
| 52 | { | ||
| 53 | 126 | case H_W: | |
| 54 | 126 | return 1.067 / xsect.rBot * pow(d/Conduit[k].slope, 0.04); | |
| 55 | 8 | case D_W: | |
| 56 | 8 | f = forcemain_getFricFactor(xsect.rBot, d/4.0, 1.0e12); | |
| 57 | 8 | return sqrt(f/185.0) * pow(d, (1./6.)); | |
| 58 | } | ||
| 59 | ✗ | return Conduit[k].roughness; | |
| 60 | } | ||
| 61 | |||
| 62 | //============================================================================= | ||
| 63 | |||
| 64 | 134 | double forcemain_getRoughFactor(int j, double lengthFactor) | |
| 65 | // | ||
| 66 | // Input: j = link index | ||
| 67 | // lengthFactor = factor by which a pipe will be artifically lengthened | ||
| 68 | // Output: returns a roughness adjustment factor for a force main | ||
| 69 | // Purpose: computes an adjustment factor for a force main that compensates for | ||
| 70 | // any artificial lengthening the pipe may have received. | ||
| 71 | // | ||
| 72 | { | ||
| 73 | 134 | TXsect xsect = Link[j].xsect; | |
| 74 | double r; | ||
| 75 |
2/3✓ Branch 0 taken 126 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
|
134 | switch ( ForceMainEqn ) |
| 76 | { | ||
| 77 | 126 | case H_W: | |
| 78 | 126 | r = 1.318*xsect.rBot*pow(lengthFactor, 0.54); | |
| 79 | 126 | return GRAVITY / pow(r, 1.852); | |
| 80 | 8 | case D_W: | |
| 81 | 8 | return 1.0/8.0/lengthFactor; | |
| 82 | } | ||
| 83 | ✗ | return 0.0; | |
| 84 | } | ||
| 85 | |||
| 86 | //============================================================================= | ||
| 87 | |||
| 88 | 23626 | double forcemain_getFricSlope(int j, double v, double hrad) | |
| 89 | // | ||
| 90 | // Input: j = link index | ||
| 91 | // v = flow velocity (ft/sec) | ||
| 92 | // hrad = hydraulic radius (ft) | ||
| 93 | // Output: returns a force main pipe's friction slope | ||
| 94 | // Purpose: computes the headloss per unit length used in dynamic wave | ||
| 95 | // flow routing for a pressurized force main using either the | ||
| 96 | // Hazen-Williams or Darcy-Weisbach flow equations. | ||
| 97 | // Note: the pipe's roughness factor was saved in xsect.sBot in | ||
| 98 | // conduit_validate() in LINK.C. | ||
| 99 | // | ||
| 100 | { | ||
| 101 | double re, f; | ||
| 102 | 23626 | TXsect xsect = Link[j].xsect; | |
| 103 |
2/3✓ Branch 0 taken 570 times.
✓ Branch 1 taken 23056 times.
✗ Branch 2 not taken.
|
23626 | switch ( ForceMainEqn ) |
| 104 | { | ||
| 105 | 570 | case H_W: | |
| 106 | 570 | return xsect.sBot * pow(v, 0.852) / pow(hrad, 1.1667); | |
| 107 | 23056 | case D_W: | |
| 108 | 23056 | re = forcemain_getReynolds(v, hrad); | |
| 109 | 23056 | f = forcemain_getFricFactor(xsect.rBot, hrad, re); | |
| 110 | 23056 | return f * xsect.sBot * v / hrad; | |
| 111 | } | ||
| 112 | ✗ | return 0.0; | |
| 113 | } | ||
| 114 | |||
| 115 | //============================================================================= | ||
| 116 | |||
| 117 | 23056 | double forcemain_getReynolds(double v, double hrad) | |
| 118 | // | ||
| 119 | // Input: v = flow velocity (ft/sec) | ||
| 120 | // hrad = hydraulic radius (ft) | ||
| 121 | // Output: returns a flow's Reynolds Number | ||
| 122 | // Purpose: computes a flow's Reynolds Number | ||
| 123 | // | ||
| 124 | { | ||
| 125 | 23056 | return 4.0 * hrad * v / VISCOS; | |
| 126 | } | ||
| 127 | |||
| 128 | //============================================================================= | ||
| 129 | |||
| 130 | 23064 | double forcemain_getFricFactor(double e, double hrad, double re) | |
| 131 | // | ||
| 132 | // Input: e = roughness height (ft) | ||
| 133 | // hrad = hydraulic radius (ft) | ||
| 134 | // re = Reynolds number | ||
| 135 | // Output: returns a Darcy-Weisbach friction factor | ||
| 136 | // Purpose: computes the Darcy-Weisbach friction factor for a force main | ||
| 137 | // using the Swamee and Jain approximation to the Colebrook-White | ||
| 138 | // equation. | ||
| 139 | // | ||
| 140 | { | ||
| 141 | double f; | ||
| 142 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23064 times.
|
23064 | if ( re < 10.0 ) re = 10.0; |
| 143 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23064 times.
|
23064 | if ( re <= 2000.0 ) f = 64.0 / re; |
| 144 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23064 times.
|
23064 | else if ( re < 4000.0 ) |
| 145 | { | ||
| 146 | ✗ | f = forcemain_getFricFactor(e, hrad, 4000.0); | |
| 147 | ✗ | f = 0.032 + (f - 0.032) * ( re - 2000.0) / 2000.0; | |
| 148 | } | ||
| 149 | else | ||
| 150 | { | ||
| 151 | 23064 | f = e/3.7/(4.0*hrad); | |
| 152 |
2/2✓ Branch 0 taken 23056 times.
✓ Branch 1 taken 8 times.
|
23064 | if ( re < 1.0e10 ) f += 5.74/pow(re, 0.9); |
| 153 | 23064 | f = log10(f); | |
| 154 | 23064 | f = 0.25 / f / f; | |
| 155 | } | ||
| 156 | 23064 | return f; | |
| 157 | } | ||
| 158 |