Merging changes from upstream dev
This commit is contained in:
65
src/epanet.c
65
src/epanet.c
@@ -436,6 +436,10 @@ int DLLEXPORT ENgetpumptype(int index, int *type) {
|
||||
return EN_getpumptype(_defaultModel, index, type);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetcurvetype(int curveindex, int *type) {
|
||||
return EN_getcurvetype(_defaultModel, curveindex, type);
|
||||
}
|
||||
|
||||
int DLLEXPORT ENgetnumdemands(int nodeIndex, int *numDemands) {
|
||||
return EN_getnumdemands(_defaultModel, nodeIndex, numDemands);
|
||||
}
|
||||
@@ -2231,6 +2235,7 @@ int DLLEXPORT EN_getlinkvalue(EN_ProjectHandle ph, int index, EN_LinkProperty co
|
||||
EN_API_FLOAT_TYPE *value) {
|
||||
double a, h, q, v = 0.0;
|
||||
int returnValue = 0;
|
||||
int pmp;
|
||||
|
||||
EN_Project *p = (EN_Project*)ph;
|
||||
|
||||
@@ -2246,8 +2251,6 @@ int DLLEXPORT EN_getlinkvalue(EN_ProjectHandle ph, int index, EN_LinkProperty co
|
||||
double *LinkFlows = hyd->LinkFlows;
|
||||
double *LinkSetting = hyd->LinkSetting;
|
||||
|
||||
|
||||
|
||||
/* Check for valid arguments */
|
||||
*value = 0.0;
|
||||
if (!p->Openflag)
|
||||
@@ -2363,6 +2366,38 @@ int DLLEXPORT EN_getlinkvalue(EN_ProjectHandle ph, int index, EN_LinkProperty co
|
||||
else
|
||||
v = 1.0;
|
||||
break;
|
||||
|
||||
case EN_STATE:
|
||||
v = hyd->LinkStatus[index];
|
||||
|
||||
if (Link[index].Type == EN_PUMP) {
|
||||
pmp = findpump(net, index);
|
||||
if (hyd->LinkStatus[index] >= OPEN) {
|
||||
if (hyd->LinkFlows[index] > hyd->LinkSetting[index] * Pump[pmp].Qmax)
|
||||
v = XFLOW;
|
||||
if (hyd->LinkFlows[index] < 0.0)
|
||||
v = XHEAD;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EN_CONST_POWER:
|
||||
v = 0;
|
||||
if (Link[index].Type == EN_PUMP) {
|
||||
pmp = findpump(net, index);
|
||||
if (Pump[pmp].Ptype == CONST_HP) {
|
||||
v = Link[index].Km; // Power in HP
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EN_SPEED:
|
||||
v = 0;
|
||||
if (Link[index].Type == EN_PUMP) {
|
||||
pmp = findpump(net, index);
|
||||
v = Link[index].Kc;
|
||||
}
|
||||
break;
|
||||
|
||||
case EN_SETTING:
|
||||
if (Link[index].Type == EN_PIPE || Link[index].Type == EN_CVPIPE) {
|
||||
@@ -3187,7 +3222,7 @@ int DLLEXPORT EN_addcurve(EN_ProjectHandle ph, char *id) {
|
||||
|
||||
strcpy(tmpCur[n].ID, id);
|
||||
tmpCur[n].Npts = 1;
|
||||
tmpCur[n].Type = -1;
|
||||
tmpCur[n].Type = G_CURVE;
|
||||
tmpCur[n].X = (double *)calloc(tmpCur[n].Npts, sizeof(double));
|
||||
tmpCur[n].Y = (double *)calloc(tmpCur[n].Npts, sizeof(double));
|
||||
if (tmpCur[n].X == NULL)
|
||||
@@ -3230,9 +3265,7 @@ int DLLEXPORT EN_setcurve(EN_ProjectHandle ph, int index, EN_API_FLOAT_TYPE *x,
|
||||
EN_Project *p = (EN_Project*)ph;
|
||||
|
||||
EN_Network *net = &p->network;
|
||||
Scurve *Curve = net->Curve;
|
||||
|
||||
|
||||
Scurve *Curve = net->Curve;
|
||||
int j;
|
||||
|
||||
/* Check for valid arguments */
|
||||
@@ -3265,12 +3298,9 @@ int DLLEXPORT EN_setcurvevalue(EN_ProjectHandle ph, int index, int pnt, EN_API_F
|
||||
EN_Project *p = (EN_Project*)ph;
|
||||
|
||||
EN_Network *net = &p->network;
|
||||
|
||||
Scurve *Curve = net->Curve;
|
||||
|
||||
const int Ncurves = net->Ncurves;
|
||||
|
||||
|
||||
if (!p->Openflag)
|
||||
return (102);
|
||||
if (index <= 0 || index > Ncurves)
|
||||
@@ -3594,7 +3624,8 @@ int DLLEXPORT EN_setheadcurveindex(EN_ProjectHandle ph, int index, int curveinde
|
||||
pump->Q0 /= Ucf[FLOW];
|
||||
pump->Qmax /= Ucf[FLOW];
|
||||
pump->Hmax /= Ucf[HEAD];
|
||||
|
||||
|
||||
p->network.Curve[curveindex].Type = P_CURVE;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -3617,6 +3648,18 @@ int DLLEXPORT EN_getpumptype(EN_ProjectHandle ph, int index, int *type) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
int DLLEXPORT EN_getcurvetype(EN_Project *p, int curveindex, int *type) {
|
||||
|
||||
EN_Network *net = &p->network;
|
||||
|
||||
if (!p->Openflag)
|
||||
return (102);
|
||||
if (curveindex < 1 || curveindex > net->Ncurves)
|
||||
return (206);
|
||||
*type = net->Curve[curveindex].Type;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------
|
||||
Functions for opening files
|
||||
@@ -3986,7 +4029,7 @@ int allocdata(EN_Project *p)
|
||||
}
|
||||
for (n = 0; n <= par->MaxCurves; n++) {
|
||||
net->Curve[n].Npts = 0;
|
||||
net->Curve[n].Type = -1;
|
||||
net->Curve[n].Type = G_CURVE;
|
||||
net->Curve[n].X = NULL;
|
||||
net->Curve[n].Y = NULL;
|
||||
}
|
||||
|
||||
18
src/funcs.h
18
src/funcs.h
@@ -196,24 +196,8 @@ void matrixcoeffs(EN_Project *pr); /* Finds hyd. matrix coeffs.
|
||||
|
||||
/* ----------- SMATRIX.C ---------------*/
|
||||
int createsparse(EN_Project *pr); /* Creates sparse matrix */
|
||||
int allocsparse(EN_Project *pr); /* Allocates matrix memory */
|
||||
void freesparse(EN_Project *pr); /* Frees matrix memory */
|
||||
int buildlists(EN_Project *pr, int); /* Builds adjacency lists */
|
||||
int paralink(EN_Project *pr, int, int, int); /* Checks for parallel links */
|
||||
void xparalinks(EN_Project *pr); /* Removes parallel links */
|
||||
void freelists(EN_Project *pr); /* Frees adjacency lists */
|
||||
void countdegree(EN_Project *pr); /* Counts links at each node */
|
||||
int reordernodes(EN_Project *pr); /* Finds a node re-ordering */
|
||||
int mindegree(solver_t *s, int, int); /* Finds min. degree node */
|
||||
int growlist(EN_Project *pr, int); /* Augments adjacency list */
|
||||
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 addlink(EN_Network *net, int, int, int); /* Creates new fill-in */
|
||||
int storesparse(EN_Project *pr, int); /* Stores sparse matrix */
|
||||
int ordersparse(hydraulics_t *h, int); /* Orders matrix storage */
|
||||
void transpose(int,int *,int *, /* Transposes sparse matrix */
|
||||
int *,int *,int *,int *,int *);
|
||||
int linsolve(solver_t *s, int); /* Solves set of inear eqns. */
|
||||
int linsolve(EN_Project *pr, int); /* Solves set of linear eqns. */
|
||||
|
||||
/* ----------- QUALITY.C ---------------*/
|
||||
int openqual(EN_Project *pr); /* Opens WQ solver system */
|
||||
|
||||
1001
src/genmmd.c
Normal file
1001
src/genmmd.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -122,7 +122,7 @@ int hydsolve(EN_Project *pr, int *iter, double *relerr)
|
||||
hlosscoeff(pr, i);
|
||||
}
|
||||
matrixcoeffs(pr);
|
||||
errcode = linsolve(&hyd->solver, net->Njuncs);
|
||||
errcode = linsolve(pr, net->Njuncs);
|
||||
|
||||
/* Take action depending on error code */
|
||||
if (errcode < 0) {
|
||||
|
||||
832
src/smatrix.c
832
src/smatrix.c
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ typedef int INT4;
|
||||
---------------------------------------------------------------------
|
||||
*/
|
||||
#define MEMCHECK(x) (((x) == NULL) ? 101 : 0 )
|
||||
#define FREE(x) (free((x)))
|
||||
#define FREE(x) if ((x)) free((x))
|
||||
|
||||
/*
|
||||
---------------------------------------------------------------------
|
||||
@@ -153,8 +153,9 @@ typedef enum {
|
||||
V_CURVE, /* volume curve */
|
||||
P_CURVE, /* pump curve */
|
||||
E_CURVE, /* efficiency curve */
|
||||
H_CURVE
|
||||
} CurveType; /* head loss curve */
|
||||
H_CURVE, /* head loss curve */
|
||||
G_CURVE /* General\default curve */
|
||||
} CurveType;
|
||||
|
||||
typedef enum {
|
||||
CONST_HP, /* constant horsepower */
|
||||
|
||||
Reference in New Issue
Block a user