epyt-flow 0.14.1__py3-none-any.whl → 0.14.2__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 (55) hide show
  1. epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +8 -40
  2. epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +3 -3
  3. epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +18 -0
  4. epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +7 -24
  5. epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +374 -726
  6. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +32 -128
  7. epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +131 -0
  8. epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +1 -7
  9. epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +14 -40
  10. epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -177
  11. epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -28
  12. epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +40 -192
  13. epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +46 -101
  14. epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +24 -85
  15. epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +63 -29
  16. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +37 -70
  17. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +234 -408
  18. epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +37 -87
  19. epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +79 -153
  20. epyt_flow/EPANET/EPANET/SRC_engines/input1.c +94 -59
  21. epyt_flow/EPANET/EPANET/SRC_engines/input2.c +202 -73
  22. epyt_flow/EPANET/EPANET/SRC_engines/input3.c +351 -446
  23. epyt_flow/EPANET/EPANET/SRC_engines/main.c +93 -0
  24. epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +4 -8
  25. epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +23 -23
  26. epyt_flow/EPANET/EPANET/SRC_engines/output.c +4 -5
  27. epyt_flow/EPANET/EPANET/SRC_engines/project.c +75 -407
  28. epyt_flow/EPANET/EPANET/SRC_engines/quality.c +2 -12
  29. epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +13 -70
  30. epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +5 -7
  31. epyt_flow/EPANET/EPANET/SRC_engines/report.c +20 -88
  32. epyt_flow/EPANET/EPANET/SRC_engines/rules.c +6 -144
  33. epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +19 -19
  34. epyt_flow/EPANET/EPANET/SRC_engines/text.h +5 -16
  35. epyt_flow/EPANET/EPANET/SRC_engines/types.h +19 -73
  36. epyt_flow/EPANET/compile_linux.sh +1 -1
  37. epyt_flow/EPANET/compile_macos.sh +1 -1
  38. epyt_flow/VERSION +1 -1
  39. epyt_flow/simulation/scada/scada_data.py +1 -1
  40. epyt_flow/utils.py +66 -0
  41. epyt_flow/visualization/visualization_utils.py +4 -2
  42. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/METADATA +1 -1
  43. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/RECORD +46 -52
  44. epyt_flow/EPANET/EPANET/SRC_engines/flowbalance.c +0 -186
  45. epyt_flow/EPANET/EPANET/SRC_engines/leakage.c +0 -527
  46. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.c +0 -59
  47. epyt_flow/EPANET/EPANET/SRC_engines/util/cstr_helper.h +0 -38
  48. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.c +0 -92
  49. epyt_flow/EPANET/EPANET/SRC_engines/util/errormanager.h +0 -39
  50. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.c +0 -212
  51. epyt_flow/EPANET/EPANET/SRC_engines/util/filemanager.h +0 -81
  52. epyt_flow/EPANET/EPANET/SRC_engines/validate.c +0 -408
  53. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/WHEEL +0 -0
  54. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/licenses/LICENSE +0 -0
  55. {epyt_flow-0.14.1.dist-info → epyt_flow-0.14.2.dist-info}/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: quality.c
6
6
  Description: implements EPANET's water quality engine
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 02/14/2025
10
+ Last Updated: 05/15/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -63,16 +63,8 @@ int openqual(Project *pr)
63
63
  // Build nodal adjacency lists if they don't already exist
64
64
  if (net->Adjlist == NULL)
65
65
  {
66
- // Check for too few nodes & no fixed grade nodes
67
- if (net->Nnodes < 2) return 223;
68
- if (net->Ntanks == 0) return 224;
69
-
70
- // Build adjacency lists
71
66
  errcode = buildadjlists(net);
72
67
  if (errcode ) return errcode;
73
-
74
- // Check for unconnected nodes
75
- if (errcode = unlinked(pr)) return errcode;
76
68
  }
77
69
 
78
70
  // Create a memory pool for water quality segments
@@ -183,7 +175,6 @@ int initqual(Project *pr)
183
175
  qual->MassBalance.reacted = 0.0;
184
176
  qual->MassBalance.final = 0.0;
185
177
  qual->MassBalance.ratio = 0.0;
