Skip to content

Commit

Permalink
Merge pull request #400 from pyswmm/merge_usepa524
Browse files Browse the repository at this point in the history
  • Loading branch information
karosc authored Sep 2, 2023
2 parents 08d1322 + 6250d2c commit c760dbf
Show file tree
Hide file tree
Showing 18 changed files with 202 additions and 114 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2022, ubuntu-20.04, macos-13.4]
os: [windows-2022, ubuntu-20.04, macos-12]
requirements: [requirements-swmm.txt]
include:
- os: windows-2022
Expand Down Expand Up @@ -58,9 +58,9 @@ jobs:
shell: bash
working-directory: ./ci-tools/linux

- os: macos-13.4
- os: macos-12
sys_pkgs: brew install libomp #boost
boost_platform_version: 13.4
boost_platform_version: 12
boost_toolsit: clang
build_unit_test: make.zsh -t -g "Xcode"
build_reg_test: make.zsh -g "Xcode"
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- name: Clone ci-tools repo
uses: actions/checkout@v3
with:
repository: OpenWaterAnalytics/ci-tools
repository: pyswmm/ci-tools
ref: master
path: ci-tools

Expand Down Expand Up @@ -143,8 +143,8 @@ jobs:

- name: Before reg test
env:
NRTESTS_URL: https://github.com/OpenWaterAnalytics/swmm-nrtestsuite
BENCHMARK_TAG: v3.0.2
NRTESTS_URL: https://github.com/pyswmm/swmm-nrtestsuite
BENCHMARK_TAG: v3.1.0
run: ./${{ matrix.before_reg_test }} ${{ env.BENCHMARK_TAG }}

- name: Run reg test
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()


project(swmm-solver
VERSION 5.2.3
VERSION 5.2.4
LANGUAGES C CXX
)

Expand Down
4 changes: 2 additions & 2 deletions src/solver/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 02/12/23 (Build 5.2.3)
// Date: 07/15/23 (Build 5.2.4)
// Author: L. Rossman
//
// Various Constants
Expand All @@ -17,7 +17,7 @@
//------------------

// OWA Version string stored in version.h
// #define VERSION 52003
// #define VERSION 52004
#define MAGICNUMBER 516114522
#define EOFMARK 0x1A // Use 0x04 for UNIX systems
#define MAXTITLE 3 // Max. # title lines
Expand Down
6 changes: 4 additions & 2 deletions src/solver/dwflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 08/01/22 (Build 5.2.1)
// Date: 06/12/23 (Build 5.2.4)
// Author: L. Rossman
// M. Tryby (EPA)
// R. Dickinson (CDM)
Expand All @@ -26,6 +26,8 @@
// (qOld) in call to link_getLossRate.
// Build 5.2.1:
// - Implements the new option to skip checking for normal flow limitations.
// Build 5.2.4:
// - Arguments to function link_getLossRate changed.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -231,7 +233,7 @@ void dwflow_findConduitFlow(int j, int steps, double omega, double dt)
}

// --- 6. term for evap and seepage losses per unit length
dq6 = link_getLossRate(j, qLast) * 2.5 * dt * v / link_getLength(j);
dq6 = link_getLossRate(j, DW, qLast, dt) * 2.5 * dt * v / link_getLength(j);

// --- combine terms to find new conduit flow
denom = 1.0 + dq1 + dq5;
Expand Down
49 changes: 31 additions & 18 deletions src/solver/dynwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 11/01/21 (Build 5.2.0)
// Date: 07/13/23 (Build 5.2.4)
// Author: L. Rossman
// M. Tryby (EPA)
// R. Dickinson (CDM)
Expand Down Expand Up @@ -44,6 +44,9 @@
// - Roll back the 5.1.014 change for conduit losses in updateNodeFlows().
// Build 5.2.0:
// - Support added for reporting most frequent non-converging links.
// Build 5.2.4:
// - Conduit evap+seepage outflow split evenly between outflow from
// conduit's upstream and non-outfall downstream nodes.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -129,7 +132,7 @@ void dynwave_init()
" Not enough memory for dynamic wave routing.");
return;
}

