epyt-flow 0.13.1__py3-none-any.whl → 0.14.1__py3-none-any.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.
Files changed (63) hide show
  1. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +40 -8
  2. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +3 -3
  3. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +24 -7
  4. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +726 -374
  5. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +128 -32
  6. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +7 -1
  7. epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +186 -0
  8. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +40 -14
  9. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -177
  10. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -28
  11. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +192 -40
  12. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +101 -46
  13. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +85 -24
  14. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +29 -63
  15. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +70 -37
  16. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +408 -234
  17. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +87 -37
  18. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +153 -79
  19. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +59 -94
  20. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +73 -202
  21. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +446 -351
  22. epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +527 -0
  23. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +8 -4
  24. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +23 -23
  25. epyt_flow/EPANET/EPANET/SRC_engines/output.c +5 -4
  26. epyt_flow/EPANET/EPANET/SRC_engines/project.c +407 -75
  27. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +12 -2
  28. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +70 -13
  29. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +7 -5
  30. epyt_flow/EPANET/EPANET/SRC_engines/report.c +88 -20
  31. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +144 -6
  32. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +19 -19
  33. epyt_flow/EPANET/EPANET/SRC_engines/text.h +16 -5
  34. epyt_flow/EPANET/EPANET/SRC_engines/types.h +73 -19
  35. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +59 -0
  36. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +38 -0
  37. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +92 -0
  38. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +39 -0
  39. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +212 -0
  40. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +81 -0
  41. epyt_flow/EPANET/EPANET/SRC_engines/validate.c +408 -0
  42. epyt_flow/EPANET/compile_linux.sh +1 -1
  43. epyt_flow/EPANET/compile_macos.sh +2 -2
  44. epyt_flow/VERSION +1 -1
  45. epyt_flow/__init__.py +1 -1
  46. epyt_flow/gym/scenario_control_env.py +26 -3
  47. epyt_flow/simulation/backend/my_epyt.py +58 -13
  48. epyt_flow/simulation/events/quality_events.py +6 -6
  49. epyt_flow/simulation/events/sensor_faults.py +24 -24
  50. epyt_flow/simulation/events/system_event.py +3 -3
  51. epyt_flow/simulation/scada/scada_data.py +10 -14
  52. epyt_flow/simulation/scenario_simulator.py +100 -20
  53. epyt_flow/topology.py +8 -1
  54. epyt_flow/uncertainty/model_uncertainty.py +292 -150
  55. epyt_flow/uncertainty/uncertainties.py +2 -2
  56. {epyt_flow-0.13.1.dist-info → epyt_flow-0.14.1.dist-info}/METADATA +4 -4
  57. {epyt_flow-0.13.1.dist-info → epyt_flow-0.14.1.dist-info}/RECORD +60 -54
  58. {epyt_flow-0.13.1.dist-info → epyt_flow-0.14.1.dist-info}/WHEEL +1 -1
  59. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +0 -18
  60. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +0 -131
  61. epyt_flow/EPANET/EPANET/SRC_engines/main.c +0 -93
  62. {epyt_flow-0.13.1.dist-info → epyt_flow-0.14.1.dist-info}/licenses/LICENSE +0 -0
  63. {epyt_flow-0.13.1.dist-info → epyt_flow-0.14.1.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.2
4
+ Version: 2.3
5
5
  Module: epanet2.c
6
6
  Description: implementation of the legacy EPANET API functions
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 11/02/2019
10
+ Last Updated: 02/14/2025
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -99,12 +99,20 @@ int DLLEXPORT ENopen(const char *inpFile, const char *rptFile, const char *outFi
99
99
  return errcode;
100
100
  }
101
101
 
102
+ int DLLEXPORT ENopenX(const char *inpFile, const char *rptFile, const char *outFile)
103
+ {
104
+ int errcode = 0;
105
+ createtmpfiles();
106
+ errcode = EN_openX(_defaultProject, inpFile, rptFile, outFile);
107
+ return errcode;
108
+ }
109
+
102
110
  int DLLEXPORT ENgettitle(char *line1, char *line2, char *line3)
103
111
  {
104
112
  return EN_gettitle(_defaultProject, line1, line2, line3) ;
105
113
  }
106
114
 
107
- int DLLEXPORT ENsettitle(char *line1, char *line2, char *line3)
115
+ int DLLEXPORT ENsettitle(const char *line1, const char *line2, const char *line3)
108
116
  {
109
117
  return EN_settitle(_defaultProject, line1, line2, line3) ;
110
118
  }
@@ -114,11 +122,20 @@ int DLLEXPORT ENgetcomment(int object, int index, char *comment)
114
122
  return EN_getcomment(_defaultProject, object, index, comment);
115
123
  }