186
- qual->MassBalance.segCount = 0;
187
178
  return errcode;
188
179
  }
189
180
 
@@ -411,7 +402,6 @@ int closequal(Project *pr)
411
402
  FREE(qual->FlowDir);
412
403
  FREE(qual->SortedNodes);
413
404
  }
414
- freeadjlists(&pr->network);
415
405
  return errcode;
416
406
  }
417
407
 
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: qualreact.c
6
6
  Description: computes water quality reactions within pipes and tanks
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 12/16/2024
10
+ Last Updated: 05/15/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -232,7 +232,7 @@ double piperate(Project *pr, int k)
232
232
  }
233
233
 
234
234
  // Compute Reynolds No.
235
- // Flow rate made consistent with how it's saved to hydraulics file
235
+ // Flow rate made consistent with how its saved to hydraulics file
236
236
  q = (hyd->LinkStatus[k] <= CLOSED) ? 0.0 : hyd->LinkFlow[k];
237
237
  a = PI * d * d / 4.0; // pipe area
238
238
  u = fabs(q) / a; // flow velocity
@@ -492,13 +492,6 @@ void tankmix1(Project *pr, int i, double vin, double win, double vnet)
492
492
  seg->v += vnet;
493
493
  seg->v = MAX(0.0, seg->v);
494
494
  tank->C = seg->c;
495
-
496
- // Account for mass lost in tank overflow
497
- if (seg->v > tank->Vmax)
498
- {
499
- qual->MassBalance.outflow += ((seg->v) - tank->Vmax) * tank->C;
500
- seg->v = tank->Vmax;
501
- }
502
495
  }
503
496
  }
504
497
 
@@ -520,8 +513,7 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
520
513
 
521
514
  int k;
522
515
  double vt, // Transferred volume
523
- vmz, // Full mixing zone volume
524
- vsz; // Full stagnant zone volume
516
+ vmz; // Full mixing zone volume
525
517
  Pseg mixzone, // Mixing zone segment
526
518
  stagzone; // Stagnant zone segment
527
519
  Stank *tank = &pr->network.Tank[i];
@@ -533,7 +525,7 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
533
525
  if (mixzone == NULL || stagzone == NULL) return;
534
526
 
535
527
  // Full mixing zone volume
536
- vmz = tank->V1frac * tank->Vmax;
528
+ vmz = tank->V1max;
537
529
 
538
530
  // Tank is filling
539
531
  vt = 0.0;
@@ -566,31 +558,16 @@ void tankmix2(Project *pr, int i, double vin, double win, double vnet)
566
558
  // Update segment volumes
567
559
  if (vt > 0.0)
568
560
  {
569
- if (vnet > 0.0)
570
- {
571
- mixzone->v = vmz;
572
- stagzone->v += vt;
573
-
574
- // Account for mass lost in overflow from stagnant zone
575
- vsz = (tank->Vmax) - vmz;
576
- if (stagzone->v > vsz)
577
- {
578
- qual->MassBalance.outflow += ((stagzone->v) - vsz) * stagzone->c;
579
- stagzone->v = vsz;
580
- }
581
- }
582
- else
583
- {
584
- stagzone->v = MAX(0.0, ((stagzone->v) - vt));
585
- mixzone->v = vmz + vt + vnet;
586
- }
561
+ mixzone->v = vmz;
562
+ if (vnet > 0.0) stagzone->v += vt;
563
+ else stagzone->v = MAX(0.0, ((stagzone->v) - vt));
587
564
  }
588
565
  else
589
566
  {
590
567
  mixzone->v += vnet;
591
568
  mixzone->v = MIN(mixzone->v, vmz);
592
569
  mixzone->v = MAX(0.0, mixzone->v);
593
- if (vmz - mixzone->v > 0.0) stagzone->v = 0.0;
570
+ stagzone->v = 0.0;
594
571
  }
595
572
 
596
573
  // Use quality of mixing zone to represent quality of
@@ -635,13 +612,10 @@ void tankmix3(Project *pr, int i, double vin, double win, double vnet)
635
612
  else addseg(pr, k, vin, cin);
636
613
  }
637
614
 
