Compare commits

..

15 Commits

Author SHA1 Message Date
Huarch
51caa50374 修正 epanet_output 读取 bin 文件数据错误的问题
Some checks are pending
linux / build (push) Waiting to run
macOS / build (push) Waiting to run
epanet2-win32 / build (push) Waiting to run
epanet2-win64 / build (push) Waiting to run
2026-01-05 16:58:07 +08:00
Lew Rossman
39407a3a17 Merge pull request #881 from OpenWaterAnalytics/dev-setting-initstatus
Update EN_setlinkvalue for EN_INITSTATUS
2025-09-29 16:51:20 -04:00
Lew Rossman
0bb2e73c8e Update EN_setlinkvalue for EN_INITSTATUS 2025-09-25 09:38:33 -04:00
Lew Rossman
0004dc2bec Merge pull request #880 from alissamueller/dev-pumpstatus-bugfix
Fixes Bug in EN_setlinkvalue
2025-09-23 10:43:53 -04:00
Lew Rossman
24013a95b2 Update CODEVERSION in types.h 2025-09-23 10:37:15 -04:00
Alissa
f456d207db Fixes Bug in setlinkvalue
status value is only converted to StatusType enum for initial status
2025-09-23 13:13:59 +02:00
Lew Rossman
d5d431d34a Merge pull request #879 from OpenWaterAnalytics/dev-leakage_NAN_fix
Avoid possible NAN in leakage.c
2025-09-12 13:18:20 -04:00
Lew Rossman
d345541af7 Avoid possible NAN in leakage.c 2025-09-10 11:06:05 -04:00
Lew Rossman
b1630f3091 Merge pull request #877 from OpenWaterAnalytics/EN_setpipedata_bug_fix
Fixes bug in EN_setpipedata
2025-09-04 17:31:50 -04:00
Lew Rossman
1605567fda Merge pull request #874 from 0tkl/doc-usage
Add EN_LINKQUAL and EN_PUMP_STATE to the usage topic
2025-09-04 17:30:59 -04:00
Lew Rossman
1f24209516 Fixes bug in EN_setpipedata
See issue #876 .
2025-09-03 15:11:49 -04:00
0tkl
e62f69c939 Document EN_LINKQUAL and EN_PUMP_STATE enums 2025-08-13 16:03:13 +08:00
0tkl
aabe60a6ae add missing parentheses 2025-08-13 15:56:03 +08:00
0tkl
30e644330c add a missing line break after list 2025-08-13 15:55:04 +08:00
0tkl
2a75f1e83c fix a typo 2025-08-13 15:51:15 +08:00
5 changed files with 33 additions and 22 deletions

View File

