diff --git a/ReleaseNotes2_2.md b/ReleaseNotes2_2.md index 85fb84a..f6b097b 100644 --- a/ReleaseNotes2_2.md +++ b/ReleaseNotes2_2.md @@ -1,4 +1,3 @@ - Release Notes for EPANET 2.2 (Draft) ============================ @@ -162,6 +161,35 @@ Both network files are available [here](https://doi.org/10.23719/1375314). |`ENdeleterule` || |`ENsetnodeid` || |`ENsetlinkid` || +|`ENgetcurvetype`|Get the type of a curve| +|`ENgetdemandmodel`|Retrieves the type of demand model in use and its parameters| +|`ENsetdemandmodel`|Sets the type of demand model to use and its parameters| +|`ENsetflowunits`|Sets the flow units| +|`ENaddcontrol`|Specify parameters to add a new simple control| +|`ENsetdemandpattern`|Sets the index of the demand pattern assigned to a node for a category index| +|`ENgetrule`|Gets the number of premises, true actions, and false actions and the priority of an existing rule-based control| +|`ENsetrulepriority`|Sets the priority of the existing rule-based control| +|`ENgetpremise`|Gets the components of a premise/condition in an existing rule-based control| +|`ENsetpremise`|Sets the components of a premise/condition in an existing rule-based control| +|`ENsetpremiseindex`|Sets the index of an object in a premise of an existing rule-based control| +|`ENsetpremisestatus`|Sets the status in a premise of an existing rule-based control| +|`ENsetpremisevalue`|Sets the value in a premise of an existing rule-based control| +|`ENgettrueaction`|Gets the components of a true-action in an existing rule-based control| +|`ENsettrueaction`|Sets the components of a true-action in an existing rule-based control| +|`ENgetfalseaction`|Gets the components of a false-action in an existing rule-based control| +|`ENsetfalseaction`|Sets the components of a false-action in an existing rule-based control| +|`ENgetruleID`|Returns the ID of a rule| +|`ENinit`|Initializes an EPANET session| +|`ENsetheadcurveindex`|Sets the curve id for a specified pump index| +|`ENsetlinktype`|Set the link type code for a specified link| +|`ENaddnode`|Adds a new node| +|`ENaddlink`|Adds a new link| +|`ENdeletelink`|Deletes a link| +|`ENdeletenode`|Deletes a node| +| `ENsetnodeid` |Change the ID name for a node| +| `ENsetlinkid` |Change the ID name for a link| +|`ENgetdemandname`|Sets the node's demand name for a category| +|`ENsetdemandname`|Sets the node's demand name for a category| ## API Extensions (additional definitions) ### Link value types: @@ -178,10 +206,14 @@ Both network files are available [here](https://doi.org/10.23719/1375314). - `EN_HW` - `EN_DW` - `EN_CM` -### Misc. options: +### Option types: - `EN_HEADERROR` - `EN_FLOWCHANGE` - `EN_DEMANDDEFPAT` + - `EN_HEADLOSSFORM` +### Time statistic types: + - `EN_MAXHEADERROR` + - `EN_MAXFLOWCHANGE` - `EN_MASSBALANCE` - `EN_UNCONDITIONAL` - `EN_CONDITIONAL` @@ -191,7 +223,10 @@ Both network files are available [here](https://doi.org/10.23719/1375314). - `EN_E_CURVE` - `EN_H_CURVE` - `EN_G_CURVE` - +### Demand model types: + - `EN_DDA` + - `EN_PDA` + ## Authors contributing to this release: - List item diff --git a/src/epanet.c b/src/epanet.c index 550d1b2..4634373 100644 --- a/src/epanet.c +++ b/src/epanet.c @@ -3209,6 +3209,9 @@ int DLLEXPORT EN_setlinknodes(EN_ProjectHandle ph, int index, int node1, int nod int type; EN_Project *p = (EN_Project*)ph; EN_Network *net = &p->network; + + // Check that end and start nodes are not the same + if (node1 == node2) return set_error(p->error_handle, 222); // Check that nodes exist if (node1 < 0 || node1 > net->Nnodes) return set_error(p->error_handle, 203); diff --git a/tests/test_output.cpp b/tests/test_output.cpp index fa8bb98..b0848a1 100644 --- a/tests/test_output.cpp +++ b/tests/test_output.cpp @@ -24,34 +24,42 @@ #define DATA_PATH "./example1.out" -using namespace std; +using namespace std; -// Custom test to check the minimum number of correct decimal digits between -// the test and the ref vectors. -boost::test_tools::predicate_result check_cdd(std::vector& test, - std::vector& ref, long cdd_tol) -{ - float tmp, min_cdd = 100.0; - - // TODO: What is the vectors aren't the same length? +// Custom test to check the minimum number of correct decimal digits between +// the test and the ref vectors. +boost::test_tools::predicate_result check_cdd(std::vector& test, + std::vector& ref, long cdd_tol){ + float tmp, min_cdd = 10.0; + + // TODO: What if the vectors aren't the same length? std::vector::iterator test_it; std::vector::iterator ref_it; - for (test_it = test.begin(); test_it < test.end(); ++test_it) { - for (ref_it = ref.begin(); ref_it < ref.end(); ++ref_it) { - - if (*test_it != *ref_it) { - tmp = - log10f(abs(*test_it - *ref_it)); - if (tmp < min_cdd) min_cdd = tmp; - } + for (test_it = test.begin(), ref_it = ref.begin(); + (test_it < test.end()) && (ref_it < ref.end()); + ++test_it, ++ref_it) + { + if (*test_it != *ref_it) { + // Compute log absolute error + tmp = abs(*test_it - *ref_it); + if (tmp < 1.0e-7f) + tmp = 1.0e-7f; + + else if (tmp > 2.0f) + tmp = 1.0f; + + tmp = -log10(tmp); + if (tmp < 0.0f) + tmp = 0.0f; + + if (tmp < min_cdd) + min_cdd = tmp; } } - if (min_cdd == 100.0) - return true; - else - return floor(min_cdd) <= cdd_tol; + return floor(min_cdd) >= cdd_tol; } boost::test_tools::predicate_result check_string(std::string test, std::string ref) @@ -96,7 +104,7 @@ struct Fixture{ free((void*)array); error = ENR_close(&p_handle); } - + std::string path; int error; ENR_Handle p_handle; @@ -110,14 +118,14 @@ BOOST_AUTO_TEST_SUITE(test_output_fixture) BOOST_FIXTURE_TEST_CASE(test_getNetSize, Fixture) { int *i_array = NULL; - + error = ENR_getNetSize(p_handle, &i_array, &array_dim); BOOST_REQUIRE(error == 0); // nodes, tanks, links, pumps, valves std::vector test; test.assign(i_array, i_array + array_dim); - + std::vector ref = {11,2,13,1,0}; BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end()); @@ -149,11 +157,11 @@ BOOST_FIXTURE_TEST_CASE(test_getElementName, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getNodeAttribute, Fixture) { - + error = ENR_getNodeAttribute(p_handle, 1, ENR_quality, &array, &array_dim); BOOST_REQUIRE(error == 0); - std::vector ref_vec = { 1.0f, + std::vector ref_vec = { 1.0f, 0.44407997f, 0.43766347f, 0.42827705f, @@ -197,10 +205,10 @@ BOOST_FIXTURE_TEST_CASE(test_getLinkAttribute, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { - + error = ENR_getNodeResult(p_handle, 1, 2, &array, &array_dim); BOOST_REQUIRE(error == 0); - + std::vector ref_vec = {0.041142918f, 150.0f, 987.98358f, @@ -213,7 +221,7 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeResult, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { - + error = ENR_getLinkResult(p_handle, 24, 13, &array, &array_dim); BOOST_REQUIRE(error == 0); @@ -233,7 +241,7 @@ BOOST_FIXTURE_TEST_CASE(test_getLinkResult, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getNodeSeries, Fixture){ - + error = ENR_getNodeSeries(p_handle, 2, ENR_pressure, 0, 10, &array, &array_dim); BOOST_REQUIRE(error == 0); @@ -250,12 +258,12 @@ BOOST_FIXTURE_TEST_CASE(test_getNodeSeries, Fixture){ std::vector test_vec; test_vec.assign(array, array + array_dim); - + BOOST_CHECK(check_cdd(test_vec, ref_vec, 3)); } BOOST_FIXTURE_TEST_CASE(test_getLinkSeries, Fixture) { - + error = ENR_getLinkSeries(p_handle, 2, ENR_flow, 0, 10, &array, &array_dim); BOOST_REQUIRE(error == 0); @@ -277,7 +285,7 @@ BOOST_FIXTURE_TEST_CASE(test_getLinkSeries, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getNetReacts, Fixture) { - + error = ENR_getNetReacts(p_handle, &array, &array_dim); BOOST_REQUIRE(error == 0); @@ -293,7 +301,7 @@ BOOST_FIXTURE_TEST_CASE(test_getNetReacts, Fixture) { } BOOST_FIXTURE_TEST_CASE(test_getEnergyUsage, Fixture) { - + int linkIdx; error = ENR_getEnergyUsage(p_handle, 1, &linkIdx, &array, &array_dim); diff --git a/win_build/WinSDK/epanet2.def b/win_build/WinSDK/epanet2.def index 44955ec..529cfc9 100644 --- a/win_build/WinSDK/epanet2.def +++ b/win_build/WinSDK/epanet2.def @@ -36,6 +36,7 @@ EXPORTS ENgetlinkid = _ENgetlinkid@8 ENgetlinkindex = _ENgetlinkindex@8 ENgetlinknodes = _ENgetlinknodes@12 + ENsetlinknodes = _ENsetlinknodes@12 ENgetlinktype = _ENgetlinktype@8 ENgetlinkvalue = _ENgetlinkvalue@12 ENgetnodeid = _ENgetnodeid@8