// --- initialize node surface areas & crown elev.
for (i = 0; i < Nobjects[NODE]; i++ )
{
Expand All @@ -144,6 +147,7 @@ void dynwave_init()
j = Link[i].node1;
z = Node[j].invertElev + Link[i].offset1 + Link[i].xsect.yFull;
Node[j].crownElev = MAX(Node[j].crownElev, z);

j = Link[i].node2;
z = Node[j].invertElev + Link[i].offset2 + Link[i].xsect.yFull;
Node[j].crownElev = MAX(Node[j].crownElev, z);
Expand Down Expand Up @@ -534,29 +538,39 @@ void updateNodeFlows(int i)
int n1 = Link[i].node1;
int n2 = Link[i].node2;
double q = Link[i].newFlow;
double uniformLossRate = 0.0;

// --- compute any uniform seepage loss from a conduit
if ( Link[i].type == CONDUIT )
{
k = Link[i].subIndex;
uniformLossRate = Conduit[k].evapLossRate + Conduit[k].seepLossRate;
barrels = Conduit[k].barrels;
uniformLossRate *= barrels;
}
double conduitLossRate = 0.0;

// --- update total inflow & outflow at upstream/downstream nodes
if ( q >= 0.0 )
{
Node[n1].outflow += q + uniformLossRate;
Node[n1].outflow += q;
Node[n2].inflow += q;
}
else
{
Node[n1].inflow -= q;
Node[n2].outflow -= q - uniformLossRate;
Node[n2].outflow -= q;
}


// --- add any uniform evap & seepage loss from conduit link
if ( Link[i].type == CONDUIT )
{
k = Link[i].subIndex;
barrels = Conduit[k].barrels;
conduitLossRate = (Conduit[k].evapLossRate + Conduit[k].seepLossRate) *
barrels;
if (conduitLossRate > 0.0)
{
// --- outfall nodes do not share evap & seepage losses
if (Node[n1].type != OUTFALL && Node[n2].type != OUTFALL)
conduitLossRate /= 2.0;
if (Node[n1].type != OUTFALL)
Node[n1].outflow += conduitLossRate;
if (Node[n2].type != OUTFALL)
Node[n2].outflow += conduitLossRate;
}
}

// --- add surf. area contributions to upstream/downstream nodes
Xnode[Link[i].node1].newSurfArea += Link[i].surfArea1 * barrels;
Xnode[Link[i].node2].newSurfArea += Link[i].surfArea2 * barrels;
Expand Down Expand Up @@ -585,7 +599,7 @@ int findNodeDepths(double dt)
//
{
int i;
double yOld; // previous node depth (ft)
double yOld = 0.0; // previous node depth (ft)

// --- compute outfall depths based on flow in connecting link
for ( i = 0; i < Nobjects[LINK]; i++ ) link_setOutfallDepth(i);
Expand Down Expand Up @@ -654,12 +668,11 @@ void setNodeDepth(int i, double dt)
Node[i].overflow = 0.0;
surfArea = Xnode[i].newSurfArea;
surfArea = MAX(surfArea, MinSurfArea);

// --- determine average net flow volume into node over the time step
dQ = Node[i].inflow - Node[i].outflow;
dV = 0.5 * (Node[i].oldNetInflow + dQ) * dt;


// --- determine if node is EXTRAN surcharged
if (SurchargeMethod == EXTRAN)
{
Expand Down
6 changes: 4 additions & 2 deletions src/solver/flowrout.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 05/02/22 (Build 5.2.1)
// Date: 06/12/23 (Build 5.2.4)
// Author: L. Rossman
// M. Tryby (EPA)
//
Expand All @@ -27,6 +27,8 @@
// Build 5.2.1:
// - For storage routing, after convergence the reported depth is now
// based on the last volume found rather than the next trial depth.
// Build 5.2.4:
// - Arguments to link_getLossRate changed.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -767,7 +769,7 @@ int steadyflow_execute(int j, double* qin, double* qout, double tStep)
else
{
// --- adjust flow for evap and infil losses
q -= link_getLossRate(j, q);
q -= link_getLossRate(j, SF, q, tStep);

// --- flow can't exceed full flow
if ( q > Link[j].qFull )
Expand Down
6 changes: 4 additions & 2 deletions src/solver/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 11/01/21 (Build 5.2.0)
// Date: 06/12/23 (Build 5.2.4)
// Author: L. Rossman
// M. Tryby (EPA)
//
Expand All @@ -29,6 +29,8 @@
// - Support added for named variables & math expressions in control rules.
// - Support added for tracking a gage's prior n-hour rainfall total.
// - Refactored external inflow code.
// Build 5.2.4:
// - Additional arguments added to function link_getLossRate.
//-----------------------------------------------------------------------------

#ifndef FUNCS_H
Expand Down Expand Up @@ -425,7 +427,7 @@ double link_getYnorm(int link, double q);
double link_getVelocity(int link, double q, double y);
double link_getFroude(int link, double v, double y);
double link_getPower(int link);
double link_getLossRate(int link, double q);
double link_getLossRate(int link, int routeModel, double q, double tstep);
char link_getFullState(double a1, double a2, double aFull);

void link_getResults(int link, double wt, float x[]);
Expand Down
12 changes: 8 additions & 4 deletions src/solver/inlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 10/08/22 (Build 5.2.2)
// Date: 07/13/23 (Build 5.2.4)
// Author: L. Rossman
//
// Street/Channel Inlet Functions
Expand All @@ -18,6 +18,10 @@
// - Substitutes the constant BIG for HUGE.
// Build 5.2.2:
// - Additional statistics added to Street Flow Summary table.
// Build 5.2.4:
// - Fixed expression for equivalent gutter slope in getCurbInletCapture.
// - Corrected sign in equation for effective head in a curb inlet
// with an inclined throat opening in getCurbOrificeFlow.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -1444,7 +1448,7 @@ double getCurbInletCapture(double Q, double L)
// Input: Q = flow rate seen by inlet (cfs)
// L = length of inlet opening (ft)
// Output: returns captured flow rate (cfs)
// Purpose: finds the flow captured by an on-sag inlet.
// Purpose: finds the flow captured by an on-grade curb opening inlet.
//
{
double Se = Sx, // equivalent gutter slope
Expand All @@ -1460,7 +1464,7 @@ double getCurbInletCapture(double Q, double L)
{
Sr = Sw / Sx;
Eo = getEo(Sr, T-W, W);
Se = Sx + Sw * Eo; //HEC-22 Eq(4-24)
Se = Sx + (a/W) * Eo; //HEC-22 Eq(4-24)
}

// --- opening length for full capture
Expand Down Expand Up @@ -1741,7 +1745,7 @@ double getCurbOrificeFlow(double di, double h, double L, int throatAngle)
if (throatAngle == HORIZONTAL_THROAT)
d = di - h / 2.0;
else if (throatAngle == INCLINED_THROAT)
d = di + (h / 2.0) * 0.7071;
d = di - (h / 2.0) * 0.7071;
return 0.67 * h * L * sqrt(2.0 * 32.16 * d); //HEC-22 Eq(4-31a)
}

Expand Down
6 changes: 4 additions & 2 deletions src/solver/kinwave.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 11/01/21 (Build 5.2.0)
// Date: 06/12/23 (Build 5.2.4)
// Author: L. Rossman
// M. Tryby (EPA)
//
Expand All @@ -15,6 +15,8 @@
// - Conduit inflow passed to function that computes conduit losses.
// Build 5.1.014:
// - Arguments to function link_getLossRate changed.
// Build 5.2.4:
// - Arguments to function link_getLossRate changed again.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -100,7 +102,7 @@ int kinwave_execute(int j, double* qinflow, double* qoutflow, double tStep)
qin = (*qinflow) / Conduit[k].barrels / Qfull;

// --- compute evaporation and infiltration loss rate
q3 = link_getLossRate(j, qin*Qfull) / Qfull;
q3 = link_getLossRate(j, KW, qin*Qfull, tStep) / Qfull;

// --- normalize previous areas
a1 = Conduit[k].a1 / Afull;
Expand Down
7 changes: 5 additions & 2 deletions src/solver/lid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Project: EPA SWMM5
// Version: 5.2
// Date: 02/10/23 (Build 5.2.3)
// Date: 07/13/23 (Build 5.2.4)
// Author: L. Rossman
//
// This module handles all data processing involving LID (Low Impact
Expand Down Expand Up @@ -70,6 +70,8 @@
// - Covered property added to RAIN_BARREL parameters
// Build 5.2.3
// - Fixed double counting of initial water volume in green roof drain mat.
// Build 5.2.4
// - Fixed test for invalid data in readDrainData function.
//-----------------------------------------------------------------------------
#define _CRT_SECURE_NO_DEPRECATE

Expand Down Expand Up @@ -786,7 +788,7 @@ int readDrainData(int j, char* toks[], int ntoks)
for (i = 0; i < 6; i++) x[i] = 0.0;
for (i = 2; i < 8; i++)
{
if ( (ntoks > i) && (! getDouble(toks[i], &x[i-2]) || x[i-2]) < 0.0 )
if ( (ntoks > i) && (! getDouble(toks[i], &x[i-2]) || x[i-2] < 0.0) )
return error_setInpError(ERR_NUMBER, toks[i]);
}

Expand Down Expand Up @@ -1084,6 +1086,7 @@ void validateLidProc(int j)
// moved clogging factor conversion logic to readStorageData and readPavementData
// in 14d2e62e9a6baad89f6cd2dc0c55907e1d2289b2 to allow multiple calls to validateLidProc
// in toolkit.c

//... for certain LID types, immediate overflow of excess surface water
// occurs if either the surface roughness or slope is zero
LidProcs[j].surface.canOverflow = TRUE;
Expand Down
Loading

0 comments on commit c760dbf

Please sign in to comment.