Add EN_PRESS_UNITS to EN_getoption & EN_setoption
This commit is contained in:
@@ -23,11 +23,11 @@ BOOST_FIXTURE_TEST_CASE(test_anlys_getoption, FixtureOpenClose)
|
||||
{
|
||||
int i;
|
||||
|
||||
std::vector<double> test(23);
|
||||
std::vector<double> test(26);
|
||||
double *array = test.data();
|
||||
|
||||
std::vector<double> ref = {40.0, 0.001, 0.01, 0.5, 1.0, 0.0, 0.0, 0.0, 75.0, 0.0, 0.0, 0.0,
|
||||
1.0, 1.0, 10.0, 2.0, 10.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0};
|
||||
1.0, 1.0, 10.0, 2.0, 10.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0};
|
||||
|
||||
error = EN_solveH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
@@ -36,7 +36,7 @@ BOOST_FIXTURE_TEST_CASE(test_anlys_getoption, FixtureOpenClose)
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
|
||||
for (i=EN_TRIALS; i<=EN_CONCENLIMIT; i++) {
|
||||
for (i=EN_TRIALS; i<=EN_PRESS_UNITS; i++) {
|
||||
error = EN_getoption(ph, i, array++);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ BOOST_FIXTURE_TEST_CASE(test_anlys_getoption, FixtureOpenClose)
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(ref.begin(), ref.end(), test.begin(), test.end());
|
||||
|
||||
double temp;
|
||||
error = EN_getoption(ph, 25, &temp);
|
||||
error = EN_getoption(ph, 26, &temp);
|
||||
BOOST_CHECK(error == 251);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,8 +116,79 @@ BOOST_AUTO_TEST_CASE(test_run)
|
||||
EN_deleteproject(ph);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_FIXTURE_TEST_CASE(test_pressure_units, FixtureInitClose)
|
||||
{
|
||||
int index;
|
||||
long t;
|
||||
double p, units;
|
||||
|
||||
// Create basic network
|
||||
error = EN_addnode(ph, "R1", EN_RESERVOIR, &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_setnodevalue(ph, index, EN_ELEVATION, 100);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_addnode(ph, "J1", EN_JUNCTION, &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_addlink(ph, "P1", EN_PIPE, "R1", "J1", &index);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Run simulation and get junction pressure
|
||||
error = EN_openH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_initH(ph, EN_NOSAVE);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_runH(ph, &t);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getnodevalue(ph, 1, EN_PRESSURE, &p);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(abs(p - 43.33) < 1.e-5);
|
||||
|
||||
// Get pressure unit and check that it is PSI
|
||||
error = EN_getoption(ph, EN_PRESS_UNITS, &units);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(units == EN_PSI);
|
||||
|
||||
// Check that pressure unit is PSI
|
||||
error = EN_setoption(ph, EN_PRESS_UNITS, EN_METERS);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Change to meters and confirm that units are still PSI
|
||||
error = EN_getoption(ph, EN_PRESS_UNITS, &units);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(units == EN_PSI);
|
||||
|
||||
// Change flow units to LPS to change to metric units and rerun simulation
|
||||
error = EN_setflowunits(ph, EN_LPS);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_initH(ph, EN_NOSAVE);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_runH(ph, &t);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
// Confirm that pressure is now in meters
|
||||
error = EN_getnodevalue(ph, 1, EN_PRESSURE, &p);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(abs(p - 30.48) < 1.e-5);
|
||||
error = EN_getoption(ph, EN_PRESS_UNITS, &units);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(units == EN_METERS);
|
||||
|
||||
// Set and check that pressure units are in kPa
|
||||
error = EN_setoption(ph, EN_PRESS_UNITS, EN_KPA);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
error = EN_getoption(ph, EN_PRESS_UNITS, &units);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(units == EN_KPA);
|
||||
error = EN_getnodevalue(ph, 1, EN_PRESSURE, &p);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
BOOST_CHECK(abs(p - 298.76035) < 1.e-5);
|
||||
|
||||
error = EN_closeH(ph);
|
||||
BOOST_REQUIRE(error == 0);
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_proj_fixture)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user