Skip to content

Commit 8266e44

Browse files
authored
Merge pull request #390 from OpenWaterAnalytics/develop
2 parents 1ea204b + 2e5b21d commit 8266e44

36 files changed

+1155
-283
lines changed

.github/workflows/build-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
- name: Before reg test
145145
env:
146146
NRTESTS_URL: https://github.com/OpenWaterAnalytics/swmm-nrtestsuite
147-
BENCHMARK_TAG: v3.0.0
147+
BENCHMARK_TAG: v3.0.1
148148
run: ./${{ matrix.before_reg_test }} ${{ env.BENCHMARK_TAG }}
149149

150150
- name: Run reg test

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# CMakeLists.txt - CMake configuration file for swmm-solver
33
#
44
# Created: July 11, 2019
5-
# Updated: May 19, 2021
5+
# Modified: Aug 16, 2022
66
#
77
# Authors: Michael E. Tryby
88
# US EPA ORD/CESER
@@ -22,7 +22,7 @@ endif()
2222

2323

2424
project(swmm-solver
25-
VERSION 5.2.1
25+
VERSION 5.2.3
2626
LANGUAGES C CXX
2727
)
2828

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Stormwater-Management-Model
22

3-
ORD Stormwater Management Model (aka "SWMM")
3+
Stormwater Management Model (aka "SWMM") solver only
44

55
## Introduction
66
This is the open source SWMM source code repository maintained by the Open

src/solver/consts.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Project: EPA SWMM5
55
// Version: 5.2
6-
// Date: 06/01/22 (Build 5.2.1)
6+
// Date: 02/12/23 (Build 5.2.3)
77
// Author: L. Rossman
88
//
99
// Various Constants
@@ -17,7 +17,7 @@
1717
//------------------
1818

1919
// OWA Version string stored in version.h
20-
// #define VERSION 52001
20+
// #define VERSION 52003
2121
#define MAGICNUMBER 516114522
2222
#define EOFMARK 0x1A // Use 0x04 for UNIX systems
2323
#define MAXTITLE 3 // Max. # title lines

src/solver/controls.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,8 @@ void updateActionList(struct TAction* a)
11981198
listItem->next = ActionList;
11991199
ActionList = listItem;
12001200
}
1201-
listItem->action = a;
1202-
}
1201+
listItem->action = a;
1202+
}
12031203

12041204
//=============================================================================
12051205

