EPANET  2.1
 All Data Structures Files Functions Modules Pages
funcs.h
1 /*
2 **************************************************************************
3 
4 FUNCS.H -- Function Prototypes for EPANET Program
5 
6 VERSION: 2.00
7 DATE: 5/8/00
8  9/25/00
9  10/25/00
10  12/29/00
11  3/1/01
12  2/14/08 (2.00.12)
13 AUTHOR: L. Rossman
14  US EPA - NRMRL
15 
16 **************************************************************************
17 */
18 
19 /*****************************************************************/
20 /* Most float arguments have been changed to double - 7/3/07 */
21 /*****************************************************************/
22 
23 /* ------- EPANET.C --------------------*/
24 /*
25 ** NOTE: The exportable functions that can be called
26 ** via the DLL are prototyped in TOOLKIT.H.
27 */
28 
29 #ifndef FUNCS_H
30 #define FUNCS_H
31 
32 void initpointers(void); /* Initializes pointers */
33 int allocdata(void); /* Allocates memory */
34 void freeTmplist(STmplist *); /* Frees items in linked list */
35 void freeFloatlist(SFloatlist *); /* Frees list of floats */
36 void freedata(void); /* Frees allocated memory */
37 int openfiles(char *,char *,char *); /* Opens input & report files */
38 int openhydfile(void); /* Opens hydraulics file */
39 int openoutfile(void); /* Opens binary output file */
40 int strcomp(char *, char *); /* Compares two strings */
41 char* getTmpName(char* fname); /* Gets temporary file name */ //(2.00.12 - LR)
42 double interp(int, double *, /* Interpolates a data curve */
43  double *, double);
44 int findnode(char *); /* Finds node's index from ID */
45 int findlink(char *); /* Finds link's index from ID */
46 char* geterrmsg(int); /* Gets text of error message */
47 void errmsg(int); /* Reports program error */
48 void writecon(char *); /* Writes text to console */
49 void writewin(char *); /* Passes text to calling app */
50 
51 /* ------- INPUT1.C --------------------*/
52 int getdata(void); /* Gets network data */
53 void setdefaults(void); /* Sets default values */
54 void initreport(void); /* Initializes report options */
55 void adjustdata(void); /* Adjusts input data */
56 int inittanks(void); /* Initializes tank levels */
57 void initunits(void); /* Determines reporting units */
58 void convertunits(void); /* Converts data to std. units*/
59 
60 /* -------- INPUT2.C -------------------*/
61 int netsize(void); /* Determines network size */
62 int readdata(void); /* Reads in network data */
63 int newline(int, char *); /* Processes new line of data */
64 int addnodeID(int, char *); /* Adds node ID to data base */
65 int addlinkID(int, char *); /* Adds link ID to data base */
66 int addpattern(char *); /* Adds pattern to data base */
67 int addcurve(char *); /* Adds curve to data base */
68 STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
69 int unlinked(void); /* Checks for unlinked nodes */
70 int getpumpparams(void); /* Computes pump curve coeffs.*/
71 int getpatterns(void); /* Gets pattern data from list*/
72 int getcurves(void); /* Gets curve data from list */
73 int findmatch(char *,char *[]); /* Finds keyword in line */
74 int match(char *, char *); /* Checks for word match */
75 int gettokens(char *); /* Tokenizes input line */
76 int getfloat(char *, double *); /* Converts string to double */
77 double hour(char *, char *); /* Converts time to hours */
78 int setreport(char *); /* Processes reporting command*/
79 void inperrmsg(int,int,char *); /* Input error message */
80 
81 /* ---------- INPUT3.C -----------------*/
82 int juncdata(void); /* Processes junction data */
83 int tankdata(void); /* Processes tank data */
84 int pipedata(void); /* Processes pipe data */
85 int pumpdata(void); /* Processes pump data */
86 int valvedata(void); /* Processes valve data */
87 int patterndata(void); /* Processes pattern data */
88 int curvedata(void); /* Processes curve data */
89 int coordata(void); /* Processes coordinate data */
90 int demanddata(void); /* Processes demand data */
91 int controldata(void); /* Processes simple controls */
92 int energydata(void); /* Processes energy data */
93 int sourcedata(void); /* Processes source data */
94 int emitterdata(void); /* Processes emitter data */
95 int qualdata(void); /* Processes quality data */
96 int reactdata(void); /* Processes reaction data */
97 int mixingdata(void); /* Processes tank mixing data */
98 int statusdata(void); /* Processes link status data */
99 int reportdata(void); /* Processes report options */
100 int timedata(void); /* Processes time options */
101 int optiondata(void); /* Processes analysis options */
102 int optionchoice(int); /* Processes option choices */
103 int optionvalue(int); /* Processes option values */
104 int getpumpcurve(int); /* Constructs a pump curve */
105 int powercurve(double, double, double,/* Coeffs. of power pump curve*/
106  double, double, double *,
107  double *, double *);
108 int valvecheck(int, int, int); /* Checks valve placement */
109 void changestatus(int, char, double); /* Changes status of a link */
110 
111 /* -------------- RULES.C --------------*/
112 void initrules(void); /* Initializes rule base */
113 void addrule(char *); /* Adds rule to rule base */
114 int allocrules(void); /* Allocates memory for rule */
115 int ruledata(void); /* Processes rule input data */
116 int checkrules(long); /* Checks all rules */
117 void freerules(void); /* Frees rule base memory */
118 
119 /* ------------- REPORT.C --------------*/
120 int writereport(void); /* Writes formatted report */
121 void writelogo(void); /* Writes program logo */
122 void writesummary(void); /* Writes network summary */
123 void writehydstat(int,double); /* Writes hydraulic status */
124 void writeenergy(void); /* Writes energy usage */
125 int writeresults(void); /* Writes node/link results */
126 void writeheader(int,int); /* Writes heading on report */
127 void writeline(char *); /* Writes line to report file */
128 void writerelerr(int, double); /* Writes convergence error */
129 void writestatchange(int,char,char); /* Writes link status change */
130 void writecontrolaction(int, int); /* Writes control action taken*/
131 void writeruleaction(int, char *); /* Writes rule action taken */
132 int writehydwarn(int,double); /* Writes hydraulic warnings */
133 void writehyderr(int); /* Writes hydraulic error msg.*/
134 int disconnected(void); /* Checks for disconnections */
135 void marknodes(int, int *, char *); /* Identifies connected nodes */
136 void getclosedlink(int, char *); /* Finds a disconnecting link */
137 void writelimits(int,int); /* Writes reporting limits */
138 int checklimits(double *,int,int); /* Checks variable limits */
139 void writetime(char *); /* Writes current clock time */
140 char *clocktime(char *, long); /* Converts time to hrs:min */
141 char *fillstr(char *, char, int); /* Fills string with character*/
142 int getnodetype(int); /* Determines node type */
143 
144 /* --------- HYDRAUL.C -----------------*/
145 int openhyd(void); /* Opens hydraulics solver */
146 
147 /*** Updated 3/1/01 ***/
148 void inithyd(int); /* Re-sets initial conditions */
149 
150 int runhyd(long *); /* Solves 1-period hydraulics */
151 int nexthyd(long *); /* Moves to next time period */
152 void closehyd(void); /* Closes hydraulics solver */
153 int allocmatrix(void); /* Allocates matrix coeffs. */
154 void freematrix(void); /* Frees matrix coeffs. */
155 void initlinkflow(int, char, double); /* Initializes link flow */
156 void setlinkflow(int, double); /* Sets link flow via headloss*/
157 void setlinkstatus(int, char, char *, /* Sets link status */
158  double *);
159 void setlinksetting(int, double, /* Sets pump/valve setting */
160  char *, double *);
161 void resistance(int); /* Computes resistance coeff. */
162 void demands(void); /* Computes current demands */
163 int controls(void); /* Controls link settings */
164 long timestep(void); /* Computes new time step */
165 void tanktimestep(long *); /* Time till tanks fill/drain */
166 void controltimestep(long *); /* Time till control action */
167 void ruletimestep(long *); /* Time till rule action */
168 void addenergy(long); /* Accumulates energy usage */
169 void getenergy(int, double *, double *); /* Computes link energy use */
170 void tanklevels(long); /* Computes new tank levels */
171 double tankvolume(int,double); /* Finds tank vol. from grade */
172 double tankgrade(int,double); /* Finds tank grade from vol. */
173 int netsolve(int *,double *); /* Solves network equations */
174 int badvalve(int); /* Checks for bad valve */
175 int valvestatus(void); /* Updates valve status */
176 int linkstatus(void); /* Updates link status */
177 char cvstatus(char,double,double); /* Updates CV status */
178 char pumpstatus(int,double); /* Updates pump status */
179 char prvstatus(int,char,double, /* Updates PRV status */
180  double,double);
181 char psvstatus(int,char,double, /* Updates PSV status */
182  double,double);
183 char fcvstatus(int,char,double, /* Updates FCV status */
184  double);
185 void tankstatus(int,int,int); /* Checks if tank full/empty */
186 int pswitch(void); /* Pressure switch controls */
187 double newflows(void); /* Updates link flows */
188 void newcoeffs(void); /* Computes matrix coeffs. */
189 void linkcoeffs(void); /* Computes link coeffs. */
190 void nodecoeffs(void); /* Computes node coeffs. */
191 void valvecoeffs(void); /* Computes valve coeffs. */
192 void pipecoeff(int); /* Computes pipe coeff. */
193 double DWcoeff(int, double *); /* Computes D-W coeff. */
194 void pumpcoeff(int); /* Computes pump coeff. */
195 
196 /*** Updated 10/25/00 ***/
197 /*** Updated 12/29/00 ***/
198 void curvecoeff(int,double,double *, /* Computes curve coeffs. */
199  double *);
200 
201 void gpvcoeff(int); /* Computes GPV coeff. */
202 void pbvcoeff(int); /* Computes PBV coeff. */
203 void tcvcoeff(int); /* Computes TCV coeff. */
204 void prvcoeff(int,int,int); /* Computes PRV coeff. */
205 void psvcoeff(int,int,int); /* Computes PSV coeff. */
206 void fcvcoeff(int,int,int); /* Computes FCV coeff. */
207 void emittercoeffs(void); /* Computes emitter coeffs. */
208 double emitflowchange(int); /* Computes new emitter flow */
209 
210 /* ----------- SMATRIX.C ---------------*/
211 int createsparse(void); /* Creates sparse matrix */
212 int allocsparse(void); /* Allocates matrix memory */
213 void freesparse(void); /* Frees matrix memory */
214 int buildlists(int); /* Builds adjacency lists */
215 int paralink(int, int, int); /* Checks for parallel links */
216 void xparalinks(void); /* Removes parallel links */
217 void freelists(void); /* Frees adjacency lists */
218 void countdegree(void); /* Counts links at each node */
219 int reordernodes(void); /* Finds a node re-ordering */
220 int mindegree(int, int); /* Finds min. degree node */
221 int growlist(int); /* Augments adjacency list */
222 int newlink(Padjlist); /* Adds fill-ins for a node */
223 int linked(int, int); /* Checks if 2 nodes linked */
224 int addlink(int, int, int); /* Creates new fill-in */
225 int storesparse(int); /* Stores sparse matrix */
226 int ordersparse(int); /* Orders matrix storage */
227 void transpose(int,int *,int *, /* Transposes sparse matrix */
228  int *,int *,int *,int *,int *);
229 int linsolve(int, double *, double *, /* Solution of linear eqns. */
230  double *); /* via Cholesky factorization */
231 
232 /* ----------- QUALITY.C ---------------*/
233 int openqual(void); /* Opens WQ solver system */
234 void initqual(void); /* Initializes WQ solver */
235 int runqual(long *); /* Gets current WQ results */
236 int nextqual(long *); /* Updates WQ by hyd.timestep */
237 int stepqual(long *); /* Updates WQ by WQ time step */
238 int closequal(void); /* Closes WQ solver system */
239 int gethyd(long *, long *); /* Gets next hyd. results */
240 char setReactflag(void); /* Checks for reactive chem. */
241 void transport(long); /* Transports mass in network */
242 void initsegs(void); /* Initializes WQ segments */
243 void reorientsegs(void); /* Re-orients WQ segments */
244 void updatesegs(long); /* Updates quality in segments*/
245 void removesegs(int); /* Removes a WQ segment */
246 void addseg(int,double,double); /* Adds a WQ segment to pipe */
247 void accumulate(long); /* Sums mass flow into node */
248 void updatenodes(long); /* Updates WQ at nodes */
249 void sourceinput(long); /* Computes source inputs */
250 void release(long); /* Releases mass from nodes */
251 void updatetanks(long); /* Updates WQ in tanks */
252 void updatesourcenodes(long); /* Updates WQ at source nodes */
253 void tankmix1(int, long); /* Complete mix tank model */
254 void tankmix2(int, long); /* 2-compartment tank model */
255 void tankmix3(int, long); /* FIFO tank model */
256 void tankmix4(int, long); /* LIFO tank model */
257 double sourcequal(Psource); /* Finds WQ input from source */
258 double avgqual(int); /* Finds avg. quality in pipe */
259 void ratecoeffs(void); /* Finds wall react. coeffs. */
260 double piperate(int); /* Finds wall react. coeff. */
261 double pipereact(int,double,double,long);/* Reacts water in a pipe */
262 double tankreact(double,double,double,
263  long); /* Reacts water in a tank */
264 double bulkrate(double,double,double); /* Finds bulk reaction rate */
265 double wallrate(double,double,double,double);/* Finds wall reaction rate */
266 
267 
268 /* ------------ OUTPUT.C ---------------*/
269 int savenetdata(void); /* Saves basic data to file */
270 int savehyd(long *); /* Saves hydraulic solution */
271 int savehydstep(long *); /* Saves hydraulic timestep */
272 int saveenergy(void); /* Saves energy usage */
273 int readhyd(long *); /* Reads hydraulics from file */
274 int readhydstep(long *); /* Reads time step from file */
275 int saveoutput(void); /* Saves results to file */
276 int nodeoutput(int, REAL4 *, double); /* Saves node results to file */
277 int linkoutput(int, REAL4 *, double); /* Saves link results to file */
278 int savefinaloutput(void); /* Finishes saving output */
279 int savetimestat(REAL4 *, char); /* Saves time stats to file */
280 int savenetreacts(double, double,
281  double, double); /* Saves react. rates to file */
282 int saveepilog(void); /* Saves output file epilog */
283 
284 
285 /* ------------ INPFILE.C --------------*/
286 int saveinpfile(char *); /* Saves network to text file */
287 
288 #endif
Definition: types.h:137
Definition: types.h:287
Definition: types.h:186
Definition: types.h:144