epanet-plus 0.1.0__cp314-cp314-macosx_10_15_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of epanet-plus might be problematic. Click here for more details.
- docs/conf.py +67 -0
- epanet-msx-src/dispersion.h +27 -0
- epanet-msx-src/hash.c +107 -0
- epanet-msx-src/hash.h +28 -0
- epanet-msx-src/include/epanetmsx.h +104 -0
- epanet-msx-src/include/epanetmsx_export.h +42 -0
- epanet-msx-src/mathexpr.c +937 -0
- epanet-msx-src/mathexpr.h +39 -0
- epanet-msx-src/mempool.c +204 -0
- epanet-msx-src/mempool.h +24 -0
- epanet-msx-src/msxchem.c +1285 -0
- epanet-msx-src/msxcompiler.c +368 -0
- epanet-msx-src/msxdict.h +42 -0
- epanet-msx-src/msxdispersion.c +586 -0
- epanet-msx-src/msxerr.c +116 -0
- epanet-msx-src/msxfile.c +260 -0
- epanet-msx-src/msxfuncs.c +175 -0
- epanet-msx-src/msxfuncs.h +35 -0
- epanet-msx-src/msxinp.c +1504 -0
- epanet-msx-src/msxout.c +398 -0
- epanet-msx-src/msxproj.c +791 -0
- epanet-msx-src/msxqual.c +2011 -0
- epanet-msx-src/msxrpt.c +400 -0
- epanet-msx-src/msxtank.c +422 -0
- epanet-msx-src/msxtoolkit.c +1164 -0
- epanet-msx-src/msxtypes.h +551 -0
- epanet-msx-src/msxutils.c +524 -0
- epanet-msx-src/msxutils.h +56 -0
- epanet-msx-src/newton.c +158 -0
- epanet-msx-src/newton.h +34 -0
- epanet-msx-src/rk5.c +287 -0
- epanet-msx-src/rk5.h +39 -0
- epanet-msx-src/ros2.c +293 -0
- epanet-msx-src/ros2.h +35 -0
- epanet-msx-src/smatrix.c +816 -0
- epanet-msx-src/smatrix.h +29 -0
- epanet-src/AUTHORS +60 -0
- epanet-src/LICENSE +21 -0
- epanet-src/enumstxt.h +151 -0
- epanet-src/epanet.c +5937 -0
- epanet-src/epanet2.c +961 -0
- epanet-src/epanet2.def +131 -0
- epanet-src/errors.dat +79 -0
- epanet-src/flowbalance.c +186 -0
- epanet-src/funcs.h +219 -0
- epanet-src/genmmd.c +1000 -0
- epanet-src/hash.c +177 -0
- epanet-src/hash.h +28 -0
- epanet-src/hydcoeffs.c +1303 -0
- epanet-src/hydraul.c +1164 -0
- epanet-src/hydsolver.c +781 -0
- epanet-src/hydstatus.c +442 -0
- epanet-src/include/epanet2.h +466 -0
- epanet-src/include/epanet2_2.h +1962 -0
- epanet-src/include/epanet2_enums.h +518 -0
- epanet-src/inpfile.c +884 -0
- epanet-src/input1.c +672 -0
- epanet-src/input2.c +970 -0
- epanet-src/input3.c +2265 -0
- epanet-src/leakage.c +527 -0
- epanet-src/mempool.c +146 -0
- epanet-src/mempool.h +24 -0
- epanet-src/output.c +853 -0
- epanet-src/project.c +1691 -0
- epanet-src/quality.c +695 -0
- epanet-src/qualreact.c +800 -0
- epanet-src/qualroute.c +696 -0
- epanet-src/report.c +1559 -0
- epanet-src/rules.c +1500 -0
- epanet-src/smatrix.c +871 -0
- epanet-src/text.h +508 -0
- epanet-src/types.h +928 -0
- epanet-src/util/cstr_helper.c +59 -0
- epanet-src/util/cstr_helper.h +38 -0
- epanet-src/util/errormanager.c +92 -0
- epanet-src/util/errormanager.h +39 -0
- epanet-src/util/filemanager.c +212 -0
- epanet-src/util/filemanager.h +81 -0
- epanet-src/validate.c +408 -0
- epanet.cpython-314-darwin.so +0 -0
- epanet_plus/VERSION +1 -0
- epanet_plus/__init__.py +8 -0
- epanet_plus/epanet_plus.c +118 -0
- epanet_plus/epanet_toolkit.py +2730 -0
- epanet_plus/epanet_wrapper.py +2429 -0
- epanet_plus/include/epanet_plus.h +9 -0
- epanet_plus-0.1.0.dist-info/METADATA +153 -0
- epanet_plus-0.1.0.dist-info/RECORD +106 -0
- epanet_plus-0.1.0.dist-info/WHEEL +6 -0
- epanet_plus-0.1.0.dist-info/licenses/LICENSE +21 -0
- epanet_plus-0.1.0.dist-info/top_level.txt +11 -0
- examples/basic_usage.py +35 -0
- examples/epanet_msx.py +35 -0
- python-extension/ext.c +344 -0
- python-extension/pyepanet.c +2150 -0
- python-extension/pyepanet.h +144 -0
- python-extension/pyepanet2.c +1835 -0
- python-extension/pyepanet2.h +142 -0
- python-extension/pyepanet_plus.c +37 -0
- python-extension/pyepanet_plus.h +4 -0
- python-extension/pyepanetmsx.c +388 -0
- python-extension/pyepanetmsx.h +35 -0
- tests/test_epanet.py +16 -0
- tests/test_epanetmsx.py +36 -0
- tests/test_epyt.py +114 -0
- tests/test_load_inp_from_buffer.py +18 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
/************************************************************************
|
|
2
|
+
** MODULE: TYPES.H
|
|
3
|
+
** PROJECT: EPANET-MSX
|
|
4
|
+
** DESCRIPTION: Global constants and data types used by the EPANET
|
|
5
|
+
** Multi-Species Extension toolkit.
|
|
6
|
+
** AUTHORS: see AUTHORS
|
|
7
|
+
** Copyright: see AUTHORS
|
|
8
|
+
** License: see LICENSE
|
|
9
|
+
** VERSION: 2.0.00
|
|
10
|
+
** LAST UPDATE: 08/30/2022
|
|
11
|
+
***********************************************************************/
|
|
12
|
+
|
|
13
|
+
#ifndef MSXTYPES_H
|
|
14
|
+
#define MSXTYPES_H
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
#include "mathexpr.h"
|
|
19
|
+
#include "mempool.h"
|
|
20
|
+
|
|
21
|
+
//-----------------------------------------------------------------------------
|
|
22
|
+
// Definition of 4-byte integers & reals
|
|
23
|
+
//-----------------------------------------------------------------------------
|
|
24
|
+
typedef int INT4;
|
|
25
|
+
typedef float REAL4;
|
|
26
|
+
|
|
27
|
+
//-----------------------------------------------------------------------------
|
|
28
|
+
// Macros for memory allocation
|
|
29
|
+
//-----------------------------------------------------------------------------
|
|
30
|
+
#define MEMCHECK(x) (((x) == NULL) ? ERR_MEMORY : 0 )
|
|
31
|
+
#define FREE(x) { if (x) { free(x); x = NULL; } }
|
|
32
|
+
|
|
33
|
+
//-----------------------------------------------------------------------------
|
|
34
|
+
// Conversion macros to be used in place of functions
|
|
35
|
+
//-----------------------------------------------------------------------------
|
|
36
|
+
#define INT(x) ((int)(x)) // integer portion of x
|
|
37
|
+
#define FRAC(x) ((x)-(int)(x)) // fractional part of x
|
|
38
|
+
#define ABS(x) (((x)<0) ? -(x) : (x)) // absolute value of x
|
|
39
|
+
#define MIN(x,y) (((x)<=(y)) ? (x) : (y)) // minimum of x and y
|
|
40
|
+
#define MAX(x,y) (((x)>=(y)) ? (x) : (y)) // maximum of x and y
|
|
41
|
+
#define ROUND(x) (((x)>=0) ? (int)((x)+.5) : (int)((x)-.5))
|
|
42
|
+
// round-off of x
|
|
43
|
+
#define MOD(x,y) ((x)%(y)) // x modulus y
|
|
44
|
+
#define SQR(x) ((x)*(x)) // x-squared
|
|
45
|
+
#define SGN(x) (((x)<0) ? (-1) : (1)) // sign of x
|
|
46
|
+
#define UCHAR(x) (((x) >= 'a' && (x) <= 'z') ? ((x)&~32) : (x))
|
|
47
|
+
// uppercase char of x
|
|
48
|
+
//-----------------------------------------------------------------------------
|
|
49
|
+
// Macro to evaluate function f with error checking
|
|
50
|
+
// (Fatal errors are numbered higher than 100)
|
|
51
|
+
//-----------------------------------------------------------------------------
|
|
52
|
+
#define CALL(err, f) (err = ( (err>100) ? (err) : (f) ))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
//-----------------------------------------------------------------------------
|
|
56
|
+
// Defined Constants
|
|
57
|
+
//-----------------------------------------------------------------------------
|
|
58
|
+
#define MAGICNUMBER 516114521
|
|
59
|
+
#define VERSION 200000
|
|
60
|
+
#define MAXMSG 1024 // Max. # characters in message text
|
|
61
|
+
#define MAXLINE 1024 // Max. # characters in input line
|
|
62
|
+
#define TRUE 1
|
|
63
|
+
#define FALSE 0
|
|
64
|
+
#define BIG 1.E10
|
|
65
|
+
#define TINY 1.E-6
|
|
66
|
+
#define MISSING -1.E10
|
|
67
|
+
#define PI 3.141592654
|
|
68
|
+
#define VISCOS 1.1E-5 // Kinematic viscosity of water
|
|
69
|
+
// @ 20 deg C (sq ft/sec)
|
|
70
|
+
|
|
71
|
+
//-----------------------------------------------------------------------------
|
|
72
|
+
// Various conversion factors
|
|
73
|
+
//-----------------------------------------------------------------------------
|
|
74
|
+
#define M2perFT2 0.09290304
|
|
75
|
+
#define CM2perFT2 929.0304
|
|
76
|
+
#define DAYperSEC 1.1574E-5
|
|
77
|
+
#define HOURperSEC 2.7778E-4
|
|
78
|
+
#define MINUTEperSEC 0.016667
|
|
79
|
+
#define GPMperCFS 448.831
|
|
80
|
+
#define AFDperCFS 1.9837
|
|
81
|
+
#define MGDperCFS 0.64632
|
|
82
|
+
#define IMGDperCFS 0.5382
|
|
83
|
+
#define LPSperCFS 28.317
|
|
84
|
+
#define LPMperCFS 1699.0
|
|
85
|
+
#define CMHperCFS 101.94
|
|
86
|
+
#define CMDperCFS 2446.6
|
|
87
|
+
#define MLDperCFS 2.4466
|
|
88
|
+
#define M3perFT3 0.028317
|
|
89
|
+
#define LperFT3 28.317
|
|
90
|
+
#define MperFT 0.3048
|
|
91
|
+
#define PSIperFT 0.4333
|
|
92
|
+
#define KPAperPSI 6.895
|
|
93
|
+
#define KWperHP 0.7457
|
|
94
|
+
#define SECperDAY 86400
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
//-----------------------------------------------------------------------------
|
|
98
|
+
// Enumerated Types
|
|
99
|
+
//-----------------------------------------------------------------------------
|
|
100
|
+
enum ObjectTypes // Object types
|
|
101
|
+
{NODE,
|
|
102
|
+
LINK,
|
|
103
|
+
TANK,
|
|
104
|
+
SPECIES,
|
|
105
|
+
TERM,
|
|
106
|
+
PARAMETER,
|
|
107
|
+
CONSTANT,
|
|
108
|
+
PATTERN,
|
|
109
|
+
MAX_OBJECTS};
|
|
110
|
+
|
|
111
|
+
enum SourceType // Type of source quality input
|
|
112
|
+
{CONCEN, // inflow concentration
|
|
113
|
+
MASS, // mass inflow booster
|
|
114
|
+
SETPOINT, // setpoint booster
|
|
115
|
+
FLOWPACED}; // flow paced booster
|
|
116
|
+
|
|
117
|
+
enum UnitSystemType // Unit system:
|
|
118
|
+
{US, // US
|
|
119
|
+
SI}; // SI (metric)
|
|
120
|
+
|
|
121
|
+
enum FlowUnitsType // Flow units:
|
|
122
|
+
{CFS, // cubic feet per second
|
|
123
|
+
GPM, // gallons per minute
|
|
124
|
+
MGD, // million gallons per day
|
|
125
|
+
IMGD, // imperial million gal. per day
|
|
126
|
+
AFD, // acre-feet per day
|
|
127
|
+
LPS, // liters per second
|
|
128
|
+
LPM, // liters per minute
|
|
129
|
+
MLD, // megaliters per day
|
|
130
|
+
CMH, // cubic meters per hour
|
|
131
|
+
CMD}; // cubic meters per day
|
|
132
|
+
|
|
133
|
+
enum MixType // Tank mixing regimes
|
|
134
|
+
{MIX1, // 1-compartment model
|
|
135
|
+
MIX2, // 2-compartment model
|
|
136
|
+
FIFO, // First in, first out model
|
|
137
|
+
LIFO}; // Last in, first out model
|
|
138
|
+
|
|
139
|
+
enum SpeciesType // Types of water quality species
|
|
140
|
+
{BULK, // bulk flow species
|
|
141
|
+
WALL}; // pipe wall attached species
|
|
142
|
+
|
|
143
|
+
enum ExpressionType // Types of math expressions
|
|
144
|
+
{NO_EXPR, // no expression
|
|
145
|
+
RATE, // reaction rate
|
|
146
|
+
FORMULA, // simple formula
|
|
147
|
+
EQUIL}; // equilibrium expression
|
|
148
|
+
|
|
149
|
+
enum SolverType // ODE solver options
|
|
150
|
+
{EUL, // Euler
|
|
151
|
+
RK5, // 5th order Runge-Kutta
|
|
152
|
+
ROS2}; // 2nd order Rosenbrock
|
|
153
|
+
|
|
154
|
+
enum CouplingType // Degree of coupling for solving DAE's
|
|
155
|
+
{NO_COUPLING, // no coupling between alg. & diff. eqns.
|
|
156
|
+
FULL_COUPLING}; // full coupling between alg. &diff. eqns.
|
|
157
|
+
|
|
158
|
+
enum MassUnitsType // Concentration mass units
|
|
159
|
+
{MG, // milligram
|
|
160
|
+
UG, // microgram
|
|
161
|
+
MOLE, // mole
|
|
162
|
+
MMOLE}; // millimole
|
|
163
|
+
|
|
164
|
+
enum AreaUnitsType // Pipe surface area units
|
|
165
|
+
{FT2, // square feet
|
|
166
|
+
M2, // square meters
|
|
167
|
+
CM2}; // square centimeters
|
|
168
|
+
|
|
169
|
+
enum RateUnitsType // Reaction rate time units
|
|
170
|
+
{SECONDS, // seconds
|
|
171
|
+
MINUTES, // minutes
|
|
172
|
+
HOURS, // hours
|
|
173
|
+
DAYS}; // days
|
|
174
|
+
|
|
175
|
+
enum UnitsType // Measurement unit types
|
|
176
|
+
{LENGTH_UNITS, // length
|
|
177
|
+
DIAM_UNITS, // pipe diameter
|
|
178
|
+
AREA_UNITS, // surface area
|
|
179
|
+
VOL_UNITS, // volume
|
|
180
|
+
FLOW_UNITS, // flow
|
|
181
|
+
CONC_UNITS, // concentration volume
|
|
182
|
+
RATE_UNITS, // reaction rate time units
|
|
183
|
+
MAX_UNIT_TYPES};
|
|
184
|
+
|
|
185
|
+
enum HydVarType // Hydraulic variables
|
|
186
|
+
{DIAMETER = 1, // link diameter
|
|
187
|
+
FLOW, // link flow rate
|
|
188
|
+
VELOCITY, // link flow velocity
|
|
189
|
+
REYNOLDS, // Reynolds number
|
|
190
|
+
SHEAR, // link shear velocity
|
|
191
|
+
FRICTION, // friction factor
|
|
192
|
+
AREAVOL, // area/volume
|
|
193
|
+
ROUGHNESS, // roughness /*Feng Shang 01/29/2008*/
|
|
194
|
+
LENGTH, // pipe length /*Feng Shang 01/27/2023
|
|
195
|
+
MAX_HYD_VARS};
|
|
196
|
+
|
|
197
|
+
enum TstatType // Time series statistics
|
|
198
|
+
{SERIES, // full time series
|
|
199
|
+
AVGERAGE, // time-averages
|
|
200
|
+
MINIMUM, // minimum values
|
|
201
|
+
MAXIMUM, // maximum values
|
|
202
|
+
RANGE}; // max - min values
|
|
203
|
+
|
|
204
|
+
enum OptionType // Analysis options
|
|
205
|
+
{AREA_UNITS_OPTION,
|
|
206
|
+
RATE_UNITS_OPTION,
|
|
207
|
+
SOLVER_OPTION,
|
|
208
|
+
COUPLING_OPTION,
|
|
209
|
+
TIMESTEP_OPTION,
|
|
210
|
+
RTOL_OPTION,
|
|
211
|
+
ATOL_OPTION,
|
|
212
|
+
COMPILER_OPTION,
|
|
213
|
+
MAXSEGMENT_OPTION,
|
|
214
|
+
PECLETNUMER_OPTION};
|
|
215
|
+
|
|
216
|
+
enum CompilerType // C compiler type
|
|
217
|
+
{NO_COMPILER,
|
|
218
|
+
VC, // MS Visual C compiler
|
|
219
|
+
GC}; // Gnu C compiler
|
|
220
|
+
|
|
221
|
+
enum FileModeType // File modes
|
|
222
|
+
{SCRATCH_FILE,
|
|
223
|
+
SAVED_FILE,
|
|
224
|
+
USED_FILE};
|
|
225
|
+
|
|
226
|
+
enum SectionType // Input data file sections
|
|
227
|
+
{s_TITLE,
|
|
228
|
+
s_SPECIES,
|
|
229
|
+
s_COEFF,
|
|
230
|
+
s_TERM,
|
|
231
|
+
s_PIPE,
|
|
232
|
+
s_TANK,
|
|
233
|
+
s_SOURCE,
|
|
234
|
+
s_QUALITY,
|
|
235
|
+
s_PARAMETER,
|
|
236
|
+
s_PATTERN,
|
|
237
|
+
s_OPTION,
|
|
238
|
+
s_REPORT,
|
|
239
|
+
s_Diffu,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
enum ErrorCodeType // Error codes (501-525)
|
|
243
|
+
{ERR_FIRST = 500,
|
|
244
|
+
ERR_MEMORY, // 501
|
|
245
|
+
ERR_NO_EPANET_FILE, // 502
|
|
246
|
+
ERR_OPEN_MSX_FILE, // 503
|
|
247
|
+
ERR_OPEN_HYD_FILE, // 504
|
|
248
|
+
ERR_READ_HYD_FILE, // 505
|
|
249
|
+
ERR_MSX_INPUT, // 506
|
|
250
|
+
ERR_NUM_PIPE_EXPR, // 507
|
|
251
|
+
ERR_NUM_TANK_EXPR, // 508
|
|
252
|
+
ERR_INTEGRATOR_OPEN, // 509
|
|
253
|
+
ERR_NEWTON_OPEN, // 510
|
|
254
|
+
ERR_OPEN_OUT_FILE, // 511
|
|
255
|
+
ERR_IO_OUT_FILE, // 512
|
|
256
|
+
ERR_INTEGRATOR, // 513
|
|
257
|
+
ERR_NEWTON, // 514
|
|
258
|
+
ERR_INVALID_OBJECT_TYPE, // 515
|
|
259
|
+
ERR_INVALID_OBJECT_INDEX, // 516
|
|
260
|
+
ERR_UNDEFINED_OBJECT_ID, // 517
|
|
261
|
+
ERR_INVALID_OBJECT_PARAMS, // 518
|
|
262
|
+
ERR_MSX_NOT_OPENED, // 519
|
|
263
|
+
ERR_MSX_OPENED, // 520
|
|
264
|
+
ERR_OPEN_RPT_FILE, // 521
|
|
265
|
+
ERR_COMPILE_FAILED, // 522
|
|
266
|
+
ERR_COMPILED_LOAD, // 523
|
|
267
|
+
ERR_ILLEGAL_MATH, // 524
|
|
268
|
+
ERR_MAX};
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
//-----------------------------------------------------------------------------
|
|
272
|
+
// Data Structures
|
|
273
|
+
//-----------------------------------------------------------------------------
|
|
274
|
+
struct NumList // List of numerical values
|
|
275
|
+
{
|
|
276
|
+
double value;
|
|
277
|
+
struct NumList *next;
|
|
278
|
+
};
|
|
279
|
+
typedef struct NumList SnumList;
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
typedef struct // TIME PATTERN OBJECT
|
|
283
|
+
{
|
|
284
|
+
char *id; // pattern ID
|
|
285
|
+
long length; // number of pattern factors
|
|
286
|
+
long interval; // current time interval
|
|
287
|
+
SnumList *first; // first mutiplier
|
|
288
|
+
SnumList *current; // current multiplier
|
|
289
|
+
} Spattern;
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
struct Ssource // WATER QUALITY SOURCE OBJECT
|
|
293
|
+
{
|
|
294
|
+
char type; // sourceType
|
|
295
|
+
int species; // species index
|
|
296
|
+
double c0; // base concentration
|
|
297
|
+
int pat; // time pattern index
|
|
298
|
+
double massRate; // actual mass flow rate
|
|
299
|
+
struct Ssource *next; // next bulk species source
|
|
300
|
+
};
|
|
301
|
+
typedef struct Ssource *Psource;
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
typedef struct // NODE OBJECT
|
|
305
|
+
{
|
|
306
|
+
Psource sources; // ptr. to WQ source list
|
|
307
|
+
double *c; // current species concentrations
|
|
308
|
+
double *c0; // initial species concentrations
|
|
309
|
+
int tank; // tank index
|
|
310
|
+
char rpt; // reporting flag
|
|
311
|
+
} Snode;
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
typedef struct // LINK OBJECT
|
|
315
|
+
{
|
|
316
|
+
int nsegs; // number of active segments
|
|
317
|
+
int n1; // start node index
|
|
318
|
+
int n2; // end node index
|
|
319
|
+
double diam; // diameter
|
|
320
|
+
double len; // length
|
|
321
|
+
char rpt; // reporting flag
|
|
322
|
+
double *c0; // initial species concentrations
|
|
323
|
+
double *reacted;
|
|
324
|
+
double *param; // kinetic parameter values
|
|
325
|
+
double roughness; // roughness
|
|
326
|
+
double areasquare;
|
|
327
|
+
double HydVar[MAX_HYD_VARS]; // hydraulic variables
|
|
328
|
+
} Slink;
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
typedef struct // TANK OBJECT
|
|
332
|
+
{
|
|
333
|
+
int node; // node index of tank
|
|
334
|
+
double hstep; // integration time step
|
|
335
|
+
double a; // tank area
|
|
336
|
+
double v0; // initial volume
|
|
337
|
+
double v; // tank volume
|
|
338
|
+
int mixModel; // type of mixing model
|
|
339
|
+
double vMix; // mixing compartment size
|
|
340
|
+
double *param; // kinetic parameter values
|
|
341
|
+
double *c; // current species concentrations
|
|
342
|
+
double *reacted;
|
|
343
|
+
} Stank;
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
struct Sseg // PIPE SEGMENT OBJECT
|
|
347
|
+
{
|
|
348
|
+
double hstep; // integration time step
|
|
349
|
+
double v; // segment volume
|
|
350
|
+
double *c; // species concentrations
|
|
351
|
+
double * lastc; // species concentrations of previous step
|
|
352
|
+
struct Sseg *prev; // ptr. to previous segment
|
|
353
|
+
struct Sseg *next; // ptr. to next segment
|
|
354
|
+
double hresponse, // for dispersion response of initial,
|
|
355
|
+
uresponse, // upstream and downstream condition
|
|
356
|
+
dresponse;
|
|
357
|
+
};
|
|
358
|
+
typedef struct Sseg *Pseg;
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
#define MAXUNITS 16
|
|
362
|
+
typedef struct // CHEMICAL SPECIES OBJECT
|
|
363
|
+
{
|
|
364
|
+
char *id; // name
|
|
365
|
+
char units[MAXUNITS]; // mass units code
|
|
366
|
+
double aTol; // absolute tolerance
|
|
367
|
+
double rTol; // relative tolerance
|
|
368
|
+
int type; // BULK or WALL
|
|
369
|
+
int pipeExprType; // type of pipe chemistry
|
|
370
|
+
int tankExprType; // type of tank chemistry
|
|
371
|
+
int precision; // reporting precision
|
|
372
|
+
char rpt; // reporting flag
|
|
373
|
+
MathExpr *pipeExpr; // pipe chemistry expression
|
|
374
|
+
MathExpr *tankExpr; // tank chemistry expression
|
|
375
|
+
} Sspecies;
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
typedef struct // INTERMEDIATE TERM OBJECT
|
|
379
|
+
{
|
|
380
|
+
char *id; // name
|
|
381
|
+
MathExpr *expr; // math expression for term
|
|
382
|
+
} Sterm;
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
typedef struct // REACTION RATE PARAMETER OBJECT
|
|
386
|
+
{
|
|
387
|
+
char *id; // name
|
|
388
|
+
double value; // value
|
|
389
|
+
} Sparam;
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
typedef struct // MATH EXPRESSION CONSTANT OBJECT
|
|
393
|
+
{
|
|
394
|
+
char *id; // name
|
|
395
|
+
double value; // value
|
|
396
|
+
} Sconst;
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
#define MAXFNAME 259 // Max. # characters in file name
|
|
400
|
+
typedef struct // FILE OBJECT
|
|
401
|
+
{
|
|
402
|
+
char name[MAXFNAME]; // file name
|
|
403
|
+
char mode; // see FileModeType enumeration below
|
|
404
|
+
FILE* file; // FILE structure pointer
|
|
405
|
+
} TFile;
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
struct Sadjlist // Node Adjacency List Item
|
|
410
|
+
{
|
|
411
|
+
int node; // index of connecting node
|
|
412
|
+
int link; // index of connecting link
|
|
413
|
+
struct Sadjlist* next; // next item in list
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
typedef struct Sadjlist* Padjlist; // Pointer to adjacency list
|
|
417
|
+
|
|
418
|
+
typedef enum {
|
|
419
|
+
NEGATIVE = -1, // flow in reverse of pre-assigned direction
|
|
420
|
+
ZERO_FLOW = 0, // zero flow
|
|
421
|
+
POSITIVE = 1 // flow in pre-assigned direction
|
|
422
|
+
} FlowDirection;
|
|
423
|
+
|
|
424
|
+
typedef struct // Mass Balance Components
|
|
425
|
+
{
|
|
426
|
+
double * initial; // initial mass in system
|
|
427
|
+
double * inflow; // mass inflow to system
|
|
428
|
+
double * indisperse; // mass dispersed into the system
|
|
429
|
+
double * outflow; // mass outflow from system
|
|
430
|
+
double * reacted; // mass reacted in system
|
|
431
|
+
double * final; // final mass in system
|
|
432
|
+
double * ratio; // ratio of mass added to mass lost
|
|
433
|
+
} SmassBalance;
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
typedef struct
|
|
437
|
+
{
|
|
438
|
+
|
|
439
|
+
double viscosity;
|
|
440
|
+
double DIFFUS; // Diffusivity of chlorine 1.3E-8 @ 20 deg C (sq ft/sec)
|
|
441
|
+
double PecletLimit; // The Pectlet number below which the dispersion in a pipe is considered
|
|
442
|
+
|
|
443
|
+
int* Order; // Node-to-row of re-ordered matrix
|
|
444
|
+
int* Row; // Row-to-node of re-ordered matrix
|
|
445
|
+
int* Ndx; // Index of link's coeff. in Aij
|
|
446
|
+
int* XLNZ; // Start position of each column in NZSUB
|
|
447
|
+
int* NZSUB; // Row index of each coeff.in each column
|
|
448
|
+
int* LNZ; // Position of each coeff. in Aij array
|
|
449
|
+
int* Degree; // Number of links adjacent to each node
|
|
450
|
+
int Ncoeffs; // Number of non-zero matrix coeffs
|
|
451
|
+
|
|
452
|
+
int* link; // Array used by linear eqn. solver
|
|
453
|
+
int* first; // Array used by linear eqn. solver
|
|
454
|
+
double* temp; // Array used by linear eqn. solver
|
|
455
|
+
double* Aii; // Diagonal matrix coeffs.
|
|
456
|
+
double* Aij; // Non-zero, off-diagonal matrix coeffs.
|
|
457
|
+
double* F; // Right hand side vector
|
|
458
|
+
|
|
459
|
+
Padjlist* Adjlist; // Node adjacency lists
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
double* md; // molecular diffusion
|
|
463
|
+
double* ld; // fixed longitudinal dispersion coefficient
|
|
464
|
+
double* pipeDispersionCoeff; //effective longitudinal dispersion coefficient
|
|
465
|
+
} Sdispersion;
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
typedef struct // MSX PROJECT VARIABLES
|
|
469
|
+
{
|
|
470
|
+
TFile HydFile, // EPANET hydraulics file
|
|
471
|
+
MsxFile, // MSX input file
|
|
472
|
+
OutFile, // MSX binary output file
|
|
473
|
+
TmpOutFile, // Scratch MSX binary output file
|
|
474
|
+
RptFile; // MSX report file
|
|
475
|
+
|
|
476
|
+
char Title[MAXLINE+1], // Project title
|
|
477
|
+
Msg[MAXLINE+1]; // Message string
|
|
478
|
+
|
|
479
|
+
int Nobjects[MAX_OBJECTS], // Numbers of each type of object
|
|
480
|
+
Unitsflag, // Unit system flag
|
|
481
|
+
Flowflag, // Flow units flag
|
|
482
|
+
Saveflag, // Save results flag
|
|
483
|
+
Rptflag, // Report results flag
|
|
484
|
+
Coupling, // Degree of coupling for solving DAE's
|
|
485
|
+
Compiler, // chemistry function compiler code
|
|
486
|
+
AreaUnits, // Surface area units
|
|
487
|
+
RateUnits, // Reaction rate time units
|
|
488
|
+
Solver, // Choice of ODE solver
|
|
489
|
+
PageSize, // Lines per page in report
|
|
490
|
+
Nperiods, // Number of reporting periods
|
|
491
|
+
ErrCode, // Error code
|
|
492
|
+
ProjectOpened, // Project opened flag
|
|
493
|
+
QualityOpened; // Water quality system opened flag
|
|
494
|
+
int MaxSegments; // Maximum number of segments in a link
|
|
495
|
+
long HydOffset, // Hydraulics file byte offset
|
|
496
|
+
Pstep, // Time pattern time step (sec)
|
|
497
|
+
Pstart, // Starting pattern time (sec)
|
|
498
|
+
Rstep, // Reporting time step (sec)
|
|
499
|
+
Rstart, // Time when reporting starts
|
|
500
|
+
Statflag; // Reporting statistic flag
|
|
501
|
+
|
|
502
|
+
int64_t Qstep, // Quality time step (millisec)
|
|
503
|
+
Qtime, // Current quality time (millisec)
|
|
504
|
+
Htime, // Current hydraulic time (millisec)
|
|
505
|
+
Rtime, // Next reporting time (millisec)
|
|
506
|
+
Dur; // Duration of simulation (millisec)
|
|
507
|
+
|
|
508
|
+
REAL4 *D, // Node demands
|
|
509
|
+
*H, // Node heads
|
|
510
|
+
*Q, // Link flows
|
|
511
|
+
*S; // Link status
|
|
512
|
+
|
|
513
|
+
double Ucf[MAX_UNIT_TYPES], // Unit conversion factors
|
|
514
|
+
DefRtol, // Default relative error tolerance
|
|
515
|
+
DefAtol, // Default absolute error tolerance
|
|
516
|
+
*K, // Vector of expression constants
|
|
517
|
+
*C0, // Species initial quality vector
|
|
518
|
+
*C1; // Species concentration vector
|
|
519
|
+
|
|
520
|
+
Pseg *FirstSeg, // First WQ segment in each pipe/tank
|
|
521
|
+
*LastSeg; // Last WQ segment in each pipe/tank
|
|
522
|
+
|
|
523
|
+
Sspecies *Species; // WQ species data
|
|
524
|
+
Sparam *Param; // Expression parameters
|
|
525
|
+
Sconst *Const; // Expression constants
|
|
526
|
+
Sterm *Term; // Intermediate terms
|
|
527
|
+
Snode *Node; // Node data
|
|
528
|
+
Slink *Link; // Link data
|
|
529
|
+
Stank *Tank; // Tank data
|
|
530
|
+
Spattern *Pattern; // Pattern data
|
|
531
|
+
|
|
532
|
+
char HasWallSpecies; // wall species indicator
|
|
533
|
+
char OutOfMemory; // out of memory indicator
|
|
534
|
+
Padjlist* Adjlist; // Node adjacency lists
|
|
535
|
+
Pseg* NewSeg; // new segment added to each pipe
|
|
536
|
+
Pseg FreeSeg; // pointer to unused segment
|
|
537
|
+
FlowDirection *FlowDir; // flow direction for each pipe
|
|
538
|
+
SmassBalance MassBalance;
|
|
539
|
+
alloc_handle_t* QualPool; // memory pool
|
|
540
|
+
|
|
541
|
+
int DispersionFlag; // 1 if dispersion modeling
|
|
542
|
+
|
|
543
|
+
double* MassIn; // mass inflow of each species to each node
|
|
544
|
+
double* SourceIn; // external mass inflow of each species from WQ source;
|
|
545
|
+
int* SortedNodes;
|
|
546
|
+
|
|
547
|
+
Sdispersion Dispersion;
|
|
548
|
+
|
|
549
|
+
} MSXproject;
|
|
550
|
+
|
|
551
|
+
#endif
|