Merge pull request #177 from LRossman/contributor-lr
Changes to get Net1.inp to run
This commit is contained in:
4
LICENSE
4
LICENSE
@@ -1,7 +1,11 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
Works are copyright (c) 2018 their respective AUTHORS,
|
Works are copyright (c) 2018 their respective AUTHORS,
|
||||||
unless such work is in the Public Domain (again, see AUTHORS)
|
unless such work is in the Public Domain (again, see AUTHORS)
|
||||||
|
=======
|
||||||
|
Copyright (c) 2017 Open Water Analytics
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
28
appveyor.yml
28
appveyor.yml
@@ -9,8 +9,23 @@
|
|||||||
|
|
||||||
version: 2.0.{build}
|
version: 2.0.{build}
|
||||||
|
|
||||||
image:
|
matrix:
|
||||||
- Visual Studio 2013
|
allow_failures:
|
||||||
|
#GROUP: (SUPPORTED/EXPERIMENTAL)
|
||||||
|
#EXPERIMENTAL is allowed to fail under build matrix
|
||||||
|
- GROUP: "EXPERIMENTAL"
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||||
|
GENERATOR: "Visual Studio 10 2010"
|
||||||
|
GROUP: "SUPPORTED"
|
||||||
|
BOOST_ROOT: "C:/Libraries/boost"
|
||||||
|
# New build on Visual Studio 15 2017
|
||||||
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
|
GENERATOR: "Visual Studio 15 2017"
|
||||||
|
GROUP: "EXPERIMENTAL"
|
||||||
|
BOOST_ROOT: "C:/Libraries/boost_1_67_0"
|
||||||
|
|
||||||
# called before repo cloning
|
# called before repo cloning
|
||||||
init:
|
init:
|
||||||
@@ -18,8 +33,11 @@ init:
|
|||||||
- set BUILD_HOME=buildprod
|
- set BUILD_HOME=buildprod
|
||||||
- set TEST_HOME=nrtestsuite
|
- set TEST_HOME=nrtestsuite
|
||||||
- set NRTEST_SCRIPT=C:\Python27\Scripts
|
- set NRTEST_SCRIPT=C:\Python27\Scripts
|
||||||
- set GENERATOR="Visual Studio 10 2010"
|
# See values set
|
||||||
- set BOOST_ROOT="C:\\Libraries\\boost"
|
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
|
||||||
|
- echo %BUILD_HOME%
|
||||||
|
- echo %GENERATOR%
|
||||||
|
- echo %BOOST_ROOT%
|
||||||
|
|
||||||
# called after repo clone
|
# called after repo clone
|
||||||
install:
|
install:
|
||||||
@@ -29,7 +47,7 @@ install:
|
|||||||
before_build:
|
before_build:
|
||||||
- mkdir %BUILD_HOME%
|
- mkdir %BUILD_HOME%
|
||||||
- cd %BUILD_HOME%
|
- cd %BUILD_HOME%
|
||||||
- cmake -G %GENERATOR%
|
- cmake -G "%GENERATOR%"
|
||||||
-DBUILD_TESTS=1
|
-DBUILD_TESTS=1
|
||||||
-DBOOST_ROOT="%BOOST_ROOT%"
|
-DBOOST_ROOT="%BOOST_ROOT%"
|
||||||
-DBoost_USE_STATIC_LIBS="ON" ..
|
-DBoost_USE_STATIC_LIBS="ON" ..
|
||||||
|
|||||||
13
run/main.c
13
run/main.c
@@ -5,9 +5,9 @@
|
|||||||
#define MAXMSG 255 /* Max. # characters in message text */
|
#define MAXMSG 255 /* Max. # characters in message text */
|
||||||
#define MAXWARNCODE 99
|
#define MAXWARNCODE 99
|
||||||
/* text copied here, no more need of include "text.h" */
|
/* text copied here, no more need of include "text.h" */
|
||||||
#define FMT01 "\nEPANET Version %d.%d.%d\n"
|
#define FMT01 "\nEPANET Version %d.%d.%d"
|
||||||
#define FMT03 "\n Correct syntax is:\n %s <input file> <output file>\n"
|
#define FMT03 "\n Correct syntax is:\n %s <input file> <output file>\n"
|
||||||
#define FMT09 "\nEPANET completed.\n"
|
#define FMT09 "\n\nEPANET completed."
|
||||||
#define FMT10 "\nEPANET completed. There are warnings."
|
#define FMT10 "\nEPANET completed. There are warnings."
|
||||||
#define FMT11 "\nEPANET completed. There are errors."
|
#define FMT11 "\nEPANET completed. There are errors."
|
||||||
|
|
||||||
@@ -87,7 +87,8 @@ int main(int argc, char *argv[])
|
|||||||
/* Call the main control function */
|
/* Call the main control function */
|
||||||
if (strlen(f2)> 0) {
|
if (strlen(f2)> 0) {
|
||||||
/* use stdout for progress messages */
|
/* use stdout for progress messages */
|
||||||
errcode = ENepanet(f1,f2,f3,writeConsole);
|
//errcode = ENepanet(f1,f2,f3,writeConsole);
|
||||||
|
errcode = ENepanet(f1, f2, f3, NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* use stdout for reporting, no progress messages */
|
/* use stdout for reporting, no progress messages */
|
||||||
@@ -101,21 +102,21 @@ int main(int argc, char *argv[])
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (errcode > MAXWARNCODE) printf("\n Fatal Error: ");
|
||||||
ENgeterror(errcode, errmsg, MAXMSG);
|
ENgeterror(errcode, errmsg, MAXMSG);
|
||||||
writeConsole(errmsg);
|
writeConsole(errmsg);
|
||||||
if (errcode > MAXWARNCODE) {
|
if (errcode > MAXWARNCODE) {
|
||||||
/* error */
|
// error //
|
||||||
writeConsole(FMT11);
|
writeConsole(FMT11);
|
||||||
return(errcode);
|
return(errcode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* warning */
|
// warning //
|
||||||
writeConsole(FMT10);
|
writeConsole(FMT10);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} /* End of main */
|
} /* End of main */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
138
src/epanet.c
138
src/epanet.c
@@ -108,6 +108,10 @@ execute function x and set the error code equal to its return value.
|
|||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#define WINDOWS
|
#define WINDOWS
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -125,7 +129,6 @@ execute function x and set the error code equal to its return value.
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
#include "epanet2.h"
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
@@ -166,218 +169,295 @@ int DLLEXPORT ENepanet(char *f1, char *f2, char *f3,
|
|||||||
EN_free(_defaultModel);
|
EN_free(_defaultModel);
|
||||||
return (errcode);
|
return (errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENopen(char *f1, char *f2, char *f3) {
|
int DLLEXPORT ENopen(char *f1, char *f2, char *f3) {
|
||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
ERRCODE(EN_alloc(&_defaultModel));
|
ERRCODE(EN_alloc(&_defaultModel));
|
||||||
EN_open(_defaultModel, f1, f2, f3);
|
EN_open(_defaultModel, f1, f2, f3);
|
||||||
return (errcode);
|
return (errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsaveinpfile(char *filename) {
|
int DLLEXPORT ENsaveinpfile(char *filename) {
|
||||||
return EN_saveinpfile(_defaultModel, filename);
|
return EN_saveinpfile(_defaultModel, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENclose() { return EN_close(_defaultModel); }
|
int DLLEXPORT ENclose() { return EN_close(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENsolveH() { return EN_solveH(_defaultModel); }
|
int DLLEXPORT ENsolveH() { return EN_solveH(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENsaveH() { return EN_saveH(_defaultModel); }
|
int DLLEXPORT ENsaveH() { return EN_saveH(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENopenH() { return EN_openH(_defaultModel); }
|
int DLLEXPORT ENopenH() { return EN_openH(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENinitH(int flag) { return EN_initH(_defaultModel, flag); }
|
int DLLEXPORT ENinitH(int flag) { return EN_initH(_defaultModel, flag); }
|
||||||
|
|
||||||
int DLLEXPORT ENrunH(long *t) { return EN_runH(_defaultModel, t); }
|
int DLLEXPORT ENrunH(long *t) { return EN_runH(_defaultModel, t); }
|
||||||
|
|
||||||
int DLLEXPORT ENnextH(long *tstep) { return EN_nextH(_defaultModel, tstep); }
|
int DLLEXPORT ENnextH(long *tstep) { return EN_nextH(_defaultModel, tstep); }
|
||||||
|
|
||||||
int DLLEXPORT ENcloseH() { return EN_closeH(_defaultModel); }
|
int DLLEXPORT ENcloseH() { return EN_closeH(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENsavehydfile(char *filename) {
|
int DLLEXPORT ENsavehydfile(char *filename) {
|
||||||
return EN_savehydfile(_defaultModel, filename);
|
return EN_savehydfile(_defaultModel, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENusehydfile(char *filename) {
|
int DLLEXPORT ENusehydfile(char *filename) {
|
||||||
return EN_usehydfile(_defaultModel, filename);
|
return EN_usehydfile(_defaultModel, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsolveQ() { return EN_solveQ(_defaultModel); }
|
int DLLEXPORT ENsolveQ() { return EN_solveQ(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENopenQ() { return EN_openQ(_defaultModel); }
|
int DLLEXPORT ENopenQ() { return EN_openQ(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENinitQ(int saveflag) {
|
int DLLEXPORT ENinitQ(int saveflag) {
|
||||||
return EN_initQ(_defaultModel, saveflag);
|
return EN_initQ(_defaultModel, saveflag);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENrunQ(long *t) { return EN_runQ(_defaultModel, t); }
|
int DLLEXPORT ENrunQ(long *t) { return EN_runQ(_defaultModel, t); }
|
||||||
|
|
||||||
int DLLEXPORT ENnextQ(long *tstep) { return EN_nextQ(_defaultModel, tstep); }
|
int DLLEXPORT ENnextQ(long *tstep) { return EN_nextQ(_defaultModel, tstep); }
|
||||||
|
|
||||||
int DLLEXPORT ENstepQ(long *tleft) { return EN_stepQ(_defaultModel, tleft); }
|
int DLLEXPORT ENstepQ(long *tleft) { return EN_stepQ(_defaultModel, tleft); }
|
||||||
|
|
||||||
int DLLEXPORT ENcloseQ() { return EN_closeQ(_defaultModel); }
|
int DLLEXPORT ENcloseQ() { return EN_closeQ(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENwriteline(char *line) {
|
int DLLEXPORT ENwriteline(char *line) {
|
||||||
return EN_writeline(_defaultModel, line);
|
return EN_writeline(_defaultModel, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENreport() { return EN_report(_defaultModel); }
|
int DLLEXPORT ENreport() { return EN_report(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultModel); }
|
int DLLEXPORT ENresetreport() { return EN_resetreport(_defaultModel); }
|
||||||
|
|
||||||
int DLLEXPORT ENsetreport(char *s) { return EN_setreport(_defaultModel, s); }
|
int DLLEXPORT ENsetreport(char *s) { return EN_setreport(_defaultModel, s); }
|
||||||
|
|
||||||
int DLLEXPORT ENgetversion(int *v) { return EN_getversion(v); }
|
int DLLEXPORT ENgetversion(int *v) { return EN_getversion(v); }
|
||||||
|
|
||||||
int DLLEXPORT ENgetcontrol(int cindex, int *ctype, int *lindex,
|
int DLLEXPORT ENgetcontrol(int cindex, int *ctype, int *lindex,
|
||||||
EN_API_FLOAT_TYPE *setting, int *nindex,
|
EN_API_FLOAT_TYPE *setting, int *nindex,
|
||||||
EN_API_FLOAT_TYPE *level) {
|
EN_API_FLOAT_TYPE *level) {
|
||||||
return EN_getcontrol(_defaultModel, cindex, ctype, lindex, setting, nindex,
|
return EN_getcontrol(_defaultModel, cindex, ctype, lindex, setting, nindex,
|
||||||
level);
|
level);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcount(int code, int *count) {
|
int DLLEXPORT ENgetcount(int code, int *count) {
|
||||||
return EN_getcount(_defaultModel, (EN_CountType)code, count);
|
return EN_getcount(_defaultModel, (EN_CountType)code, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetoption(int code, EN_API_FLOAT_TYPE *value) {
|
int DLLEXPORT ENgetoption(int code, EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getoption(_defaultModel, (EN_Option)code, value);
|
return EN_getoption(_defaultModel, (EN_Option)code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgettimeparam(int code, long *value) {
|
int DLLEXPORT ENgettimeparam(int code, long *value) {
|
||||||
return EN_gettimeparam(_defaultModel, code, value);
|
return EN_gettimeparam(_defaultModel, code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetflowunits(int *code) {
|
int DLLEXPORT ENgetflowunits(int *code) {
|
||||||
return EN_getflowunits(_defaultModel, code);
|
return EN_getflowunits(_defaultModel, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetflowunits(int code) {
|
int DLLEXPORT ENsetflowunits(int code) {
|
||||||
return EN_setflowunits(_defaultModel, code);
|
return EN_setflowunits(_defaultModel, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetpatternindex(char *id, int *index) {
|
int DLLEXPORT ENgetpatternindex(char *id, int *index) {
|
||||||
return EN_getpatternindex(_defaultModel, id, index);
|
return EN_getpatternindex(_defaultModel, id, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetpatternid(int index, char *id) {
|
int DLLEXPORT ENgetpatternid(int index, char *id) {
|
||||||
return EN_getpatternid(_defaultModel, index, id);
|
return EN_getpatternid(_defaultModel, index, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetpatternlen(int index, int *len) {
|
int DLLEXPORT ENgetpatternlen(int index, int *len) {
|
||||||
return EN_getpatternlen(_defaultModel, index, len);
|
return EN_getpatternlen(_defaultModel, index, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetpatternvalue(int index, int period,
|
int DLLEXPORT ENgetpatternvalue(int index, int period,
|
||||||
EN_API_FLOAT_TYPE *value) {
|
EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getpatternvalue(_defaultModel, index, period, value);
|
return EN_getpatternvalue(_defaultModel, index, period, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcurveindex(char *id, int *index) {
|
int DLLEXPORT ENgetcurveindex(char *id, int *index) {
|
||||||
return EN_getcurveindex(_defaultModel, id, index);
|
return EN_getcurveindex(_defaultModel, id, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcurveid(int index, char *id) {
|
int DLLEXPORT ENgetcurveid(int index, char *id) {
|
||||||
return EN_getcurveid(_defaultModel, index, id);
|
return EN_getcurveid(_defaultModel, index, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcurvelen(int index, int *len) {
|
int DLLEXPORT ENgetcurvelen(int index, int *len) {
|
||||||
return EN_getcurvelen(_defaultModel, index, len);
|
return EN_getcurvelen(_defaultModel, index, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE *x,
|
int DLLEXPORT ENgetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE *x,
|
||||||
EN_API_FLOAT_TYPE *y) {
|
EN_API_FLOAT_TYPE *y) {
|
||||||
return EN_getcurvevalue(_defaultModel, index, pnt, x, y);
|
return EN_getcurvevalue(_defaultModel, index, pnt, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetqualtype(int *qualcode, int *tracenode) {
|
int DLLEXPORT ENgetqualtype(int *qualcode, int *tracenode) {
|
||||||
return EN_getqualtype(_defaultModel, qualcode, tracenode);
|
return EN_getqualtype(_defaultModel, qualcode, tracenode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetqualinfo(int *qualcode, char *chemname, char *chemunits,
|
int DLLEXPORT ENgetqualinfo(int *qualcode, char *chemname, char *chemunits,
|
||||||
int *tracenode) {
|
int *tracenode) {
|
||||||
return EN_getqualinfo(_defaultModel, qualcode, chemname, chemunits,
|
return EN_getqualinfo(_defaultModel, qualcode, chemname, chemunits,
|
||||||
tracenode);
|
tracenode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgeterror(int errcode, char *errmsg, int n) {
|
int DLLEXPORT ENgeterror(int errcode, char *errmsg, int n) {
|
||||||
return EN_geterror(errcode, errmsg, n);
|
return EN_geterror(errcode, errmsg, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetstatistic(int code, EN_API_FLOAT_TYPE *value) {
|
int DLLEXPORT ENgetstatistic(int code, EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getstatistic(_defaultModel, code, value);
|
return EN_getstatistic(_defaultModel, code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetnodeindex(char *id, int *index) {
|
int DLLEXPORT ENgetnodeindex(char *id, int *index) {
|
||||||
return EN_getnodeindex(_defaultModel, id, index);
|
return EN_getnodeindex(_defaultModel, id, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetnodeid(int index, char *id) {
|
int DLLEXPORT ENgetnodeid(int index, char *id) {
|
||||||
return EN_getnodeid(_defaultModel, index, id);
|
return EN_getnodeid(_defaultModel, index, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetnodetype(int index, int *code) {
|
int DLLEXPORT ENgetnodetype(int index, int *code) {
|
||||||
return EN_getnodetype(_defaultModel, index, code);
|
return EN_getnodetype(_defaultModel, index, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x,
|
int DLLEXPORT ENgetcoord(int index, EN_API_FLOAT_TYPE *x,
|
||||||
EN_API_FLOAT_TYPE *y) {
|
EN_API_FLOAT_TYPE *y) {
|
||||||
return EN_getcoord(_defaultModel, index, x, y);
|
return EN_getcoord(_defaultModel, index, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y) {
|
int DLLEXPORT ENsetcoord(int index, EN_API_FLOAT_TYPE x, EN_API_FLOAT_TYPE y) {
|
||||||
return EN_setcoord(_defaultModel, index, x, y);
|
return EN_setcoord(_defaultModel, index, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value) {
|
int DLLEXPORT ENgetnodevalue(int index, int code, EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getnodevalue(_defaultModel, index, code, value);
|
return EN_getnodevalue(_defaultModel, index, code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetlinkindex(char *id, int *index) {
|
int DLLEXPORT ENgetlinkindex(char *id, int *index) {
|
||||||
return EN_getlinkindex(_defaultModel, id, index);
|
return EN_getlinkindex(_defaultModel, id, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetlinkid(int index, char *id) {
|
int DLLEXPORT ENgetlinkid(int index, char *id) {
|
||||||
return EN_getlinkid(_defaultModel, index, id);
|
return EN_getlinkid(_defaultModel, index, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetlinktype(int index, EN_LinkType *code) {
|
int DLLEXPORT ENgetlinktype(int index, EN_LinkType *code) {
|
||||||
return EN_getlinktype(_defaultModel, index, code);
|
return EN_getlinktype(_defaultModel, index, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2) {
|
int DLLEXPORT ENgetlinknodes(int index, int *node1, int *node2) {
|
||||||
return EN_getlinknodes(_defaultModel, index, node1, node2);
|
return EN_getlinknodes(_defaultModel, index, node1, node2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value) {
|
int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getlinkvalue(_defaultModel, index, (EN_LinkProperty)code, value);
|
return EN_getlinkvalue(_defaultModel, index, (EN_LinkProperty)code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetcurve(int curveIndex, char *id, int *nValues,
|
int DLLEXPORT ENgetcurve(int curveIndex, char *id, int *nValues,
|
||||||
EN_API_FLOAT_TYPE **xValues,
|
EN_API_FLOAT_TYPE **xValues,
|
||||||
EN_API_FLOAT_TYPE **yValues) {
|
EN_API_FLOAT_TYPE **yValues) {
|
||||||
return EN_getcurve(_defaultModel, curveIndex, id, nValues, xValues, yValues);
|
return EN_getcurve(_defaultModel, curveIndex, id, nValues, xValues, yValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex,
|
int DLLEXPORT ENsetcontrol(int cindex, int ctype, int lindex,
|
||||||
EN_API_FLOAT_TYPE setting, int nindex,
|
EN_API_FLOAT_TYPE setting, int nindex,
|
||||||
EN_API_FLOAT_TYPE level) {
|
EN_API_FLOAT_TYPE level) {
|
||||||
return EN_setcontrol(_defaultModel, cindex, ctype, lindex, setting, nindex,
|
return EN_setcontrol(_defaultModel, cindex, ctype, lindex, setting, nindex,
|
||||||
level);
|
level);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v) {
|
int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v) {
|
||||||
return EN_setnodevalue(_defaultModel, index, code, v);
|
return EN_setnodevalue(_defaultModel, index, code, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v) {
|
int DLLEXPORT ENsetlinkvalue(int index, int code, EN_API_FLOAT_TYPE v) {
|
||||||
return EN_setlinkvalue(_defaultModel, index, code, v);
|
return EN_setlinkvalue(_defaultModel, index, code, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENaddpattern(char *id) {
|
int DLLEXPORT ENaddpattern(char *id) {
|
||||||
return EN_addpattern(_defaultModel, id);
|
return EN_addpattern(_defaultModel, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *f, int n) {
|
int DLLEXPORT ENsetpattern(int index, EN_API_FLOAT_TYPE *f, int n) {
|
||||||
return EN_setpattern(_defaultModel, index, f, n);
|
return EN_setpattern(_defaultModel, index, f, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetpatternvalue(int index, int period,
|
int DLLEXPORT ENsetpatternvalue(int index, int period,
|
||||||
EN_API_FLOAT_TYPE value) {
|
EN_API_FLOAT_TYPE value) {
|
||||||
return EN_setpatternvalue(_defaultModel, index, period, value);
|
return EN_setpatternvalue(_defaultModel, index, period, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENaddcurve(char *id) { return EN_addcurve(_defaultModel, id); }
|
int DLLEXPORT ENaddcurve(char *id) { return EN_addcurve(_defaultModel, id); }
|
||||||
|
|
||||||
int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y,
|
int DLLEXPORT ENsetcurve(int index, EN_API_FLOAT_TYPE *x, EN_API_FLOAT_TYPE *y,
|
||||||
int n) {
|
int n) {
|
||||||
return EN_setcurve(_defaultModel, index, x, y, n);
|
return EN_setcurve(_defaultModel, index, x, y, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE x,
|
int DLLEXPORT ENsetcurvevalue(int index, int pnt, EN_API_FLOAT_TYPE x,
|
||||||
EN_API_FLOAT_TYPE y) {
|
EN_API_FLOAT_TYPE y) {
|
||||||
return EN_setcurvevalue(_defaultModel, index, pnt, x, y);
|
return EN_setcurvevalue(_defaultModel, index, pnt, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsettimeparam(int code, long value) {
|
int DLLEXPORT ENsettimeparam(int code, long value) {
|
||||||
return EN_settimeparam(_defaultModel, code, value);
|
return EN_settimeparam(_defaultModel, code, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v) {
|
int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v) {
|
||||||
return EN_setoption(_defaultModel, code, v);
|
return EN_setoption(_defaultModel, code, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetstatusreport(int code) {
|
int DLLEXPORT ENsetstatusreport(int code) {
|
||||||
return EN_setstatusreport(_defaultModel, code);
|
return EN_setstatusreport(_defaultModel, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits,
|
int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits,
|
||||||
char *tracenode) {
|
char *tracenode) {
|
||||||
return EN_setqualtype(_defaultModel, qualcode, chemname, chemunits,
|
return EN_setqualtype(_defaultModel, qualcode, chemname, chemunits,
|
||||||
tracenode);
|
tracenode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetheadcurveindex(int index, int *curveindex) {
|
int DLLEXPORT ENgetheadcurveindex(int index, int *curveindex) {
|
||||||
return EN_getheadcurveindex(_defaultModel, index, curveindex);
|
return EN_getheadcurveindex(_defaultModel, index, curveindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetheadcurveindex(int index, int curveindex) {
|
int DLLEXPORT ENsetheadcurveindex(int index, int curveindex) {
|
||||||
return EN_setheadcurveindex(_defaultModel, index, curveindex);
|
return EN_setheadcurveindex(_defaultModel, index, curveindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetpumptype(int index, int *type) {
|
int DLLEXPORT ENgetpumptype(int index, int *type) {
|
||||||
return EN_getpumptype(_defaultModel, index, type);
|
return EN_getpumptype(_defaultModel, index, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) {
|
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) {
|
||||||
return EN_getnumdemands(_defaultModel, nodeIndex, numDemands);
|
return EN_getnumdemands(_defaultModel, nodeIndex, numDemands);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx,
|
int DLLEXPORT ENgetbasedemand(int nodeIndex, int demandIdx,
|
||||||
EN_API_FLOAT_TYPE *baseDemand) {
|
EN_API_FLOAT_TYPE *baseDemand) {
|
||||||
return EN_getbasedemand(_defaultModel, nodeIndex, demandIdx, baseDemand);
|
return EN_getbasedemand(_defaultModel, nodeIndex, demandIdx, baseDemand);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIdx,
|
int DLLEXPORT ENsetbasedemand(int nodeIndex, int demandIdx,
|
||||||
EN_API_FLOAT_TYPE baseDemand) {
|
EN_API_FLOAT_TYPE baseDemand) {
|
||||||
return EN_setbasedemand(_defaultModel, nodeIndex, demandIdx, baseDemand);
|
return EN_setbasedemand(_defaultModel, nodeIndex, demandIdx, baseDemand);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) {
|
int DLLEXPORT ENgetdemandpattern(int nodeIndex, int demandIdx, int *pattIdx) {
|
||||||
return EN_getdemandpattern(_defaultModel, nodeIndex, demandIdx, pattIdx);
|
return EN_getdemandpattern(_defaultModel, nodeIndex, demandIdx, pattIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value) {
|
int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value) {
|
||||||
return EN_getaveragepatternvalue(_defaultModel, index, value);
|
return EN_getaveragepatternvalue(_defaultModel, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetrule(int index, int *nPremises, int *nTrueActions, int *nFalseActions, EN_API_FLOAT_TYPE *priority) {
|
|
||||||
|
int DLLEXPORT ENgetrule(int index, int *nPremises, int *nTrueActions,
|
||||||
|
int *nFalseActions, EN_API_FLOAT_TYPE *priority) {
|
||||||
return EN_getrule(_defaultModel, index, nPremises, nTrueActions, nFalseActions, priority);
|
return EN_getrule(_defaultModel, index, nPremises, nTrueActions, nFalseActions, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,19 +485,23 @@ int DLLEXPORT ENsetpremisevalue(int indexRule, int indexPremise, EN_API_FLOAT_TY
|
|||||||
return EN_setpremisevalue(_defaultModel, indexRule, indexPremise, value);
|
return EN_setpremisevalue(_defaultModel, indexRule, indexPremise, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgettrueaction(int indexRule, int indexAction, int *indexLink, int *status, EN_API_FLOAT_TYPE *setting){
|
int DLLEXPORT ENgettrueaction(int indexRule, int indexAction, int *indexLink,
|
||||||
|
int *status, EN_API_FLOAT_TYPE *setting){
|
||||||
return EN_gettrueaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
return EN_gettrueaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsettrueaction(int indexRule, int indexAction, int indexLink, int status, EN_API_FLOAT_TYPE setting){
|
int DLLEXPORT ENsettrueaction(int indexRule, int indexAction, int indexLink,
|
||||||
|
int status, EN_API_FLOAT_TYPE setting){
|
||||||
return EN_settrueaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
return EN_settrueaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENgetfalseaction(int indexRule, int indexAction, int *indexLink, int *status, EN_API_FLOAT_TYPE *setting){
|
int DLLEXPORT ENgetfalseaction(int indexRule, int indexAction, int *indexLink,
|
||||||
|
int *status, EN_API_FLOAT_TYPE *setting){
|
||||||
return EN_getfalseaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
return EN_getfalseaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENsetfalseaction(int indexRule, int indexAction, int indexLink, int status, EN_API_FLOAT_TYPE setting){
|
int DLLEXPORT ENsetfalseaction(int indexRule, int indexAction, int indexLink,
|
||||||
|
int status, EN_API_FLOAT_TYPE setting){
|
||||||
return EN_setfalseaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
return EN_setfalseaction(_defaultModel, indexRule, indexAction, indexLink, status, setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,16 +512,20 @@ int DLLEXPORT ENgetruleID(int indexRule, char* id){
|
|||||||
int DLLEXPORT ENsetlinktype(char *id, EN_LinkType toType) {
|
int DLLEXPORT ENsetlinktype(char *id, EN_LinkType toType) {
|
||||||
return EN_setlinktype(_defaultModel, id, toType);
|
return EN_setlinktype(_defaultModel, id, toType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENaddnode(char *id, EN_NodeType nodeType) {
|
int DLLEXPORT ENaddnode(char *id, EN_NodeType nodeType) {
|
||||||
return EN_addnode(_defaultModel, id, nodeType);
|
return EN_addnode(_defaultModel, id, nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENaddlink(char *id, EN_LinkType linkType, char *fromNode,
|
int DLLEXPORT ENaddlink(char *id, EN_LinkType linkType, char *fromNode,
|
||||||
char *toNode) {
|
char *toNode) {
|
||||||
return EN_addlink(_defaultModel, id, linkType, fromNode, toNode);
|
return EN_addlink(_defaultModel, id, linkType, fromNode, toNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENdeletelink(int index) {
|
int DLLEXPORT ENdeletelink(int index) {
|
||||||
return EN_deletelink(_defaultModel, index);
|
return EN_deletelink(_defaultModel, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DLLEXPORT ENdeletenode(int index) {
|
int DLLEXPORT ENdeletenode(int index) {
|
||||||
return EN_deletenode(_defaultModel, index);
|
return EN_deletenode(_defaultModel, index);
|
||||||
}
|
}
|
||||||
@@ -707,7 +795,6 @@ int DLLEXPORT EN_solveH(EN_Project *p)
|
|||||||
tstep = 0;
|
tstep = 0;
|
||||||
ERRCODE(EN_runH(p, &t));
|
ERRCODE(EN_runH(p, &t));
|
||||||
ERRCODE(EN_nextH(p, &tstep));
|
ERRCODE(EN_nextH(p, &tstep));
|
||||||
|
|
||||||
/*** Updated 6/24/02 ***/
|
/*** Updated 6/24/02 ***/
|
||||||
writecon("\b\b\b\b\b\b\b\b\b\b");
|
writecon("\b\b\b\b\b\b\b\b\b\b");
|
||||||
} while (tstep > 0);
|
} while (tstep > 0);
|
||||||
@@ -825,8 +912,10 @@ int DLLEXPORT EN_initH(EN_Project *p, int flag)
|
|||||||
errcode = openhydfile(p);
|
errcode = openhydfile(p);
|
||||||
if (!errcode)
|
if (!errcode)
|
||||||
p->save_options.Saveflag = TRUE;
|
p->save_options.Saveflag = TRUE;
|
||||||
else
|
else {
|
||||||
errmsg(p, errcode);
|
errmsg(p, errcode);
|
||||||
|
return errcode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize hydraulics */
|
/* Initialize hydraulics */
|
||||||
@@ -1546,7 +1635,7 @@ int DLLEXPORT EN_geterror(int errcode, char *errmsg, int n) {
|
|||||||
strncpy(errmsg, WARN6, n);
|
strncpy(errmsg, WARN6, n);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
geterrmsg(n, newMsg);
|
geterrmsg(errcode, newMsg);
|
||||||
strncpy(errmsg, newMsg, n);
|
strncpy(errmsg, newMsg, n);
|
||||||
}
|
}
|
||||||
if (strlen(errmsg) == 0)
|
if (strlen(errmsg) == 0)
|
||||||
@@ -3330,7 +3419,7 @@ int openhydfile(EN_Project *p)
|
|||||||
out->HydFile = NULL;
|
out->HydFile = NULL;
|
||||||
switch (out->Hydflag) {
|
switch (out->Hydflag) {
|
||||||
case SCRATCH:
|
case SCRATCH:
|
||||||
getTmpName(p, out->HydFname);
|
getTmpName(out->HydFname);
|
||||||
out->HydFile = fopen(out->HydFname, "w+b");
|
out->HydFile = fopen(out->HydFname, "w+b");
|
||||||
break;
|
break;
|
||||||
case SAVE:
|
case SAVE:
|
||||||
@@ -3423,7 +3512,7 @@ int openoutfile(EN_Project *p)
|
|||||||
// else if ( (OutFile = tmpfile()) == NULL)
|
// else if ( (OutFile = tmpfile()) == NULL)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getTmpName(p, out->OutFname);
|
getTmpName(out->OutFname);
|
||||||
if ((out->OutFile = fopen(out->OutFname, "w+b")) == NULL)
|
if ((out->OutFile = fopen(out->OutFname, "w+b")) == NULL)
|
||||||
{
|
{
|
||||||
writecon(FMT08);
|
writecon(FMT08);
|
||||||
@@ -3441,7 +3530,7 @@ int openoutfile(EN_Project *p)
|
|||||||
if (!errcode) {
|
if (!errcode) {
|
||||||
if (rep->Tstatflag != SERIES) {
|
if (rep->Tstatflag != SERIES) {
|
||||||
// if ( (TmpOutFile = tmpfile()) == NULL) errcode = 304;
|
// if ( (TmpOutFile = tmpfile()) == NULL) errcode = 304;
|
||||||
getTmpName(p, out->TmpFname);
|
getTmpName(out->TmpFname);
|
||||||
out->TmpOutFile = fopen(out->TmpFname, "w+b");
|
out->TmpOutFile = fopen(out->TmpFname, "w+b");
|
||||||
if (out->TmpOutFile == NULL)
|
if (out->TmpOutFile == NULL)
|
||||||
errcode = 304;
|
errcode = 304;
|
||||||
@@ -3748,17 +3837,35 @@ void freedata(EN_Project *p)
|
|||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*** New function for 2.00.12 ***/
|
char *getTmpName(char *fname)
|
||||||
char *getTmpName(EN_Project *p, char *fname)
|
|
||||||
//
|
//
|
||||||
// Input: fname = file name string
|
// Input: fname = file name string
|
||||||
// Output: returns pointer to file name
|
// Output: returns pointer to file name
|
||||||
// Purpose: creates a temporary file name with path prepended to it.
|
// Purpose: creates a temporary file name with path prepended to it.
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
out_file_t *out = &p->out_files;
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
char* name = NULL;
|
||||||
|
|
||||||
|
// --- use Windows _tempnam function to get a pointer to an
|
||||||
|
// unused file name that begins with "en"
|
||||||
|
name = _tempnam(NULL, "en");
|
||||||
|
if (name == NULL) return NULL;
|
||||||
|
|
||||||
|
// --- copy the file name to fname
|
||||||
|
if (strlen(name) < MAXFNAME) strncpy(fname, name, MAXFNAME);
|
||||||
|
else fname = NULL;
|
||||||
|
|
||||||
|
// --- free the pointer returned by _tempnam
|
||||||
|
if (name) free(name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
/////////////////// DEPRECATED /////////////////////////////////////
|
||||||
// --- for Windows systems:
|
// --- for Windows systems:
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
|
out_file_t *out = &p->out_files;
|
||||||
// --- use system function tmpnam() to create a temporary file name
|
// --- use system function tmpnam() to create a temporary file name
|
||||||
char name[MAXFNAME + 1];
|
char name[MAXFNAME + 1];
|
||||||
int n;
|
int n;
|
||||||
@@ -3782,6 +3889,7 @@ char *getTmpName(EN_Project *p, char *fname)
|
|||||||
|
|
||||||
// --- now add the prefix to the file name
|
// --- now add the prefix to the file name
|
||||||
strcat(fname, name);
|
strcat(fname, name);
|
||||||
|
*/
|
||||||
|
|
||||||
// --- for non-Windows systems:
|
// --- for non-Windows systems:
|
||||||
#else
|
#else
|
||||||
|
|||||||
272
src/funcs.h
272
src/funcs.h
@@ -31,32 +31,32 @@ AUTHOR: L. Rossman
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void initpointers(EN_Project *p); /* Initializes pointers */
|
void initpointers(EN_Project *p); /* Initializes pointers */
|
||||||
int allocdata(EN_Project *p); /* Allocates memory */
|
int allocdata(EN_Project *p); /* Allocates memory */
|
||||||
void freeTmplist(STmplist *); /* Frees items in linked list */
|
void freeTmplist(STmplist *); /* Frees items in linked list */
|
||||||
void freeFloatlist(SFloatlist *); /* Frees list of floats */
|
void freeFloatlist(SFloatlist *); /* Frees list of floats */
|
||||||
void freedata(EN_Project *p); /* Frees allocated memory */
|
void freedata(EN_Project *p); /* Frees allocated memory */
|
||||||
int openfiles(EN_Project *p, char *,char *,char *); /* Opens input & report files */
|
int openfiles(EN_Project *p, char *,char *,char *); /* Opens input & report files */
|
||||||
int openhydfile(EN_Project *p); /* Opens hydraulics file */
|
int openhydfile(EN_Project *p); /* Opens hydraulics file */
|
||||||
int openoutfile(EN_Project *p); /* Opens binary output file */
|
int openoutfile(EN_Project *p); /* Opens binary output file */
|
||||||
int strcomp(char *, char *); /* Compares two strings */
|
int strcomp(char *, char *); /* Compares two strings */
|
||||||
char* getTmpName(EN_Project *p, char* fname); /* Gets temporary file name */
|
char* getTmpName(char* fname); /* Gets temporary file name */
|
||||||
double interp(int, double *,double *, double); /* Interpolates a data curve */
|
double interp(int, double *,double *, double); /* Interpolates a data curve */
|
||||||
|
|
||||||
int findnode(EN_Network *n, char *); /* Finds node's index from ID */
|
int findnode(EN_Network *n, char *); /* Finds node's index from ID */
|
||||||
int findlink(EN_Network *n, char *); /* Finds link's index from ID */
|
int findlink(EN_Network *n, char *); /* Finds link's index from ID */
|
||||||
int findtank(EN_Network *n, int); /* Find tank index from node index */ // (AH)
|
int findtank(EN_Network *n, int); /* Find tank index from node index */ // (AH)
|
||||||
int findvalve(EN_Network *n, int); /* Find valve index from node index */ // (AH)
|
int findvalve(EN_Network *n, int); /* Find valve index from node index */ // (AH)
|
||||||
int findpump(EN_Network *n, int); /* Find pump index from node index */ // (AH)
|
int findpump(EN_Network *n, int); /* Find pump index from node index */ // (AH)
|
||||||
char *geterrmsg(int errcode, char *msg); /* Gets text of error message */
|
char *geterrmsg(int errcode, char *msg); /* Gets text of error message */
|
||||||
void errmsg(EN_Project *p, int); /* Reports program error */
|
void errmsg(EN_Project *p, int); /* Reports program error */
|
||||||
void writecon(char *); /* Writes text to console */
|
void writecon(char *); /* Writes text to console */
|
||||||
void writewin(void (*vp)(char *), char *); /* Passes text to calling app */
|
void writewin(void (*vp)(char *), char *); /* Passes text to calling app */
|
||||||
|
|
||||||
/* ------- INPUT1.C --------------------*/
|
/* ------- INPUT1.C --------------------*/
|
||||||
int getdata(EN_Project *pr); /* Gets network data */
|
int getdata(EN_Project *pr); /* Gets network data */
|
||||||
void setdefaults(EN_Project *pr); /* Sets default values */
|
void setdefaults(EN_Project *pr); /* Sets default values */
|
||||||
void initreport(report_options_t *r); /* Initializes report options */
|
void initreport(report_options_t *r); /* Initializes report options */
|
||||||
void adjustdata(EN_Project *pr); /* Adjusts input data */
|
void adjustdata(EN_Project *pr); /* Adjusts input data */
|
||||||
int inittanks(EN_Project *pr); /* Initializes tank levels */
|
int inittanks(EN_Project *pr); /* Initializes tank levels */
|
||||||
void initunits(EN_Project *pr); /* Determines reporting units */
|
void initunits(EN_Project *pr); /* Determines reporting units */
|
||||||
@@ -65,23 +65,23 @@ void convertunits(EN_Project *pr); /* Converts data to std. uni
|
|||||||
/* -------- INPUT2.C -------------------*/
|
/* -------- INPUT2.C -------------------*/
|
||||||
int netsize(EN_Project *pr); /* Determines network size */
|
int netsize(EN_Project *pr); /* Determines network size */
|
||||||
int readdata(EN_Project *pr); /* Reads in network data */
|
int readdata(EN_Project *pr); /* Reads in network data */
|
||||||
int newline(EN_Project *pr, int, char *); /* Processes new line of data */
|
int newline(EN_Project *pr, int, char *); /* Processes new line of data */
|
||||||
int addnodeID(EN_Network *n, int, char *); /* Adds node ID to data base */
|
int addnodeID(EN_Network *n, int, char *); /* Adds node ID to data base */
|
||||||
int addlinkID(EN_Network *n, int, char *); /* Adds link ID to data base */
|
int addlinkID(EN_Network *n, int, char *); /* Adds link ID to data base */
|
||||||
int addpattern(parser_data_t *par, char *); /* Adds pattern to data base */
|
int addpattern(parser_data_t *par, char *); /* Adds pattern to data base */
|
||||||
int addcurve(parser_data_t *par, char *); /* Adds curve to data base */
|
int addcurve(parser_data_t *par, char *); /* Adds curve to data base */
|
||||||
STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
|
STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
|
||||||
int unlinked(EN_Project *pr); /* Checks for unlinked nodes */
|
int unlinked(EN_Project *pr); /* Checks for unlinked nodes */
|
||||||
int getpumpparams(EN_Project *pr); /* Computes pump curve coeffs.*/
|
int getpumpparams(EN_Project *pr); /* Computes pump curve coeffs.*/
|
||||||
int getpatterns(EN_Project *pr); /* Gets pattern data from list*/
|
int getpatterns(EN_Project *pr); /* Gets pattern data from list*/
|
||||||
int getcurves(EN_Project *pr); /* Gets curve data from list */
|
int getcurves(EN_Project *pr); /* Gets curve data from list */
|
||||||
int findmatch(char *, char *[]); /* Finds keyword in line */
|
int findmatch(char *, char *[]); /* Finds keyword in line */
|
||||||
int match(const char *, const char *); /* Checks for word match */
|
int match(const char *, const char *); /* Checks for word match */
|
||||||
int gettokens(char *s, char** Tok, int maxToks, char *comment); /* Tokenizes input line */
|
int gettokens(char *s, char** Tok, int maxToks, char *comment); /* Tokenizes input line */
|
||||||
int getfloat(char *, double *); /* Converts string to double */
|
int getfloat(char *, double *); /* Converts string to double */
|
||||||
double hour(char *, char *); /* Converts time to hours */
|
double hour(char *, char *); /* Converts time to hours */
|
||||||
int setreport(EN_Project *pr, char *); /* Processes reporting command*/
|
int setreport(EN_Project *pr, char *); /* Processes reporting command*/
|
||||||
void inperrmsg(EN_Project *pr, int,int,char *); /* Input error message */
|
void inperrmsg(EN_Project *pr, int,int,char *); /* Input error message */
|
||||||
|
|
||||||
/* ---------- INPUT3.C -----------------*/
|
/* ---------- INPUT3.C -----------------*/
|
||||||
int juncdata(EN_Project *pr); /* Processes junction data */
|
int juncdata(EN_Project *pr); /* Processes junction data */
|
||||||
@@ -104,188 +104,206 @@ int statusdata(EN_Project *pr); /* Processes link status dat
|
|||||||
int reportdata(EN_Project *pr); /* Processes report options */
|
int reportdata(EN_Project *pr); /* Processes report options */
|
||||||
int timedata(EN_Project *pr); /* Processes time options */
|
int timedata(EN_Project *pr); /* Processes time options */
|
||||||
int optiondata(EN_Project *pr); /* Processes analysis options */
|
int optiondata(EN_Project *pr); /* Processes analysis options */
|
||||||
int optionchoice(EN_Project *pr, int); /* Processes option choices */
|
int optionchoice(EN_Project *pr, int); /* Processes option choices */
|
||||||
int optionvalue(EN_Project *pr, int); /* Processes option values */
|
int optionvalue(EN_Project *pr, int); /* Processes option values */
|
||||||
int getpumpcurve(EN_Project *pr, int); /* Constructs a pump curve */
|
int getpumpcurve(EN_Project *pr, int); /* Constructs a pump curve */
|
||||||
int powercurve(double, double, double,/* Coeffs. of power pump curve*/
|
int powercurve(double, double, double, /* Coeffs. of power pump curve*/
|
||||||
double, double, double *,
|
double, double, double *,
|
||||||
double *, double *);
|
double *, double *);
|
||||||
int valvecheck(EN_Project *pr, int, int, int); /* Checks valve placement */
|
int valvecheck(EN_Project *pr, int, int, int); /* Checks valve placement */
|
||||||
void changestatus(EN_Network *net, int, StatType, double); /* Changes status of a link */
|
void changestatus(EN_Network *net, int, StatType, double); /* Changes status of a link */
|
||||||
|
|
||||||
/* -------------- RULES.C --------------*/
|
/* -------------- RULES.C --------------*/
|
||||||
void initrules(rules_t *rules); /* Initializes rule base */
|
void initrules(rules_t *rules); /* Initializes rule base */
|
||||||
void addrule(parser_data_t *par, char *); /* Adds rule to rule base */
|
void addrule(parser_data_t *par, char *); /* Adds rule to rule base */
|
||||||
int allocrules(EN_Project *pr); /* Allocates memory for rule */
|
int allocrules(EN_Project *pr); /* Allocates memory for rule */
|
||||||
int ruledata(EN_Project *pr); /* Processes rule input data */
|
int ruledata(EN_Project *pr); /* Processes rule input data */
|
||||||
int checkrules(EN_Project *pr, long); /* Checks all rules */
|
int checkrules(EN_Project *pr, long); /* Checks all rules */
|
||||||
void freerules(EN_Project *pr); /* Frees rule base memory */
|
void freerules(EN_Project *pr); /* Frees rule base memory */
|
||||||
|
int writeRuleinInp(EN_Project *pr, FILE *f, /* Writes rule to an INP file */
|
||||||
|
int RuleIdx);
|
||||||
|
|
||||||
/* ------------- REPORT.C --------------*/
|
/* ------------- REPORT.C --------------*/
|
||||||
int writereport(EN_Project *pr); /* Writes formatted report */
|
int writereport(EN_Project *pr); /* Writes formatted report */
|
||||||
void writelogo(EN_Project *pr); /* Writes program logo */
|
void writelogo(EN_Project *pr); /* Writes program logo */
|
||||||
void writesummary(EN_Project *pr); /* Writes network summary */
|
void writesummary(EN_Project *pr); /* Writes network summary */
|
||||||
void writehydstat(EN_Project *pr, int,double); /* Writes hydraulic status */
|
void writehydstat(EN_Project *pr, int,double); /* Writes hydraulic status */
|
||||||
void writeenergy(EN_Project *pr); /* Writes energy usage */
|
void writeenergy(EN_Project *pr); /* Writes energy usage */
|
||||||
int writeresults(EN_Project *pr); /* Writes node/link results */
|
int writeresults(EN_Project *pr); /* Writes node/link results */
|
||||||
void writeheader(EN_Project *pr, int,int); /* Writes heading on report */
|
void writeheader(EN_Project *pr, int,int); /* Writes heading on report */
|
||||||
void writeline(EN_Project *pr, char *); /* Writes line to report file */
|
void writeline(EN_Project *pr, char *); /* Writes line to report file */
|
||||||
void writerelerr(EN_Project *pr, int, double); /* Writes convergence error */
|
void writerelerr(EN_Project *pr, int, double); /* Writes convergence error */
|
||||||
void writestatchange(EN_Project *pr, int,char,char); /* Writes link status change */
|
void writestatchange(EN_Project *pr, int,char,char); /* Writes link status change */
|
||||||
void writecontrolaction(EN_Project *pr, int, int); /* Writes control action taken*/
|
void writecontrolaction(EN_Project *pr, int, int); /* Writes control action taken*/
|
||||||
void writeruleaction(EN_Project *pr, int, char *); /* Writes rule action taken */
|
void writeruleaction(EN_Project *pr, int, char *); /* Writes rule action taken */
|
||||||
int writehydwarn(EN_Project *pr, int,double); /* Writes hydraulic warnings */
|
int writehydwarn(EN_Project *pr, int,double); /* Writes hydraulic warnings */
|
||||||
void writehyderr(EN_Project *pr, int); /* Writes hydraulic error msg.*/
|
void writehyderr(EN_Project *pr, int); /* Writes hydraulic error msg.*/
|
||||||
int disconnected(EN_Project *pr); /* Checks for disconnections */
|
int disconnected(EN_Project *pr); /* Checks for disconnections */
|
||||||
void marknodes(EN_Project *pr, int, int *, char *); /* Identifies connected nodes */
|
void marknodes(EN_Project *pr, int, int *, char *); /* Identifies connected nodes */
|
||||||
void getclosedlink(EN_Project *pr, int, char *); /* Finds a disconnecting link */
|
void getclosedlink(EN_Project *pr, int, char *); /* Finds a disconnecting link */
|
||||||
void writelimits(EN_Project *pr, int,int); /* Writes reporting limits */
|
void writelimits(EN_Project *pr, int,int); /* Writes reporting limits */
|
||||||
int checklimits(report_options_t *rep, double *,int,int); /* Checks variable limits */
|
int checklimits(report_options_t *rep, double *,int,int); /* Checks variable limits */
|
||||||
void writetime(EN_Project *pr, char *); /* Writes current clock time */
|
void writetime(EN_Project *pr, char *); /* Writes current clock time */
|
||||||
char *clocktime(char *, long); /* Converts time to hrs:min */
|
char *clocktime(char *, long); /* Converts time to hrs:min */
|
||||||
char *fillstr(char *, char, int); /* Fills string with character*/
|
char *fillstr(char *, char, int); /* Fills string with character*/
|
||||||
int getnodetype(EN_Network *net, int); /* Determines node type */
|
int getnodetype(EN_Network *net, int); /* Determines node type */
|
||||||
|
|
||||||
/* --------- HYDRAUL.C -----------------*/
|
/* --------- HYDRAUL.C -----------------*/
|
||||||
int openhyd(EN_Project *pr); /* Opens hydraulics solver */
|
int openhyd(EN_Project *pr); /* Opens hydraulics solver */
|
||||||
|
|
||||||
/*** Updated 3/1/01 ***/
|
/*** Updated 3/1/01 ***/
|
||||||
void inithyd(EN_Project *pr, int initFlags); /* Re-sets initial conditions */
|
void inithyd(EN_Project *pr, int initFlags); /* Re-sets initial conditions */
|
||||||
|
|
||||||
int runhyd(EN_Project *pr, long *); /* Solves 1-period hydraulics */
|
int runhyd(EN_Project *pr, long *); /* Solves 1-period hydraulics */
|
||||||
int nexthyd(EN_Project *pr, long *); /* Moves to next time period */
|
int nexthyd(EN_Project *pr, long *); /* Moves to next time period */
|
||||||
void closehyd(EN_Project *pr); /* Closes hydraulics solver */
|
void closehyd(EN_Project *pr); /* Closes hydraulics solver */
|
||||||
int allocmatrix(EN_Project *pr); /* Allocates matrix coeffs. */
|
int allocmatrix(EN_Project *pr); /* Allocates matrix coeffs. */
|
||||||
void freematrix(EN_Project *pr); /* Frees matrix coeffs. */
|
void freematrix(EN_Project *pr); /* Frees matrix coeffs. */
|
||||||
void initlinkflow(EN_Project *pr, int, char, double); /* Initializes link flow */
|
void initlinkflow(EN_Project *pr, int, char,
|
||||||
void setlinkflow(EN_Project *pr, int, double); /* Sets link flow via headloss*/
|
double); /* Initializes link flow */
|
||||||
void setlinkstatus(EN_Project *pr, int, char, StatType *, double *); /* Sets link status */
|
void setlinkflow(EN_Project *pr, int, double); /* Sets link flow via headloss*/
|
||||||
|
void setlinkstatus(EN_Project *pr, int, char,
|
||||||
|
StatType *, double *); /* Sets link status */
|
||||||
|
|
||||||
void setlinksetting(EN_Project *pr, int, double, StatType *, double *); /* Sets pump/valve setting */
|
void setlinksetting(EN_Project *pr, int, double,
|
||||||
|
StatType *, double *); /* Sets pump/valve setting */
|
||||||
|
|
||||||
void resistance(EN_Project *pr, int); /* Computes resistance coeff. */
|
void resistance(EN_Project *pr, int); /* Computes resistance coeff. */
|
||||||
void demands(EN_Project *pr); /* Computes current demands */
|
void demands(EN_Project *pr); /* Computes current demands */
|
||||||
int controls(EN_Project *pr); /* Controls link settings */
|
int controls(EN_Project *pr); /* Controls link settings */
|
||||||
long timestep(EN_Project *pr); /* Computes new time step */
|
long timestep(EN_Project *pr); /* Computes new time step */
|
||||||
int tanktimestep(EN_Project *pr, long *); /* Time till tanks fill/drain */
|
int tanktimestep(EN_Project *pr, long *); /* Time till tanks fill/drain */
|
||||||
void controltimestep(EN_Project *pr, long *); /* Time till control action */
|
void controltimestep(EN_Project *pr, long *); /* Time till control action */
|
||||||
void ruletimestep(EN_Project *pr, long *); /* Time till rule action */
|
void ruletimestep(EN_Project *pr, long *); /* Time till rule action */
|
||||||
void addenergy(EN_Project *pr, long); /* Accumulates energy usage */
|
void addenergy(EN_Project *pr, long); /* Accumulates energy usage */
|
||||||
void getenergy(EN_Project *pr, int, double *, double *); /* Computes link energy use */
|
void getenergy(EN_Project *pr, int, double *,
|
||||||
void tanklevels(EN_Project *pr, long); /* Computes new tank levels */
|
double *); /* Computes link energy use */
|
||||||
double tankvolume(EN_Project *pr, int,double); /* Finds tank vol. from grade */
|
void tanklevels(EN_Project *pr, long); /* Computes new tank levels */
|
||||||
double tankgrade(EN_Project *pr, int,double); /* Finds tank grade from vol. */
|
double tankvolume(EN_Project *pr, int,double); /* Finds tank vol. from grade */
|
||||||
int netsolve(EN_Project *pr, int *,double *); /* Solves network equations */
|
double tankgrade(EN_Project *pr, int,double); /* Finds tank grade from vol. */
|
||||||
int badvalve(EN_Project *pr, int); /* Checks for bad valve */
|
int netsolve(EN_Project *pr, int *,double *); /* Solves network equations */
|
||||||
|
int badvalve(EN_Project *pr, int); /* Checks for bad valve */
|
||||||
int valvestatus(EN_Project *pr); /* Updates valve status */
|
int valvestatus(EN_Project *pr); /* Updates valve status */
|
||||||
int linkstatus(EN_Project *pr); /* Updates link status */
|
int linkstatus(EN_Project *pr); /* Updates link status */
|
||||||
StatType cvstatus(EN_Project *pr, StatType,double,double); /* Updates CV status */
|
StatType cvstatus(EN_Project *pr, StatType,
|
||||||
StatType pumpstatus(EN_Project *pr, int,double); /* Updates pump status */
|
double,double); /* Updates CV status */
|
||||||
StatType prvstatus(EN_Project *pr, int,StatType,double,double,double); /* Updates PRV status */
|
StatType pumpstatus(EN_Project *pr, int,double); /* Updates pump status */
|
||||||
|
StatType prvstatus(EN_Project *pr, int,StatType,
|
||||||
|
double,double,double); /* Updates PRV status */
|
||||||
|
|
||||||
StatType psvstatus(EN_Project *pr, int,StatType,double,double,double); /* Updates PSV status */
|
StatType psvstatus(EN_Project *pr, int,StatType,
|
||||||
|
double,double,double); /* Updates PSV status */
|
||||||
|
|
||||||
StatType fcvstatus(EN_Project *pr, int,StatType,double,double); /* Updates FCV status */
|
StatType fcvstatus(EN_Project *pr, int,StatType,
|
||||||
|
double,double); /* Updates FCV status */
|
||||||
|
|
||||||
void tankstatus(EN_Project *pr, int,int,int); /* Checks if tank full/empty */
|
void tankstatus(EN_Project *pr, int,int,int); /* Checks if tank full/empty */
|
||||||
int pswitch(EN_Project *pr); /* Pressure switch controls */
|
int pswitch(EN_Project *pr); /* Pressure switch controls */
|
||||||
double newflows(EN_Project *pr); /* Updates link flows */
|
double newflows(EN_Project *pr); /* Updates link flows */
|
||||||
void newcoeffs(EN_Project *pr); /* Computes matrix coeffs. */
|
void newcoeffs(EN_Project *pr); /* Computes matrix coeffs. */
|
||||||
void linkcoeffs(EN_Project *pr); /* Computes link coeffs. */
|
void linkcoeffs(EN_Project *pr); /* Computes link coeffs. */
|
||||||
void nodecoeffs(EN_Project *pr); /* Computes node coeffs. */
|
void nodecoeffs(EN_Project *pr); /* Computes node coeffs. */
|
||||||
void valvecoeffs(EN_Project *pr); /* Computes valve coeffs. */
|
void valvecoeffs(EN_Project *pr); /* Computes valve coeffs. */
|
||||||
void pipecoeff(EN_Project *pr, int); /* Computes pipe coeff. */
|
void pipecoeff(EN_Project *pr, int); /* Computes pipe coeff. */
|
||||||
double DWcoeff(EN_Project *pr, int, double *); /* Computes D-W coeff. */
|
double DWcoeff(EN_Project *pr, int, double *); /* Computes D-W coeff. */
|
||||||
void pumpcoeff(EN_Project *pr, int); /* Computes pump coeff. */
|
void pumpcoeff(EN_Project *pr, int); /* Computes pump coeff. */
|
||||||
|
|
||||||
/*** Updated 10/25/00 ***/
|
/*** Updated 10/25/00 ***/
|
||||||
/*** Updated 12/29/00 ***/
|
/*** Updated 12/29/00 ***/
|
||||||
void curvecoeff(EN_Project *pr, int,double,double *,double *); /* Computes curve coeffs. */
|
void curvecoeff(EN_Project *pr, int,double,
|
||||||
|
double *,double *); /* Computes curve coeffs. */
|
||||||
|
|
||||||
|
|
||||||
void gpvcoeff(EN_Project *pr, int iLink); /* Computes GPV coeff. */
|
void gpvcoeff(EN_Project *pr, int iLink); /* Computes GPV coeff. */
|
||||||
void pbvcoeff(EN_Project *pr, int iLink); /* Computes PBV coeff. */
|
void pbvcoeff(EN_Project *pr, int iLink); /* Computes PBV coeff. */
|
||||||
void tcvcoeff(EN_Project *pr, int iLink); /* Computes TCV coeff. */
|
void tcvcoeff(EN_Project *pr, int iLink); /* Computes TCV coeff. */
|
||||||
void prvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes PRV coeff. */
|
void prvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes PRV coeff. */
|
||||||
void psvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes PSV coeff. */
|
void psvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes PSV coeff. */
|
||||||
void fcvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes FCV coeff. */
|
void fcvcoeff(EN_Project *pr, int iLink, int n1, int n2); /* Computes FCV coeff. */
|
||||||
void emittercoeffs(EN_Project *pr); /* Computes emitter coeffs. */
|
void emittercoeffs(EN_Project *pr); /* Computes emitter coeffs. */
|
||||||
double emitflowchange(EN_Project *pr, int); /* Computes new emitter flow */
|
double emitflowchange(EN_Project *pr, int); /* Computes new emitter flow */
|
||||||
|
|
||||||
/* ----------- SMATRIX.C ---------------*/
|
/* ----------- SMATRIX.C ---------------*/
|
||||||
int createsparse(EN_Project *pr); /* Creates sparse matrix */
|
int createsparse(EN_Project *pr); /* Creates sparse matrix */
|
||||||
int allocsparse(EN_Project *pr); /* Allocates matrix memory */
|
int allocsparse(EN_Project *pr); /* Allocates matrix memory */
|
||||||
void freesparse(EN_Project *pr); /* Frees matrix memory */
|
void freesparse(EN_Project *pr); /* Frees matrix memory */
|
||||||
int buildlists(EN_Project *pr, int); /* Builds adjacency lists */
|
int buildlists(EN_Project *pr, int); /* Builds adjacency lists */
|
||||||
int paralink(EN_Project *pr, int, int, int); /* Checks for parallel links */
|
int paralink(EN_Project *pr, int, int, int); /* Checks for parallel links */
|
||||||
void xparalinks(EN_Project *pr); /* Removes parallel links */
|
void xparalinks(EN_Project *pr); /* Removes parallel links */
|
||||||
void freelists(EN_Project *pr); /* Frees adjacency lists */
|
void freelists(EN_Project *pr); /* Frees adjacency lists */
|
||||||
void countdegree(EN_Project *pr); /* Counts links at each node */
|
void countdegree(EN_Project *pr); /* Counts links at each node */
|
||||||
int reordernodes(EN_Project *pr); /* Finds a node re-ordering */
|
int reordernodes(EN_Project *pr); /* Finds a node re-ordering */
|
||||||
int mindegree(solver_t *s, int, int); /* Finds min. degree node */
|
int mindegree(solver_t *s, int, int); /* Finds min. degree node */
|
||||||
int growlist(EN_Project *pr, int); /* Augments adjacency list */
|
int growlist(EN_Project *pr, int); /* Augments adjacency list */
|
||||||
int newlink(EN_Project *pr, Padjlist); /* Adds fill-ins for a node */
|
int newlink(EN_Project *pr, Padjlist); /* Adds fill-ins for a node */
|
||||||
int linked(EN_Network *net, int, int); /* Checks if 2 nodes linked */
|
int linked(EN_Network *net, int, int); /* Checks if 2 nodes linked */
|
||||||
int addlink(EN_Network *net, int, int, int); /* Creates new fill-in */
|
int addlink(EN_Network *net, int, int, int); /* Creates new fill-in */
|
||||||
int storesparse(EN_Project *pr, int); /* Stores sparse matrix */
|
int storesparse(EN_Project *pr, int); /* Stores sparse matrix */
|
||||||
int ordersparse(hydraulics_t *h, int); /* Orders matrix storage */
|
int ordersparse(hydraulics_t *h, int); /* Orders matrix storage */
|
||||||
void transpose(int,int *,int *, /* Transposes sparse matrix */
|
void transpose(int,int *,int *, /* Transposes sparse matrix */
|
||||||
int *,int *,int *,int *,int *);
|
int *,int *,int *,int *,int *);
|
||||||
int linsolve(solver_t *s, int); /* via Cholesky factorization */
|
int linsolve(solver_t *s, int); /* Solves set of linear eqns. */
|
||||||
|
|
||||||
/* ----------- QUALITY.C ---------------*/
|
/* ----------- QUALITY.C ---------------*/
|
||||||
int openqual(EN_Project *pr); /* Opens WQ solver system */
|
int openqual(EN_Project *pr); /* Opens WQ solver system */
|
||||||
void initqual(EN_Project *pr); /* Initializes WQ solver */
|
void initqual(EN_Project *pr); /* Initializes WQ solver */
|
||||||
int runqual(EN_Project *pr, long *); /* Gets current WQ results */
|
int runqual(EN_Project *pr, long *); /* Gets current WQ results */
|
||||||
int nextqual(EN_Project *pr, long *); /* Updates WQ by hyd.timestep */
|
int nextqual(EN_Project *pr, long *); /* Updates WQ by hyd.timestep */
|
||||||
int stepqual(EN_Project *pr, long *); /* Updates WQ by WQ time step */
|
int stepqual(EN_Project *pr, long *); /* Updates WQ by WQ time step */
|
||||||
int closequal(EN_Project *pr); /* Closes WQ solver system */
|
int closequal(EN_Project *pr); /* Closes WQ solver system */
|
||||||
int gethyd(EN_Project *pr, long *, long *); /* Gets next hyd. results */
|
int gethyd(EN_Project *pr, long *, long *); /* Gets next hyd. results */
|
||||||
char setReactflag(EN_Project *pr); /* Checks for reactive chem. */
|
char setReactflag(EN_Project *pr); /* Checks for reactive chem. */
|
||||||
void transport(EN_Project *pr, long); /* Transports mass in network */
|
void transport(EN_Project *pr, long); /* Transports mass in network */
|
||||||
void initsegs(EN_Project *pr); /* Initializes WQ segments */
|
void initsegs(EN_Project *pr); /* Initializes WQ segments */
|
||||||
void reorientsegs(EN_Project *pr); /* Re-orients WQ segments */
|
void reorientsegs(EN_Project *pr); /* Re-orients WQ segments */
|
||||||
void updatesegs(EN_Project *pr, long); /* Updates quality in segments*/
|
void updatesegs(EN_Project *pr, long); /* Updates quality in segments*/
|
||||||
void removesegs(EN_Project *pr, int); /* Removes a WQ segment */
|
void removesegs(EN_Project *pr, int); /* Removes a WQ segment */
|
||||||
void addseg(EN_Project *pr, int,double,double); /* Adds a WQ segment to pipe */
|
void addseg(EN_Project *pr, int,double,double); /* Adds a WQ segment to pipe */
|
||||||
void accumulate(EN_Project *pr, long); /* Sums mass flow into node */
|
void accumulate(EN_Project *pr, long); /* Sums mass flow into node */
|
||||||
void updatenodes(EN_Project *pr, long); /* Updates WQ at nodes */
|
void updatenodes(EN_Project *pr, long); /* Updates WQ at nodes */
|
||||||
void sourceinput(EN_Project *pr, long); /* Computes source inputs */
|
void sourceinput(EN_Project *pr, long); /* Computes source inputs */
|
||||||
void release(EN_Project *pr, long); /* Releases mass from nodes */
|
void release(EN_Project *pr, long); /* Releases mass from nodes */
|
||||||
void updatetanks(EN_Project *pr, long); /* Updates WQ in tanks */
|
void updatetanks(EN_Project *pr, long); /* Updates WQ in tanks */
|
||||||
void updatesourcenodes(EN_Project *pr, long); /* Updates WQ at source nodes */
|
void updatesourcenodes(EN_Project *pr, long); /* Updates WQ at source nodes */
|
||||||
void tankmix1(EN_Project *pr, int, long); /* Complete mix tank model */
|
void tankmix1(EN_Project *pr, int, long); /* Complete mix tank model */
|
||||||
void tankmix2(EN_Project *pr, int, long); /* 2-compartment tank model */
|
void tankmix2(EN_Project *pr, int, long); /* 2-compartment tank model */
|
||||||
void tankmix3(EN_Project *pr, int, long); /* FIFO tank model */
|
void tankmix3(EN_Project *pr, int, long); /* FIFO tank model */
|
||||||
void tankmix4(EN_Project *pr, int, long); /* LIFO tank model */
|
void tankmix4(EN_Project *pr, int, long); /* LIFO tank model */
|
||||||
double sourcequal(EN_Project *pr, Psource); /* Finds WQ input from source */
|
double sourcequal(EN_Project *pr, Psource); /* Finds WQ input from source */
|
||||||
double avgqual(EN_Project *pr, int); /* Finds avg. quality in pipe */
|
double avgqual(EN_Project *pr, int); /* Finds avg. quality in pipe */
|
||||||
void ratecoeffs(EN_Project *pr); /* Finds wall react. coeffs. */
|
void ratecoeffs(EN_Project *pr); /* Finds wall react. coeffs. */
|
||||||
double piperate(EN_Project *pr, int); /* Finds wall react. coeff. */
|
double piperate(EN_Project *pr, int); /* Finds wall react. coeff. */
|
||||||
double pipereact(EN_Project *pr, int,double,double,long);/* Reacts water in a pipe */
|
double pipereact(EN_Project *pr, int,double,
|
||||||
double tankreact(EN_Project *pr, double,double,double,long); /* Reacts water in a tank */
|
double,long); /* Reacts water in a pipe */
|
||||||
double bulkrate(EN_Project *pr, double,double,double); /* Finds bulk reaction rate */
|
double tankreact(EN_Project *pr, double,double,
|
||||||
double wallrate(EN_Project *pr, double,double,double,double);/* Finds wall reaction rate */
|
double,long); /* Reacts water in a tank */
|
||||||
|
double bulkrate(EN_Project *pr, double,double,
|
||||||
|
double); /* Finds bulk reaction rate */
|
||||||
|
double wallrate(EN_Project *pr, double,double,
|
||||||
|
double,double); /* Finds wall reaction rate */
|
||||||
|
|
||||||
|
|
||||||
/* ------------ OUTPUT.C ---------------*/
|
/* ------------ OUTPUT.C ---------------*/
|
||||||
int savenetdata(EN_Project *pr); /* Saves basic data to file */
|
int savenetdata(EN_Project *pr); /* Saves basic data to file */
|
||||||
int savehyd(EN_Project *pr, long *); /* Saves hydraulic solution */
|
int savehyd(EN_Project *pr, long *); /* Saves hydraulic solution */
|
||||||
int savehydstep(EN_Project *pr, long *); /* Saves hydraulic timestep */
|
int savehydstep(EN_Project *pr, long *); /* Saves hydraulic timestep */
|
||||||
int saveenergy(EN_Project *pr); /* Saves energy usage */
|
int saveenergy(EN_Project *pr); /* Saves energy usage */
|
||||||
int readhyd(EN_Project *pr, long *); /* Reads hydraulics from file */
|
int readhyd(EN_Project *pr, long *); /* Reads hydraulics from file */
|
||||||
int readhydstep(FILE *hydFile, long *); /* Reads time step from file */
|
int readhydstep(FILE *hydFile, long *); /* Reads time step from file */
|
||||||
int saveoutput(EN_Project *pr); /* Saves results to file */
|
int saveoutput(EN_Project *pr); /* Saves results to file */
|
||||||
int nodeoutput(EN_Project *pr, int, REAL4 *, double); /* Saves node results to file */
|
int nodeoutput(EN_Project *pr, int, REAL4 *,
|
||||||
int linkoutput(EN_Project *pr, int, REAL4 *, double); /* Saves link results to file */
|
double); /* Saves node results to file */
|
||||||
|
int linkoutput(EN_Project *pr, int, REAL4 *,
|
||||||
|
double); /* Saves link results to file */
|
||||||
int savefinaloutput(EN_Project *pr); /* Finishes saving output */
|
int savefinaloutput(EN_Project *pr); /* Finishes saving output */
|
||||||
int savetimestat(EN_Project *pr, REAL4 *, HdrType); /* Saves time stats to file */
|
int savetimestat(EN_Project *pr, REAL4 *,
|
||||||
int savenetreacts(EN_Project *pr, double, double,double, double);
|
HdrType); /* Saves time stats to file */
|
||||||
/* Saves react. rates to file */
|
int savenetreacts(EN_Project *pr, double,
|
||||||
|
double,double, double); /* Saves react. rates to file */
|
||||||
int saveepilog(EN_Project *pr); /* Saves output file epilog */
|
int saveepilog(EN_Project *pr); /* Saves output file epilog */
|
||||||
|
|
||||||
|
|
||||||
/* ------------ INPFILE.C --------------*/
|
/* ------------ INPFILE.C --------------*/
|
||||||
int saveinpfile(EN_Project *pr, char *); /* Saves network to text file */
|
int saveinpfile(EN_Project *pr, char *); /* Saves network to text file */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -680,6 +680,7 @@ void demands(EN_Project *pr)
|
|||||||
setlinksetting(pr, i, net->Pattern[j].F[k], &hyd->LinkStatus[i], &hyd->LinkSetting[i]);
|
setlinksetting(pr, i, net->Pattern[j].F[k], &hyd->LinkStatus[i], &hyd->LinkSetting[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* End of demands */
|
} /* End of demands */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,7 @@ AUTHOR: L. Rossman
|
|||||||
--------------------- Module Global Variables ----------------------
|
--------------------- Module Global Variables ----------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAXITER \
|
#define MAXITER 200 /* Default max. # hydraulic iterations */
|
||||||
200 /* Default max. # hydraulic iterations */
|
|
||||||
#define HACC 0.001 /* Default hydraulics convergence ratio */
|
#define HACC 0.001 /* Default hydraulics convergence ratio */
|
||||||
#define HTOL 0.0005 /* Default hydraulic head tolerance (ft) */
|
#define HTOL 0.0005 /* Default hydraulic head tolerance (ft) */
|
||||||
|
|
||||||
@@ -62,8 +61,7 @@ AUTHOR: L. Rossman
|
|||||||
#define RQTOL 1E-7 /* Default low flow resistance tolerance */
|
#define RQTOL 1E-7 /* Default low flow resistance tolerance */
|
||||||
#define CHECKFREQ 2 /* Default status check frequency */
|
#define CHECKFREQ 2 /* Default status check frequency */
|
||||||
#define MAXCHECK 10 /* Default # iterations for status checks */
|
#define MAXCHECK 10 /* Default # iterations for status checks */
|
||||||
#define DAMPLIMIT \
|
#define DAMPLIMIT 0 /* Default damping threshold */
|
||||||
0 /* Default damping threshold */
|
|
||||||
|
|
||||||
extern char *Fldname[]; /* Defined in enumstxt.h in EPANET.C */
|
extern char *Fldname[]; /* Defined in enumstxt.h in EPANET.C */
|
||||||
extern char *RptFlowUnitsTxt[];
|
extern char *RptFlowUnitsTxt[];
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ int savenetdata(EN_Project *pr)
|
|||||||
ibuf[0] = MAGICNUMBER;
|
ibuf[0] = MAGICNUMBER;
|
||||||
|
|
||||||
/*** CODEVERSION replaces VERSION ***/
|
/*** CODEVERSION replaces VERSION ***/
|
||||||
ibuf[1] = CODEVERSION;
|
//ibuf[1] = CODEVERSION;
|
||||||
|
ibuf[1] = 20012; // keep version at 2.00.12 so that GUI will run
|
||||||
|
|
||||||
ibuf[2] = net->Nnodes;
|
ibuf[2] = net->Nnodes;
|
||||||
ibuf[3] = net->Ntanks;
|
ibuf[3] = net->Ntanks;
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ void initqual(EN_Project *pr)
|
|||||||
net->Node[i].S->Smass = 0.0;
|
net->Node[i].S->Smass = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qu->QTempVolumes =
|
||||||
|
calloc(net->Ntanks,
|
||||||
|
sizeof(double)); // keep track of next tank volumes.
|
||||||
qu->QTankVolumes =
|
qu->QTankVolumes =
|
||||||
calloc(net->Ntanks,
|
calloc(net->Ntanks,
|
||||||
sizeof(double)); // keep track of previous step's tank volumes.
|
sizeof(double)); // keep track of previous step's tank volumes.
|
||||||
@@ -287,7 +290,7 @@ int nextqual(EN_Project *pr, long *tstep)
|
|||||||
{
|
{
|
||||||
long hydstep; /* Hydraulic solution time step */
|
long hydstep; /* Hydraulic solution time step */
|
||||||
int errcode = 0;
|
int errcode = 0;
|
||||||
double *tankVolumes;
|
//double *tankVolumes = NULL;
|
||||||
int i;
|
int i;
|
||||||
EN_Network *net;
|
EN_Network *net;
|
||||||
hydraulics_t *hyd;
|
hydraulics_t *hyd;
|
||||||
@@ -315,10 +318,10 @@ int nextqual(EN_Project *pr, long *tstep)
|
|||||||
// if we're operating in stepwise mode, capture the tank levels so we can
|
// if we're operating in stepwise mode, capture the tank levels so we can
|
||||||
// restore them later.
|
// restore them later.
|
||||||
if (hyd->OpenHflag) {
|
if (hyd->OpenHflag) {
|
||||||
tankVolumes = calloc(net->Ntanks, sizeof(double));
|
//tankVolumes = calloc(net->Ntanks, sizeof(double));
|
||||||
for (i = 1; i <= net->Ntanks; ++i) {
|
for (i = 1; i <= net->Ntanks; ++i) {
|
||||||
if (net->Tank[i].A != 0) { // skip reservoirs
|
if (net->Tank[i].A != 0) { // skip reservoirs
|
||||||
tankVolumes[i - 1] = net->Tank[i].V;
|
qu->QTempVolumes[i - 1] = net->Tank[i].V;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +362,7 @@ int nextqual(EN_Project *pr, long *tstep)
|
|||||||
for (i = 1; i <= net->Ntanks; i++) {
|
for (i = 1; i <= net->Ntanks; i++) {
|
||||||
if (net->Tank[i].A != 0) { // skip reservoirs again
|
if (net->Tank[i].A != 0) { // skip reservoirs again
|
||||||
int n = net->Tank[i].Node;
|
int n = net->Tank[i].Node;
|
||||||
net->Tank[i].V = tankVolumes[i - 1];
|
net->Tank[i].V = qu->QTempVolumes[i - 1];
|
||||||
hyd->NodeHead[n] = tankgrade(pr, i, net->Tank[i].V);
|
hyd->NodeHead[n] = tankgrade(pr, i, net->Tank[i].V);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,7 +373,7 @@ int nextqual(EN_Project *pr, long *tstep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(tankVolumes);
|
//free(tankVolumes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (errcode);
|
return (errcode);
|
||||||
@@ -448,6 +451,7 @@ int closequal(EN_Project *pr)
|
|||||||
free(qu->MassIn);
|
free(qu->MassIn);
|
||||||
free(qu->PipeRateCoeff);
|
free(qu->PipeRateCoeff);
|
||||||
free(qu->TempQual);
|
free(qu->TempQual);
|
||||||
|
free(qu->QTempVolumes);
|
||||||
free(qu->QTankVolumes);
|
free(qu->QTankVolumes);
|
||||||
free(qu->QLinkFlow);
|
free(qu->QLinkFlow);
|
||||||
return (errcode);
|
return (errcode);
|
||||||
|
|||||||
@@ -542,6 +542,7 @@ typedef struct {
|
|||||||
Climit, /// Limiting potential quality
|
Climit, /// Limiting potential quality
|
||||||
*NodeQual, /// Node quality state
|
*NodeQual, /// Node quality state
|
||||||
*TempQual, /// General purpose array for water quality
|
*TempQual, /// General purpose array for water quality
|
||||||
|
*QTempVolumes,
|
||||||
*QTankVolumes,
|
*QTankVolumes,
|
||||||
*QLinkFlow,
|
*QLinkFlow,
|
||||||
*PipeRateCoeff;
|
*PipeRateCoeff;
|
||||||
@@ -551,12 +552,12 @@ typedef struct {
|
|||||||
Qtime; /// Current quality time (sec)
|
Qtime; /// Current quality time (sec)
|
||||||
|
|
||||||
char OutOfMemory; /* Out of memory indicator */
|
char OutOfMemory; /* Out of memory indicator */
|
||||||
alloc_handle_t *SegPool; // Memory pool for water quality segments
|
alloc_handle_t *SegPool; // Memory pool for water quality segments
|
||||||
|
|
||||||
Pseg FreeSeg; /* Pointer to unused segment */
|
Pseg FreeSeg; /* Pointer to unused segment */
|
||||||
Pseg *FirstSeg, /* First (downstream) segment in each pipe */
|
Pseg *FirstSeg, /* First (downstream) segment in each pipe */
|
||||||
*LastSeg; /* Last (upstream) segment in each pipe */
|
*LastSeg; /* Last (upstream) segment in each pipe */
|
||||||
FlowDirection *FlowDir; /* Flow direction for each pipe */
|
FlowDirection *FlowDir; /* Flow direction for each pipe */
|
||||||
double *VolIn; /* Total volume inflow to node */
|
double *VolIn; /* Total volume inflow to node */
|
||||||
double *MassIn; /* Total mass inflow to node */
|
double *MassIn; /* Total mass inflow to node */
|
||||||
double Sc; /* Schmidt Number */
|
double Sc; /* Schmidt Number */
|
||||||
|
|||||||
Reference in New Issue
Block a user