src/solver/enums.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,18 @@
116116
// Cross section shape types
117117
//-------------------------------------
118118
enum XsectType {
119-
DUMMY, // 0
119+
DUMMY, // 0
120120
CIRCULAR, // 1 closed
121121
FILLED_CIRCULAR, // 2 closed
122122
RECT_CLOSED, // 3 closed
123-
RECT_OPEN, // 4
124-
TRAPEZOIDAL, // 5
125-
TRIANGULAR, // 6
123+
RECT_OPEN, // 4
124+
TRAPEZOIDAL, // 5
125+
TRIANGULAR, // 6
126126
PARABOLIC, // 7
127-
POWERFUNC, // 8
128-
RECT_TRIANG, // 9
127+
POWERFUNC, // 8
128+
RECT_TRIANG, // 9
129129
RECT_ROUND, // 10
130-
MOD_BASKET, // 11
130+
MOD_BASKET, // 11
131131
HORIZ_ELLIPSE, // 12 closed
132132
VERT_ELLIPSE, // 13 closed
133133
ARCH, // 14 closed
@@ -197,7 +197,7 @@
197197
//-------------------------------------
198198
// Computed node quantities
199199
//-------------------------------------
200-
#define MAX_NODE_RESULTS 7
200+
#define MAX_NODE_RESULTS 7
201201
enum NodeResultType {
202202
NODE_DEPTH, // water depth above invert
203203
NODE_HEAD, // hydraulic head
@@ -418,7 +418,7 @@ enum CompatibilityType {
418418

419419
enum PumpCurveType {
420420
TYPE1_PUMP, // flow varies stepwise with wet well volume
421-
TYPE2_PUMP, // flow varies stepwise with inlet depth
421+
TYPE2_PUMP, // flow varies stepwise with inlet depth
422422
TYPE3_PUMP, // flow varies with head delivered
423423
TYPE4_PUMP, // flow varies with inlet depth
424424
TYPE5_PUMP, // variable speed version of TYPE3 pump

src/solver/funcs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void report_writeTimeStepStats(TTimeStepStats* timeStepStats);
9393
void report_writeErrorMsg(int code, char* msg);
9494
void report_writeErrorCode(void);
9595
void report_writeInputErrorMsg(int k, int sect, char* line, long lineCount);
96-
void report_writeWarningMsg(char* msg, char* id);
96+
void report_writeWarningMsg(char* msg, char* id);
9797
void report_writeTseriesErrorMsg(int code, TTable *tseries);
9898

9999
void inputrpt_writeInput(void);
@@ -270,7 +270,7 @@ void massbal_addSeepageLoss(int pollut, double seepLoss);
270270
void massbal_addToFinalStorage(int pollut, double mass);
271271
double massbal_getStepFlowError(void);
272272
double massbal_getRunoffError(void);
273-
double massbal_getFlowError(void);
273+
double massbal_getFlowError(char isFinalStorage); // OWA EDIT - added isFinalStorage param to allow running flow error calcs
274274

275275
//-----------------------------------------------------------------------------
276276
// Simulation Statistics Methods
@@ -496,7 +496,7 @@ void controls_addToCount(char* s);
496496
int controls_addVariable(char* tok[], int ntoks);
497497
int controls_addExpression(char* tok[], int ntoks);
498498
int controls_addRuleClause(int rule, int keyword, char* Tok[], int nTokens);
499-
int controls_evaluate(DateTime currentTime, DateTime elapsedTime,
499+
int controls_evaluate(DateTime currentTime, DateTime elapsedTime,
500500
double tStep);
501501

502502
//-----------------------------------------------------------------------------

src/solver/gage.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void gage_setState(int j, DateTime t)
406406
// --- otherwise update next rainfall interval date
407407
Gage[j].startDate = Gage[j].nextDate;
408408
Gage[j].endDate = datetime_addSeconds(Gage[j].startDate,
409-
Gage[j].rainInterval);
409+
Gage[j].rainInterval);
410410
Gage[j].rainfall = Gage[j].nextRainfall;
411411
if ( !getNextRainfall(j) ) Gage[j].nextDate = NO_DATE;
412412
}
@@ -670,11 +670,11 @@ int getNextRainfall(int j)
670670
{
671671
if ( Frain.file && Gage[j].currentFilePos < Gage[j].endFilePos )
672672
{
673-
fseek(Frain.file, Gage[j].currentFilePos, SEEK_SET);
674-
fread(&Gage[j].nextDate, sizeof(DateTime), 1, Frain.file);
675-
fread(&vNext, sizeof(float), 1, Frain.file);
676-
Gage[j].currentFilePos = ftell(Frain.file);
677-
rNext = convertRainfall(j, (double)vNext);
673+
fseek(Frain.file, Gage[j].currentFilePos, SEEK_SET);
674+
fread(&Gage[j].nextDate, sizeof(DateTime), 1, Frain.file);
675+
fread(&vNext, sizeof(float), 1, Frain.file);
676+
Gage[j].currentFilePos = ftell(Frain.file);
677+
rNext = convertRainfall(j, (double)vNext);
678678
}
679679
else return 0;
680680
}
@@ -684,9 +684,9 @@ int getNextRainfall(int j)
684684
k = Gage[j].tSeries;
685685
if ( k >= 0 )
686686
{
687-
if ( !table_getNextEntry(&Tseries[k],
688-
&Gage[j].nextDate, &rNext) ) return 0;
689-
rNext = convertRainfall(j, rNext);
687+
if ( !table_getNextEntry(&Tseries[k],
688+
&Gage[j].nextDate, &rNext) ) return 0;
689+
rNext = convertRainfall(j, rNext);
690690
}
691691
else return 0;
692692
}

src/solver/globals.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// - Minimum dynamic wave routing variable time step added.
2020
// Build 5.1.011:
2121
// - Changed WarningCode to Warnings (# warnings issued)
22-
// - Added error message text as a variable.
22+
// - Added error message text as a variable.
2323
// - Added elapsed simulation time (in decimal days) variable.
2424
// - Added variables associated with detailed routing events.
2525
// Build 5.1.012:

src/solver/include/toolkit.h

+30
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "../enums.h"
2626
#include "../datetime.h"
2727
#include "../lid.h"
28+
#include "../inlet.h"
2829

2930
#ifdef __cplusplus
3031
extern "C" {
@@ -312,6 +313,24 @@ EXPORT_TOOLKIT int swmm_getLinkParam(int index, SM_LinkProperty param, double *v
312313
*/
313314
EXPORT_TOOLKIT int swmm_setLinkParam(int index, SM_LinkProperty param, double value);
314315

316+
/**
317+
@brief Get a property value for the inlets of a specified link.
318+
@param index The index of a link
319+
@param Param The property type code (See @ref SM_InletProperty)
320+
@param[out] value The value of the inlet's property
321+
@return Error code
322+
*/
323+
EXPORT_TOOLKIT int swmm_getInletParam(int index, SM_InletProperty param, double *value);
324+
325+
/**
326+
@brief Set a property value for the inlets of a specified link.
327+
@param index The index of a link
328+
@param Param The property type code (See @ref SM_InletProperty)
329+
@param value The new value of the inlet's property
330+
@return Error code
331+
*/
332+
EXPORT_TOOLKIT int swmm_setInletParam(int index, SM_InletProperty param, double value);
333+
315334
/**
316335
@brief Get a property value for specified subcatchment.
317336
@param index The index of a subcatchment
@@ -421,6 +440,17 @@ EXPORT_TOOLKIT int swmm_setLinkPollut(int index, SM_LinkPollut type, int polluta
421440
*/
422441
EXPORT_TOOLKIT int swmm_getLinkResult(int index, SM_LinkResult type, double *result);
423442

443+
/**
444+
@brief Gets results for the inlets of a specified link.
445+
@param index The index of a link with inlets
446+
@param type The result type code (See @ref SM_InletResult)
447+
@param result Pollutant index to set
448+
@param[out] result The result of the inlet's property
449+
@return Error code
450+
*/
451+
EXPORT_TOOLKIT int swmm_getInletResult(int index, SM_InletResult type, double *result);
452+
453+
424454
/**
425455
@brief Gets pollutant values for a specified link.
426456
@param index The index of a link

src/solver/include/toolkit_enums.h

+16
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,21 @@ typedef enum {
275275
SM_STORAGEDRAIN = 29, /**< Underdrain flow rate layer */
276276
} SM_LidResult;
277277

278+
typedef enum {
279+
SM_INLETNUMINLETS = 0,
280+
SM_INLETCLOGFACTOR = 1,
281+
SM_INLETFLOWLIMIT = 2,
282+
SM_INLETLOCALDEPRESS = 3,
283+
SM_INLETLOCALWIDTH = 4
284+
} SM_InletProperty;
285+
286+
typedef enum {
287+
SM_INLETFLOWFACTOR = 0,
288+
SM_INLETFLOWCAPTURE = 1,
289+
SM_INLETBACKFLOW = 2,
290+
SM_INLETBACKFLOWRATIO = 3,
291+
292+
} SM_InletResult;
293+
278294

279295
#endif /* TOOLKIT_ENUMS_H_ */

src/solver/include/toolkit_error.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ enum ToolkitErrorType {
1313
ERR_TKAPI_LIDUNIT_INDEX = 2009,
1414
ERR_TKAPI_UNDEFINED_LID = 2010,
1515
ERR_TKAPI_MEMORY = 2011,
16+
ERR_TKAPI_NO_INLET = 2012,
1617

1718
TKMAXERRMSG = 3000
1819
};

src/solver/include/toolkit_errors.txt

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ERR(2008, "\n API Key Error: Invalid Pattern Index")
1212
ERR(2009, "\n API Key Error: Invalid Lid Unit Index")
1313
ERR(2010, "\n API Key Error: Undefined Subcatchment Lid")
1414
ERR(2011, "\n API Key Error: No memory allocated for return value")
15+
ERR(2012, "\n API Key Error: Specified link is not assigned an inlet")

src/solver/inlet.c

+22-45
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Project: EPA SWMM5
55
// Version: 5.2
6-
// Date: 06/01/22 (Build 5.2.1)
6+
// Date: 10/08/22 (Build 5.2.2)
77
// Author: L. Rossman
88
//
99
// Street/Channel Inlet Functions
@@ -16,6 +16,8 @@
1616
//
1717
// Build 5.2.1:
1818
// - Substitutes the constant BIG for HUGE.
19+
// Build 5.2.2:
20+
// - Additional statistics added to Street Flow Summary table.
1921
//-----------------------------------------------------------------------------
2022
#define _CRT_SECURE_NO_DEPRECATE
2123

@@ -68,38 +70,7 @@ typedef struct
6870
} TInletDesign;
6971

7072

71-
// Inlet performance statistics
72-
typedef struct
73-
{
74-
int flowPeriods; // # periods with approach flow
75-
int capturePeriods; // # periods with captured flow
76-
int backflowPeriods; // # periods with backflow
77-
double peakFlow; // peak flow seen by inlet (cfs)
78-
double peakFlowCapture; // capture efficiency at peak flow
79-
double avgFlowCapture; // average capture efficiency
80-
double bypassFreq; // frequency of bypass flow
81-
} TInletStats;
82-
83-
// Inlet list object
84-
struct TInlet
85-
{
86-
int linkIndex; // index of conduit link with the inlet
87-
int designIndex; // index of inlet's design
88-
int nodeIndex; // index of node receiving captured flow
89-
int numInlets; // # inlets on each side of street or in channel
90-
int placement; // whether inlet is on-grade or on-sag
91-
double clogFactor; // fractional degree of inlet clogging
92-
double flowLimit; // inlet flow restriction (cfs)
93-
double localDepress; // local gutter depression (ft)
94-
double localWidth; // local depression width (ft)
95-
96-
double flowFactor; // flow = flowFactor * (flow spread)^2.67
97-
double flowCapture; // captured flow rate (cfs)
98-
double backflow; // backflow from capture node (cfs)
99-
double backflowRatio; // inlet backflow / capture node overflow
100-
TInletStats stats; // inlet performance statistics
101-
TInlet * nextInlet; // next inlet in list
102-
};
73+
// OWA EDIT - TInlet and TInletStats struct defs moved to inlet.h to be shared by toolkit.c
10374

10475
// Shared inlet variables
10576
TInletDesign * InletDesigns; // array of available inlet designs
@@ -1030,17 +1001,18 @@ void writeStreetStatsHeader()
10301001
report_writeLine("*******************");
10311002
report_writeLine("");
10321003
fprintf(Frpt.file,
1033-
"\n ----------------------------------------------------------------------------------------------------------------------"
1034-
"\n Peak Maximum Maximum Peak Flow Average Bypass BackFlow"
1035-
"\n Flow Spread Depth Inlet Inlet Capture Capture Frequency Frequency");
1004+
"\n ---------------------------------------------------------------------------------------------------------------------------------------"
1005+
"\n Peak Avg. Bypass Back Peak Peak"
1006+
"\n Peak Maximum Maximum Flow Flow Flow Flow Capture Bypass"
1007+
"\n Flow Spread Depth Inlet Inlet Inlet Capture Capture Freq Freq / Inlet Flow");
10361008
if (UnitSystem == US) fprintf(Frpt.file,
1037-
"\n Street Conduit %3s ft ft Design Location %% %% %% %%",
1038-
FlowUnitWords[FlowUnits]);
1009+
"\n Street Conduit %3s ft ft Design Location Count Pcnt Pcnt Pcnt Pcnt %3s %3s",
1010+
FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits]);
10391011
else fprintf(Frpt.file,
1040-
"\n Street Conduit %3s m m Design Location %% %% %% %%",
1041-
FlowUnitWords[FlowUnits]);
1012+
"\n Street Conduit %3s m m Design Location Pcnt Pcnt Pcnt Pcnt %3s %3s",
1013+
FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits]);
10421014
fprintf(Frpt.file,
1043-
"\n ----------------------------------------------------------------------------------------------------------------------");
1015+
"\n ---------------------------------------------------------------------------------------------------------------------------------------");
10441016
}
10451017