638
- // Find volume leaving tank, adjusted so its volume doesn't exceed Vmax
639
- vout = vin - vnet;
640
- if (tank->V >= tank->Vmax && vnet > 0.0) vout = vin;
641
-
642
- // Withdraw outflow from first segment
615
+ // Withdraw flow from first segment
643
616
  vsum = 0.0;
644
617
  wsum = 0.0;
618
+ vout = vin - vnet;
645
619
  while (vout > 0.0)
646
620
  {
647
621
  seg = qual->FirstSeg[k];
@@ -669,10 +643,6 @@ void tankmix3(Project *pr, int i, double vin, double win, double vnet)
669
643
  if (vsum > 0.0) tank->C = wsum / vsum;
670
644
  else if (qual->FirstSeg[k] == NULL) tank->C = 0.0;
671
645
  else tank->C = qual->FirstSeg[k]->c;
672
-
673
- // Account for mass lost in overflow from 1st segment
674
- if (tank->V >= tank->Vmax && vnet > 0.0)
675
- qual->MassBalance.outflow += vnet * tank->C;
676
646
  }
677
647
 
678
648
 
@@ -699,7 +669,7 @@ void tankmix4(Project *pr, int i, double vin, double win, double vnet)
699
669
  k = net->Nlinks + i;
700
670
  if (qual->LastSeg[k] == NULL || qual->FirstSeg[k] == NULL) return;
701
671
 
702
- // Find inflow concentration
672
+ // Find inflows & outflows
703
673
  if (vin > 0.0) cin = win / vin;
704
674
  else cin = 0.0;
705
675
 
@@ -717,33 +687,6 @@ void tankmix4(Project *pr, int i, double vin, double win, double vnet)
717
687
 
718
688
  // Update reported tank quality
719
689
  tank->C = qual->LastSeg[k]->c;
720
-
721
- // If tank full then remove vnet from leading segments
722
- if (tank->V >= tank->Vmax)
723
- {
724
- wsum = 0.0;
725
- while (vnet > 0.0)
726
- {
727
- seg = qual->FirstSeg[k];
728
- if (seg == NULL) break;
729
- vseg = seg->v; // Flow volume from leading seg
730
- vseg = MIN(vseg, vnet);
731
- if (seg == qual->LastSeg[k]) vseg = vnet;
732
- wsum += (seg->c) * vseg;
733
- vnet -= vseg; // Remaining flow volume
734
- if (vnet >= 0.0 && vseg >= seg->v) // Seg used up
735
- {
736
- if (seg->prev)
737
- {
738
- qual->FirstSeg[k] = seg->prev;
739
- seg->prev = qual->FreeSeg;
740
- qual->FreeSeg = seg;
741
- }
742
- }
743
- else seg->v -= vseg; // Remaining volume in segment
744
- }
745
- qual->MassBalance.outflow += wsum;
746
- }
747
690
  }
748
691
 
749
692
  // If tank emptying then remove last segments until vnet consumed
@@ -772,7 +715,7 @@ void tankmix4(Project *pr, int i, double vin, double win, double vnet)
772
715
  vsum += vseg;
773
716
  wsum += (seg->c) * vseg;
774
717
 
775
- // ... update remaining volume to remove
718
+ // ... update remiaing volume to remove
776
719
  vnet -= vseg;
777
720
 
778
721
  // ... if no more volume left in current segment
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: qualroute.c
6
6
  Description: computes water quality transport over a single time step
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 02/14/2025
10
+ Last Updated: 05/15/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -183,7 +183,6 @@ void evalnodeinflow(Project *pr, int k, long tstep, double *volin,
183
183
  // ... recycle the used up segment
184
184
  seg->prev = qual->FreeSeg;
185
185
  qual->FreeSeg = seg;
186
- qual->MassBalance.segCount--;
187
186
  }
188
187
 
189
188
  // ... otherwise just reduce this segment's volume
@@ -247,7 +246,7 @@ double findnodequal(Project *pr, int n, double volin,
247
246
  return qual->NodeQual[n];
248
247
  }
249
248
 
250
- // Find quality contributed by any external chemical source
249
+ // Find quality contribued by any external chemical source
251
250
  else qual->SourceQual = findsourcequal(pr, n, volout, tstep);
252
251
  if (qual->SourceQual == 0.0) return qual->NodeQual[n];
253
252
 
@@ -610,10 +609,10 @@ void initsegs(Project *pr)
610
609
  addseg(pr, k, v, c);