@@ -70,7 +70,7 @@ EN_addlink(ph, "P1", EN_PIPE, "J1", "J2", &index);
// additional function calls to complete building the network // additional function calls to complete building the network
\endcode \endcode
See the @ref Example2 for a more complete example. The labels used to name objects cannot contain spaces, semi-colons, or double quotes nor exceed @ref EN_SizeLimits "EN_MAXID" characters in length. While adding objects their properties can be set as described in the next section. Attemtping to change a network's structure by adding or deleting nodes and links while the Toolkit's hydraulic or water quality solvers are open will result in an error condition. See the @ref Example2 for a more complete example. The labels used to name objects cannot contain spaces, semi-colons, or double quotes nor exceed @ref EN_SizeLimits "EN_MAXID" characters in length. While adding objects their properties can be set as described in the next section. Attempting to change a network's structure by adding or deleting nodes and links while the Toolkit's hydraulic or water quality solvers are open will result in an error condition.
@section Properties Setting Object Properties @section Properties Setting Object Properties
@@ -179,14 +179,16 @@ int runConcurrentQuality(EN_Project ph)
The @ref EN_getnodevalue and @ref EN_getlinkvalue functions can also be used to retrieve the results of hydraulic and water quality simulations. The computed parameters (and their Toolkit codes) that can be retrieved are as follows: The @ref EN_getnodevalue and @ref EN_getlinkvalue functions can also be used to retrieve the results of hydraulic and water quality simulations. The computed parameters (and their Toolkit codes) that can be retrieved are as follows:
|For Nodes: | For Links: | |For Nodes: | For Links: |
|------------------------------------ | ----------------------------------------- | |------------------------------------ | ----------------------------------------- |
|\b EN_DEMAND (total node outflow |\b EN_FLOW (flow rate) | |\b EN_DEMAND (total node outflow) |\b EN_FLOW (flow rate) |
|\b EN_HEAD (hydraulic head) |\b EN_VELOCITY (flow velocity) | |\b EN_HEAD (hydraulic head) |\b EN_VELOCITY (flow velocity) |
|\b EN_PRESSURE (pressure) |\b EN_HEADLOSS (head loss) | |\b EN_PRESSURE (pressure) |\b EN_HEADLOSS (head loss) |
|\b EN_TANKLEVEL (tank water level) |\b EN_STATUS (link status) | |\b EN_TANKLEVEL (tank water level) |\b EN_STATUS (link status) |
|\b EN_TANKVOLUME (tank water volume) |\b EN_SETTING (pump speed or valve setting)| |\b EN_TANKVOLUME (tank water volume) |\b EN_SETTING (pump speed or valve setting)|
|\b EN_QUALITY (water quality) |\b EN_ENERGY (pump energy usage) | |\b EN_QUALITY (water quality) |\b EN_ENERGY (pump energy usage) |
|\b EN_SOURCEMASS (source mass inflow)|\b EN_PUMP_EFFIC (pump efficiency) | |\b EN_SOURCEMASS (source mass inflow)|\b EN_LINKQUAL (water quality) |
| |\b EN_LINK_LEAKAGE (pipe leakage flow rate | | |\b EN_PUMP_STATE (pump state) |
| |\b EN_PUMP_EFFIC (pump efficiency) |
| |\b EN_LINK_LEAKAGE (pipe leakage flow rate)|
In addition, the following quantities related to a node's outflow can be retrieved: In addition, the following quantities related to a node's outflow can be retrieved:
-# EN_FULLDEMAND (consumer demand requested) -# EN_FULLDEMAND (consumer demand requested)
@@ -194,6 +196,7 @@ In addition, the following quantities related to a node's outflow can be retriev
-# EN_DEMANDDEFICIT (difference between consumer demand requested and delivered) -# EN_DEMANDDEFICIT (difference between consumer demand requested and delivered)
-# EN_EMITTERFLOW (outflow through a node's emitter) -# EN_EMITTERFLOW (outflow through a node's emitter)
-# EN_LEAKAGEFLOW (outflow due to leakage in a node's connecting pipes) -# EN_LEAKAGEFLOW (outflow due to leakage in a node's connecting pipes)
where `EN_DEMAND` is the sum of `EN_DEMANDFLOW`, `EN_EMITTERFLOW`, and `EN_LEAKAGEFLOW`. where `EN_DEMAND` is the sum of `EN_DEMANDFLOW`, `EN_EMITTERFLOW`, and `EN_LEAKAGEFLOW`.
The following code shows how to retrieve the pressure at each node of a network after each time step of a hydraulic analysis (`writetofile` is a user-defined function that will write a record to a file): The following code shows how to retrieve the pressure at each node of a network after each time step of a hydraulic analysis (`writetofile` is a user-defined function that will write a record to a file):

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 04/23/2025 Last Updated: 09/03/2025
****************************************************************************** ******************************************************************************
*/ */
@@ -4130,12 +4130,17 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
case EN_STATUS: case EN_STATUS:
// Cannot set status for a check valve // Cannot set status for a check valve
if (Link[index].Type == CVPIPE) return 207; if (Link[index].Type == CVPIPE) return 207;
// Status 's' must be either EN_CLOSED (0) or EN_OPEN (1)
// (to set the status of a valve to ACTIVE, assign a value to its
// EN_INITSETTING or EN_SETTING property)
s = (char)ROUND(value); s = (char)ROUND(value);
if (s < 0 || s > 2) return 211; if (s < 0 || s > 1) return 211;
s = s + CLOSED;
if (property == EN_INITSTATUS) if (property == EN_INITSTATUS)
{ {
Link[index].InitStatus = s; // Convert 0/1 to StatusType CLOSED/OPEN
Link[index].InitStatus = s + CLOSED;
} }
else else
{ {
@@ -4340,11 +4345,11 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
Link[index].Diam = diameter; Link[index].Diam = diameter;
Link[index].Kc = rough; Link[index].Kc = rough;
if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]); if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]);
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
// Update minor loss factor & pipe flow resistance // Update pipe flow resistance
if (p->hydraul.OpenHflag) if (p->hydraul.OpenHflag)
{ {
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
resistcoeff(p, index); resistcoeff(p, index);
} }
else Link[index].InitSetting = Link[index].Kc; else Link[index].InitSetting = Link[index].Kc;

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 06/14/2024 Last Updated: 09/10/2025
****************************************************************************** ******************************************************************************
*/ */
/* /*
@@ -432,12 +432,15 @@ int leakagehasconverged(Project *pr)
// Directly compute a reference leakage at this pressure head // Directly compute a reference leakage at this pressure head
qref = 0.0; qref = 0.0;
if ( h > 0.0)
{
// Contribution from pipes with fixed area leaks // Contribution from pipes with fixed area leaks
if (hyd->Leakage[i].cfa > 0.0) if (hyd->Leakage[i].cfa > 0.0)
qref = sqrt(h / hyd->Leakage[i].cfa); qref = sqrt(h / hyd->Leakage[i].cfa);
// Contribution from pipes with variable area leaks // Contribution from pipes with variable area leaks
if (hyd->Leakage[i].cva > 0.0) if (hyd->Leakage[i].cva > 0.0)
qref += pow((h / hyd->Leakage[i].cva), 1.5); qref += pow((h / hyd->Leakage[i].cva), 1.5);
}
// Compare reference leakage to solution leakage // Compare reference leakage to solution leakage
qtest = hyd->Leakage[i].qfa + hyd->Leakage[i].qva; qtest = hyd->Leakage[i].qfa + hyd->Leakage[i].qva;

View File

@@ -750,7 +750,7 @@ int EXPORT_OUT_API ENR_getNodeResult(ENR_Handle p_handle, int periodIndex,
else else
{ {
for (j = 0; j < NNODERESULTS; j++) for (j = 0; j < NNODERESULTS; j++)
temp[j] = getNodeValue(p_handle, periodIndex, nodeIndex, j); temp[j] = getNodeValue(p_handle, periodIndex, nodeIndex, j + 1);
*outValueArray = temp; *outValueArray = temp;
*length = NNODERESULTS; *length = NNODERESULTS;
@@ -778,7 +778,7 @@ int EXPORT_OUT_API ENR_getLinkResult(ENR_Handle p_handle, int periodIndex,
else else
{ {
for (j = 0; j < NLINKRESULTS; j++) for (j = 0; j < NLINKRESULTS; j++)
temp[j] = getLinkValue(p_handle, periodIndex, linkIndex, j); temp[j] = getLinkValue(p_handle, periodIndex, linkIndex, j + 1);
*outValueArray = temp; *outValueArray = temp;
*length = NLINKRESULTS; *length = NLINKRESULTS;

View File

@@ -7,7 +7,7 @@
Authors: see AUTHORS Authors: see AUTHORS
Copyright: see AUTHORS Copyright: see AUTHORS
License: see LICENSE License: see LICENSE
Last Updated: 04/19/2025 Last Updated: 09/03/2025
****************************************************************************** ******************************************************************************
*/ */
@@ -31,7 +31,7 @@ typedef int INT4;
Various constants Various constants
---------------------------------------------- ----------------------------------------------
*/ */
#define CODEVERSION 20301 #define CODEVERSION 20303
#define MAGICNUMBER 516114521 #define MAGICNUMBER 516114521
#define ENGINE_VERSION 201 // Used for binary hydraulics file #define ENGINE_VERSION 201 // Used for binary hydraulics file
#define EOFMARK 0x1A // Use 0x04 for UNIX systems #define EOFMARK 0x1A // Use 0x04 for UNIX systems