Instead of changing block out status checking routine, water quality module considers pipe 'closed' status in the routine bypassing flow information just like tank volume changes.

This commit is contained in:
mickey
2013-03-11 11:54:03 -04:00
parent 8e499b0318
commit f883a5551b
7 changed files with 66 additions and 26 deletions

View File

@@ -276,6 +276,9 @@
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
};
buildConfigurationList = 1DEB914E08733D8E0010E9CD /* Build configuration list for PBXProject "epanet" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
@@ -366,10 +369,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
EXECUTABLE_PREFIX = lib;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
@@ -383,6 +386,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
COMBINE_HIDPI_IMAGES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EXECUTABLE_PREFIX = lib;
GCC_MODEL_TUNING = G5;
@@ -397,15 +401,19 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = macinclude;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx;
};
name = Debug;
};
@@ -413,13 +421,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = macinclude;
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx;
};
name = Release;
};
@@ -429,14 +441,12 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = CLE;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
INSTALL_PATH = /usr/local/bin;
PREBINDING = NO;
PRODUCT_NAME = runepanet;
};
name = Debug;
@@ -447,13 +457,11 @@
ALWAYS_SEARCH_USER_PATHS = NO;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
GCC_PREPROCESSOR_DEFINITIONS = CLE;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_PREPROCESSOR_DEFINITIONS = "";
INSTALL_PATH = /usr/local/bin;
PREBINDING = NO;
PRODUCT_NAME = runepanet;
ZERO_LINK = NO;
};

View File

@@ -1668,9 +1668,8 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, float *value)
case EN_FLOW:
/*** Updated 10/25/00 ***/
//if (S[index] <= CLOSED) v = 0.0;
/*else*/ v = Q[index]*Ucf[FLOW];
if (S[index] <= CLOSED) v = 0.0;
else v = Q[index]*Ucf[FLOW];
break;
case EN_VELOCITY:

View File

@@ -161,8 +161,9 @@ int savehyd(long *htime)
/* Force flow in closed links to be zero then save flows */
for (i=1; i<=Nlinks; i++)
{
//if (S[i] <= CLOSED) x[i] = 0.0f;
/*else*/ x[i] = (REAL4)Q[i];
if (S[i] <= CLOSED) x[i] = 0.0f;
else x[i] = (REAL4)Q[i];
}
fwrite(x+1,sizeof(REAL4),Nlinks,HydFile);

View File

@@ -154,6 +154,7 @@ void initqual()
if (Node[i].S != NULL) Node[i].S->Smass = 0.0;
QTankVolumes = calloc(Ntanks, sizeof(double)); // keep track of previous step's tank volumes.
QLinkFlow = calloc(Nlinks, sizeof(double)); // keep track of previous step's link flows.
/* Set WQ parameters */
Bucf = 1.0;
@@ -230,10 +231,18 @@ int runqual(long *t)
Htime = hydtime + hydstep;
}
else {
// stepwise
// stepwise calculation
for (int i=1; i<= Ntanks; ++i) {
QTankVolumes[i-1] = Tank[i].V;
}
for (int i=1; i<= Nlinks; ++i)
{
if (S[i] <= CLOSED) {
QLinkFlow[i-1] = Q[i];
}
}
}
}
return(errcode);
@@ -256,9 +265,14 @@ int nextqual(long *tstep)
/* Determine time step */
*tstep = 0;
hydstep = Htime - Qtime;
// hydstep = Htime - Qtime;
if (Htime <= Dur) hydstep = Htime - Qtime;
else hydstep = 0;
double *tankVolumes;
// if we're operating in stepwise mode, capture the tank levels so we can restore them later.
if (OpenHflag) {
tankVolumes = calloc(Ntanks, sizeof(double));
@@ -267,6 +281,7 @@ int nextqual(long *tstep)
tankVolumes[i-1] = Tank[i].V;
}
}
// restore the previous step's tank volumes
for (int i=1; i<=Ntanks; i++) {
if (Tank[i].A != 0) { // skip reservoirs again
@@ -275,8 +290,15 @@ int nextqual(long *tstep)
H[n] = tankgrade(i,Tank[i].V);
}
}
// restore the previous step's pipe link flows
for (int i=1; i<=Nlinks; i++) {
if (S[i] <= CLOSED) {
Q[i] = 0.0;
}
}
}
/* Perform water quality routing over this time step */
if (Qualflag != NONE && hydstep > 0) transport(hydstep);
@@ -298,6 +320,13 @@ int nextqual(long *tstep)
H[n] = tankgrade(i,Tank[i].V);
}
}
for (int i=1; i<=Nlinks; ++i) {
if (S[i] <= CLOSED) {
Q[i] = QLinkFlow[i-1];
}
}
free(tankVolumes);
}
@@ -369,6 +398,7 @@ int closequal()
free(R);
free(XC);
free(QTankVolumes);
free(QLinkFlow);
return(errcode);
}
@@ -467,8 +497,6 @@ void transport(long tstep)
{
long qtime, dt;
/* Repeat until elapsed time equals hydraulic time step */
AllocSetPool(SegPool); //(2.00.11 - LR)
@@ -485,7 +513,6 @@ void transport(long tstep)
}
updatesourcenodes(tstep); /* Update quality at source nodes */
}