611
610
 
612
611
  // Create a 2nd segment for the 2-compartment tank model
613
- if (!qual->OutOfMemory && net->Tank[j].MixModel == MIX2)
612
+ if (net->Tank[j].MixModel == MIX2)
614
613
  {
615
614
  // ... mixing zone segment
616
- v1 = MAX(0, v - net->Tank[j].V1frac * net->Tank[j].Vmax);
615
+ v1 = MAX(0, v - net->Tank[j].V1max);
617
616
  qual->FirstSeg[k]->v = v1;
618
617
 
619
618
  // ... stagnant zone segment
@@ -692,5 +691,4 @@ void addseg(Project *pr, int k, double v, double c)
692
691
  if (qual->FirstSeg[k] == NULL) qual->FirstSeg[k] = seg;
693
692
  if (qual->LastSeg[k] != NULL) qual->LastSeg[k]->prev = seg;
694
693
  qual->LastSeg[k] = seg;
695
- qual->MassBalance.segCount++;
696
694
  }
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: report.c
6
6
  Description: procedures for writing formatted text to a report file
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 02/14/2025
10
+ Last Updated: 07/22/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -45,7 +45,7 @@ static void writeenergy(Project *);
45
45
  static int writeresults(Project *);
46
46
  static int disconnected(Project *);
47
47
  static void marknodes(Project *, int, int *, char *);
48
- static void getclosedlink(Project *, int, char *, int *);
48
+ static void getclosedlink(Project *, int, char *);
49
49
  static void writelimits(Project *, int, int);
50
50
  static int checklimits(Report *, double *, int, int);
51
51
  static char *fillstr(char *, char, int);
@@ -67,7 +67,7 @@ int clearreport(Project *pr)
67
67
  return 0;
68
68
  }
69
69
 
70
- int copyreport(Project* pr, const char *filename)
70
+ int copyreport(Project* pr, char *filename)
71
71
  /*
72
72
  **------------------------------------------------------
73
73
  ** Input: filename = name of file to copy to
@@ -291,7 +291,7 @@ void writesummary(Project *pr)
291
291
  if (qual->Qualflag == NONE || time->Dur == 0.0) sprintf(s, FMT29);
292
292
  else if (qual->Qualflag == CHEM) sprintf(s, FMT30, qual->ChemName);
293
293
  else if (qual->Qualflag == TRACE) sprintf(s, FMT31, net->Node[qual->TraceNode].ID);
294
- else if (qual->Qualflag == AGE) sprintf(s, FMT32);
294
+ else if (qual->Qualflag == AGE) printf(s, FMT32);
295
295
  writeline(pr, s);
296
296
  if (qual->Qualflag != NONE && time->Dur > 0)
297
297
  {
@@ -422,51 +422,13 @@ void writehydstat(Project *pr, int iter, double relerr)
422
422
  writeline(pr, " ");
423
423
  }
424
424
 
425
- void writeflowbalance(Project *pr)
426
- /*
427
- **-------------------------------------------------------------
428
- ** Input: none
429
- ** Output: none
430
- ** Purpose: writes hydraulic flow balance ratio to report file.
431
- **-------------------------------------------------------------
432
- */
433
- {
434
- Hydraul *hyd = &pr->hydraul;
435
- Report *rpt = &pr->report;
436
- char s1[MAXMSG+1];
437
- double ucf = pr->Ucf[FLOW];
438
-
439
- snprintf(s1, MAXMSG, "Hydraulic Flow Balance (%s)", rpt->Field[DEMAND].Units);
440
- writeline(pr, s1);
441
- snprintf(s1, MAXMSG, "================================");
442
- writeline(pr, s1);
443
- snprintf(s1, MAXMSG, "Total Inflow: %12.3f", hyd->FlowBalance.totalInflow*ucf);
444
- writeline(pr, s1);
445
- snprintf(s1, MAXMSG, "Consumer Demand: %12.3f", hyd->FlowBalance.consumerDemand*ucf);
446
- writeline(pr, s1);
447
- snprintf(s1, MAXMSG, "Demand Deficit: %12.3f", hyd->FlowBalance.deficitDemand*ucf);
448
- writeline(pr, s1);
449
- snprintf(s1, MAXMSG, "Emitter Flow: %12.3f", hyd->FlowBalance.emitterDemand*ucf);
450
- writeline(pr, s1);
451
- snprintf(s1, MAXMSG, "Leakage Flow: %12.3f", hyd->FlowBalance.leakageDemand*ucf);
452
- writeline(pr, s1);
453
- snprintf(s1, MAXMSG, "Total Outflow: %12.3f", hyd->FlowBalance.totalOutflow*ucf);
454
- writeline(pr, s1);
455
- snprintf(s1, MAXMSG, "Storage Flow: %12.3f", hyd->FlowBalance.storageDemand*ucf);
456
- writeline(pr, s1);
457
- snprintf(s1, MAXMSG, "Flow Ratio: %12.3f", hyd->FlowBalance.ratio);
458
- writeline(pr, s1);
459
- snprintf(s1, MAXMSG, "================================\n");
460
- writeline(pr, s1);
461
- }
462
-
463
425
  void writemassbalance(Project *pr)