116
124
 
117
- int DLLEXPORT ENsetcomment(int object, int index, char *comment)
125
+ int DLLEXPORT ENsetcomment(int object, int index, const char *comment)
118
126
  {
119
127
  return EN_setcomment(_defaultProject, object, index, comment);
120
128
  }
121
129
 
130
+ int DLLEXPORT ENgettag(int object, int index, char *tag)
131
+ {
132
+ return EN_gettag(_defaultProject, object, index, tag);
133
+ }
134
+
135
+ int DLLEXPORT ENsettag(int object, int index, const char *tag)
136
+ {
137
+ return EN_settag(_defaultProject, object, index, tag);
138
+ }
122
139
  int DLLEXPORT ENgetcount(int object, int *count)
123
140
  {
124
141
  return EN_getcount(_defaultProject, object, count);
@@ -156,12 +173,12 @@ int DLLEXPORT ENnextH(long *tStep) { return EN_nextH(_defaultProject, tStep); }
156
173
 
157
174
  int DLLEXPORT ENcloseH() { return EN_closeH(_defaultProject); }
158
175
 
159
- int DLLEXPORT ENsavehydfile(char *filename)
176
+ int DLLEXPORT ENsavehydfile(const char *filename)
160
177
  {
161
178
  return EN_savehydfile(_defaultProject, filename);
162
179
  }
163
180
 
164
- int DLLEXPORT ENusehydfile(char *filename)
181
+ int DLLEXPORT ENusehydfile(const char *filename)
165
182
  {
166
183
  return EN_usehydfile(_defaultProject, filename);
167
184
  }
@@ -192,11 +209,11 @@ int DLLEXPORT ENcloseQ() { return EN_closeQ(_defaultProject); }
192
209
 
193
210
  ********************************************************************/
194
211
 
195
- int DLLEXPORT ENwriteline(char *line) { return EN_writeline(_defaultProject, line); }
212
+ int DLLEXPORT ENwriteline(const char *line) { return EN_writeline(_defaultProject, line); }
196
213
 
197
214
  int DLLEXPORT ENreport() { return EN_report(_defaultProject); }
198
215
 
199
- int DLLEXPORT ENcopyreport(char *filename)
216
+ int DLLEXPORT ENcopyreport(const char *filename)
200
217
  {
201
218
  return EN_copyreport(_defaultProject, filename);
202
219
  }
@@ -205,13 +222,23 @@ int DLLEXPORT ENclearreport() { return EN_clearreport(_defaultProject); }
205
222
 
206
223
  int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultProject); }
207
224
 
208
- int DLLEXPORT ENsetreport(char *format) { return EN_setreport(_defaultProject, format); }
225
+ int DLLEXPORT ENsetreport(const char *format) { return EN_setreport(_defaultProject, format); }
209
226
 
210
227
  int DLLEXPORT ENsetstatusreport(int level)
211
228
  {
212
229
  return EN_setstatusreport(_defaultProject, level);
213
230
  }
214
231
 
232
+ int DLLEXPORT ENsetreportcallback(void (*callback)(void *userData, void *EN_projectHandle, const char*))
233
+ {
234
+ return EN_setreportcallback(_defaultProject, callback);
235
+ }
236
+
237
+ int DLLEXPORT ENsetreportcallbackuserdata(void *userData)
238
+ {
239
+ return EN_setreportcallbackuserdata(_defaultProject, userData);
240
+ }
241
+
215
242
  int DLLEXPORT ENgetversion(int *version) { return EN_getversion(version); }
