more stepwise mods

This commit is contained in:
sam hatchett
2013-02-04 21:17:58 -05:00
parent afc80b6b13
commit b4164f56b4
5 changed files with 52 additions and 51 deletions

View File

@@ -56,13 +56,6 @@
remoteGlobalIDString = D2AAC0620554660B00DB518D;
remoteInfo = epanet;
};
22EF555816BC7FCC00F3988A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = D2AAC0620554660B00DB518D;
remoteInfo = epanet;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -256,7 +249,6 @@
buildRules = (
);
dependencies = (
22EF555916BC7FCC00F3988A /* PBXTargetDependency */,
);
name = TestLemonTiger;
productName = TestLemonTiger;
@@ -364,11 +356,6 @@
target = D2AAC0620554660B00DB518D /* epanet */;
targetProxy = 22322FAF1068370B00641384 /* PBXContainerItemProxy */;
};
22EF555916BC7FCC00F3988A /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = D2AAC0620554660B00DB518D /* epanet */;
targetProxy = 22EF555816BC7FCC00F3988A /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */

View File

@@ -1049,13 +1049,22 @@ void tanklevels(long tstep)
/* Update the tank's volume & water elevation */
n = Tank[i].Node;
// only adjust tank volume if we're in sequential mode.
// otherwise, the tankmixing function will do it for us.
if (!OpenQflag) {
dv = D[n]*tstep;
Tank[i].V += dv;
}
/*** Updated 6/24/02 ***/
/* Check if tank full/empty within next second */
if (Tank[i].V + D[n] >= Tank[i].Vmax) Tank[i].V = Tank[i].Vmax;
if (Tank[i].V - D[n] <= Tank[i].Vmin) Tank[i].V = Tank[i].Vmin;
if (Tank[i].V + D[n] >= Tank[i].Vmax) {
Tank[i].V = Tank[i].Vmax;
}
else if (Tank[i].V - D[n] <= Tank[i].Vmin) {
Tank[i].V = Tank[i].Vmin;
}
H[n] = tankgrade(i,Tank[i].V);
}

View File

@@ -1005,22 +1005,29 @@ void updatetanks(long dt)
/* Examine each reservoir & tank */
for (i=1; i<=Ntanks; i++)
{
n = Tank[i].Node;
/* Use initial quality for reservoirs */
if (Tank[i].A == 0.0)
{
n = Tank[i].Node;
C[n] = Node[n].C0;
}
/* Update tank WQ based on mixing model */
else switch(Tank[i].MixModel)
else {
switch(Tank[i].MixModel)
{
case MIX2: tankmix2(i,dt); break;
case FIFO: tankmix3(i,dt); break;
case LIFO: tankmix4(i,dt); break;
default: tankmix1(i,dt); break;
}
// if we're operating in stepwise mode, we'll need to update tank head conditions
if (OpenHflag) {
H[n] = tankgrade(i,Tank[i].V);
}
}
}
}
@@ -1076,10 +1083,7 @@ void tankmix1(int i, long dt)
/* Determine tank & volumes */
vold = Tank[i].V;
n = Tank[i].Node;
if (!OpenHflag) {
Tank[i].V += D[n]*dt;
}
vin = VolIn[n];
/* Compute inflow concen. */

View File

@@ -6,7 +6,8 @@
using namespace std;
void checkErr(int err, std::string function);
void stats();
void hydStats();
void qualStats();
int main(int argc, char * argv[]) {
@@ -37,7 +38,7 @@ int main(int argc, char * argv[]) {
checkErr( ENrunH(&simulationTime), "ENrunH" );
checkErr( ENnextH(&nextEventH), "ENnextH" );
stats();
hydStats();
// gather hydraulic results
@@ -51,23 +52,11 @@ int main(int argc, char * argv[]) {
checkErr( ENinitQ(EN_SAVE), "ENinitQ" );
do {
//long htime;
//ENgettimeparam(EN_HTIME, &htime);
//cout << "Htime = " << htime << endl;
checkErr( ENrunQ(&simulationTime), "ENrunQ" );
//ENgettimeparam(EN_HTIME, &htime);
//cout << "Htime = " << htime << endl;
checkErr( ENnextQ(&nextEventH), "ENstepQ" );
//ENgettimeparam(EN_HTIME, &htime);
//cout << "Htime = " << htime << endl;
// wq results
//cout << simulationTime << "\t\t" << nextEventH << endl;
qualStats();
} while (nextEventH > 0);
// water quality is done
@@ -85,7 +74,7 @@ int main(int argc, char * argv[]) {
/* stepwise solver (LemonTiger) */
cout << "*****LemonTiger results******" << endl;
checkErr( ENopen(argv[1], argv[2], "out2.bin"), "ENopen" );
checkErr( ENopen(argv[1], argv[2], (char*)"out2.bin"), "ENopen" );
checkErr( ENopenH(), "ENopenH" );
checkErr( ENinitH(EN_NOSAVE), "ENinitH" );
@@ -105,7 +94,8 @@ int main(int argc, char * argv[]) {
checkErr( ENnextH(&nextEventH), "ENnextH" );
checkErr( ENnextQ(&nextEventQ), "ENstepQ" );
stats();
//hydStats();
qualStats();
// wq results
//cout << simulationTime << "\t\t" << nextEventH << endl;
@@ -126,14 +116,24 @@ int main(int argc, char * argv[]) {
void stats() {
void hydStats() {
long htime;
int nodeIndex;
float head, volume;
float head;
ENgettimeparam(EN_HTIME, &htime);
ENgetnodeindex((char*)"1", &nodeIndex);
ENgetnodevalue(nodeIndex, EN_HEAD, &head);
cout << htime << "\t\t" << head << endl;
cout << htime << "\t\th = " << head << endl;
}
void qualStats() {
long htime;
int nodeIndex;
float quality;
ENgettimeparam(EN_HTIME, &htime);
ENgetnodeindex((char*)"1", &nodeIndex);
ENgetnodevalue(nodeIndex, EN_QUALITY, &quality);
cout << htime << "\t\tc = " << quality << endl;
}

View File

@@ -311,6 +311,7 @@ Link 330 OPEN IF Node 1 ABOVE 19.1
[QUALITY]
;Node InitQual
[SOURCES]
;Node Type Quality Pattern
@@ -331,7 +332,7 @@ Link 330 OPEN IF Node 1 ABOVE 19.1
;Tank Model
[TIMES]
Duration 6:00
Duration 24:00
Hydraulic Timestep 1:00
Quality Timestep 0:05
Pattern Timestep 1:00