10461018
//=============================================================================
@@ -1095,19 +1067,24 @@ void writeStreetStats(int link)
10951067
fprintf(Frpt.file, " ON-GRADE");
10961068
else
10971069
fprintf(Frpt.file, " ON-SAG ");
1070+
fprintf(Frpt.file, " %5d", inlet->numInlets);
10981071
fp = inlet->stats.flowPeriods / 100.0;
10991072
if (fp > 0.0)
11001073
{
11011074
cp = inlet->stats.capturePeriods / 100.0;
1102-
fprintf(Frpt.file, " %9.2f", inlet->stats.peakFlowCapture);
1075+
fprintf(Frpt.file, " %7.2f", inlet->stats.peakFlowCapture);
11031076
if (cp > 0.0)
11041077
{
11051078
afc = inlet->stats.avgFlowCapture / cp;
11061079
bpf = inlet->stats.bypassFreq / cp;
11071080
}
1108-
fprintf(Frpt.file, " %9.2f", afc);
1109-
fprintf(Frpt.file, " %9.2f", bpf);
1110-
fprintf(Frpt.file, " %9.2f", inlet->stats.backflowPeriods / fp);
1081+
fprintf(Frpt.file, " %7.2f", afc);
1082+
fprintf(Frpt.file, " %7.2f", bpf);
1083+
fprintf(Frpt.file, " %7.2f", inlet->stats.backflowPeriods / fp);
1084+
fprintf(Frpt.file, " %7.2f", (maxFlow / Street[t].sides) * UCF(FLOW) *
1085+
0.01 * inlet->stats.peakFlowCapture / inlet->numInlets);
1086+
fprintf(Frpt.file, " %7.2f", maxFlow * UCF(FLOW) * 0.01 *
1087+
(100.0 - inlet->stats.peakFlowCapture));
11111088
}
11121089
}
11131090
}

0 commit comments

Comments
 (0)