216
243
 
217
244
  int DLLEXPORT ENgeterror(int errcode, char *errmsg, int maxLen)
@@ -232,6 +259,10 @@ int DLLEXPORT ENgetresultindex(int type, int index, int *value)
232
259
  return EN_getresultindex(_defaultProject, type, index, value);
233
260
  }
234
261
 
262
+ int DLLEXPORT ENtimetonextevent(int *eventType, long *duration, int *elementIndex)
263
+ {
264
+ return EN_timetonextevent(_defaultProject, eventType, duration, elementIndex);
265
+ }
235
266
 
236
267
  /********************************************************************
237
268
 
@@ -283,8 +314,8 @@ int DLLEXPORT ENgetqualtype(int *qualType, int *traceNode)
283
314
  return EN_getqualtype(_defaultProject, qualType, traceNode);
284
315
  }
285
316
 
286
- int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
287
- char *traceNode)
317
+ int DLLEXPORT ENsetqualtype(int qualType, const char *chemName,
318
+ const char *chemUnits, const char *traceNode)
288
319
  {
289
320
  return EN_setqualtype(_defaultProject, qualType, chemName, chemUnits, traceNode);
290
321
  }
@@ -295,7 +326,7 @@ int DLLEXPORT ENsetqualtype(int qualType, char *chemName, char *chemUnits,
295
326
 
296
327
  ********************************************************************/
297
328
 
298
- int DLLEXPORT ENaddnode(char *id, int nodeType, int *index)
329
+ int DLLEXPORT ENaddnode(const char *id, int nodeType, int *index)
299
330
  {
300
331
  return EN_addnode(_defaultProject, id, nodeType, index);
301
332
  }
@@ -305,7 +336,7 @@ int DLLEXPORT ENdeletenode(int index, int actionCode)
305
336
  return EN_deletenode(_defaultProject, index, actionCode);
306
337
  }
307
338
 
308
- int DLLEXPORT ENgetnodeindex(char *id, int *index)
339
+ int DLLEXPORT ENgetnodeindex(const char *id, int *index)
309
340
  {
310
341
  return EN_getnodeindex(_defaultProject, id, index);
311
342
  }
@@ -315,7 +346,7 @@ int DLLEXPORT ENgetnodeid(int index, char *id)
315
346
  return EN_getnodeid(_defaultProject, index, id);
316
347
  }
317
348
 
318
- int DLLEXPORT ENsetnodeid(int index, char *newid)
349
+ int DLLEXPORT ENsetnodeid(int index, const char *newid)
319
350
  {
320
351
  return EN_setnodeid(_defaultProject, index, newid);
321
352
  }
@@ -333,13 +364,27 @@ int DLLEXPORT ENgetnodevalue(int index, int property, EN_API_FLOAT_TYPE *value)
333
364
  return errcode;
334
365
  }
335
366
 
367
+ int DLLEXPORT ENgetnodevalues(int property, EN_API_FLOAT_TYPE *values)
368
+ {
369
+ int i, errcode = 0;
370
+ EN_API_FLOAT_TYPE value;
371
+
372
+ for (i = 1; i <= _defaultProject->network.Nnodes; i++)
373
+ {
374
+ errcode = ENgetnodevalue(i, property, &value);
375
+ values[i-1] = value;
376
+ if (errcode != 0) return errcode;
377
+ }
378
+ return 0;
379
+ }
380
+
336
381
  int DLLEXPORT ENsetnodevalue(int index, int property, EN_API_FLOAT_TYPE value)
337
382
  {
338
383
  return EN_setnodevalue(_defaultProject, index, property, value);
339
384
  }
340
385
 
341
386
  int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE dmnd,
342
- char *dmndpat)
387
+ const char *dmndpat)
343
388
  {
344
389
  return EN_setjuncdata(_defaultProject, index, elev, dmnd, dmndpat);
345
390
  }
@@ -347,7 +392,7 @@ int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE
347
392
  int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