14
src/testLemonTiger.cpp Normal file → Executable file
View File

@@ -1,6 +1,8 @@
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "testLemonTiger.h"
#include "toolkit.h"
@@ -135,7 +137,7 @@ int main(int argc, char * argv[]) {
// summarize the results
//printResults(&epanetResults, &lemonTigerResults, cout);
printResults(&epanetResults, &lemonTigerResults, cout);
compare(&epanetResults, &lemonTigerResults, cout);
} catch (int err) {
@@ -181,8 +183,10 @@ void printResults(result_t* results1, result_t* results2, std::ostream &out) {
for (resultIterator = (*results1).begin(); resultIterator != (*results1).end(); ++resultIterator) {
// get the current frame
const long time = resultIterator->first;
const networkNodeState_t nodeState1 = resultIterator->second.nodeState;
const networkLinkState_t linkState1 = resultIterator->second.linkState;
const networkNodeState_t networkNodeState1= resultIterator->second.nodeState;
//nodeState1 = resultIterator->second.nodeState;
const networkLinkState_t networkLinkState1 = resultIterator->second.linkState;
//linkState1 = resultIterator->second.linkState;
// see if this time is indexed in the second state container
if ((*results2).find(time) == (*results2).end()) {
@@ -207,7 +211,7 @@ void printResults(result_t* results1, result_t* results2, std::ostream &out) {
// loop through the nodes in the networkState objs, and print out the results for this time period
networkNodeState_t::const_iterator networkNodeIterator;
for (networkNodeIterator = nodeState1.begin(); networkNodeIterator != nodeState1.end(); ++networkNodeIterator) {
for (networkNodeIterator = networkNodeState1.begin(); networkNodeIterator != networkNodeState1.end(); ++networkNodeIterator) {
int nodeIndex = networkNodeIterator->first;
// trusting that all nodes are present...
const nodeState_t nodeState1 = networkNodeIterator->second;
@@ -230,7 +234,7 @@ void printResults(result_t* results1, result_t* results2, std::ostream &out) {
}
networkLinkState_t::const_iterator networkLinkIterator;
for (networkLinkIterator = linkState1.begin(); networkLinkIterator != linkState1.end(); ++networkLinkIterator) {
for (networkLinkIterator = networkLinkState1.begin(); networkLinkIterator != networkLinkState1.end(); ++networkLinkIterator) {
int linkIndex = networkLinkIterator->first;
// trusting that all nodes are present...
const linkState_t linkState1 = networkLinkIterator->second;

0
src/testLemonTiger.h Normal file → Executable file
View File

View File

@@ -154,6 +154,7 @@ AUTHOR: L. Rossman
*XC; /* General Purpose array - WQ */
double *H; /* Node heads */
double *QTankVolumes;
double *QLinkFlow; //woohn 03112013
STmplist *Patlist; /* Temporary time pattern list */
STmplist *Curvelist; /* Temporary list of curves */
Spattern *Pattern; /* Time patterns */