Merge pull request #368 from LRossman/lrossman-dev
Added additional network building features (#367)
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
Release Notes for EPANET 2.2 (Draft)
|
Release Notes for EPANET 2.2 (Draft)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
This document describes the changes and updates that have been made to version 2.2 of EPANET.
|
This document describes the changes and updates that have been made to version 2.2 of EPANET.
|
||||||
|
|
||||||
## Thread-Safe API Functions
|
## Thread-Safe API Functions
|
||||||
|
|
||||||
A duplicate set of the version 2.1 API functions has been provided that allow multiple EPANET projects to be analyzed concurrently in a thread-safe manner. These functions maintain the same name as the original but use a `EN_` prefix instead of `EN`. In addition, the first argument to each of these functions is a handle that identifies the network data for the particular project being analyzed. For example, instead of writing:
|
A duplicate set of API functions has been provided that allow multiple EPANET projects to be analyzed concurrently in a thread-safe manner. These functions maintain the same name as the original but use a `EN_` prefix instead of `EN`. In addition, the first argument to each of these functions is a handle that identifies the particular project being analyzed. For example, instead of writing:
|
||||||
|
|
||||||
`ENgetnodevalue(nodeIndex, EN_ELEVATION, &elev)`
|
`ENgetnodevalue(nodeIndex, EN_ELEVATION, &elev)`
|
||||||
|
|
||||||
@@ -13,14 +12,14 @@ one would use:
|
|||||||
|
|
||||||
`EN_getnodevalue(ph, nodeIndex, EN_ELEVATION, &elev)`
|
`EN_getnodevalue(ph, nodeIndex, EN_ELEVATION, &elev)`
|
||||||
|
|
||||||
where `ph` is the handle assigned to the project.
|
where `ph` is the handle assigned to the project.
|
||||||
|
|
||||||
Two new functions have been added to the API to manage the creation and deletion of project handles. `EN_createproject` creates a new project along with its handle, while `EN_deleteproject` deletes a project. An example of using the thread-safe version of the API is shown below:
|
Two new functions have been added to the API to manage the creation and deletion of project handles. `EN_createproject` creates a new project along with its handle, while `EN_deleteproject` deletes a project. An example of using the thread-safe version of the API is shown below:
|
||||||
```
|
```
|
||||||
#include "epanet2.h"
|
#include "epanet2_2.h"
|
||||||
int runEpanet(char *finp, char *frpt)
|
int runEpanet(char *finp, char *frpt)
|
||||||
{
|
{
|
||||||
EN_ProjectHandle ph = 0;
|
EN_Project ph = 0;
|
||||||
int err;
|
int err;
|
||||||
err = EN_createproject(&ph);
|
err = EN_createproject(&ph);
|
||||||
if (err) return err;
|
if (err) return err;
|
||||||
@@ -32,6 +31,35 @@ int runEpanet(char *finp, char *frpt)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Prototypes of the thread-safe functions appear in the `epanet2_2.h` header file while `epanet2.h` contains prototypes of the legacy-style API functions. The enumerated constants used with both types of functions have been moved to `epanet2_enums.h`.
|
||||||
|
|
||||||
|
## Network Building By Code
|
||||||
|
|
||||||
|
API users now have the ability to build a complete EPANET network model using just function calls, without the need to open an EPANET-formatted input file. All types of network objects can be created and have their properties set using these calls, including both simple and rule-based controls. Here is an example of building a simple 2-node, 1-pipe network just through code:
|
||||||
|
```
|
||||||
|
#include "epanet2_2.h"
|
||||||
|
int buildandrunEpanet(char *frpt)
|
||||||
|
{
|
||||||
|
EN_Project ph = 0;
|
||||||
|
int err;
|
||||||
|
err = EN_createproject(&ph);
|
||||||
|
if (err) return err;
|
||||||
|
EN_init(ph, frpt, "", EN_GPM, EN_HW);
|
||||||
|
EN_addnode(ph, "J1, EN_JUNCTION);
|
||||||
|
EN_setjuncdata(ph, 1, 710, 500, ""); //elev, demand
|
||||||
|
EN_addnode(ph, "R1", EN_RESERVOIR);
|
||||||
|
EN_setnodevalue(ph, 2, EN_ELEVATION, 800);
|
||||||
|
EN_addlink(ph, "P1", EN_PIPE, "R1", "J1");
|
||||||
|
EN_setpipedata(ph, 1, 5280, 14, 100, 0); // length, diam, C-factor
|
||||||
|
EN_setreport(ph, "NODES ALL");
|
||||||
|
err = EN_solveH(ph);
|
||||||
|
if (!err) err = EN_report(ph);
|
||||||
|
EN_close(ph);
|
||||||
|
EN_deleteproject(&ph);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Instead of using `EN_open` to load data from a file, `EN_init` is used to initialize a project with the names of its report and binary files, and its flow units and head loss formula. The legacy-style API has a complementary set of functions for building networks from code.
|
||||||
|
|
||||||
## Additional Convergence Parameters
|
## Additional Convergence Parameters
|
||||||
|
|
||||||
@@ -44,16 +72,19 @@ Two new analysis options have been added to provide more rigorous convergence cr
|
|||||||
These new parameters augment the current `EN_ACCURACY` option which always remains in effect. In addition, both `EN_HEADERROR` and `EN_FLOWCHANGE` can be used as parameters in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve their computed values (even when their option values are 0) after a hydraulic solution has been completed.
|
These new parameters augment the current `EN_ACCURACY` option which always remains in effect. In addition, both `EN_HEADERROR` and `EN_FLOWCHANGE` can be used as parameters in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve their computed values (even when their option values are 0) after a hydraulic solution has been completed.
|
||||||
|
|
||||||
## Improved Linear Solver Routine
|
## Improved Linear Solver Routine
|
||||||
|
|
||||||
EPANET's hydraulic solver requires solving a system of linear equations over a series of iterations until a set of convergence criteria are met. The coefficient matrix of this linear system is square and symmetric. It has a row for each network node and a non-zero off-diagonal coefficient for each link. The numerical effort needed to solve the linear system can be reduced if the nodes are re-ordered so that the non-zero coefficients cluster more tightly around the diagonal.
|
EPANET's hydraulic solver requires solving a system of linear equations over a series of iterations until a set of convergence criteria are met. The coefficient matrix of this linear system is square and symmetric. It has a row for each network node and a non-zero off-diagonal coefficient for each link. The numerical effort needed to solve the linear system can be reduced if the nodes are re-ordered so that the non-zero coefficients cluster more tightly around the diagonal.
|
||||||
|
|
||||||
EPANET's original node re-ordering scheme has been replaced by the more powerful **Multiple Minimum Degree (MMD)** algorithm. On a series of eight networks ranging in size from 7,700 to 100,000 nodes **MMD** reduced the solution time for a single period (steady state) hydraulic analysis by an average of 58%.
|
EPANET's original node re-ordering scheme has been replaced by the more powerful **Multiple Minimum Degree (MMD)** algorithm. On a series of eight networks ranging in size from 7,700 to 100,000 nodes **MMD** reduced the solution time for a single period (steady state) hydraulic analysis by an average of 58%.
|
||||||
|
|
||||||
## Improved Handling of Near-Zero Flows
|
## Improved Handling of Near-Zero Flows
|
||||||
|
|
||||||
EPANET's hydraulic solver can generate an ill-conditioned solution matrix when pipe flows approach zero unless some adjustment is made (i.e., as a pipe's flow approaches 0 its head loss gradient also approaches 0 causing its reciprocal, which is used to form the solution matrix's coefficients, to approach infinity). EPANET 2.0 used an arbitrary cutoff on head loss gradient to prevent it from becoming 0. This approach doesn't allow a pipe to follow any head loss v. flow relation in the region below the cutoff and can produce incorrect solutions for some networks (see [Estrada et al., 2009](https://ascelibrary.org/doi/full/10.1061/%28ASCE%29IR.1943-4774.0000100)).
|
EPANET's hydraulic solver can generate an ill-conditioned solution matrix when pipe flows approach zero unless some adjustment is made (i.e., as a pipe's flow approaches 0 its head loss gradient also approaches 0 causing its reciprocal, which is used to form the solution matrix's coefficients, to approach infinity). EPANET 2.0 used an arbitrary cutoff on head loss gradient to prevent it from becoming 0. This approach doesn't allow a pipe to follow any head loss v. flow relation in the region below the cutoff and can produce incorrect solutions for some networks (see [Estrada et al., 2009](https://ascelibrary.org/doi/full/10.1061/%28ASCE%29IR.1943-4774.0000100)).
|
||||||
|
|
||||||
The hydraulic solver has been modified to use a linear head loss v. flow relation for flows approaching zero. For the Darcy-Weisbach equation, the linear Hagen-Poiseuille formula is used for laminar flow where the Reynolds Number is <= 2000. For the Hazen-Williams and Chezy-Manning equations, a flow limit `Qa` is established for each pipe, equal to the flow that produces the EPANET 2 gradient cutoff. For flows below this a linear head loss relation is used between 0 and the head loss at `Qa` and the gradient always equals the cutoff. EPANET 2.2 is now able to correctly solve the examples presented in Estrada et al. (2009) as well as those in [Gorev et al., (2013)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000694) and [Elhay and Simpson (2011)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000411).
|
The hydraulic solver has been modified to use a linear head loss v. flow relation for flows approaching zero. For the Darcy-Weisbach equation, the linear Hagen-Poiseuille formula is used for laminar flow where the Reynolds Number is <= 2000. For the Hazen-Williams and Chezy-Manning equations, a flow limit `Qa` is established for each pipe, equal to the flow that produces the EPANET 2 gradient cutoff. For flows below this a linear head loss relation is used between 0 and the head loss at `Qa` and the gradient always equals the cutoff. EPANET 2.2 is now able to correctly solve the examples presented in Estrada et al. (2009) as well as those in [Gorev et al., (2013)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000694) and [Elhay and Simpson (2011)](https://ascelibrary.org/doi/10.1061/%28ASCE%29HY.1943-7900.0000411).
|
||||||
|
|
||||||
## Pressure Dependent Demands
|
## Pressure Dependent Demands
|
||||||
|
|
||||||
EPANET has always employed a Demand Driven Analysis (**DDA**) when modeling network hydraulics. Under this approach nodal demands at a given point in time are fixed values that must be delivered no matter what nodal heads and link flows are produced by a hydraulic solution. This can result in situations where required demands are satisfied at nodes that have negative pressures - a physical impossibility.
|
EPANET has always employed a Demand Driven Analysis (**DDA**) when modeling network hydraulics. Under this approach nodal demands at a given point in time are fixed values that must be delivered no matter what nodal heads and link flows are produced by a hydraulic solution. This can result in situations where required demands are satisfied at nodes that have negative pressures - a physical impossibility.
|
||||||
|
|
||||||
To address this issue EPANET has been extended to use a Pressure Driven Analysis (**PDA**) if so desired. Under **PDA**, the demand *D* delivered at a node depends on the node's available pressure *P* according to:
|
To address this issue EPANET has been extended to use a Pressure Driven Analysis (**PDA**) if so desired. Under **PDA**, the demand *D* delivered at a node depends on the node's available pressure *P* according to:
|
||||||
@@ -64,7 +95,6 @@ where *D<sub>f</sub>* is the full demand required, *P<sub>min</sub>* is the pres
|
|||||||
|
|
||||||
To implement pressure driven analysis four new parameters have been added to the [OPTIONS] section of the EPANET input file:
|
To implement pressure driven analysis four new parameters have been added to the [OPTIONS] section of the EPANET input file:
|
||||||
|
|
||||||
|
|
||||||
| Parameter | Description | Default |
|
| Parameter | Description | Default |
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
| DEMAND MODEL | either DDA or PDA | DDA |
|
| DEMAND MODEL | either DDA or PDA | DDA |
|
||||||
@@ -89,6 +119,7 @@ for the thread-safe API. Some additional points regarding the new **PDA** option
|
|||||||
- *P<sub>min</sub>* is allowed to equal to *P<sub>req</sub>*. This condition can be used to find a solution that results in the smallest amount of demand reductions needed to insure that no node delivers positive demand at a pressure below *P<sub>min</min>*.
|
- *P<sub>min</sub>* is allowed to equal to *P<sub>req</sub>*. This condition can be used to find a solution that results in the smallest amount of demand reductions needed to insure that no node delivers positive demand at a pressure below *P<sub>min</min>*.
|
||||||
|
|
||||||
## Improved Water Quality Mass Balance
|
## Improved Water Quality Mass Balance
|
||||||
|
|
||||||
As described by [Davis et al. (2018)](https://www.drink-water-eng-sci.net/11/25/2018/dwes-11-25-2018.pdf) EPANET's water quality simulations can result in some significant mass balance errors when modeling short term mass injections (errors are much smaller for continuous source flows). The entire water quality engine has been re-written to eliminate these errors. It still uses the Lagrangian Time Driven transport method but now analyzes each network node in topologically sorted order rather than in arbitrary order.
|
As described by [Davis et al. (2018)](https://www.drink-water-eng-sci.net/11/25/2018/dwes-11-25-2018.pdf) EPANET's water quality simulations can result in some significant mass balance errors when modeling short term mass injections (errors are much smaller for continuous source flows). The entire water quality engine has been re-written to eliminate these errors. It still uses the Lagrangian Time Driven transport method but now analyzes each network node in topologically sorted order rather than in arbitrary order.
|
||||||
|
|
||||||
A Mass Balance Report now appears the end of a simulation's Status Report that lists the various components (inflow, outflow, reaction) that comprise the network's overall mass balance. In addition `EN_MASSBALANCE` can be used as a parameter in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve the Mass Balance Ratio (Total Outflow Mass / Total Inflow Mass) at any point during a water quality simulation.
|
A Mass Balance Report now appears the end of a simulation's Status Report that lists the various components (inflow, outflow, reaction) that comprise the network's overall mass balance. In addition `EN_MASSBALANCE` can be used as a parameter in the `ENgetstatistic` (or `EN_getstatistic`) function to retrieve the Mass Balance Ratio (Total Outflow Mass / Total Inflow Mass) at any point during a water quality simulation.
|
||||||
@@ -106,98 +137,109 @@ Mass balance ratio (MBR) results for two of the networks analyzed by Davis et al
|
|||||||
|
|
||||||
Both network files are available [here](https://doi.org/10.23719/1375314).
|
Both network files are available [here](https://doi.org/10.23719/1375314).
|
||||||
|
|
||||||
## Code Changes
|
|
||||||
|
|
||||||
- The header file `vars.h` containing global variables has been eliminated. Instead a number of new structures incorporating these variables has been added to `types.h`. These structures have been incorporated into the new `EN_Project` structure, also defined in `types.h`, which gets passed into each of the thread-safe API functions as a pointer.
|
|
||||||
- Each of the legacy API functions now simply calls its thread-safe counterpart passing in a pointer to a default global`EN_Project` variable that is declared in `types.h`.
|
|
||||||
- Throughout all code modules, global variables that were previously accessed through `vars.h` are now accessed using the `EN_Project` pointer that is passed into the functions where the variables appear.
|
|
||||||
- The exceedingly long `hydraul.c` file has been split into four separate files:
|
|
||||||
- `hydraul.c` now contains just the code needed to initialize a hydraulic analysis, set demands and control actions at each time step, and determine the length of the next time step to take.
|
|
||||||
- `hydsolver.c` implements EPANET's hydraulic solver at a single point in time.
|
|
||||||
- `hydcoeffs.c` computes values of the matrix coefficients (derived from link head losses and their gradients) used by the hydraulic solver.
|
|
||||||
- `hydstatus.c` checks for status changes in valves and pumps as requested by the hydraulic solver.
|
|
||||||
- The Multiple Minimum Degree re-ordering algorithm appears in a new file named `genmmd.c`. This is 1990's legacy code that is readily available on the web and can be found in several linear equation solver libraries.
|
|
||||||
- The original `quality.c` file has also been split into three separate files:
|
|
||||||
- `quality.c` initializes the quality solver and supervises the quality calculations over each simulation time step.
|
|
||||||
- `qualreact.c` reacts the quality constituent within each pipe and tank over a single time step and also implements the various tank mixing models.
|
|
||||||
- `qualroute.c` topologically sorts the network's nodes when flow directions change and implements the Lagrangian Time Driven transport algorithm over a single time step.
|
|
||||||
|
|
||||||
## General changes
|
|
||||||
- Read and write demand categories names
|
|
||||||
|
|
||||||
## New API functions
|
## New API functions
|
||||||
|Function|Description|
|
|Function|Description|
|
||||||
|--|--|
|
|--|--|
|
||||||
|`ENinit`|Initializes an EPANET session|
|
|`EN_createproject` | creates a new EPANET project |
|
||||||
|`ENsetflowunits`|Sets the flow units|
|
|`EN_deleteproject` | deletes an EPANET project |
|
||||||
|`ENgetdemandmodel`|Retrieves the type of demand model in use and its parameters|
|
|`EN_init`|Initializes an EPANET project|
|
||||||
|`ENsetdemandmodel`|Sets the type of demand model to use and its parameters|
|
|`EN_setflowunits`|Sets the project's flow units|
|
||||||
|`ENgetdemandname`|Sets the node's demand name for a category|
|
|`EN_addnode`|Adds a new node to a project|
|
||||||
|`ENsetdemandname`|Sets the node's demand name for a category|
|
|`EN_addlink`|Adds a new link to a project|
|
||||||
|`ENsetdemandpattern`|Sets the index of the demand pattern assigned to a node for a category index|
|
|`EN_addcontrol`|Adds a new simple control to a project|
|
||||||
|`ENsetheadcurveindex`|Sets the curve id for a specified pump index|
|
|`EN_addrule`|Adds a new control rule to a project|
|
||||||
|`ENgetrule`|Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control|
|
|`EN_deletenode`|Deletes a node from the project|
|
||||||
|`ENsetrulepriority`|Sets the priority of the existing rule-based control|
|
|`EN_deletelink`|Deletes a link from the project|
|
||||||
|`ENgetpremise`|Gets the components of a premise/condition in an existing rule-based control|
|
|`EN_deletecontrol`|Deletes a simple control from the project|
|
||||||
|`ENsetpremise`|Sets the components of a premise/condition in an existing rule-based control|
|
|`EN_deleterule`|Deletes a rule-based control from the project|
|
||||||
|`ENsetpremiseindex`|Sets the index of an object in a premise of an existing rule-based control|
|
|`EN_setnodeid`|Changes the ID name for a node|
|
||||||
|`ENsetpremisestatus`|Sets the status in a premise of an existing rule-based control|
|
|`EN_setjuncdata` |Sets values for a junction's parameters |
|
||||||
|`ENsetpremisevalue`|Sets the value in a premise of an existing rule-based control|
|
|`EN_settankdata` |Sets values for a tank's parameters|
|
||||||
|`ENgetthenaction`|Get the components of a THEN action in a rule-based control|
|
|`EN_setlinkid`|Changes the ID name for a link|
|
||||||
|`ENsetthenaction`|Set the components of a THEN action in a rule-based control|
|
|`EN_setlinknodes`|Sets a link's start- and end-nodes|
|
||||||
|`ENgetelseaction`|Get the components of an ELSE action in a rule-based control|
|
|`EN_setlinktype`|Changes the type of a specific link|
|
||||||
|`ENsetelseaction`|Set the components of an ELSE action in a rule-based control|
|
|`EN_setpipedata`|Sets values for a pipe's parameters|
|
||||||
|`ENgetruleID`|Returns the ID of a rule|
|
|`EN_getdemandmodel`|Retrieves the type of demand model in use |
|
||||||
|`ENgetcurvetype`|Get the type of a curve|
|
|`EN_setdemandmodel`|Sets the type of demand model to use|
|
||||||
|`ENsetlinknodes`|Set the indexes of a link's start- and end-nodes|
|
|`EN_getdemandname`|Gets the name of a node's demand category|
|
||||||
|`ENsetlinktype`|Set the link type code for a specified link|
|
|`EN_setdemandname`|Sets the name of a node's demand category|
|
||||||
|`ENaddnode`|Adds a new node|
|
|`EN_setdemandpattern`|Assigns a time pattern to a node's demand category |
|
||||||
|`ENaddlink`|Adds a new link|
|
|`EN_getcurvetype`|Gets a curve's type|
|
||||||
|`ENaddcontrol`|Specify parameters to add a new simple control|
|
|`EN_setheadcurveindex`|Sets the index of a head curve used by a pump |
|
||||||
|`ENaddrule`|Add a new control rule to the project|
|
|`EN_getrule`|Gets the number of elements in a rule-based control |
|
||||||
|`ENdeletenode`|Deletes a node|
|
|`EN_getruleid` | Gets the name assigned to a rule-based control |
|
||||||
|`ENdeletelink`|Deletes a link|
|
|`EN_getpremise`|Gets the contents of a premise in a rule-based control|
|
||||||
|`ENdeletecontrol`|Delete an existing simple control|
|
|`EN_setpremise`|Sets the contents of a premise in a rule-based control|
|
||||||
|`ENdeleterule`|Delete a rule-based control|
|
|`EN_setpremiseindex`|Sets the index of an object in a premise of a rule-based control|
|
||||||
|`ENsetnodeid`|Change the ID name for a node|
|
|`EN_setpremisestatus`|Sets the status of an object in a premise of a rule-based control|
|
||||||
|`ENsetlinkid`|Change the ID name for a link|
|
|`EN_setpremisevalue`|Sets the value of a property in a premise of a rule-based control|
|
||||||
|
|`EN_getthenaction`|Gets the contents of a THEN action in a rule-based control|
|
||||||
|
|`EN_setthenaction`|Sets the contents of a THEN action in a rule-based control|
|
||||||
|
|`EN_getelseaction`|Gets the contents of an ELSE action in a rule-based control|
|
||||||
|
|`EN_setelseaction`|Set the contents of an ELSE action in a rule-based control|
|
||||||
|
|`EN_setrulepriority`|Sets the priority of a rule-based control|
|
||||||
|
In addition to these new functions, a tank's volume curve `EN_VOLCURVE` can be set using `EN_setnodevalue` and `EN_setlinkvalue` can now be used to set the following pump properties:
|
||||||
|
- `EN_PUMP_POWER` (constant power rating)
|
||||||
|
- `EN_PUMP_HCURVE` (head characteristic curve)
|
||||||
|
- `EN_PUMP_ECURVE` (efficiency curve)
|
||||||
|
- `EN_PUMP_ECOST` (average energy price)
|
||||||
|
- `EN_PUMP_EPAT` (energy pricing pattern)
|
||||||
|
- `EN_LINKPATTERN` (speed setting pattern)
|
||||||
|
|
||||||
|
Access to the following global energy options have been added to `EN_getoption` and `EN_setoption`:
|
||||||
|
- `EN_GLOBALEFFIC` (global pump efficiency)
|
||||||
|
- `EN_GLOBALPRICE` (global average energy price per kW-Hour)
|
||||||
|
- `EN_GLOBALPATTERN` (global energy price pattern)
|
||||||
|
- `EN_DEMANDCHARGE` (price per maximum kW of energy consumption)
|
||||||
|
|
||||||
|
## New API Constants
|
||||||
|
|
||||||
## API Extensions (additional definitions)
|
|
||||||
### Link value types:
|
### Link value types:
|
||||||
- `EN_EFFICIENCY`
|
- `EN_PUMP_STATE`
|
||||||
- `EN_HEADCURVE`
|
- `EN_PUMP_EFFIC`
|
||||||
- `EN_EFFICIENCYCURVE`
|
- `EN_PUMP_POWER`
|
||||||
- `EN_PRICEPATTERN`
|
- `EN_PUMP_HCURVE`
|
||||||
- `EN_STATE`
|
- `EN_PUMP_ECURVE`
|
||||||
- `EN_CONST_POWER`
|
- `EN_PUMP_ECOST`
|
||||||
- `EN_SPEED`
|
- `EN_PUMP_EPAT`
|
||||||
|
|
||||||
### Count types:
|
### Count types:
|
||||||
- `EN_RULECOUNT`
|
- `EN_RULECOUNT`
|
||||||
|
|
||||||
### Head loss formula:
|
### Head loss formula:
|
||||||
- `EN_HW`
|
- `EN_HW`
|
||||||
- `EN_DW`
|
- `EN_DW`
|
||||||
- `EN_CM`
|
- `EN_CM`
|
||||||
### Option types:
|
|
||||||
|
### Hydraulic option types:
|
||||||
- `EN_HEADERROR`
|
- `EN_HEADERROR`
|
||||||
- `EN_FLOWCHANGE`
|
- `EN_FLOWCHANGE`
|
||||||
- `EN_DEMANDDEFPAT`
|
- `EN_DEFDEMANDPAT`
|
||||||
- `EN_HEADLOSSFORM`
|
- `EN_HEADLOSSFORM`
|
||||||
### Time statistic types:
|
- `EN_GLOBALEFFIC`
|
||||||
|
- `EN_GLOBALPRICE`
|
||||||
|
- `EN_GLOBALPATTERN`
|
||||||
|
- `EN_DEMANDCHARGE`
|
||||||
|
|
||||||
|
### Simulation statistic types:
|
||||||
- `EN_MAXHEADERROR`
|
- `EN_MAXHEADERROR`
|
||||||
- `EN_MAXFLOWCHANGE`
|
- `EN_MAXFLOWCHANGE`
|
||||||
- `EN_MASSBALANCE`
|
- `EN_MASSBALANCE`
|
||||||
### Action code types:
|
|
||||||
|
### Action code types:
|
||||||
- `EN_UNCONDITIONAL`
|
- `EN_UNCONDITIONAL`
|
||||||
- `EN_CONDITIONAL`
|
- `EN_CONDITIONAL`
|
||||||
|
|
||||||
### Curve types:
|
### Curve types:
|
||||||
- `EN_V_CURVE`
|
- `EN_VOLUME_CURVE`
|
||||||
- `EN_P_CURVE`
|
- `EN_PUMP_CURVE`
|
||||||
- `EN_E_CURVE`
|
- `EN_EFFIC_CURVE`
|
||||||
- `EN_H_CURVE`
|
- `EN_HLOSS_CURVE`
|
||||||
- `EN_G_CURVE`
|
- `EN_GENERIC_CURVE`
|
||||||
|
|
||||||
### Demand model types:
|
### Demand model types:
|
||||||
- `EN_DDA`
|
- `EN_DDA`
|
||||||
- `EN_PDA`
|
- `EN_PDA`
|
||||||
|
|
||||||
## Authors contributing to this release:
|
## Authors contributing to this release:
|
||||||
- List item
|
- List item
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
|
|||||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||||
'(EPANET2.DLL)
|
'(EPANET2.DLL)
|
||||||
|
|
||||||
'Last updated on 4/3/07
|
'Last updated on 01/01/2019
|
||||||
|
|
||||||
' These are codes used by the DLL functions
|
' These are codes used by the DLL functions
|
||||||
Public Const EN_ELEVATION = 0 ' Node parameters
|
Public Const EN_ELEVATION = 0 ' Node parameters
|
||||||
@@ -50,15 +50,16 @@ Public Const EN_HEADLOSS = 10
|
|||||||
Public Const EN_STATUS = 11
|
Public Const EN_STATUS = 11
|
||||||
Public Const EN_SETTING = 12
|
Public Const EN_SETTING = 12
|
||||||
Public Const EN_ENERGY = 13
|
Public Const EN_ENERGY = 13
|
||||||
Public Const EN_LINKQUAL = 14 'ES
|
Public Const EN_LINKQUAL = 14
|
||||||
Public Const EN_LINKPATTERN = 15
|
Public Const EN_LINKPATTERN = 15
|
||||||
Public Const EN_EFFICIENCY = 16
|
|
||||||
Public Const EN_HEADCURVE = 17
|
Public Const EN_PUMP_STATE = 16
|
||||||
Public Const EN_EFFICIENCYCURVE = 18
|
Public Const EN_PUMP_EFFIC = 17
|
||||||
Public Const EN_PRICEPATTERN = 19
|
Public Const EN_PUMP_POWER = 18
|
||||||
Public Const EN_STATE = 20
|
Public Const EN_PUMP_HCURVE = 19
|
||||||
Public Const EN_CONST_POWER = 21
|
Public Const EN_PUMP_ECURVE = 20
|
||||||
Public Const EN_SPEED = 22
|
Public Const EN_PUMP_ECOST = 21
|
||||||
|
Public Const EN_PUMP_EPAT = 22
|
||||||
|
|
||||||
Public Const EN_DURATION = 0 ' Time parameters
|
Public Const EN_DURATION = 0 ' Time parameters
|
||||||
Public Const EN_HYDSTEP = 1
|
Public Const EN_HYDSTEP = 1
|
||||||
@@ -76,13 +77,13 @@ Public Const EN_QTIME = 12
|
|||||||
Public Const EN_HALTFLAG = 13
|
Public Const EN_HALTFLAG = 13
|
||||||
Public Const EN_NEXTEVENT = 14
|
Public Const EN_NEXTEVENT = 14
|
||||||
|
|
||||||
Public Const EN_ITERATIONS = 0
|
Public Const EN_ITERATIONS = 0 ' Run statistics
|
||||||
Public Const EN_RELATIVEERROR = 1
|
Public Const EN_RELATIVEERROR = 1
|
||||||
Public Const EN_MAXHEADERROR = 2
|
Public Const EN_MAXHEADERROR = 2
|
||||||
Public Const EN_MAXFLOWCHANGE = 3
|
Public Const EN_MAXFLOWCHANGE = 3
|
||||||
Public Const EN_MASSBALANCE = 4
|
Public Const EN_MASSBALANCE = 4
|
||||||
|
|
||||||
Public Const EN_NODECOUNT = 0 'Component counts
|
Public Const EN_NODECOUNT = 0 ' Component counts
|
||||||
Public Const EN_TANKCOUNT = 1
|
Public Const EN_TANKCOUNT = 1
|
||||||
Public Const EN_LINKCOUNT = 2
|
Public Const EN_LINKCOUNT = 2
|
||||||
Public Const EN_PATCOUNT = 3
|
Public Const EN_PATCOUNT = 3
|
||||||
@@ -114,7 +115,7 @@ Public Const EN_MASS = 1
|
|||||||
Public Const EN_SETPOINT = 2
|
Public Const EN_SETPOINT = 2
|
||||||
Public Const EN_FLOWPACED = 3
|
Public Const EN_FLOWPACED = 3
|
||||||
|
|
||||||
Public Const EN_HW = 0 ' Head loss formula
|
Public Const EN_HW = 0 ' Head loss formulas
|
||||||
Public Const EN_DW = 1
|
Public Const EN_DW = 1
|
||||||
Public Const EN_CM = 2
|
Public Const EN_CM = 2
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ Public Const EN_CMD = 9
|
|||||||
Public Const EN_DDA = 0 ' Demand driven analysis
|
Public Const EN_DDA = 0 ' Demand driven analysis
|
||||||
Public Const EN_PDA = 1 ' Pressure driven analysis
|
Public Const EN_PDA = 1 ' Pressure driven analysis
|
||||||
|
|
||||||
Public Const EN_TRIALS = 0 ' Misc. options
|
Public Const EN_TRIALS = 0 ' Hydraulic options
|
||||||
Public Const EN_ACCURACY = 1
|
Public Const EN_ACCURACY = 1
|
||||||
Public Const EN_TOLERANCE = 2
|
Public Const EN_TOLERANCE = 2
|
||||||
Public Const EN_EMITEXPON = 3
|
Public Const EN_EMITEXPON = 3
|
||||||
@@ -141,41 +142,82 @@ Public Const EN_HEADERROR = 5
|
|||||||
Public Const EN_FLOWCHANGE = 6
|
Public Const EN_FLOWCHANGE = 6
|
||||||
Public Const EN_DEMANDDEFPAT = 7
|
Public Const EN_DEMANDDEFPAT = 7
|
||||||
Public Const EN_HEADLOSSFORM = 8
|
Public Const EN_HEADLOSSFORM = 8
|
||||||
|
Public Const EN_GLOBALEFFIC = 9
|
||||||
|
Public Const EN_GLOBALPRICE = 10
|
||||||
|
Public Const EN_GLOBALPATTERN = 11
|
||||||
|
Public Const EN_DEMANDCHARGE = 12
|
||||||
|
|
||||||
Public Const EN_LOWLEVEL = 0 ' Control types
|
Public Const EN_LOWLEVEL = 0 ' Control types
|
||||||
Public Const EN_HILEVEL = 1
|
Public Const EN_HILEVEL = 1
|
||||||
Public Const EN_TIMER = 2
|
Public Const EN_TIMER = 2
|
||||||
Public Const EN_TIMEOFDAY = 3
|
Public Const EN_TIMEOFDAY = 3
|
||||||
|
|
||||||
Public Const EN_AVERAGE = 1 'Time statistic types
|
Public Const EN_AVERAGE = 1 ' Time statistic types
|
||||||
Public Const EN_MINIMUM = 2
|
Public Const EN_MINIMUM = 2
|
||||||
Public Const EN_MAXIMUM = 3
|
Public Const EN_MAXIMUM = 3
|
||||||
Public Const EN_RANGE = 4
|
Public Const EN_RANGE = 4
|
||||||
|
|
||||||
Public Const EN_MIX1 = 0 'Tank mixing models
|
Public Const EN_MIX1 = 0 ' Tank mixing models
|
||||||
Public Const EN_MIX2 = 1
|
Public Const EN_MIX2 = 1
|
||||||
Public Const EN_FIFO = 2
|
Public Const EN_FIFO = 2
|
||||||
Public Const EN_LIFO = 3
|
Public Const EN_LIFO = 3
|
||||||
|
|
||||||
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
||||||
Public Const EN_SAVE = 1
|
Public Const EN_SAVE = 1
|
||||||
|
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||||
|
Public Const EN_SAVE_AND_INIT = 11
|
||||||
|
|
||||||
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
Public Const EN_CONST_HP = 0 ' Constant horsepower pump curve
|
||||||
|
Public Const EN_POWER_FUNC = 1 ' Power function pump cuve
|
||||||
|
Public Const EN_CUSTOM = 2 ' User-defined custom pump curve
|
||||||
|
Public Const EN_NOCURVE = 3 ' No pump curve
|
||||||
|
|
||||||
Public Const EN_CONST_HP = 0 ' constant horsepower
|
Public Const EN_VOLUME_CURVE = 0 ' Volume curve
|
||||||
Public Const EN_POWER_FUNC = 1 ' power function
|
Public Const EN_PUMP_CURVE = 1 ' Pump curve
|
||||||
Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
Public Const EN_EFFIC_CURVE = 2 ' Efficiency curve
|
||||||
Public Const EN_NOCURVE = 3 ' no curve
|
Public Const EN_HLOSS_CURVE = 3 ' Head loss curve
|
||||||
|
Public Const EN_GENERIC_CURVE = 4 ' Generic curve
|
||||||
Public Const EN_V_CURVE = 0 ' volume curve
|
|
||||||
Public Const EN_P_CURVE = 1 ' pump curve
|
|
||||||
Public Const EN_E_CURVE = 2 ' efficiency curve
|
|
||||||
Public Const EN_H_CURVE = 3 ' head loss curve
|
|
||||||
Public Const EN_G_CURVE = 4 ' General\default curve
|
|
||||||
|
|
||||||
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
||||||
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
||||||
|
|
||||||
|
Public Const EN_NO_REPORT = 0 ' No status report
|
||||||
|
Public Const EN_NORMAL_REPORT = 1 ' Normal status report
|
||||||
|
Public Const EN_FULL_REPORT = 2 ' Full status report
|
||||||
|
|
||||||
|
Public Const EN_R_NODE = 6 ' Rule objects
|
||||||
|
Public Const EN_R_LINK = 7
|
||||||
|
Public Const EN_R_SYSTEM = 8
|
||||||
|
|
||||||
|
Public Const EN_R_DEMAND = 0 ' Rule variables
|
||||||
|
Public Const EN_R_HEAD = 1
|
||||||
|
Public Const EN_R_GRADE = 2
|
||||||
|
Public Const EN_R_LEVEL = 3
|
||||||
|
Public Const EN_R_PRESSURE = 4
|
||||||
|
Public Const EN_R_FLOW = 5
|
||||||
|
Public Const EN_R_STATUS = 6
|
||||||
|
Public Const EN_R_SETTING = 7
|
||||||
|
Public Const EN_R_POWER = 8
|
||||||
|
Public Const EN_R_TIME = 9
|
||||||
|
Public Const EN_R_CLOCKTIME = 10
|
||||||
|
Public Const EN_R_FILLTIME = 11
|
||||||
|
Public Const EN_R_DRAINTIME = 12
|
||||||
|
|
||||||
|
Public Const EN_R_EQ = 0 ' Rule operators
|
||||||
|
Public Const EN_R_NE = 1
|
||||||
|
Public Const EN_R_LE = 2
|
||||||
|
Public Const EN_R_GE = 3
|
||||||
|
Public Const EN_R_LT = 4
|
||||||
|
Public Const EN_R_GT = 5
|
||||||
|
Public Const EN_R_IS = 6
|
||||||
|
Public Const EN_R_NOT = 7
|
||||||
|
Public Const EN_R_BELOW = 8
|
||||||
|
Public Const EN_R_ABOVE = 9
|
||||||
|
|
||||||
|
Public Const EN_R_IS_OPEN = 1 ' Rule status types
|
||||||
|
Public Const EN_R_IS_CLOSED = 2
|
||||||
|
Public Const EN_R_IS_ACTIVE = 3
|
||||||
|
|
||||||
'These are the external functions that comprise the DLL
|
'These are the external functions that comprise the DLL
|
||||||
|
|
||||||
'System Functions
|
'System Functions
|
||||||
@@ -236,6 +278,8 @@ Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
|||||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal index As Long, code As Long) As Long
|
||||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||||
|
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Long
|
||||||
|
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Long
|
||||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, X As Single, Y As Single) As Long
|
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, X As Single, Y As Single) As Long
|
||||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal X As Single, ByVal Y As Single) As Long
|
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal X As Single, ByVal Y As Single) As Long
|
||||||
|
|
||||||
@@ -262,6 +306,7 @@ Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
|||||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
|
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Long, ByVal node1 As Long, ByVal node2 As Long) As Long
|
||||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, value As Single) As Long
|
||||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal index As Long, ByVal code As Long, ByVal value As Single) As Long
|
||||||
|
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Long, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Long
|
||||||
|
|
||||||
'Pump Functions
|
'Pump Functions
|
||||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
|
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal pumpIndex As Long, curveIndex As Long) As Long
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 11/29/2018
|
Last Updated: 12/31/2018
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -44,12 +44,6 @@
|
|||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
#elif defined(CYGWIN)
|
#elif defined(CYGWIN)
|
||||||
#define DLLEXPORT __stdcall
|
#define DLLEXPORT __stdcall
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define DLLEXPORT
|
|
||||||
#else
|
|
||||||
#define DLLEXPORT
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define DLLEXPORT
|
#define DLLEXPORT
|
||||||
#endif
|
#endif
|
||||||
@@ -510,6 +504,34 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v);
|
int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Set a group of properties for a junction node.
|
||||||
|
@param index The index of a junction node.
|
||||||
|
@param elev The junction's elevation.
|
||||||
|
@param dmnd The junction's primary base demand.
|
||||||
|
@param dmndpat The name of the demand's time pattern ("" for no pattern)
|
||||||
|
@return Error code.
|
||||||
|
*/
|
||||||
|
int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE dmnd, char *dmndpat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Set a group of properties for a tank node.
|
||||||
|
@param index The index of a tank node.
|
||||||
|
@param elev The tank's bottom elevation.
|
||||||
|
@param initlvl The initial water level in the tank.
|
||||||
|
@param minlvl The minimum water level for the tank.
|
||||||
|
@param maxlvl The maximum water level for the tank.
|
||||||
|
@param diam The tank's diameter (0 if volume curve used).
|
||||||
|
@param minvol The volume of the tank at its minimum water level.
|
||||||
|
@param volcurve The name of the tank's volume curve ("" for no curve)
|
||||||
|
@return Error code.
|
||||||
|
*/
|
||||||
|
int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
|
||||||
|
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||||
|
EN_API_FLOAT_TYPE minvol, char *volcurve);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get coordinates (x,y) for a node.
|
@brief Get coordinates (x,y) for a node.
|
||||||
@param index The index of a node (first node is index 1).
|
@param index The index of a node (first node is index 1).
|
||||||
@@ -743,6 +765,20 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v);
|
int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Set a collection of property values for a pipe link.
|
||||||
|
@param index The index of a pipe link.
|
||||||
|
@param length The pipe's length.
|
||||||
|
@param diam The pipe's diameter.
|
||||||
|
@param rough The pipe's roughness coefficient.
|
||||||
|
@param mloss The pipe's minor loss coefficient.
|
||||||
|
@return Error code.
|
||||||
|
*/
|
||||||
|
int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length,
|
||||||
|
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough,
|
||||||
|
EN_API_FLOAT_TYPE mloss);
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Pump Functions
|
Pump Functions
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
|
||||||
'(EPANET2.DLL) for use with VB.Net.
|
'(EPANET2.DLL) for use with VB.Net.
|
||||||
|
|
||||||
'Last updated on 7/19/15 - LR
|
'Last updated on 01/01/2019
|
||||||
|
|
||||||
Imports System.Runtime.InteropServices
|
Imports System.Runtime.InteropServices
|
||||||
Imports System.Text
|
Imports System.Text
|
||||||
@@ -55,15 +55,16 @@ Public Const EN_HEADLOSS = 10
|
|||||||
Public Const EN_STATUS = 11
|
Public Const EN_STATUS = 11
|
||||||
Public Const EN_SETTING = 12
|
Public Const EN_SETTING = 12
|
||||||
Public Const EN_ENERGY = 13
|
Public Const EN_ENERGY = 13
|
||||||
Public Const EN_LINKQUAL = 14 'ES
|
Public Const EN_LINKQUAL = 14
|
||||||
Public Const EN_LINKPATTERN = 15
|
Public Const EN_LINKPATTERN = 15
|
||||||
Public Const EN_EFFICIENCY = 16
|
|
||||||
Public Const EN_HEADCURVE = 17
|
Public Const EN_PUMP_STATE = 16
|
||||||
Public Const EN_EFFICIENCYCURVE = 18
|
Public Const EN_PUMP_EFFIC = 17
|
||||||
Public Const EN_PRICEPATTERN = 19
|
Public Const EN_PUMP_POWER = 18
|
||||||
Public Const EN_STATE = 20
|
Public Const EN_PUMP_HCURVE = 19
|
||||||
Public Const EN_CONST_POWER = 21
|
Public Const EN_PUMP_ECURVE = 20
|
||||||
Public Const EN_SPEED = 22
|
Public Const EN_PUMP_ECOST = 21
|
||||||
|
Public Const EN_PUMP_EPAT = 22
|
||||||
|
|
||||||
Public Const EN_DURATION = 0 ' Time parameters
|
Public Const EN_DURATION = 0 ' Time parameters
|
||||||
Public Const EN_HYDSTEP = 1
|
Public Const EN_HYDSTEP = 1
|
||||||
@@ -75,7 +76,7 @@ Public Const EN_REPORTSTART = 6
|
|||||||
Public Const EN_RULESTEP = 7
|
Public Const EN_RULESTEP = 7
|
||||||
Public Const EN_STATISTIC = 8
|
Public Const EN_STATISTIC = 8
|
||||||
Public Const EN_PERIODS = 9
|
Public Const EN_PERIODS = 9
|
||||||
Public Const EN_STARTTIME = 10 'ES
|
Public Const EN_STARTTIME = 10
|
||||||
Public Const EN_HTIME = 11
|
Public Const EN_HTIME = 11
|
||||||
Public Const EN_QTIME = 12
|
Public Const EN_QTIME = 12
|
||||||
Public Const EN_HALTFLAG = 13
|
Public Const EN_HALTFLAG = 13
|
||||||
@@ -119,7 +120,7 @@ Public Const EN_MASS = 1
|
|||||||
Public Const EN_SETPOINT = 2
|
Public Const EN_SETPOINT = 2
|
||||||
Public Const EN_FLOWPACED = 3
|
Public Const EN_FLOWPACED = 3
|
||||||
|
|
||||||
Public Const EN_HW = 0 ' Head loss formula
|
Public Const EN_HW = 0 ' Head loss formulas
|
||||||
Public Const EN_DW = 1
|
Public Const EN_DW = 1
|
||||||
Public Const EN_CM = 2
|
Public Const EN_CM = 2
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ Public Const EN_CMD = 9
|
|||||||
Public Const EN_DDA = 0 ' Demand driven analysis
|
Public Const EN_DDA = 0 ' Demand driven analysis
|
||||||
Public Const EN_PDA = 1 ' Pressure driven analysis
|
Public Const EN_PDA = 1 ' Pressure driven analysis
|
||||||
|
|
||||||
Public Const EN_TRIALS = 0 ' Misc. options
|
Public Const EN_TRIALS = 0 ' Hydraulic options
|
||||||
Public Const EN_ACCURACY = 1
|
Public Const EN_ACCURACY = 1
|
||||||
Public Const EN_TOLERANCE = 2
|
Public Const EN_TOLERANCE = 2
|
||||||
Public Const EN_EMITEXPON = 3
|
Public Const EN_EMITEXPON = 3
|
||||||
@@ -146,39 +147,82 @@ Public Const EN_HEADERROR = 5
|
|||||||
Public Const EN_FLOWCHANGE = 6
|
Public Const EN_FLOWCHANGE = 6
|
||||||
Public Const EN_DEMANDDEFPAT = 7
|
Public Const EN_DEMANDDEFPAT = 7
|
||||||
Public Const EN_HEADLOSSFORM = 8
|
Public Const EN_HEADLOSSFORM = 8
|
||||||
|
Public Const EN_GLOBALEFFIC = 9
|
||||||
|
Public Const EN_GLOBALPRICE = 10
|
||||||
|
Public Const EN_GLOBALPATTERN = 11
|
||||||
|
Public Const EN_DEMANDCHARGE = 12
|
||||||
|
|
||||||
Public Const EN_LOWLEVEL = 0 ' Control types
|
Public Const EN_LOWLEVEL = 0 ' Control types
|
||||||
Public Const EN_HILEVEL = 1
|
Public Const EN_HILEVEL = 1
|
||||||
Public Const EN_TIMER = 2
|
Public Const EN_TIMER = 2
|
||||||
Public Const EN_TIMEOFDAY = 3
|
Public Const EN_TIMEOFDAY = 3
|
||||||
|
|
||||||
Public Const EN_AVERAGE = 1 'Time statistic types
|
Public Const EN_AVERAGE = 1 ' Time statistic types
|
||||||
Public Const EN_MINIMUM = 2
|
Public Const EN_MINIMUM = 2
|
||||||
Public Const EN_MAXIMUM = 3
|
Public Const EN_MAXIMUM = 3
|
||||||
Public Const EN_RANGE = 4
|
Public Const EN_RANGE = 4
|
||||||
|
|
||||||
Public Const EN_MIX1 = 0 'Tank mixing models
|
Public Const EN_MIX1 = 0 ' Tank mixing models
|
||||||
Public Const EN_MIX2 = 1
|
Public Const EN_MIX2 = 1
|
||||||
Public Const EN_FIFO = 2
|
Public Const EN_FIFO = 2
|
||||||
Public Const EN_LIFO = 3
|
Public Const EN_LIFO = 3
|
||||||
|
|
||||||
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
Public Const EN_NOSAVE = 0 ' Save-results-to-file flag
|
||||||
Public Const EN_SAVE = 1
|
Public Const EN_SAVE = 1
|
||||||
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
Public Const EN_INITFLOW = 10 ' Re-initialize flow flag
|
||||||
|
Public Const EN_SAVE_AND_INIT = 11
|
||||||
|
|
||||||
Public Const EN_CONST_HP = 0 ' constant horsepower
|
Public Const EN_CONST_HP = 0 ' Constant horsepower pump curve
|
||||||
Public Const EN_POWER_FUNC = 1 ' power function
|
Public Const EN_POWER_FUNC = 1 ' Power function pump curve
|
||||||
Public Const EN_CUSTOM = 2 ' user-defined custom curve
|
Public Const EN_CUSTOM = 2 ' User-defined custom pump curve
|
||||||
|
Public Const EN_NOCURVE = 3 ' No pump curve
|
||||||
|
|
||||||
Public Const EN_V_CURVE = 0 ' volume curve
|
Public Const EN_VOLUME_CURVE = 0 ' Volume curve
|
||||||
Public Const EN_P_CURVE = 1 ' pump curve
|
Public Const EN_PUMP_CURVE = 1 ' Pump curve
|
||||||
Public Const EN_E_CURVE = 2 ' efficiency curve
|
Public Const EN_EFFIC_CURVE = 2 ' Efficiency curve
|
||||||
Public Const EN_H_CURVE = 3 ' head loss curve
|
Public Const EN_HLOSS_CURVE = 3 ' Head loss curve
|
||||||
Public Const EN_G_CURVE = 4 ' General\default curve
|
Public Const EN_GENERIC_CURVE = 4 ' Generic curve
|
||||||
|
|
||||||
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
Public Const EN_UNCONDITIONAL = 0 ' Unconditional object deletion
|
||||||
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
||||||
|
|
||||||
|
Public Const EN_NO_REPORT = 0 ' No status report
|
||||||
|
Public Const EN_NORMAL_REPORT = 1 ' Normal status report
|
||||||
|
Public Const EN_FULL_REPORT = 2 ' Full status report
|
||||||
|
|
||||||
|
Public Const EN_R_NODE = 6 ' Rule objects
|
||||||
|
Public Const EN_R_LINK = 7
|
||||||
|
Public Const EN_R_SYSTEM = 8
|
||||||
|
|
||||||
|
Public Const EN_R_DEMAND = 0 ' Rule variables
|
||||||
|
Public Const EN_R_HEAD = 1
|
||||||
|
Public Const EN_R_GRADE = 2
|
||||||
|
Public Const EN_R_LEVEL = 3
|
||||||
|
Public Const EN_R_PRESSURE = 4
|
||||||
|
Public Const EN_R_FLOW = 5
|
||||||
|
Public Const EN_R_STATUS = 6
|
||||||
|
Public Const EN_R_SETTING = 7
|
||||||
|
Public Const EN_R_POWER = 8
|
||||||
|
Public Const EN_R_TIME = 9
|
||||||
|
Public Const EN_R_CLOCKTIME = 10
|
||||||
|
Public Const EN_R_FILLTIME = 11
|
||||||
|
Public Const EN_R_DRAINTIME = 12
|
||||||
|
|
||||||
|
Public Const EN_R_EQ = 0 ' Rule operators
|
||||||
|
Public Const EN_R_NE = 1
|
||||||
|
Public Const EN_R_LE = 2
|
||||||
|
Public Const EN_R_GE = 3
|
||||||
|
Public Const EN_R_LT = 4
|
||||||
|
Public Const EN_R_GT = 5
|
||||||
|
Public Const EN_R_IS = 6
|
||||||
|
Public Const EN_R_NOT = 7
|
||||||
|
Public Const EN_R_BELOW = 8
|
||||||
|
Public Const EN_R_ABOVE = 9
|
||||||
|
|
||||||
|
Public Const EN_R_IS_OPEN = 1 ' Rule status types
|
||||||
|
Public Const EN_R_IS_CLOSED = 2
|
||||||
|
Public Const EN_R_IS_ACTIVE = 3
|
||||||
|
|
||||||
'These are the external functions that comprise the DLL
|
'These are the external functions that comprise the DLL
|
||||||
|
|
||||||
'System Functions
|
'System Functions
|
||||||
@@ -239,6 +283,8 @@ Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
|||||||
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
|
Declare Function ENgetnodetype Lib "epanet2.dll" (ByVal Index As Int32, ByRef Code As Int32) As Int32
|
||||||
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
Declare Function ENgetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||||
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
Declare Function ENsetnodevalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||||
|
Declare Function ENsetjuncdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal dmnd As Single, ByVal dmndpat As String) As Int32
|
||||||
|
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Int32, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Int32
|
||||||
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByRef X As Single, ByRef Y As Single) As Int32
|
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByRef X As Single, ByRef Y As Single) As Int32
|
||||||
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByVal X As Single, ByVal Y As Single) As Int32
|
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal Index As Int32, ByVal X As Single, ByVal Y As Single) As Int32
|
||||||
|
|
||||||
@@ -265,6 +311,7 @@ Public Const EN_CONDITIONAL = 1 ' Conditional object deletion
|
|||||||
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
|
Declare Function ENsetlinknodes Lib "epanet2.dll" (ByVal index As Int32, ByVal node1 As Int32, ByVal node2 As Int32) As Int32
|
||||||
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
Declare Function ENgetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByRef Value As Single) As Int32
|
||||||
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
Declare Function ENsetlinkvalue Lib "epanet2.dll" (ByVal Index As Int32, ByVal Code As Int32, ByVal Value As Single) As Int32
|
||||||
|
Declare Function ENsetpipedata Lib "epanet2.dll" (ByVal index As Int32, ByVal length As Single, ByVal diam As Single, ByVal rough As Single, ByVal mloss As Single) As Int32
|
||||||
|
|
||||||
'Pump Functions
|
'Pump Functions
|
||||||
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES
|
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal Index As Int32, ByVal CurveIndex As int32) As Int32 'ES
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 11/29/2018
|
Last Updated: 12/31/2018
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -46,22 +46,14 @@
|
|||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
#elif defined(CYGWIN)
|
#elif defined(CYGWIN)
|
||||||
#define DLLEXPORT __stdcall
|
#define DLLEXPORT __stdcall
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define DLLEXPORT
|
|
||||||
#else
|
|
||||||
#define DLLEXPORT
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#define DLLEXPORT
|
#define DLLEXPORT
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "epanet2_enums.h"
|
#include "epanet2_enums.h"
|
||||||
|
|
||||||
|
|
||||||
// --- Declare the EPANET toolkit functions
|
// --- Declare the EPANET toolkit functions
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -137,6 +129,12 @@ typedef struct Project *EN_Project;
|
|||||||
int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *code);
|
int DLLEXPORT EN_getnodetype(EN_Project ph, int index, int *code);
|
||||||
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE *value);
|
int DLLEXPORT EN_getnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE *value);
|
||||||
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
int DLLEXPORT EN_setnodevalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
int DLLEXPORT EN_setjuncdata(EN_Project ph, int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE dmnd, char *dmndpat);
|
||||||
|
int DLLEXPORT EN_settankdata(EN_Project ph, int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
|
||||||
|
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||||
|
EN_API_FLOAT_TYPE minvol, char *volcurve);
|
||||||
int DLLEXPORT EN_getcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
|
int DLLEXPORT EN_getcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE *x,
|
||||||
EN_API_FLOAT_TYPE *y);
|
EN_API_FLOAT_TYPE *y);
|
||||||
int DLLEXPORT EN_setcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE x,
|
int DLLEXPORT EN_setcoord(EN_Project ph, int index, EN_API_FLOAT_TYPE x,
|
||||||
@@ -173,6 +171,9 @@ typedef struct Project *EN_Project;
|
|||||||
int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, EN_LinkProperty code,
|
int DLLEXPORT EN_getlinkvalue(EN_Project ph, int index, EN_LinkProperty code,
|
||||||
EN_API_FLOAT_TYPE *value);
|
EN_API_FLOAT_TYPE *value);
|
||||||
int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
int DLLEXPORT EN_setlinkvalue(EN_Project ph, int index, int code, EN_API_FLOAT_TYPE v);
|
||||||
|
int DLLEXPORT EN_setpipedata(EN_Project ph, int index, EN_API_FLOAT_TYPE length,
|
||||||
|
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss);
|
||||||
|
|
||||||
|
|
||||||
int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *outType);
|
int DLLEXPORT EN_getpumptype(EN_Project ph, int linkIndex, int *outType);
|
||||||
int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int pumpIndex, int *curveIndex);
|
int DLLEXPORT EN_getheadcurveindex(EN_Project ph, int pumpIndex, int *curveIndex);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 11/29/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -69,13 +69,14 @@ typedef enum {
|
|||||||
EN_ENERGY = 13, //!> Current pump energy usage
|
EN_ENERGY = 13, //!> Current pump energy usage
|
||||||
EN_LINKQUAL = 14, //!> Current link quality
|
EN_LINKQUAL = 14, //!> Current link quality
|
||||||
EN_LINKPATTERN = 15, //!> Pump speed time pattern
|
EN_LINKPATTERN = 15, //!> Pump speed time pattern
|
||||||
EN_EFFICIENCY = 16, //!> Current pump efficiency
|
|
||||||
EN_HEADCURVE = 17, //!> Pump head v. flow curve
|
EN_PUMP_STATE = 16, //!> Current pump status
|
||||||
EN_EFFICIENCYCURVE = 18, //!> Pump efficiency v. flow curve
|
EN_PUMP_EFFIC = 17, //!> Current pump efficiency
|
||||||
EN_PRICEPATTERN = 19, //!> Pump energy price time pattern
|
EN_PUMP_POWER = 18, //!> Pump constant power rating
|
||||||
EN_STATE = 20, //!> Current pump status
|
EN_PUMP_HCURVE = 19, //!> Pump head v. flow curve
|
||||||
EN_CONST_POWER = 21, //!> Horsepower of constant horsepower pump
|
EN_PUMP_ECURVE = 20, //!> Pump efficiency v. flow curve
|
||||||
EN_SPEED = 22 //!> Current pump speed setting
|
EN_PUMP_ECOST = 21, //!> Pump average energy price
|
||||||
|
EN_PUMP_EPAT = 22 //!> Pump energy price time pattern
|
||||||
} EN_LinkProperty;
|
} EN_LinkProperty;
|
||||||
|
|
||||||
/// Time parameter codes
|
/// Time parameter codes
|
||||||
@@ -181,17 +182,21 @@ typedef enum {
|
|||||||
EN_PDA = 1 //!< Pressure driven analysis
|
EN_PDA = 1 //!< Pressure driven analysis
|
||||||
} EN_DemandModel;
|
} EN_DemandModel;
|
||||||
|
|
||||||
/// Simulation Option codes
|
/// Simulation option codes
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EN_TRIALS = 0, //!> Maximum hydraulic trials allowed
|
EN_TRIALS = 0, //!> Maximum hydraulic trials allowed
|
||||||
EN_ACCURACY = 1, //!> Hydraulic convergence accuracy
|
EN_ACCURACY = 1, //!> Hydraulic convergence accuracy
|
||||||
EN_TOLERANCE = 2, //!> Water quality tolerance
|
EN_TOLERANCE = 2, //!> Water quality tolerance
|
||||||
EN_EMITEXPON = 3, //!> Exponent for emitter head loss formula
|
EN_EMITEXPON = 3, //!> Exponent for emitter head loss formula
|
||||||
EN_DEMANDMULT = 4, //!> Global demand multiplier
|
EN_DEMANDMULT = 4, //!> Global demand multiplier
|
||||||
EN_HEADERROR = 5, //!> Maximum allowable head loss error
|
EN_HEADERROR = 5, //!> Maximum allowable head loss error
|
||||||
EN_FLOWCHANGE = 6, //!> Maximum allowable flow change
|
EN_FLOWCHANGE = 6, //!> Maximum allowable flow change
|
||||||
EN_DEMANDDEFPAT = 7, //!> Default demand time pattern
|
EN_DEFDEMANDPAT = 7, //!> Default demand time pattern
|
||||||
EN_HEADLOSSFORM = 8 //!> Head loss formula code
|
EN_HEADLOSSFORM = 8, //!> Head loss formula code
|
||||||
|
EN_GLOBALEFFIC = 9, //!> Global pump efficiency
|
||||||
|
EN_GLOBALPRICE = 10, //!> Global energy price per KWH
|
||||||
|
EN_GLOBALPATTERN = 11, //!> Global energy price pattern
|
||||||
|
EN_DEMANDCHARGE = 12 //!> Energy charge per max. KW usage
|
||||||
} EN_Option;
|
} EN_Option;
|
||||||
|
|
||||||
/// Simple control types
|
/// Simple control types
|
||||||
@@ -236,19 +241,26 @@ typedef enum {
|
|||||||
|
|
||||||
/// Data curve types
|
/// Data curve types
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EN_V_CURVE = 0, //!< Tank volume curve
|
EN_VOLUME_CURVE = 0, //!< Tank volume curve
|
||||||
EN_P_CURVE = 1, //!< Pump characteristic curve
|
EN_PUMP_CURVE = 1, //!< Pump head curve
|
||||||
EN_E_CURVE = 2, //!< Pump efficiency curve
|
EN_EFFIC_CURVE = 2, //!< Pump efficiency curve
|
||||||
EN_H_CURVE = 3, //!< Valve head loss curve
|
EN_HLOSS_CURVE = 3, //!< Valve head loss curve
|
||||||
EN_G_CURVE = 4 //!< General\default curve
|
EN_GENERIC_CURVE = 4 //!< Generic curve
|
||||||
} EN_CurveType;
|
} EN_CurveType;
|
||||||
|
|
||||||
/// Deletion action types
|
/// Deletion action codes
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EN_UNCONDITIONAL = 0, //!> Delete all controls that contain object
|
EN_UNCONDITIONAL = 0, //!> Delete all controls that contain object
|
||||||
EN_CONDITIONAL = 1 //!> Cancel object deletion if contained in controls
|
EN_CONDITIONAL = 1 //!> Cancel object deletion if contained in controls
|
||||||
} EN_ActionCodeType;
|
} EN_ActionCodeType;
|
||||||
|
|
||||||
|
/// Status report options
|
||||||
|
typedef enum {
|
||||||
|
EN_NO_REPORT = 0,
|
||||||
|
EN_NORMAL_REPORT = 1,
|
||||||
|
EN_FULL_REPORT = 2
|
||||||
|
} EN_StatusReport;
|
||||||
|
|
||||||
/// Rule object codes
|
/// Rule object codes
|
||||||
typedef enum {
|
typedef enum {
|
||||||
EN_R_NODE = 6,
|
EN_R_NODE = 6,
|
||||||
@@ -294,12 +306,5 @@ typedef enum {
|
|||||||
EN_R_IS_ACTIVE = 3
|
EN_R_IS_ACTIVE = 3
|
||||||
} EN_RuleStatus;
|
} EN_RuleStatus;
|
||||||
|
|
||||||
/// Status report types
|
|
||||||
typedef enum {
|
|
||||||
EN_NO_REPORT = 0,
|
|
||||||
EN_NORMAL_REPORT = 1,
|
|
||||||
EN_FULL_REPORT = 2
|
|
||||||
} EN_StatusReport;
|
|
||||||
|
|
||||||
|
|
||||||
#endif //EPANET2_ENUMS_H
|
#endif //EPANET2_ENUMS_H
|
||||||
|
|||||||
342
src/epanet.c
342
src/epanet.c
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 12/15/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
|
|||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
|
|
||||||
// Set system flags
|
// Set system flags
|
||||||
p->Openflag = TRUE;
|
p->Openflag = FALSE;
|
||||||
p->hydraul.OpenHflag = FALSE;
|
p->hydraul.OpenHflag = FALSE;
|
||||||
p->quality.OpenQflag = FALSE;
|
p->quality.OpenQflag = FALSE;
|
||||||
p->outfile.SaveHflag = FALSE;
|
p->outfile.SaveHflag = FALSE;
|
||||||
@@ -143,6 +143,10 @@ int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
|
|||||||
p->report.Messageflag = TRUE;
|
p->report.Messageflag = TRUE;
|
||||||
p->report.Rptflag = 1;
|
p->report.Rptflag = 1;
|
||||||
|
|
||||||
|
// Check for valid arguments
|
||||||
|
if (unitsType < 0 || unitsType > CMD) return 251;
|
||||||
|
if (headLossType < 0 || headLossType > CM) return 251;
|
||||||
|
|
||||||
// Open files
|
// Open files
|
||||||
errcode = openfiles(p, "", f2, f3);
|
errcode = openfiles(p, "", f2, f3);
|
||||||
|
|
||||||
@@ -167,6 +171,7 @@ int DLLEXPORT EN_init(EN_Project p, const char *f2, const char *f3,
|
|||||||
// Initialize the default demand pattern
|
// Initialize the default demand pattern
|
||||||
p->parser.MaxPats = 0;
|
p->parser.MaxPats = 0;
|
||||||
getpatterns(p);
|
getpatterns(p);
|
||||||
|
p->Openflag = TRUE;
|
||||||
return errcode;
|
return errcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,12 +1037,25 @@ int DLLEXPORT EN_getoption(EN_Project p, EN_Option code,
|
|||||||
case EN_FLOWCHANGE:
|
case EN_FLOWCHANGE:
|
||||||
v = hyd->FlowChangeLimit * Ucf[FLOW];
|
v = hyd->FlowChangeLimit * Ucf[FLOW];
|
||||||
break;
|
break;
|
||||||
case EN_DEMANDDEFPAT:
|
case EN_DEFDEMANDPAT:
|
||||||
v = hyd->DefPat;
|
v = hyd->DefPat;
|
||||||
break;
|
break;
|
||||||
case EN_HEADLOSSFORM:
|
case EN_HEADLOSSFORM:
|
||||||
v = hyd->Formflag;
|
v = hyd->Formflag;
|
||||||
break;
|
break;
|
||||||
|
case EN_GLOBALEFFIC:
|
||||||
|
v = hyd->Epump;
|
||||||
|
break;
|
||||||
|
case EN_GLOBALPRICE:
|
||||||
|
v = hyd->Ecost;
|
||||||
|
break;
|
||||||
|
case EN_GLOBALPATTERN:
|
||||||
|
v = hyd->Epat;
|
||||||
|
break;
|
||||||
|
case EN_DEMANDCHARGE:
|
||||||
|
v = hyd->Dcost;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 251;
|
return 251;
|
||||||
}
|
}
|
||||||
@@ -1114,7 +1132,7 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
|
|||||||
hyd->FlowChangeLimit = value / Ucf[FLOW];
|
hyd->FlowChangeLimit = value / Ucf[FLOW];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_DEMANDDEFPAT:
|
case EN_DEFDEMANDPAT:
|
||||||
//check that the pattern exists or is set to zero to delete the default pattern
|
//check that the pattern exists or is set to zero to delete the default pattern
|
||||||
if (value < 0 || value > net->Npats) return 205;
|
if (value < 0 || value > net->Npats) return 205;
|
||||||
tmpPat = hyd->DefPat;
|
tmpPat = hyd->DefPat;
|
||||||
@@ -1145,6 +1163,27 @@ int DLLEXPORT EN_setoption(EN_Project p, int code, EN_API_FLOAT_TYPE v)
|
|||||||
hyd->DefPat = (int)value;
|
hyd->DefPat = (int)value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EN_GLOBALEFFIC:
|
||||||
|
if (value <= 0.0 || value > 100.0) return 213;
|
||||||
|
hyd->Epump = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_GLOBALPRICE:
|
||||||
|
if (value < 0.0) return 213;
|
||||||
|
hyd->Ecost = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_GLOBALPATTERN:
|
||||||
|
tmpPat = (int)(value + 0.5);
|
||||||
|
if (tmpPat < 0 || tmpPat > net->Npats) return 205;
|
||||||
|
hyd->Epat = tmpPat;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_DEMANDCHARGE:
|
||||||
|
if (value < 0.0) return 213;
|
||||||
|
hyd->Dcost = value;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 251;
|
return 251;
|
||||||
}
|
}
|
||||||
@@ -1214,16 +1253,16 @@ int DLLEXPORT EN_setflowunits(EN_Project p, int code)
|
|||||||
{
|
{
|
||||||
switch (net->Curve[i].Type)
|
switch (net->Curve[i].Type)
|
||||||
{
|
{
|
||||||
case V_CURVE:
|
case VOLUME_CURVE:
|
||||||
xfactor = efactor / Ucf[ELEV];
|
xfactor = efactor / Ucf[ELEV];
|
||||||
yfactor = vfactor / Ucf[VOLUME];
|
yfactor = vfactor / Ucf[VOLUME];
|
||||||
break;
|
break;
|
||||||
case H_CURVE:
|
case HLOSS_CURVE:
|
||||||
case P_CURVE:
|
case PUMP_CURVE:
|
||||||
xfactor = qfactor / Ucf[FLOW];
|
xfactor = qfactor / Ucf[FLOW];
|
||||||
yfactor = hfactor / Ucf[HEAD];
|
yfactor = hfactor / Ucf[HEAD];
|
||||||
break;
|
break;
|
||||||
case E_CURVE:
|
case EFFIC_CURVE:
|
||||||
xfactor = qfactor / Ucf[FLOW];
|
xfactor = qfactor / Ucf[FLOW];
|
||||||
yfactor = 1;
|
yfactor = 1;
|
||||||
break;
|
break;
|
||||||
@@ -2067,6 +2106,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
|
|
||||||
Snode *Node = net->Node;
|
Snode *Node = net->Node;
|
||||||
Stank *Tank = net->Tank;
|
Stank *Tank = net->Tank;
|
||||||
|
Scurve *curve;
|
||||||
|
|
||||||
const int nNodes = net->Nnodes;
|
const int nNodes = net->Nnodes;
|
||||||
const int nJuncs = net->Njuncs;
|
const int nJuncs = net->Njuncs;
|
||||||
@@ -2074,7 +2114,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
|
|
||||||
double *Ucf = p->Ucf;
|
double *Ucf = p->Ucf;
|
||||||
|
|
||||||
int j;
|
int i, j, n;
|
||||||
Pdemand demand;
|
Pdemand demand;
|
||||||
Psource source;
|
Psource source;
|
||||||
double hTmp;
|
double hTmp;
|
||||||
@@ -2179,7 +2219,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = Node[index].El + value / Ucf[ELEV];
|
value = Node[index].El + value / Ucf[ELEV];
|
||||||
if (value > Tank[j].Hmax || value < Tank[j].Hmin) return 209;
|
if (value > Tank[j].Hmax || value < Tank[j].Hmin) return 225;
|
||||||
Tank[j].H0 = value;
|
Tank[j].H0 = value;
|
||||||
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
||||||
// Resetting Volume in addition to initial volume
|
// Resetting Volume in addition to initial volume
|
||||||
@@ -2199,6 +2239,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin);
|
Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin);
|
||||||
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
||||||
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
||||||
|
Tank[j].Vcurve = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2214,6 +2255,23 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EN_VOLCURVE:
|
||||||
|
if (index < nJuncs) return 0;
|
||||||
|
i = ROUND(value);
|
||||||
|
if (i < 0 || i > net->Ncurves) return 205;
|
||||||
|
curve = &net->Curve[i];
|
||||||
|
j = index - nJuncs;
|
||||||
|
if (Tank[j].A == 0.0) return 0;
|
||||||
|
n = curve->Npts - 1;
|
||||||
|
if (Tank[j].Vmin * Ucf[VOLUME] < curve->Y[0] ||
|
||||||
|
Tank[j].Vmax * Ucf[VOLUME] > curve->Y[n]) return 225;
|
||||||
|
Tank[j].Vcurve = i;
|
||||||
|
Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin);
|
||||||
|
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
||||||
|
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
||||||
|
Tank[j].A = (curve->Y[n] - curve->Y[0]) / (curve->X[n] - curve->X[0]);
|
||||||
|
break;
|
||||||
|
|
||||||
case EN_MINLEVEL:
|
case EN_MINLEVEL:
|
||||||
if (value < 0.0) return 209;
|
if (value < 0.0) return 209;
|
||||||
if (index <= nJuncs) return 0; // not a tank or reservoir
|
if (index <= nJuncs) return 0; // not a tank or reservoir
|
||||||
@@ -2226,7 +2284,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
Tank[j].Hmin = hTmp;
|
Tank[j].Hmin = hTmp;
|
||||||
Tank[j].Vmin = (Tank[j].Hmin - Node[index].El) * Tank[j].A;
|
Tank[j].Vmin = (Tank[j].Hmin - Node[index].El) * Tank[j].A;
|
||||||
}
|
}
|
||||||
else return 209;
|
else return 225;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_MAXLEVEL:
|
case EN_MAXLEVEL:
|
||||||
@@ -2241,7 +2299,7 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
Tank[j].Hmax = hTmp;
|
Tank[j].Hmax = hTmp;
|
||||||
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
||||||
}
|
}
|
||||||
else return 209;
|
else return 225;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_MIXMODEL:
|
case EN_MIXMODEL:
|
||||||
@@ -2280,6 +2338,130 @@ int DLLEXPORT EN_setnodevalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT EN_setjuncdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE dmnd, char *patID)
|
||||||
|
/*----------------------------------------------------------------
|
||||||
|
** Input: index = junction node index
|
||||||
|
** elev = junction elevation
|
||||||
|
** dmnd = junction primary base demand
|
||||||
|
** patID = name of primary demand time pattern
|
||||||
|
** Output: none
|
||||||
|
** Returns: error code
|
||||||
|
** Purpose: sets several properties for a junction node.
|
||||||
|
**----------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Network *net = &p->network;
|
||||||
|
|
||||||
|
int i, patIndex = 0;
|
||||||
|
Snode *Node = net->Node;
|
||||||
|
Pdemand demand;
|
||||||
|
|
||||||
|
// Check that junction exists
|
||||||
|
if (!p->Openflag) return 102;
|
||||||
|
if (index <= 0 || index > net->Njuncs) return 203;
|
||||||
|
|
||||||
|
// Check that demand pattern exists
|
||||||
|
if (strlen(patID) > 0)
|
||||||
|
{
|
||||||
|
for (i = 1; i <= net->Npats; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(patID, net->Pattern[i].ID) == 0)
|
||||||
|
{
|
||||||
|
patIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (patIndex == 0) return 205;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign values to junction's parameters
|
||||||
|
Node[index].El = elev / p->Ucf[ELEV];
|
||||||
|
for (demand = Node[index].D; demand != NULL; demand = demand->next)
|
||||||
|
{
|
||||||
|
if (demand->next == NULL)
|
||||||
|
{
|
||||||
|
demand->Base = dmnd / p->Ucf[FLOW];
|
||||||
|
demand->Pat = patIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT EN_settankdata(EN_Project p, int index, EN_API_FLOAT_TYPE elev,
|
||||||
|
EN_API_FLOAT_TYPE initlvl, EN_API_FLOAT_TYPE minlvl,
|
||||||
|
EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||||
|
EN_API_FLOAT_TYPE minvol, char *volcurve)
|
||||||
|
/*----------------------------------------------------------------
|
||||||
|
** Input: index = tank node index
|
||||||
|
** elev = tank bottom elevation
|
||||||
|
** initlvl = initial water depth
|
||||||
|
** minlvl = minimum water depth
|
||||||
|
** maxlvl = maximum water depth
|
||||||
|
** diam = tank diameter
|
||||||
|
** minvol = tank volume at minimum level
|
||||||
|
** volCurve = name of curve for volume v. level
|
||||||
|
** Output: none
|
||||||
|
** Returns: error code
|
||||||
|
** Purpose: sets several properties for a tank node.
|
||||||
|
**----------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Network *net = &p->network;
|
||||||
|
|
||||||
|
int i, j, n, curveIndex = 0;
|
||||||
|
double area, elevation = elev;
|
||||||
|
double *Ucf = p->Ucf;
|
||||||
|
Snode *Node = net->Node;
|
||||||
|
Stank *Tank = net->Tank;
|
||||||
|
Scurve *curve;
|
||||||
|
|
||||||
|
// Check that tank exists
|
||||||
|
if (!p->Openflag) return 102;
|
||||||
|
if (index <= net->Njuncs || index > net->Nnodes) return 203;
|
||||||
|
j = index - net->Njuncs;
|
||||||
|
if (Tank[j].A == 0) return 0; // Tank is a Reservoir
|
||||||
|
|
||||||
|
// Check for valid parameter values
|
||||||
|
if (initlvl < 0.0 || minlvl < 0.0 || maxlvl < 0.0) return 209;
|
||||||
|
if (minlvl > initlvl || minlvl > maxlvl || initlvl > maxlvl) return 225;
|
||||||
|
if (diam < 0.0 || minvol < 0.0) return 209;
|
||||||
|
|
||||||
|
// volume curve supplied
|
||||||
|
if (strlen(volcurve) > 0)
|
||||||
|
{
|
||||||
|
for (i = 1; i <= net->Ncurves; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(volcurve, net->Curve[i].ID) == 0)
|
||||||
|
{
|
||||||
|
curveIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curveIndex == 0) return 206;
|
||||||
|
curve = &net->Curve[curveIndex];
|
||||||
|
n = curve->Npts - 1;
|
||||||
|
if (minlvl < curve->X[0] || maxlvl > curve->X[n]) return 225;
|
||||||
|
area = (curve->Y[n] - curve->Y[0]) / (curve->X[n] - curve->X[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tank diameter supplied
|
||||||
|
else area = PI * diam * diam / 4.0;
|
||||||
|
|
||||||
|
// Assign parameters to tank object
|
||||||
|
net->Node[Tank[j].Node].El = elevation;
|
||||||
|
Tank[j].A = area / Ucf[ELEV] / Ucf[ELEV];
|
||||||
|
Tank[j].H0 = elevation + initlvl / Ucf[ELEV];
|
||||||
|
Tank[j].Hmin = elevation + minlvl / Ucf[ELEV];
|
||||||
|
Tank[j].Hmax = elevation + maxlvl / Ucf[ELEV];
|
||||||
|
Tank[j].Vcurve = curveIndex;
|
||||||
|
Tank[j].Vmin = tankvolume(p, j, Tank[j].Hmin);
|
||||||
|
Tank[j].V0 = tankvolume(p, j, Tank[j].H0);
|
||||||
|
Tank[j].Vmax = tankvolume(p, j, Tank[j].Hmax);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int DLLEXPORT EN_getcoord(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
|
int DLLEXPORT EN_getcoord(EN_Project p, int index, EN_API_FLOAT_TYPE *x,
|
||||||
EN_API_FLOAT_TYPE *y)
|
EN_API_FLOAT_TYPE *y)
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
@@ -3139,7 +3321,7 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
|
|||||||
else v = 1.0;
|
else v = 1.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_STATE:
|
case EN_PUMP_STATE:
|
||||||
v = hyd->LinkStatus[index];
|
v = hyd->LinkStatus[index];
|
||||||
|
|
||||||
if (Link[index].Type == EN_PUMP)
|
if (Link[index].Type == EN_PUMP)
|
||||||
@@ -3156,21 +3338,12 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_CONST_POWER:
|
case EN_PUMP_POWER:
|
||||||
v = 0;
|
v = 0;
|
||||||
if (Link[index].Type == EN_PUMP)
|
if (Link[index].Type == EN_PUMP)
|
||||||
{
|
{
|
||||||
pmp = findpump(net, index);
|
pmp = findpump(net, index);
|
||||||
if (Pump[pmp].Ptype == CONST_HP) v = Link[index].Km; // Power in HP
|
if (Pump[pmp].Ptype == CONST_HP) v = Link[index].Km; // Power in HP or KW
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EN_SPEED:
|
|
||||||
v = 0;
|
|
||||||
if (Link[index].Type == EN_PUMP)
|
|
||||||
{
|
|
||||||
pmp = findpump(net, index);
|
|
||||||
v = Link[index].Kc;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -3210,25 +3383,25 @@ int DLLEXPORT EN_getlinkvalue(EN_Project p, int index, EN_LinkProperty code,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_EFFICIENCY:
|
case EN_PUMP_EFFIC:
|
||||||
getenergy(p, index, &a, &v);
|
getenergy(p, index, &a, &v);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_PRICEPATTERN:
|
case EN_PUMP_EPAT:
|
||||||
if (Link[index].Type == EN_PUMP)
|
if (Link[index].Type == EN_PUMP)
|
||||||
{
|
{
|
||||||
v = (double)Pump[findpump(&p->network, index)].Epat;
|
v = (double)Pump[findpump(&p->network, index)].Epat;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_HEADCURVE:
|
case EN_PUMP_HCURVE:
|
||||||
if (Link[index].Type == EN_PUMP)
|
if (Link[index].Type == EN_PUMP)
|
||||||
{
|
{
|
||||||
v = (double)Pump[findpump(&p->network, index)].Hcurve;
|
v = (double)Pump[findpump(&p->network, index)].Hcurve;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EN_EFFICIENCYCURVE:
|
case EN_PUMP_ECURVE:
|
||||||
if (Link[index].Type == EN_PUMP)
|
if (Link[index].Type == EN_PUMP)
|
||||||
{
|
{
|
||||||
v = (double)Pump[findpump(&p->network, index)].Ecurve;
|
v = (double)Pump[findpump(&p->network, index)].Ecurve;
|
||||||
@@ -3262,6 +3435,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
double *LinkSetting = hyd->LinkSetting;
|
double *LinkSetting = hyd->LinkSetting;
|
||||||
char s;
|
char s;
|
||||||
double r, value = v;
|
double r, value = v;
|
||||||
|
int pumpIndex, patIndex, curveIndex;
|
||||||
|
|
||||||
if (!p->Openflag) return 102;
|
if (!p->Openflag) return 102;
|
||||||
if (index <= 0 || index > net->Nlinks) return 204;
|
if (index <= 0 || index > net->Nlinks) return 204;
|
||||||
@@ -3379,19 +3553,123 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int code, EN_API_FLOAT_TY
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EN_LINKPATTERN:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
patIndex = (int) (value + 0.5);
|
||||||
|
if (patIndex <= 0 || patIndex > net->Npats) return 205;
|
||||||
|
pumpIndex = findpump(&p->network, index);
|
||||||
|
net->Pump[pumpIndex].Upat = patIndex;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_PUMP_ECOST:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
if (value < 0.0) return 211;
|
||||||
|
pumpIndex = findpump(&p->network, index);
|
||||||
|
net->Pump[pumpIndex].Ecost = value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_PUMP_EPAT:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
patIndex = (int)(value + 0.5);
|
||||||
|
if (patIndex <= 0 || patIndex > net->Npats) return 205;
|
||||||
|
pumpIndex = findpump(&p->network, index);
|
||||||
|
net->Pump[pumpIndex].Epat = patIndex;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_PUMP_HCURVE:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
return EN_setheadcurveindex(p, index, (int)(value + 0.5));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_PUMP_POWER:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
if (value <= 0.0) return 211;
|
||||||
|
pumpIndex = findpump(&p->network, index);
|
||||||
|
net->Pump[pumpIndex].Ptype = CONST_HP;
|
||||||
|
net->Pump[pumpIndex].Hcurve = 0;
|
||||||
|
net->Link[index].Km = v;
|
||||||
|
updatepumpparams(p, pumpIndex);
|
||||||
|
net->Pump[pumpIndex].R /= Ucf[POWER];
|
||||||
|
net->Pump[pumpIndex].Q0 /= Ucf[FLOW];
|
||||||
|
net->Pump[pumpIndex].Qmax /= Ucf[FLOW];
|
||||||
|
net->Pump[pumpIndex].Hmax /= Ucf[HEAD];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EN_PUMP_ECURVE:
|
||||||
|
if (Link[index].Type == EN_PUMP)
|
||||||
|
{
|
||||||
|
curveIndex = (int)(v + 0.5);
|
||||||
|
if (curveIndex <= 0 || curveIndex > net->Ncurves) return 205;
|
||||||
|
pumpIndex = findpump(&p->network, index);
|
||||||
|
net->Pump[pumpIndex].Ecurve = curveIndex;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 251;
|
return 251;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT EN_setpipedata(EN_Project p, int index, EN_API_FLOAT_TYPE length,
|
||||||
|
EN_API_FLOAT_TYPE diam, EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
|
||||||
|
/*----------------------------------------------------------------
|
||||||
|
** Input: index = pipe link index
|
||||||
|
** length = pipe length
|
||||||
|
** diam = pipe diameter
|
||||||
|
** rough = pipe roughness coefficient
|
||||||
|
** mloss = minor loss coefficient
|
||||||
|
** Output: none
|
||||||
|
** Returns: error code
|
||||||
|
** Purpose: sets several properties for a pipe link.
|
||||||
|
**----------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Network *net = &p->network;
|
||||||
|
|
||||||
|
Slink *Link = net->Link;
|
||||||
|
double *Ucf = p->Ucf;
|
||||||
|
double diameter = diam;
|
||||||
|
|
||||||
|
// Check that pipe exists
|
||||||
|
if (!p->Openflag) return 102;
|
||||||
|
if (index <= 0 || index > net->Nlinks) return 204;
|
||||||
|
if (Link[index].Type > EN_PIPE) return 0;
|
||||||
|
|
||||||
|
// Check for valid parameters
|
||||||
|
if (length <= 0.0 || diam <= 0.0 || rough <= 0.0 || mloss < 0.0) return 211;
|
||||||
|
|
||||||
|
// Assign parameters to pipe
|
||||||
|
Link[index].Len = length / Ucf[ELEV];
|
||||||
|
diameter /= Ucf[DIAM];
|
||||||
|
Link[index].Diam = diameter;
|
||||||
|
Link[index].Kc = rough;
|
||||||
|
if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]);
|
||||||
|
|
||||||
|
// Update minor loss factor & pipe flow resistance
|
||||||
|
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
|
||||||
|
resistcoeff(p, index);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Pump Functions
|
Pump Functions
|
||||||
|
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
int DLLEXPORT EN_getpumptype(EN_Project p, int index, int *type)
|
int DLLEXPORT EN_getpumptype(EN_Project p, int index, int *type) //2.1
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
** Input: index = index of a pump link
|
** Input: index = index of a pump link
|
||||||
** Output: type = type of pump characteristic curve (see EN_PumpType)
|
** Output: type = type of pump characteristic curve (see EN_PumpType)
|
||||||
@@ -3414,7 +3692,7 @@ int DLLEXPORT EN_getpumptype(EN_Project p, int index, int *type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT EN_getheadcurveindex(EN_Project p, int index, int *curveindex)
|
int DLLEXPORT EN_getheadcurveindex(EN_Project p, int index, int *curveindex) //2.1
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
** Input: index = index of a pump link
|
** Input: index = index of a pump link
|
||||||
** Output: curveindex = index of a pump's characteristic curve
|
** Output: curveindex = index of a pump's characteristic curve
|
||||||
@@ -3480,7 +3758,7 @@ int DLLEXPORT EN_setheadcurveindex(EN_Project p, int index, int curveindex)
|
|||||||
pump->Hmax /= Ucf[HEAD];
|
pump->Hmax /= Ucf[HEAD];
|
||||||
|
|
||||||
// Designate the newly assigned curve as being a Pump Curve
|
// Designate the newly assigned curve as being a Pump Curve
|
||||||
p->network.Curve[curveindex].Type = P_CURVE;
|
p->network.Curve[curveindex].Type = PUMP_CURVE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3729,7 +4007,7 @@ int DLLEXPORT EN_addcurve(EN_Project p, char *id)
|
|||||||
curve = &net->Curve[n];
|
curve = &net->Curve[n];
|
||||||
strcpy(curve->ID, id);
|
strcpy(curve->ID, id);
|
||||||
curve->Npts = 1;
|
curve->Npts = 1;
|
||||||
curve->Type = G_CURVE;
|
curve->Type = GENERIC_CURVE;
|
||||||
curve->X = (double *)calloc(1, sizeof(double));
|
curve->X = (double *)calloc(1, sizeof(double));
|
||||||
curve->Y = (double *)calloc(1, sizeof(double));
|
curve->Y = (double *)calloc(1, sizeof(double));
|
||||||
if (curve->X == NULL) err = 1;
|
if (curve->X == NULL) err = 1;
|
||||||
|
|||||||
@@ -288,6 +288,20 @@ int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v)
|
|||||||
return EN_setnodevalue(_defaultProject, index, code, v);
|
return EN_setnodevalue(_defaultProject, index, code, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT ENsetjuncdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE dmnd,
|
||||||
|
char *dmndpat)
|
||||||
|
{
|
||||||
|
return EN_setjuncdata(_defaultProject, index, elev, dmnd, dmndpat);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT ENsettankdata(int index, EN_API_FLOAT_TYPE elev, EN_API_FLOAT_TYPE initlvl,
|
||||||
|
EN_API_FLOAT_TYPE minlvl, EN_API_FLOAT_TYPE maxlvl, EN_API_FLOAT_TYPE diam,
|
||||||
|
EN_API_FLOAT_TYPE minvol, char *volcurve)
|
||||||
|
{
|
||||||
|
return EN_settankdata(_defaultProject, index, elev, initlvl, minlvl, maxlvl,
|
||||||
|
diam, minvol, volcurve);
|
||||||
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
|
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y)
|
||||||
{
|
{
|
||||||
return EN_getcoord(_defaultProject, index, x, y);
|
return EN_getcoord(_defaultProject, index, x, y);
|
||||||
@@ -412,6 +426,13 @@ int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v)
|
|||||||
return EN_setlinkvalue(_defaultProject, index, code, v);
|
return EN_setlinkvalue(_defaultProject, index, code, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DLLEXPORT ENsetpipedata(int index, EN_API_FLOAT_TYPE length, EN_API_FLOAT_TYPE diam,
|
||||||
|
EN_API_FLOAT_TYPE rough, EN_API_FLOAT_TYPE mloss)
|
||||||
|
{
|
||||||
|
return EN_setpipedata(_defaultProject, index, length, diam, rough, mloss);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
|
||||||
Pump Functions
|
Pump Functions
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: reads and interprets network data from an EPANET input file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 12/15/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ int updatepumpparams(Project *pr, int pumpindex)
|
|||||||
curveindex = pump->Hcurve;
|
curveindex = pump->Hcurve;
|
||||||
if (curveindex == 0) return 226;
|
if (curveindex == 0) return 226;
|
||||||
curve = &net->Curve[curveindex];
|
curve = &net->Curve[curveindex];
|
||||||
curve->Type = P_CURVE;
|
curve->Type = PUMP_CURVE;
|
||||||
npts = curve->Npts;
|
npts = curve->Npts;
|
||||||
|
|
||||||
// Generic power function curve
|
// Generic power function curve
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Description: parses network data from a line of an EPANET input file
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 12/15/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ int tankdata(Project *pr)
|
|||||||
tmplist = getlistitem(parser->Tok[7], parser->Curvelist);
|
tmplist = getlistitem(parser->Tok[7], parser->Curvelist);
|
||||||
if (tmplist == NULL) return setError(parser, 7, 206);
|
if (tmplist == NULL) return setError(parser, 7, 206);
|
||||||
curve = tmplist->i;
|
curve = tmplist->i;
|
||||||
net->Curve[curve].Type = V_CURVE;
|
net->Curve[curve].Type = VOLUME_CURVE;
|
||||||
}
|
}
|
||||||
if (initlevel < 0.0) return setError(parser, 2, 209);
|
if (initlevel < 0.0) return setError(parser, 2, 209);
|
||||||
if (minlevel < 0.0) return setError(parser, 3, 209);
|
if (minlevel < 0.0) return setError(parser, 3, 209);
|
||||||
@@ -508,7 +508,7 @@ int valvedata(Project *pr)
|
|||||||
tmplist = getlistitem(parser->Tok[5], parser->Curvelist);
|
tmplist = getlistitem(parser->Tok[5], parser->Curvelist);
|
||||||
if (tmplist == NULL) return setError(parser, 5, 206);
|
if (tmplist == NULL) return setError(parser, 5, 206);
|
||||||
setting = tmplist->i;
|
setting = tmplist->i;
|
||||||
net->Curve[tmplist->i].Type = H_CURVE;
|
net->Curve[tmplist->i].Type = HLOSS_CURVE;
|
||||||
status = OPEN;
|
status = OPEN;
|
||||||
}
|
}
|
||||||
else if (!getfloat(parser->Tok[5], &setting)) return setError(parser, 5, 202);
|
else if (!getfloat(parser->Tok[5], &setting)) return setError(parser, 5, 202);
|
||||||
@@ -1391,7 +1391,7 @@ int energydata(Project *pr)
|
|||||||
listitem = getlistitem(parser->Tok[n - 1], parser->Curvelist);
|
listitem = getlistitem(parser->Tok[n - 1], parser->Curvelist);
|
||||||
if (listitem == NULL) return setError(parser, n - 1, 206);
|
if (listitem == NULL) return setError(parser, n - 1, 206);
|
||||||
Pump[j].Ecurve = listitem->i;
|
Pump[j].Ecurve = listitem->i;
|
||||||
net->Curve[listitem->i].Type = E_CURVE;
|
net->Curve[listitem->i].Type = EFFIC_CURVE;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 12/15/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ int allocdata(Project *pr)
|
|||||||
for (n = 0; n <= pr->parser.MaxCurves; n++)
|
for (n = 0; n <= pr->parser.MaxCurves; n++)
|
||||||
{
|
{
|
||||||
pr->network.Curve[n].Npts = 0;
|
pr->network.Curve[n].Npts = 0;
|
||||||
pr->network.Curve[n].Type = G_CURVE;
|
pr->network.Curve[n].Type = GENERIC_CURVE;
|
||||||
pr->network.Curve[n].X = NULL;
|
pr->network.Curve[n].X = NULL;
|
||||||
pr->network.Curve[n].Y = NULL;
|
pr->network.Curve[n].Y = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/types.h
12
src/types.h
@@ -7,7 +7,7 @@
|
|||||||
Authors: see AUTHORS
|
Authors: see AUTHORS
|
||||||
Copyright: see AUTHORS
|
Copyright: see AUTHORS
|
||||||
License: see LICENSE
|
License: see LICENSE
|
||||||
Last Updated: 12/15/2018
|
Last Updated: 01/01/2019
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -157,11 +157,11 @@ typedef enum {
|
|||||||
} QualType;
|
} QualType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
V_CURVE, // volume curve
|
VOLUME_CURVE, // volume curve
|
||||||
P_CURVE, // pump curve
|
PUMP_CURVE, // pump curve
|
||||||
E_CURVE, // efficiency curve
|
EFFIC_CURVE, // efficiency curve
|
||||||
H_CURVE, // head loss curve
|
HLOSS_CURVE, // head loss curve
|
||||||
G_CURVE // general\default curve
|
GENERIC_CURVE // generic curve
|
||||||
} CurveType;
|
} CurveType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(test_net_builder)
|
|||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_setpattern(ph, 1, P, 12);
|
error = EN_setpattern(ph, 1, P, 12);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
error = EN_setoption(ph, EN_DEMANDDEFPAT, 1);
|
error = EN_setoption(ph, EN_DEFDEMANDPAT, 1);
|
||||||
BOOST_REQUIRE(error == 0);
|
BOOST_REQUIRE(error == 0);
|
||||||
for (i = 0; i < 9; i++)
|
for (i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
114
tests/test_net_builder_2.cpp
Normal file
114
tests/test_net_builder_2.cpp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
// Test of EPANET's Network Building Functions
|
||||||
|
//
|
||||||
|
// This is a test of the API functions EN_setjuncdata, EN_settankdata & EN_setpipedata
|
||||||
|
//
|
||||||
|
#define _CRT_SECURE_NO_DEPRECATE
|
||||||
|
|
||||||
|
//#define NO_BOOST
|
||||||
|
|
||||||
|
#ifndef NO_BOOST
|
||||||
|
#define BOOST_TEST_MODULE "toolkit"
|
||||||
|
#include <boost/test/included/unit_test.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include "epanet2_2.h"
|
||||||
|
|
||||||
|
#define DATA_PATH_INP "./net1.inp"
|
||||||
|
#define DATA_PATH_RPT "./test.rpt"
|
||||||
|
#define DATA_PATH_OUT "./test.out"
|
||||||
|
|
||||||
|
#ifdef NO_BOOST
|
||||||
|
#define BOOST_REQUIRE(x) (((x)) ? cout << "\nPassed at line " << __LINE__ : cout << "\nFailed at line " << __LINE__ )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#ifndef NO_BOOST
|
||||||
|
BOOST_AUTO_TEST_SUITE (test_toolkit)
|
||||||
|
BOOST_AUTO_TEST_CASE(test_setlinktype)
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int index;
|
||||||
|
char id[EN_MAXID+1];
|
||||||
|
float p1_1, p2_1, p1_2, p2_2;
|
||||||
|
float q1_1, q2_1, q1_2, q2_2;
|
||||||
|
|
||||||
|
// Create & initialize a project
|
||||||
|
EN_Project ph = NULL;
|
||||||
|
EN_createproject(&ph);
|
||||||
|
EN_init(ph, "", "", EN_GPM, EN_HW);
|
||||||
|
|
||||||
|
// Build a network
|
||||||
|
EN_addnode(ph, "N1", EN_JUNCTION);
|
||||||
|
EN_addnode(ph, "N2", EN_JUNCTION);
|
||||||
|
EN_addnode(ph, "N3", EN_RESERVOIR);
|
||||||
|
EN_addnode(ph, "N4", EN_TANK);
|
||||||
|
EN_addlink(ph, "L1", EN_PUMP, "N3", "N1");
|
||||||
|
EN_addlink(ph, "L2", EN_PIPE, "N1", "N3");
|
||||||
|
EN_addlink(ph, "L3", EN_PIPE, "N1", "N2");
|
||||||
|
EN_addcurve(ph, "C1");
|
||||||
|
|
||||||
|
// Set network data using the new helper functions
|
||||||
|
EN_setcurvevalue(ph, 1, 1, 1500, 250);
|
||||||
|
EN_setjuncdata(ph, 1, 700, 500, "");
|
||||||
|
EN_setjuncdata(ph, 2, 710, 500, "");
|
||||||
|
EN_setnodevalue(ph, 3, EN_ELEVATION, 800);
|
||||||
|
EN_settankdata(ph, 4, 850, 120, 100, 150, 50.5, 0, "");
|
||||||
|
EN_setlinkvalue(ph, 1, EN_PUMP_HCURVE, 1);
|
||||||
|
EN_setpipedata(ph, 2, 10560, 12, 100, 0);
|
||||||
|
EN_setpipedata(ph, 3, 5280, 14, 100, 0);
|
||||||
|
|
||||||
|
// Run hydraulics
|
||||||
|
EN_solveH(ph);
|
||||||
|
|
||||||
|
// Save results
|
||||||
|
EN_getnodevalue(ph, 1, EN_PRESSURE, &p1_1);
|
||||||
|
EN_getnodevalue(ph, 2, EN_PRESSURE, &p2_1);
|
||||||
|
EN_getlinkvalue(ph, 1, EN_FLOW, &q1_1);
|
||||||
|
EN_getlinkvalue(ph, 2, EN_FLOW, &q2_1);
|
||||||
|
|
||||||
|
// Save project
|
||||||
|
EN_saveinpfile(ph, "test2.inp");
|
||||||
|
|
||||||
|
// Close project
|
||||||
|
EN_close(ph);
|
||||||
|
|
||||||
|
// Open the saved project file
|
||||||
|
EN_open(ph, "test2.inp", "", "");
|
||||||
|
|
||||||
|
// Run hydraulics
|
||||||
|
EN_solveH(ph);
|
||||||
|
|
||||||
|
// Save these new results
|
||||||
|
EN_getnodevalue(ph, 1, EN_PRESSURE, &p1_2);
|
||||||
|
EN_getnodevalue(ph, 2, EN_PRESSURE, &p2_2);
|
||||||
|
EN_getlinkindex(ph, "L1", &index);
|
||||||
|
EN_getlinkvalue(ph, index, EN_FLOW, &q1_2);
|
||||||
|
EN_getlinkindex(ph, "L2", &index);
|
||||||
|
EN_getlinkvalue(ph, index, EN_FLOW, &q2_2);
|
||||||
|
|
||||||
|
// Display old & new results
|
||||||
|
cout << "\n Node N1 Pressure: " << p1_1 << " " << p1_2;
|
||||||
|
cout << "\n Node N2 Pressure: " << p2_1 << " " << p2_2;
|
||||||
|
cout << "\n Link L1 Flow: " << q1_1 << " " << q1_2;
|
||||||
|
cout << "\n Link L2 Flow: " << q2_1 << " " << q2_2;
|
||||||
|
|
||||||
|
// Compare old & new results
|
||||||
|
BOOST_REQUIRE(p1_1 == p1_2);
|
||||||
|
BOOST_REQUIRE(p2_1 == p2_2);
|
||||||
|
BOOST_REQUIRE(q1_1 == q1_2);
|
||||||
|
BOOST_REQUIRE(q2_1 == q2_2);
|
||||||
|
|
||||||
|
// Close project
|
||||||
|
EN_close(ph);
|
||||||
|
EN_deleteproject(&ph);
|
||||||
|
}
|
||||||
|
#ifndef NO_BOOST
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
#endif
|
||||||
@@ -85,6 +85,7 @@ EXPORTS
|
|||||||
ENsetelseaction = _ENsetelseaction@20
|
ENsetelseaction = _ENsetelseaction@20
|
||||||
ENsetflowunits = _ENsetflowunits@4
|
ENsetflowunits = _ENsetflowunits@4
|
||||||
ENsetheadcurveindex = _ENsetheadcurveindex@8
|
ENsetheadcurveindex = _ENsetheadcurveindex@8
|
||||||
|
ENsetjuncdata = _ENsetjuncdata@16
|
||||||
ENsetlinkid = _ENsetlinkid@8
|
ENsetlinkid = _ENsetlinkid@8
|
||||||
ENsetlinknodes = _ENsetlinknodes@12
|
ENsetlinknodes = _ENsetlinknodes@12
|
||||||
ENsetlinktype = _ENsetlinktype@12
|
ENsetlinktype = _ENsetlinktype@12
|
||||||
@@ -93,7 +94,8 @@ EXPORTS
|
|||||||
ENsetnodevalue = _ENsetnodevalue@12
|
ENsetnodevalue = _ENsetnodevalue@12
|
||||||
ENsetoption = _ENsetoption@8
|
ENsetoption = _ENsetoption@8
|
||||||
ENsetpattern = _ENsetpattern@12
|
ENsetpattern = _ENsetpattern@12
|
||||||
ENsetpatternvalue = _ENsetpatternvalue@12
|
ENsetpatternvalue = _ENsetpatternvalue@12
|
||||||
|
ENsetpipedata = _ENsetpipedata@20
|
||||||
ENsetpremise = _ENsetpremise@36
|
ENsetpremise = _ENsetpremise@36
|
||||||
ENsetpremiseindex = _ENsetpremiseindex@12
|
ENsetpremiseindex = _ENsetpremiseindex@12
|
||||||
ENsetpremisestatus = _ENsetpremisestatus@12
|
ENsetpremisestatus = _ENsetpremisestatus@12
|
||||||
@@ -101,7 +103,8 @@ EXPORTS
|
|||||||
ENsetqualtype = _ENsetqualtype@16
|
ENsetqualtype = _ENsetqualtype@16
|
||||||
ENsetreport = _ENsetreport@4
|
ENsetreport = _ENsetreport@4
|
||||||
ENsetrulepriority = _ENsetrulepriority@8
|
ENsetrulepriority = _ENsetrulepriority@8
|
||||||
ENsetstatusreport = _ENsetstatusreport@4
|
ENsetstatusreport = _ENsetstatusreport@4
|
||||||
|
ENsettankdata = _ENsettankdata@32
|
||||||
ENsetthenaction = _ENsetthenaction@20
|
ENsetthenaction = _ENsetthenaction@20
|
||||||
ENsettimeparam = _ENsettimeparam@8
|
ENsettimeparam = _ENsettimeparam@8
|
||||||
ENsolveH = _ENsolveH@0
|
ENsolveH = _ENsolveH@0
|
||||||
|
|||||||
Reference in New Issue
Block a user