348
393
  EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
349
394
  EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
350
- EN_API_FLOAT_TYPE minvol, char *volcurve)
395
+ EN_API_FLOAT_TYPE minvol, const char *volcurve)
351
396
  {
352
397
  return EN_settankdata(_defaultProject, index, elev, initlvl, minlvl, maxlvl,
353
398
  diam, minvol, volcurve);
@@ -387,7 +432,7 @@ int DLLEXPORT ENsetdemandmodel(int model, EN_API_FLOAT_TYPE pmin,
387
432
  }
388
433
 
389
434
  int DLLEXPORT ENadddemand(int nodeIndex, EN_API_FLOAT_TYPE baseDemand,
390
- char *demandPattern, char *demandName)
435
+ const char *demandPattern, const char *demandName)
391
436
  {
392
437
  return EN_adddemand(_defaultProject, nodeIndex, baseDemand, demandPattern, demandName);
393
438
  }
@@ -397,7 +442,7 @@ int DLLEXPORT ENdeletedemand(int nodeIndex, int demandIndex)
397
442
  return EN_deletedemand(_defaultProject, nodeIndex, demandIndex);
398
443
  }
399
444
 
400
- int DLLEXPORT ENgetdemandindex(int nodeIndex, char *demandName, int *demandIndex)
445
+ int DLLEXPORT ENgetdemandindex(int nodeIndex, const char *demandName, int *demandIndex)
401
446
  {
402
447
  return EN_getdemandindex(_defaultProject, nodeIndex, demandName, demandIndex);
403
448
  }
@@ -437,7 +482,7 @@ int DLLEXPORT ENgetdemandname(int nodeIndex, int demandIndex, char *demandName)
437
482
  return EN_getdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
438
483
  }
439
484
 
440
- int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName)
485
+ int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, const char *demandName)
441
486
  {
442
487
  return EN_setdemandname(_defaultProject, nodeIndex, demandIndex, demandName);
443
488
  }
@@ -448,7 +493,8 @@ int DLLEXPORT ENsetdemandname(int nodeIndex, int demandIndex, char *demandName)
448
493
 
449
494
  ********************************************************************/
450
495
 
451
- int DLLEXPORT ENaddlink(char *id, int linkType, char *fromNode, char *toNode, int *index)
496
+ int DLLEXPORT ENaddlink(const char *id, int linkType, const char *fromNode,
497
+ const char *toNode, int *index)
452
498
  {
453
499
  return EN_addlink(_defaultProject, id, linkType, fromNode, toNode, index);
454
500
  }
@@ -458,7 +504,7 @@ int DLLEXPORT ENdeletelink(int index, int actionCode)
458
504
  return EN_deletelink(_defaultProject, index, actionCode);
459
505
  }
460
506
 
461
- int DLLEXPORT ENgetlinkindex(char *id, int *index)
507
+ int DLLEXPORT ENgetlinkindex(const char *id, int *index)
462
508
  {
463
509
  return EN_getlinkindex(_defaultProject, id, index);
464
510
  }
@@ -468,7 +514,7 @@ int DLLEXPORT ENgetlinkid(int index, char *id)
468
514
  return EN_getlinkid(_defaultProject, index, id);
469
515
  }
470
516
 
471
- int DLLEXPORT ENsetlinkid(int index, char *newid)
517
+ int DLLEXPORT ENsetlinkid(int index, const char *newid)
472
518
  {
473
519
  return EN_setlinkid(_defaultProject, index, newid);
474
520
  }
@@ -500,6 +546,19 @@ int DLLEXPORT ENgetlinkvalue(int index, int property, EN_API_FLOAT_TYPE *value)
500
546
  *value = (EN_API_FLOAT_TYPE)v;
501
547
  return errcode;
502
548
  }