464
426
  /*
465
427
  **-------------------------------------------------------------
466
428
  ** Input: none
467
429
  ** Output: none
468
430
  ** Purpose: writes water quality mass balance ratio
469
- ** (Outflow + Final Storage) / Inflow + Initial Storage
431
+ ** (Outflow + Final Storage) / Inflow + Initial Storage)
470
432
  ** to report file.
471
433
  **-------------------------------------------------------------
472
434
  */
@@ -501,8 +463,6 @@ void writemassbalance(Project *pr)
501
463
  writeline(pr, s1);
502
464
  snprintf(s1, MAXMSG, "Mass Ratio: %-.5f", qual->MassBalance.ratio);
503
465
  writeline(pr, s1);
504
- snprintf(s1, MAXMSG, "Total Segments: %d", qual->MassBalance.segCount);
505
- writeline(pr, s1);
506
466
  snprintf(s1, MAXMSG, "================================\n");
507
467
  writeline(pr, s1);
508
468
  }
@@ -916,7 +876,7 @@ void writeheader(Project *pr, int type, int contin)
916
876
  }
917
877
  }
918
878
 
919
- void writeline(Project *pr, const char *s)
879
+ void writeline(Project *pr, char *s)
920
880
  /*
921
881
  **--------------------------------------------------------------
922
882
  ** Input: *s = text string
@@ -926,12 +886,6 @@ void writeline(Project *pr, const char *s)
926
886
  */
927
887
  {
928
888
  Report *rpt = &pr->report;
929
-
930
- if (pr->report.reportCallback != NULL)
931
- {
932
- pr->report.reportCallback(pr->report.reportCallbackUserData, pr, s);
933
- return;
934
- }
935
889
 
936
890
  if (rpt->RptFile == NULL) return;
937
891
  if (rpt->Rptflag)
@@ -1327,7 +1281,7 @@ int disconnected(Project *pr)
1327
1281
  clocktime(rpt->Atime, time->Htime));
1328
1282
  writeline(pr, pr->Msg);
1329
1283
  }
1330
- getclosedlink(pr, j, marked, nodelist);
1284
+ getclosedlink(pr, j, marked);
1331
1285
  }
1332
1286
 
1333
1287
  // Free allocated memory
@@ -1390,12 +1344,11 @@ void marknodes(Project *pr, int m, int *nodelist, char *marked)
1390
1344
  }
1391
1345
  }
1392
1346
 
