this is the shape of the API
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
2298EBE116B17E440088A6DC /* lemontiger.c in Sources */ = {isa = PBXBuildFile; fileRef = 2298EBDF16B17E440088A6DC /* lemontiger.c */; };
|
2298EBE116B17E440088A6DC /* lemontiger.c in Sources */ = {isa = PBXBuildFile; fileRef = 2298EBDF16B17E440088A6DC /* lemontiger.c */; };
|
||||||
2298EBE216B17E440088A6DC /* lemontiger.h in Headers */ = {isa = PBXBuildFile; fileRef = 2298EBE016B17E440088A6DC /* lemontiger.h */; };
|
2298EBE216B17E440088A6DC /* lemontiger.h in Headers */ = {isa = PBXBuildFile; fileRef = 2298EBE016B17E440088A6DC /* lemontiger.h */; };
|
||||||
22EF555716BC744C00F3988A /* testLemonTiger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22EF555516BC744C00F3988A /* testLemonTiger.cpp */; };
|
22EF555716BC744C00F3988A /* testLemonTiger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22EF555516BC744C00F3988A /* testLemonTiger.cpp */; };
|
||||||
|
22EF555A16BC7FF500F3988A /* libepanet.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC0630554660B00DB518D /* libepanet.dylib */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@@ -55,6 +56,13 @@
|
|||||||
remoteGlobalIDString = D2AAC0620554660B00DB518D;
|
remoteGlobalIDString = D2AAC0620554660B00DB518D;
|
||||||
remoteInfo = epanet;
|
remoteInfo = epanet;
|
||||||
};
|
};
|
||||||
|
22EF555816BC7FCC00F3988A /* PBXContainerItemProxy */ = {
|
||||||
|
isa = PBXContainerItemProxy;
|
||||||
|
containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */;
|
||||||
|
proxyType = 1;
|
||||||
|
remoteGlobalIDString = D2AAC0620554660B00DB518D;
|
||||||
|
remoteInfo = epanet;
|
||||||
|
};
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@@ -114,6 +122,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
22EF555A16BC7FF500F3988A /* libepanet.dylib in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -247,6 +256,7 @@
|
|||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
dependencies = (
|
dependencies = (
|
||||||
|
22EF555916BC7FCC00F3988A /* PBXTargetDependency */,
|
||||||
);
|
);
|
||||||
name = TestLemonTiger;
|
name = TestLemonTiger;
|
||||||
productName = TestLemonTiger;
|
productName = TestLemonTiger;
|
||||||
@@ -354,6 +364,11 @@
|
|||||||
target = D2AAC0620554660B00DB518D /* epanet */;
|
target = D2AAC0620554660B00DB518D /* epanet */;
|
||||||
targetProxy = 22322FAF1068370B00641384 /* PBXContainerItemProxy */;
|
targetProxy = 22322FAF1068370B00641384 /* PBXContainerItemProxy */;
|
||||||
};
|
};
|
||||||
|
22EF555916BC7FCC00F3988A /* PBXTargetDependency */ = {
|
||||||
|
isa = PBXTargetDependency;
|
||||||
|
target = D2AAC0620554660B00DB518D /* epanet */;
|
||||||
|
targetProxy = 22EF555816BC7FCC00F3988A /* PBXContainerItemProxy */;
|
||||||
|
};
|
||||||
/* End PBXTargetDependency section */
|
/* End PBXTargetDependency section */
|
||||||
|
|
||||||
/* Begin XCBuildConfiguration section */
|
/* Begin XCBuildConfiguration section */
|
||||||
@@ -542,6 +557,7 @@
|
|||||||
22EF555316BC740400F3988A /* Release */,
|
22EF555316BC740400F3988A /* Release */,
|
||||||
);
|
);
|
||||||
defaultConfigurationIsVisible = 0;
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
};
|
};
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,104 +1,111 @@
|
|||||||
//
|
|
||||||
// testLemonTiger.cpp
|
|
||||||
// epanet
|
|
||||||
//
|
|
||||||
// Created by Sam Hatchett on 2/1/13.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "testLemonTiger.h"
|
#include "testLemonTiger.h"
|
||||||
#include "epanet2.h"
|
#include "epanet2.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
void checkErr(int err, std::string function);
|
||||||
|
|
||||||
int main(int argc, char * argv[]) {
|
int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
cout << "Lemon Tiger TEST" << endl;
|
cout << "Lemon Tiger TEST" << endl
|
||||||
|
<< "________________" << endl;
|
||||||
int err = 0; //error code
|
|
||||||
long stime = 0; //simulation time point, = t = Htime
|
|
||||||
long step = 1; //time to next time point, = tstep = hydstep
|
|
||||||
long tleft = 0; //time left in the simulation
|
|
||||||
int id, id2, id3; // some node id
|
|
||||||
float value; // some node/link value
|
|
||||||
int TIME_A = 3600*3;
|
|
||||||
int TIME_B = 3600*6; //two time points for testing
|
|
||||||
int TIME_C = 3600*10;
|
|
||||||
|
|
||||||
|
|
||||||
/* Asychronous solver (old epanet) */
|
long tstep = 0;
|
||||||
printf("*****Original EPANET results******\n");
|
long simulationTime = 0;
|
||||||
|
long nextEventH = 0;
|
||||||
if (err=ENopen(argv[1], argv[2], "")) return err;
|
long simTimeRemaining = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
for (ENopenH(), ENinitH(1), step=1;
|
|
||||||
// must save intermediate results to disk (initH(1)), otherwise WQ solver won't execute
|
|
||||||
step>0; ENnextH(&step)) {
|
|
||||||
ENrunH(&stime);
|
|
||||||
}
|
|
||||||
ENcloseH();
|
|
||||||
|
|
||||||
printf("\nReset time pointer and run WQ.\n");
|
|
||||||
for (step=1, ENopenQ(), ENinitQ(0); // this operation resets the internal time pointer (back to 0)
|
|
||||||
step>0; ENnextQ(&step)) {
|
|
||||||
|
|
||||||
ENrunQ(&stime);
|
/* Batch solver (old epanet) */
|
||||||
|
cout << "*****Original EPANET results******" << endl;
|
||||||
|
checkErr( ENopen(argv[1], argv[2], ""), "ENopen" );
|
||||||
|
|
||||||
// grab some results
|
checkErr( ENopenH(), "ENopenH" );
|
||||||
if (stime == TIME_A || stime == TIME_B || stime == TIME_C) {
|
checkErr( ENinitH(EN_SAVE), "ENinitH" );
|
||||||
printf("WQ simulation time = %d sec, step = %d sec.\n", stime, step);
|
|
||||||
|
|
||||||
ENgetnodevalue(id, EN_QUALITY, &value);
|
|
||||||
printf("Node 184's quality = \t%f.\n", value);
|
|
||||||
ENgetnodevalue(id3, EN_QUALITY, &value);
|
|
||||||
printf("Node 199's quality = \t%f.\n", value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ENcloseQ();
|
|
||||||
ENclose();
|
|
||||||
|
|
||||||
|
|
||||||
/* Sychronous solver (LemonTiger) */
|
|
||||||
printf("\n\n*****LemonTiger results******\n\n");
|
|
||||||
|
|
||||||
if (err=ENopen(argv[1], argv[2], "")) return err;
|
|
||||||
|
|
||||||
for (ENopeninitHQ(), tleft=Dur; tleft>0; ) {
|
|
||||||
|
|
||||||
//ENrunstepHQ(&stime, &tleft);
|
do {
|
||||||
ENrunnextHQ(&stime, &tleft); //well I know it should be tstep
|
/* Solve for hydraulics & advance to next time period */
|
||||||
|
tstep = 0;
|
||||||
if (stime == TIME_A || stime == TIME_B || stime == TIME_C) {
|
checkErr( ENrunH(&simulationTime), "ENrunH" );
|
||||||
//if (! (stime%1800)){
|
checkErr( ENnextH(&nextEventH), "ENnextH" );
|
||||||
printf("Simulation = %d sec, time left = %d sec.\n", stime, tleft);
|
|
||||||
ENgetnodevalue(id, EN_HEAD, &value);
|
|
||||||
printf("Node 184's head = \t%f.\n", value);
|
|
||||||
|
|
||||||
ENgetnodevalue(id, EN_QUALITY, &value);
|
|
||||||
printf("Node 184's quality = \t%f.\n", value);
|
|
||||||
|
|
||||||
ENgetnodevalue(id3, EN_HEAD, &value);
|
// gather hydraulic results
|
||||||
printf("Node 199's head = \t%f.\n", value);
|
|
||||||
|
|
||||||
ENgetnodevalue(id3, EN_QUALITY, &value);
|
} while (nextEventH > 0);
|
||||||
printf("Node 199's quality = \t%f.\n", value);
|
// hydraulics are done
|
||||||
|
checkErr( ENcloseH(), "ENcloseH" );
|
||||||
|
|
||||||
|
cout << "Running WQ..." << endl;
|
||||||
|
|
||||||
|
checkErr( ENopenQ(), "ENopenQ" );
|
||||||
|
checkErr( ENinitQ(EN_SAVE), "ENinitQ" );
|
||||||
|
|
||||||
|
do {
|
||||||
|
checkErr( ENrunQ(&simulationTime), "ENrunQ" );
|
||||||
|
checkErr( ENstepQ(&simTimeRemaining), "ENstepQ" );
|
||||||
|
|
||||||
ENgetlinkvalue(id2, EN_FLOW, &value);
|
// wq results
|
||||||
printf("Link 101's flowrate = \t%f. \n", value);
|
|
||||||
|
|
||||||
|
} while (simTimeRemaining > 0);
|
||||||
|
// water quality is done
|
||||||
|
checkErr( ENcloseQ(), "ENcloseQ" );
|
||||||
|
|
||||||
|
// everything is done
|
||||||
|
checkErr( ENclose(), "ENclose" );
|
||||||
|
|
||||||
|
|
||||||
|
nextEventH = 0;
|
||||||
|
simTimeRemaining = 0;
|
||||||
|
simulationTime = 0;
|
||||||
|
|
||||||
|
/* stepwise solver (LemonTiger) */
|
||||||
|
cout << "*****LemonTiger results******" << endl;
|
||||||
|
|
||||||
|
checkErr( ENopen(argv[1], argv[2], NULL), "ENopen" );
|
||||||
|
|
||||||
|
checkErr( ENopenH(), "ENopenH" );
|
||||||
|
checkErr( ENinitH(EN_SAVE), "ENinitH" );
|
||||||
|
checkErr( ENopenQ(), "ENopenQ" );
|
||||||
|
checkErr( ENinitQ(EN_SAVE), "ENinitQ" );
|
||||||
|
|
||||||
|
do {
|
||||||
|
/* Solve for hydraulics & advance to next time period */
|
||||||
|
tstep = 0;
|
||||||
|
checkErr( ENrunH(&simulationTime), "ENrunH" );
|
||||||
|
checkErr( ENnextH(&nextEventH), "ENnextH" );
|
||||||
|
|
||||||
printf("\n");
|
// hydraulic results
|
||||||
}
|
|
||||||
}
|
checkErr( ENrunQ(&simulationTime), "ENrunQ" );
|
||||||
ENcloseHQ();
|
checkErr( ENstepQ(&simTimeRemaining), "ENstepQ" );
|
||||||
ENclose();
|
|
||||||
|
// wq results
|
||||||
|
|
||||||
|
} while (simTimeRemaining > 0);
|
||||||
|
// all done
|
||||||
|
checkErr( ENcloseH(), "ENcloseH" );
|
||||||
|
checkErr( ENcloseQ(), "ENcloseQ" );
|
||||||
|
checkErr( ENclose(), "ENclose" );
|
||||||
|
|
||||||
|
|
||||||
|
} catch (int err) {
|
||||||
|
cerr << "exiting with error " << err << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void checkErr(int err, std::string function) {
|
||||||
|
if (err > 0) {
|
||||||
|
cerr << "Error in " << function << ": " << err << endl;
|
||||||
|
char errmsg[1024];
|
||||||
|
ENgeterror(err, errmsg, 1024);
|
||||||
|
cerr << errmsg << endl;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,6 @@
|
|||||||
#define __epanet__testLemonTiger__
|
#define __epanet__testLemonTiger__
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#endif /* defined(__epanet__testLemonTiger__) */
|
#endif /* defined(__epanet__testLemonTiger__) */
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ extern "C" {
|
|||||||
int DLLEXPORT ENopenH(void);
|
int DLLEXPORT ENopenH(void);
|
||||||
int DLLEXPORT ENinitH(int);
|
int DLLEXPORT ENinitH(int);
|
||||||
int DLLEXPORT ENrunH(long *);
|
int DLLEXPORT ENrunH(long *);
|
||||||
int DLLEXPORT ENnextH(long *);
|
int DLLEXPORT ENnextH(long *tstep);
|
||||||
int DLLEXPORT ENcloseH(void);
|
int DLLEXPORT ENcloseH(void);
|
||||||
int DLLEXPORT ENsavehydfile(char *);
|
int DLLEXPORT ENsavehydfile(char *);
|
||||||
int DLLEXPORT ENusehydfile(char *);
|
int DLLEXPORT ENusehydfile(char *);
|
||||||
|
|||||||
Reference in New Issue
Block a user