549
+ int DLLEXPORT ENgetlinkvalues(int property, EN_API_FLOAT_TYPE *values)
550
+ {
551
+ int i, errcode = 0;
552
+ EN_API_FLOAT_TYPE value;
553
+
554
+ for (i = 1; i <= _defaultProject->network.Nlinks; i++)
555
+ {
556
+ errcode = ENgetlinkvalue(i, property, &value);
557
+ values[i-1] = value;
558
+ if (errcode != 0) return errcode;
559
+ }
560
+ return 0;
561
+ }
503
562
 
504
563
  int DLLEXPORT ENsetlinkvalue(int index, int property, EN_API_FLOAT_TYPE value)
505
564
  {
@@ -516,16 +575,21 @@ int DLLEXPORT ENgetvertexcount(int index, int *count)
516
575
  {
517
576
  return EN_getvertexcount(_defaultProject, index, count);
518
577
  }
519
-
578
+
520
579
  int DLLEXPORT ENgetvertex(int index, int vertex, double *x, double *y)
521
580
  {
522
581
  return EN_getvertex(_defaultProject, index, vertex, x, y);
523
582
  }
524
583
 
584
+ int DLLEXPORT ENsetvertex(int index, int vertex, double x, double y)
585
+ {
586
+ return EN_setvertex(_defaultProject, index, vertex, x, y);
587
+ }
588
+
525
589
  int DLLEXPORT ENsetvertices(int index, double *x, double *y, int count)
526
590
  {
527
591
  return EN_setvertices(_defaultProject, index, x, y, count);
528
- }
592
+ }
529
593
 
530
594
  /********************************************************************
531
595
 
@@ -554,7 +618,7 @@ int DLLEXPORT ENsetheadcurveindex(int linkIndex, int curveIndex)
554
618
 
555
619
  ********************************************************************/
556
620
 
557
- int DLLEXPORT ENaddpattern(char *id)
621
+ int DLLEXPORT ENaddpattern(const char *id)
558
622
  {
559
623
  return EN_addpattern(_defaultProject, id);
560
624
  }
@@ -564,7 +628,7 @@ int DLLEXPORT ENdeletepattern(int index)
564
628
  return EN_deletepattern(_defaultProject, index);
565
629
  }
566
630
 
567
- int DLLEXPORT ENgetpatternindex(char *id, int *index)
631
+ int DLLEXPORT ENgetpatternindex(const char *id, int *index)
568
632
  {
569
633
  return EN_getpatternindex(_defaultProject, id, index);
570
634
  }
@@ -574,7 +638,7 @@ int DLLEXPORT ENgetpatternid(int index, char *id)
574
638
  return EN_getpatternid(_defaultProject, index, id);
575
639
  }
576
640
 
577
- int DLLEXPORT ENsetpatternid(int index, char *id)
641
+ int DLLEXPORT ENsetpatternid(int index, const char *id)
578
642
  {
579
643
  return EN_setpatternid(_defaultProject, index, id);
580
644
  }
@@ -621,13 +685,18 @@ int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *values, int len)
621
685
  return errcode;
622
686
  }
623
687
 
688
+ int DLLEXPORT ENloadpatternfile(const char *filename, const char *id)
689
+ {
690
+ return EN_loadpatternfile(_defaultProject, filename, id);
691
+ }
692
+
624
693
  /********************************************************************
625
694
 
626
695
  Data Curve Functions
627
696
 
628
697
  ********************************************************************/
629
698
 
630
- int DLLEXPORT ENaddcurve(char *id)
699
+ int DLLEXPORT ENaddcurve(const char *id)
631
700
  {
632
701
  return EN_addcurve(_defaultProject, id);
633
702
  }
@@ -637,7 +706,7 @@ int DLLEXPORT ENdeletecurve(int index)
637
706
  return EN_deletecurve(_defaultProject, index);
638
707
  }
639
708
 
640
- int DLLEXPORT ENgetcurveindex(char *id, int *index)
709
+ int DLLEXPORT ENgetcurveindex(const char *id, int *index)
641
710
  {
642
711
  return EN_getcurveindex(_defaultProject, id, index);
643
712
  }
@@ -647,7 +716,7 @@ int DLLEXPORT ENgetcurveid(int index, char *id)
647
716
  return EN_getcurveid(_defaultProject, index, id);