1393
- void getclosedlink(Project *pr, int i, char *marked, int *stack)
1347
+ void getclosedlink(Project *pr, int i, char *marked)
1394
1348
  /*
1395
1349
  **----------------------------------------------------------------
1396
1350
  ** Input: i = junction index
1397
1351
  ** marked[] = marks nodes already examined
1398
- ** stack[] = stack to hold nodes to examine
1399
1352
  ** Output: None.
1400
1353
  ** Purpose: Determines if a closed link connects to junction i.
1401
1354
  **----------------------------------------------------------------
@@ -1406,41 +1359,20 @@ void getclosedlink(Project *pr, int i, char *marked, int *stack)
1406
1359
  int j, k;
1407
1360
  Padjlist alink;
1408
1361
 
1409
- int top = 0;
1410
-
1411
- // Mark the current junction as examined and push onto stack
1412
1362
  marked[i] = 2;
1413
- stack[top] = i;
1414
-
1415
- while (top >= 0) {
1416
- i = stack[top--];
1417
- alink = net->Adjlist[i];
1418
-
1419
- // Iterate through each link adjacent to the current node
1420
- while (alink != NULL) {
1421
- k = alink->link;
1422
- j = alink->node;
1423
-
1424
- // Skip nodes that have already been examined
1425
- if (marked[j] == 2) {
1426
- alink = alink->next;
1427
- continue;
1428
- }
1429
-
1430
- // If a closed link is found, return and display a warning message
1431
- if (marked[j] == 1) {
1432
- sprintf(pr->Msg, WARN03c, net->Link[k].ID);
1433
- writeline(pr, pr->Msg);
1434
- return;
1435
- }
1436
-
1437
- // Mark the node as examined and push it onto the stack
1438
- marked[j] = 2;
1439
- stack[++top] = j;
1440
- alink = alink->next;
1363
+ for (alink = net->Adjlist[i]; alink != NULL; alink = alink->next)
1364
+ {
1365
+ k = alink->link;
1366
+ j = alink->node;
1367
+ if (marked[j] == 2) continue;
1368
+ if (marked[j] == 1)
1369
+ {
1370
+ sprintf(pr->Msg, WARN03c, net->Link[k].ID);
1371
+ writeline(pr, pr->Msg);
1372
+ return;
1441
1373
  }
1374
+ else getclosedlink(pr, j, marked);
1442
1375
  }
1443
-
1444
1376
  }
1445
1377
 
1446
1378
  void writelimits(Project *pr, int j1, int j2)
@@ -1,13 +1,13 @@
1
1
  /*
2
2
  ******************************************************************************
3
3
  Project: OWA EPANET
4
- Version: 2.3
4
+ Version: 2.2
5
5
  Module: rules.c
6
6
  Description: implements rule-based controls
7
7
  Authors: see AUTHORS
8
8
  Copyright: see AUTHORS
9
9
  License: see LICENSE
10
- Last Updated: 02/11/2025
10
+ Last Updated: 05/15/2019
11
11
  ******************************************************************************
12
12
  */
13
13
 
@@ -32,11 +32,10 @@ enum Rulewords {
32
32
  r_THEN,
33
33
  r_ELSE,
34
34
  r_PRIORITY,
35
- r_DISABLED,
36
35
  r_ERROR
37
36
  };
38
37
  char *Ruleword[] = {w_RULE, w_IF, w_AND, w_OR,
39
- w_THEN, w_ELSE, w_PRIORITY, w_DISABLED, NULL};
38
+ w_THEN, w_ELSE, w_PRIORITY, NULL};
40
39
 
41
40
  enum Varwords {
42
41
  r_DEMAND,
@@ -274,16 +273,6 @@ int ruledata(Project *pr)
274
273
  err = newpriority(pr);
275
274
  break;
276
275
 
277
- case r_DISABLED:
278
- if (rules->RuleState != r_THEN && rules->RuleState != r_ELSE &&
279
- rules->RuleState != r_PRIORITY)
280
- {
281
- err = 221;
282
- break;
283
- }
284
- net->Rule[net->Nrules].isEnabled = FALSE;
285
- break;
286
-
287
276
  default:
288
277
  err = 201;
289
278
  }
@@ -415,7 +404,7 @@ void adjustrules(Project *pr, int objtype, int index)
415
404
  }
416
405
  }
417
406
 
418
- void adjusttankrules(Project *pr, int ndiff)
407
+ void adjusttankrules(Project *pr)
419
408
  //-----------------------------------------------------------
420
409
  // Adjusts tank indices in rule premises.
421
410
  //-----------------------------------------------------------
@@ -431,8 +420,7 @@ void adjusttankrules(Project *pr, int ndiff)
431
420
  p = net->Rule[i].Premises;
432
421
  while (p != NULL)
433
422
  {
434
- if (p->object == r_NODE && p->index > njuncs)
435
- p->index += ndiff;
423
+ if (p->object == r_NODE && p->index > njuncs) p->index++;
436
424
  p = p->next;
437
425
  }
438
426
  }
