EPANET  2.1
vars.h
1 /*
2 ************************************************************************
3  Global Variables for EPANET Program
4 
5 VERSION: 2.00
6 DATE: 5/8/00
7  6/24/02
8  2/14/08 (2.00.12)
9 AUTHOR: L. Rossman
10  US EPA - NRMRL
11 
12 ************************************************************************
13 */
14 #ifndef VARS_H
15 #define VARS_H
16 
17 #include <stdio.h>
18 #include "hash.h"
19 
20 EXTERN FILE *InFile, /* Input file pointer */
21  *OutFile, /* Output file pointer */
22  *RptFile, /* Report file pointer */
23  *HydFile, /* Hydraulics file pointer */
24  *TmpOutFile; /* Temporary file handle */
25 EXTERN long HydOffset, /* Hydraulics file byte offset */
26  OutOffset1, /* 1st output file byte offset */
27  OutOffset2; /* 2nd output file byte offset */
28 EXTERN char Msg[MAXMSG+1], /* Text of output message */
29  InpFname[MAXFNAME+1], /* Input file name */
30  Rpt1Fname[MAXFNAME+1], /* Primary report file name */
31  Rpt2Fname[MAXFNAME+1], /* Secondary report file name */
32  HydFname[MAXFNAME+1], /* Hydraulics file name */
33  OutFname[MAXFNAME+1], /* Binary output file name */
34  MapFname[MAXFNAME+1], /* Map file name */
35  TmpFname[MAXFNAME+1], /* Temporary file name */ //(2.00.12 - LR)
36  TmpDir[MAXFNAME+1], /* Temporary directory name */ //(2.00.12 - LR)
37  Title[MAXTITLE][MAXMSG+1], /* Problem title */
38  ChemName[MAXID+1], /* Name of chemical */
39  ChemUnits[MAXID+1], /* Units of chemical */
40  DefPatID[MAXID+1], /* Default demand pattern ID */
41 
42 /*** Updated 6/24/02 ***/
43  Atime[13], /* Clock time (hrs:min:sec) */
44 
45  Outflag, /* Output file flag */ //(2.00.12 - LR)
46  Hydflag, /* Hydraulics flag */
47  Qualflag, /* Water quality flag */
48  Reactflag, /* Reaction indicator */ //(2.00.12 - LR)
49  Unitsflag, /* Unit system flag */
50  Flowflag, /* Flow units flag */
51  Pressflag, /* Pressure units flag */
52  Formflag, /* Hydraulic formula flag */
53  Rptflag, /* Report flag */
54  Summaryflag, /* Report summary flag */
55  Messageflag, /* Error/warning message flag */
56  Statflag, /* Status report flag */
57  Energyflag, /* Energy report flag */
58  Nodeflag, /* Node report flag */
59  Linkflag, /* Link report flag */
60  Tstatflag, /* Time statistics flag */
61  Warnflag, /* Warning flag */
62  Openflag, /* Input processed flag */
63  OpenHflag, /* Hydraul. system opened flag */
64  SaveHflag, /* Hydraul. results saved flag */
65  OpenQflag, /* Quality system opened flag */
66  SaveQflag, /* Quality results saved flag */
67  Saveflag, /* General purpose save flag */
68  Coordflag; /* Load coordinates flag */
69 EXTERN int MaxNodes, /* Node count from input file */
70  MaxLinks, /* Link count from input file */
71  MaxJuncs, /* Junction count */
72  MaxPipes, /* Pipe count */
73  MaxTanks, /* Tank count */
74  MaxPumps, /* Pump count */
75  MaxValves, /* Valve count */
76  MaxControls, /* Control count */
77  MaxRules, /* Rule count */
78  MaxPats, /* Pattern count */
79  MaxCurves, /* Curve count */
80  Nnodes, /* Number of network nodes */
81  Ntanks, /* Number of tanks */
82  Njuncs, /* Number of junction nodes */
83  Nlinks, /* Number of network links */
84  Npipes, /* Number of pipes */
85  Npumps, /* Number of pumps */
86  Nvalves, /* Number of valves */
87  Ncontrols, /* Number of simple controls */
88  Nrules, /* Number of control rules */
89  Npats, /* Number of time patterns */
90  Ncurves, /* Number of data curves */
91  Nperiods, /* Number of reporting periods */
92  Ncoeffs, /* Number of non-0 matrix coeffs*/
93  DefPat, /* Default demand pattern */
94  Epat, /* Energy cost time pattern */
95  MaxIter, /* Max. hydraulic trials */
96  ExtraIter, /* Extra hydraulic trials */
97  TraceNode, /* Source node for flow tracing */
98  PageSize, /* Lines/page in output report */
99  CheckFreq, /* Hydraulics solver parameter */
100  MaxCheck; /* Hydraulics solver parameter */
101 EXTERN double Ucf[MAXVAR], /* Unit conversion factors */
102  Ctol, /* Water quality tolerance */
103  Htol, /* Hydraulic head tolerance */
104  Qtol, /* Flow rate tolerance */
105  RQtol, /* Flow resistance tolerance */
106  Hexp, /* Exponent in headloss formula */
107  Qexp, /* Exponent in orifice formula */
108  Dmult, /* Demand multiplier */
109  Hacc, /* Hydraulics solution accuracy */
110  DampLimit, /* Solution damping threshold */ //(2.00.12 - LR)
111  BulkOrder, /* Bulk flow reaction order */
112  WallOrder, /* Pipe wall reaction order */
113  TankOrder, /* Tank reaction order */
114  Kbulk, /* Global bulk reaction coeff. */
115  Kwall, /* Global wall reaction coeff. */
116  Climit, /* Limiting potential quality */
117  Rfactor, /* Roughness-reaction factor */
118  Diffus, /* Diffusivity (sq ft/sec) */
119  Viscos, /* Kin. viscosity (sq ft/sec) */
120  SpGrav, /* Specific gravity */
121  Ecost, /* Base energy cost per kwh */
122  Dcost, /* Energy demand charge/kw/day */
123  Epump, /* Global pump efficiency */
124  Emax, /* Peak energy usage */
125  Dsystem, /* Total system demand */
126  Wbulk, /* Avg. bulk reaction rate */
127  Wwall, /* Avg. wall reaction rate */
128  Wtank, /* Avg. tank reaction rate */
129  Wsource; /* Avg. mass inflow */
130 EXTERN long Tstart, /* Starting time of day (sec) */
131  Hstep, /* Nominal hyd. time step (sec) */
132  Qstep, /* Quality time step (sec) */
133  Pstep, /* Time pattern time step (sec) */
134  Pstart, /* Starting pattern time (sec) */
135  Rstep, /* Reporting time step (sec) */
136  Rstart, /* Time when reporting starts */
137  Rtime, /* Next reporting time */
138  Htime, /* Current hyd. time (sec) */
139  Qtime, /* Current quality time (sec) */
140  Hydstep, /* Actual hydraulic time step */
141  Rulestep, /* Rule evaluation time step */
142  Dur; /* Duration of simulation (sec) */
143 EXTERN SField Field[MAXVAR]; /* Output reporting fields */
144 
145 /* Array pointers not allocated and freed in same routine */
146 EXTERN char *LinkStatus, /* Link status */
147  *OldStat; /* Previous link/tank status */
148 EXTERN double *NodeDemand, /* Node actual demand */
149  *NodeQual, /* Node actual quality */
150  *E, /* Emitter flows */
151  *LinkSetting, /* Link settings */
152  *Q, /* Link flows */
153  *PipeRateCoeff, /* Pipe reaction rate */
154  *X, /* General purpose array */
155  *TempQual; /* General purpose array for water quality */
156 EXTERN double *NodeHead; /* Node heads */
157 EXTERN double *QTankVolumes;
158 EXTERN double *QLinkFlow;
159 EXTERN STmplist *Patlist; /* Temporary time pattern list */
160 EXTERN STmplist *Curvelist; /* Temporary list of curves */
161 EXTERN Spattern *Pattern; /* Time patterns */
162 EXTERN Scurve *Curve; /* Curve data */
163 EXTERN Scoord *Coord; /* Coordinate data */
164 EXTERN Snode *Node; /* Node data */
165 EXTERN Slink *Link; /* Link data */
166 EXTERN Stank *Tank; /* Tank data */
167 EXTERN Spump *Pump; /* Pump data */
168 EXTERN Svalve *Valve; /* Valve data */
169 EXTERN Scontrol *Control; /* Control data */
170 EXTERN ENHashTable *NodeHashTable, *LinkHashTable; /* Hash tables for ID labels */
171 EXTERN Padjlist *Adjlist; /* Node adjacency lists */
172 EXTERN double _relativeError;
173 EXTERN int _iterations; /* Info about hydraulic solution */
174 
175 /*
176 ** NOTE: Hydraulic analysis of the pipe network at a given point in time
177 ** is done by repeatedly solving a linearized version of the
178 ** equations for conservation of flow & energy:
179 **
180 ** A*H = F
181 **
182 ** where H = vector of heads (unknowns) at each node,
183 ** F = vector of right-hand side coeffs.
184 ** A = square matrix of coeffs.
185 ** and both A and F are updated at each iteration until there is
186 ** negligible change in pipe flows.
187 **
188 ** Each row (or column) of A corresponds to a junction in the pipe
189 ** network. Each link (pipe, pump or valve) in the network has a
190 ** non-zero entry in the row-column of A that corresponds to its
191 ** end points. This results in A being symmetric and very sparse.
192 ** The following arrays are used to efficiently manage this sparsity:
193 */
194 
195 EXTERN double *Aii, /* Diagonal coeffs. of A */
196  *Aij, /* Non-zero, off-diagonal coeffs. of A */
197  *F; /* Right hand side coeffs. */
198 EXTERN double *P, /* Inverse headloss derivatives */
199  *Y; /* Flow correction factors */
200 EXTERN int *Order, /* Node-to-row of A */
201  *Row, /* Row-to-node of A */
202  *Ndx; /* Index of link's coeff. in Aij */
203 /*
204 ** The following arrays store the positions of the non-zero coeffs.
205 ** of the lower triangular portion of A whose values are stored in Aij:
206 */
207 EXTERN int *XLNZ, /* Start position of each column in NZSUB */
208  *NZSUB, /* Row index of each coeff. in each column */
209  *LNZ; /* Position of each coeff. in Aij array */
210 
211 #endif
Definition: types.h:275
Definition: types.h:245
Definition: types.h:154
Definition: hash.h:13
Definition: types.h:161
Definition: types.h:304
Definition: types.h:287
Definition: types.h:170
Definition: types.h:144
Definition: types.h:270
Definition: types.h:196
Definition: types.h:225