648
717
  }
649
718
 
650
- int DLLEXPORT ENsetcurveid(int index, char *id)
719
+ int DLLEXPORT ENsetcurveid(int index, const char *id)
651
720
  {
652
721
  return EN_setcurveid(_defaultProject, index, id);
653
722
  }
@@ -662,6 +731,11 @@ int DLLEXPORT ENgetcurvetype(int index, int *type)
662
731
  return EN_getcurvetype(_defaultProject, index, type);
663
732
  }
664
733
 
734
+ int DLLEXPORT ENsetcurvetype(int index, int type)
735
+ {
736
+ return EN_setcurvetype(_defaultProject, index, type);
737
+ }
738
+
665
739
  int DLLEXPORT ENgetcurvevalue(int curveIndex, int pointIndex, EN_API_FLOAT_TYPE *x,
666
740
  EN_API_FLOAT_TYPE *y)
667
741
  {
@@ -704,10 +778,10 @@ int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *xValues,
704
778
  double *xx = NULL;
705
779
  double *yy = NULL;
706
780
  int i, errcode = 0;
707
-
781
+
708
782
  if (xValues == NULL || yValues == NULL) return 206;
709
783
  if (nPoints < 1) return 202;
710
-
784
+
711
785
  xx = (double *)calloc(nPoints, sizeof(double));
712
786
  yy = (double *)calloc(nPoints, sizeof(double));
713
787
  if (xx && yy)
@@ -761,6 +835,17 @@ int DLLEXPORT ENsetcontrol(int index, int type, int linkIndex,
761
835
  nodeIndex, level);
762
836
  }
763
837
 