@@ -484,7 +472,7 @@ int writerule(Project *pr, FILE *f, int ruleIndex)
484
472
  Srule *rule = &net->Rule[ruleIndex];
485
473
  Spremise *p;
486
474
  Saction *a;
487
-
475
+
488
476
  // Write each premise clause to the file
489
477
  p = rule->Premises;
490
478
  fprintf(f, "\nIF ");
@@ -539,11 +527,6 @@ int checkrules(Project *pr, long dt)
539
527
  rules->ActionList = NULL;
540
528
  for (i = 1; i <= net->Nrules; i++)
541
529
  {
542
- // skip if the rule is disabled
543
- if (!net->Rule[i].isEnabled)
544
- {
545
- continue;
546
- }
547
530
  // If premises true, add THEN clauses to action list
548
531
  if (evalpremises(pr, i) == TRUE)
549
532
  {
@@ -566,126 +549,6 @@ int checkrules(Project *pr, long dt)
566
549
  return actionCount;
567
550
  }
568
551
 
569
- void updateruleunits(Project *pr, double dcf, double pcf, double hcf, double qcf)
570
- //-----------------------------------------------------------
571
- // Updates the units of a rule's premises and actions.
572
- //-----------------------------------------------------------
573
- {
574
- Network *net = &pr->network;
575
- Slink *Link = net->Link;
576
-
577
- int i, k;
578
- double x;
579
- Spremise *p;
580
- Saction *a;
581
-
582
- for (i = 1; i <= net->Nrules; i++)
583
- {
584
- p = net->Rule[i].Premises;
585
- while (p != NULL)
586
- {
587
-
588
- switch (p->variable)
589
- {
590
- case r_DEMAND:
591
- p->value *= dcf;
592
- break;
593
-
594
- case r_HEAD:
595
- case r_GRADE:
596
- p->value *= hcf;
597
- break;
598
-
599
- case r_PRESSURE:
600
- p->value *= pcf;
601
- break;
602
-
603
- case r_LEVEL:
604
- p->value *= hcf;
605
- break;
606
-
607
- case r_FLOW:
608
- p->value *= qcf;
609
- break;
610
-
611
- case r_SETTING:
612
-
613
- switch (Link[p->index].Type)
614
- {
615
- case PRV:
616
- case PSV:
617
- case PBV:
618
- p->value *= pcf;
619
- break;
620
- case FCV:
621
- p->value *= qcf;
622
- break;
623
- default:
624
- break;
625
- }
626
- break;
627
-
628
- default:
629
- break;
630
-
631
- }
632
- p = p->next;
633
- }
634
-
635
- a = net->Rule[i].ThenActions;
636
- while (a != NULL)
637
- {
638
- k = a->link;
639
- x = a->setting;
640
-
641
- // Change link's setting
642
- if (x != MISSING)
643
- {
644
- switch (net->Link[k].Type)
645
- {
646
- case PRV:
647
- case PSV:
648
- case PBV:
649
- a->setting *= pcf;
650
- break;
651
- case FCV:
652
- a->setting *= qcf;
653
- break;
654
- default:
655
- break;
656
- }
657
- }
658
- a = a->next;
659
- }
660
- a = net->Rule[i].ElseActions;
661
- while (a != NULL)
662
- {
663
- k = a->link;
664
- x = a->setting;
665
-
666
- // Change link's setting
667
- if (x != MISSING)
668
- {
669
- switch (net->Link[k].Type)
670
- {
671
- case PRV:
672
- case PSV:
673
- case PBV:
674
- a->setting *= pcf;
675
- break;
676
- case FCV:
677
- a->setting *= qcf;
678
- break;
679
- default:
680
- break;
681
- }
682
- }
683
- a = a->next;
684
- }
685
- }
686
- }
687
-
688
-
689
552
  void newrule(Project *pr)
690
553
  //----------------------------------------------------------
691
554
  // Adds a new rule to the project
@@ -701,7 +564,6 @@ void newrule(Project *pr)
701
564
  rule->ThenActions = NULL;
702
565
  rule->ElseActions = NULL;
703
566
  rule->priority = 0.0;
704
- rule->isEnabled = TRUE;
705
567
  pr->rules.LastPremise = NULL;
706
568
  pr->rules.LastThenAction = NULL;
707
569
  pr->rules.LastElseAction = NULL;