838
+
839
+ int DLLEXPORT ENgetcontrolenabled(int index, int *out_enabled)
840
+ {
841
+ return EN_getcontrolenabled(_defaultProject, index, out_enabled);
842
+ }
843
+
844
+ int DLLEXPORT ENsetcontrolenabled(int index, int enabled)
845
+ {
846
+ return EN_setcontrolenabled(_defaultProject, index, enabled);
847
+ }
848
+
764
849
  /********************************************************************
765
850
 
766
851
  Rule-Based Controls Functions
@@ -863,3 +948,14 @@ int DLLEXPORT ENsetrulepriority(int index, EN_API_FLOAT_TYPE priority)
863
948
  {
864
949
  return EN_setrulepriority(_defaultProject, index, priority);
865
950
  }
951
+
952
+
953
+ int DLLEXPORT ENgetruleenabled(int index, int *out_enabled)
954
+ {
955
+ return EN_getruleenabled(_defaultProject, index, out_enabled);
956
+ }
957
+
958
+ int DLLEXPORT ENsetruleenabled(int index, int enabled)
959
+ {
960
+ return EN_setruleenabled(_defaultProject, index, enabled);
961
+ }
@@ -14,6 +14,7 @@ DAT(120,"cannot solve water quality transport equations")
14
14
  // These errors apply only to an input file
15
15
  DAT(200,"one or more errors in input file")
16
16
  DAT(201,"syntax error")
17
+ DAT(299,"invalid section keyword")
17
18
 
18
19
  // These errors apply to both an input file and to API functions
19
20
  DAT(202,"illegal numeric value")
@@ -43,7 +44,10 @@ DAT(225,"invalid lower/upper levels for tank")
43
44
  DAT(226,"no head curve or power rating for pump")
44
45
  DAT(227,"invalid head curve for pump")
45
46
  DAT(230,"nonincreasing x-values for curve")
46
- DAT(233,"network has unconnected node")
47
+ DAT(231,"no data provided for curve")
48
+ DAT(232,"no data provided for pattern")
49
+ DAT(233,"network has unconnected nodes")
50
+ DAT(234,"network has an unconnected node with ID: ")
47
51
 
48
52
  // These errors apply only to API functions
49
53
  DAT(240,"nonexistent source")
@@ -60,6 +64,8 @@ DAT(259,"attempt to delete a node that still has links connected to it")
60
64
  DAT(260,"attempt to delete node assigned as a Trace Node")
61
65
  DAT(261,"attempt to delete a node or link contained in a control")
62
66
  DAT(262,"attempt to modify network structure while solver is active")
67
+ DAT(263,"node is not a tank")
68
+ DAT(264,"link is not a valve")
63
69
 
64
70
  // File errors
65
71
  DAT(301,"identical file names")
@@ -0,0 +1,186 @@
1
+ /*
2
+ ******************************************************************************
3
+ Project: OWA EPANET
4
+ Version: 2.3
5
+ Module: flowbalance.c
6
+ Description: computes components of network's flow balance
7
+ Authors: see AUTHORS
8
+ Copyright: see AUTHORS
9
+ License: see LICENSE
10
+ Last Updated: 06/26/2024
11
+ ******************************************************************************
12
+ */
13
+
14
+ #include "types.h"
15
+
16
+ // Exported functions (declared in funcs.h)
17
+ //void startflowbalance(Project *);
18
+ //void updateflowbalance(Project *, long);
19
+ //void endflowbalance(Project *);
20
+
21
+ void startflowbalance(Project *pr)
22
+ /*
23
+ **-------------------------------------------------------------------
24
+ ** Input: none
25
+ ** Output: none
26
+ ** Purpose: initializes components of the network's flow balance.
27
+ **-------------------------------------------------------------------
28
+ */
29
+ {
30
+ Hydraul *hyd = &pr->hydraul;
31
+ hyd->FlowBalance.totalInflow = 0.0;
32
+ hyd->FlowBalance.totalOutflow = 0.0;
33
+ hyd->FlowBalance.consumerDemand = 0.0;
34
+ hyd->FlowBalance.emitterDemand = 0.0;
35
+ hyd->FlowBalance.leakageDemand = 0.0;
36
+ hyd->FlowBalance.deficitDemand = 0.0;
37
+ hyd->FlowBalance.storageDemand = 0.0;
38
+ hyd->FlowBalance.ratio = 0.0;
39
+ }
40
+
41
+ void updateflowbalance(Project *pr, long hstep)
42
+ /*
43
+ **-------------------------------------------------------------------
44
+ ** Input: hstep = time step (sec)
45
+ ** Output: none
46
+ ** Purpose: updates components of the system flow balance.
47
+ **-------------------------------------------------------------------
48
+ */
49
+ {
50
+ Network *net = &pr->network;
51
+ Hydraul *hyd = &pr->hydraul;
52
+ Times *time = &pr->times;
53
+
54
+ int i, j;
55
+ double v, dt, deficit, fullDemand;
56
+ SflowBalance flowBalance;
57
+
58
+ // Determine current time interval in seconds
59
+ if (time->Dur == 0) dt = 1.0;
60
+ else if (time->Htime < time->Dur)
61
+ {
62
+ dt = (double) hstep;
63
+ }
64
+ else return;
65
+
66
+ // Initialize local flow balance
67
+ flowBalance.totalInflow = 0.0;
68
+ flowBalance.totalOutflow = 0.0;
69
+ flowBalance.consumerDemand = 0.0;
70
+ flowBalance.emitterDemand = 0.0;
71
+ flowBalance.leakageDemand = 0.0;
72
+ flowBalance.deficitDemand = 0.0;
73
+ flowBalance.storageDemand = 0.0;
74
+ fullDemand = 0.0;
75
+
76
+ // Initialize leakage loss
77
+ hyd->LeakageLoss = 0.0;
78
+
79
+ // Examine each junction node
80
+ for (i = 1; i <= net->Njuncs; i++)
81
+ {
82
+ // Accumulate consumer demand flow
83
+ v = hyd->DemandFlow[i];
84
+ if (v < 0.0)
85
+ flowBalance.totalInflow += (-v);
86
+ else
87
+ {
88
+ fullDemand += hyd->FullDemand[i];
89
+ flowBalance.consumerDemand += v;
90
+ flowBalance.totalOutflow += v;
91
+ }
92
+
93
+ // Accumulate emitter and leakage flow
94
+ v = hyd->EmitterFlow[i];
95
+ flowBalance.emitterDemand += v;
96
+ flowBalance.totalOutflow += v;
97
+ v = hyd->LeakageFlow[i];
98
+ flowBalance.leakageDemand += v;
99
+ flowBalance.totalOutflow += v;
100
+
101
+ // Accumulate demand deficit flow
102
+ if (hyd->DemandModel == PDA && hyd->FullDemand[i] > 0.0)
103
+ {
104
+ deficit = hyd->FullDemand[i] - hyd->DemandFlow[i];
105
+ if (deficit > 0.0)
106
+ flowBalance.deficitDemand += deficit;
107
+ }
108
+ }
109
+
110
+ // Examine each tank/reservoir node
111
+ for (j = 1; j <= net->Ntanks; j++)
112
+ {
113
+ i = net->Tank[j].Node;
114
+ v = hyd->NodeDemand[i];
115
+
116
+ // For a reservoir node
117
+ if (net->Tank[j].A == 0.0)
118
+ {
119
+ if (v >= 0.0)
120
+ flowBalance.totalOutflow += v;
121
+ else
122
+ flowBalance.totalInflow += (-v);
123
+ }
124
+
125
+ // For tank
126
+ else
127
+ flowBalance.storageDemand += v;
128
+ }
129
+
130
+ // Find % leakage for current period
131
+ v = flowBalance.totalInflow;
132
+ if (flowBalance.storageDemand < 0.0) v += (-flowBalance.storageDemand);
133
+ if (v > 0.0)
134
+ hyd->LeakageLoss = flowBalance.leakageDemand / v * 100.0;
135
+
136
+ // Update flow balance for entire run
137
+ hyd->FlowBalance.totalInflow += flowBalance.totalInflow * dt;
138
+ hyd->FlowBalance.totalOutflow += flowBalance.totalOutflow * dt;
139
+ hyd->FlowBalance.consumerDemand += flowBalance.consumerDemand * dt;
140
+ hyd->FlowBalance.emitterDemand += flowBalance.emitterDemand * dt;
141
+ hyd->FlowBalance.leakageDemand += flowBalance.leakageDemand * dt;
142
+ hyd->FlowBalance.deficitDemand += flowBalance.deficitDemand * dt;
143
+ hyd->FlowBalance.storageDemand += flowBalance.storageDemand * dt;
144
+ }
145
+
146
+ void endflowbalance(Project *pr)
147
+ /*
148
+ **-------------------------------------------------------------------
149
+ ** Input: none
150
+ ** Output: none
151
+ ** Purpose: finalizes components of the system flow balance.
152
+ **-------------------------------------------------------------------
153
+ */
154
+ {
155
+ Hydraul *hyd = &pr->hydraul;
156
+ Times *time = &pr->times;
157
+
158
+ double seconds, qin, qout, qstor, r;
159
+
160
+ if (time->Htime > 0)
161
+ seconds = time->Htime;
162
+ else
163
+ seconds = 1.0;
164
+ hyd->FlowBalance.totalInflow /= seconds;
165
+ hyd->FlowBalance.totalOutflow /= seconds;
166
+ hyd->FlowBalance.consumerDemand /= seconds;
167
+ hyd->FlowBalance.emitterDemand /= seconds;
168
+ hyd->FlowBalance.leakageDemand /= seconds;
169
+ hyd->FlowBalance.deficitDemand /= seconds;
170
+ hyd->FlowBalance.storageDemand /= seconds;
171
+
172
+ qin = hyd->FlowBalance.totalInflow;
173
+ qout = hyd->FlowBalance.totalOutflow;
174
+ qstor = hyd->FlowBalance.storageDemand;
175
+ if (qstor > 0.0)
176
+ qout += qstor;
177
+ else
178
+ qin -= qstor;
179
+ if (qin == qout)
180
+ r = 1.0;
181
+ else if (qin > 0.0)
182
+ r = qout / qin;
183
+ else
184
+ r = 0.0;
185
+ hyd->FlowBalance.ratio = r;
186
+ }