Fix link InitSetting/InitStatus properties
This commit is contained in:
11
src/epanet.c
11
src/epanet.c
@@ -4177,8 +4177,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
|
|||||||
{
|
{
|
||||||
Link[index].Kc = value;
|
Link[index].Kc = value;
|
||||||
Link[index].InitSetting = value;
|
Link[index].InitSetting = value;
|
||||||
valveType = Link[index].Type;
|
if (Link[index].Type > PUMP && Link[index].Type != GPV)
|
||||||
if (valveType > PUMP && valveType != GPV)
|
|
||||||
{
|
{
|
||||||
Link[index].InitStatus = ACTIVE;
|
Link[index].InitStatus = ACTIVE;
|
||||||
}
|
}
|
||||||
@@ -4343,8 +4342,12 @@ int DLLEXPORT EN_setpipedata(EN_Project p, int index, double length,
|
|||||||
if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]);
|
if (p->hydraul.Formflag == DW) Link[index].Kc /= (1000.0 * Ucf[ELEV]);
|
||||||
|
|
||||||
// Update minor loss factor & pipe flow resistance
|
// Update minor loss factor & pipe flow resistance
|
||||||
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
|
if (p->hydraul.OpenHflag)
|
||||||
resistcoeff(p, index);
|
{
|
||||||
|
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
|
||||||
|
resistcoeff(p, index);
|
||||||
|
}
|
||||||
|
else Link[index].InitSetting = Link[index].Kc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ void tanklevels(Project *, long);
|
|||||||
void resetpumpflow(Project *, int);
|
void resetpumpflow(Project *, int);
|
||||||
void getallpumpsenergy(Project *);
|
void getallpumpsenergy(Project *);
|
||||||
|
|
||||||
|
|
||||||
int openhyd(Project *pr)
|
int openhyd(Project *pr)
|
||||||
/*
|
/*
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
@@ -126,18 +127,9 @@ void inithyd(Project *pr, int initflag)
|
|||||||
// Initialize status and setting
|
// Initialize status and setting
|
||||||
hyd->LinkStatus[i] = link->InitStatus;
|
hyd->LinkStatus[i] = link->InitStatus;
|
||||||
hyd->LinkSetting[i] = link->InitSetting;
|
hyd->LinkSetting[i] = link->InitSetting;
|
||||||
|
if (link->Type > PUMP && link->Type != GPV && link->InitStatus != ACTIVE)
|
||||||
// Setting of non-ACTIVE FCV, PRV, PSV valves is "MISSING"
|
|
||||||
switch (link->Type)
|
|
||||||
{
|
{
|
||||||
case FCV:
|
hyd->LinkSetting[i] = MISSING;
|
||||||
case PRV:
|
|
||||||
case PSV:
|
|
||||||
if (link->InitStatus != ACTIVE)
|
|
||||||
{
|
|
||||||
link->Kc = MISSING;
|
|
||||||
hyd->LinkSetting[i] = MISSING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute flow resistance
|
// Compute flow resistance
|
||||||
@@ -146,7 +138,7 @@ void inithyd(Project *pr, int initflag)
|
|||||||
// Start active control valves in ACTIVE position
|
// Start active control valves in ACTIVE position
|
||||||
if (
|
if (
|
||||||
(link->Type == PRV || link->Type == PSV
|
(link->Type == PRV || link->Type == PSV
|
||||||
|| link->Type == FCV) && (link->Kc != MISSING)
|
|| link->Type == FCV) && (hyd->LinkSetting[i] != MISSING)
|
||||||
) hyd->LinkStatus[i] = ACTIVE;
|
) hyd->LinkStatus[i] = ACTIVE;
|
||||||
|
|
||||||
// Initialize flows if necessary
|
// Initialize flows if necessary
|
||||||
@@ -475,7 +467,7 @@ void setlinksetting(Project *pr, int index, double value, StatusType *s,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*k == MISSING && *s <= CLOSED) *s = OPEN;
|
if (*k == MISSING && *s <= CLOSED) *s = OPEN;
|
||||||
if (t == PCV) link->R = pcvlosscoeff(pr, index, link->Kc);
|
if (t == PCV) link->R = pcvlosscoeff(pr, index, value);
|
||||||
*k = value;
|
*k = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ void writelogo(Project *pr)
|
|||||||
int version;
|
int version;
|
||||||
int major;
|
int major;
|
||||||
int minor;
|
int minor;
|
||||||
|
int patch;
|
||||||
char s[80];
|
char s[80];
|
||||||
time_t timer; // time_t structure & functions time() &
|
time_t timer; // time_t structure & functions time() &
|
||||||
// ctime() are defined in time.h
|
// ctime() are defined in time.h
|
||||||
@@ -198,6 +199,8 @@ void writelogo(Project *pr)
|
|||||||
version = CODEVERSION;
|
version = CODEVERSION;
|
||||||
major = version / 10000;
|
major = version / 10000;
|
||||||
minor = (version % 10000) / 100;
|
minor = (version % 10000) / 100;
|
||||||
|
patch = version % 100;
|
||||||
|
//patch = version - (10000 * major) - (100 * minor);
|
||||||
|
|
||||||
time(&timer);
|
time(&timer);
|
||||||
strcpy(rpt->DateStamp, ctime(&timer));
|
strcpy(rpt->DateStamp, ctime(&timer));
|
||||||
@@ -209,7 +212,7 @@ void writelogo(Project *pr)
|
|||||||
writeline(pr, LOGO2);
|
writeline(pr, LOGO2);
|
||||||
writeline(pr, LOGO3);
|
writeline(pr, LOGO3);
|
||||||
writeline(pr, LOGO4);
|
writeline(pr, LOGO4);
|
||||||
sprintf(s, LOGO5, major, minor);
|
sprintf(s, LOGO5, major, minor, patch);
|
||||||
writeline(pr, s);
|
writeline(pr, s);
|
||||||
writeline(pr, LOGO6);
|
writeline(pr, LOGO6);
|
||||||
writeline(pr, "");
|
writeline(pr, "");
|
||||||
|
|||||||
@@ -359,7 +359,7 @@
|
|||||||
#define LOGO4 \
|
#define LOGO4 \
|
||||||
"* Analysis for Pipe Networks *"
|
"* Analysis for Pipe Networks *"
|
||||||
#define LOGO5 \
|
#define LOGO5 \
|
||||||
"* Version %d.%d *"
|
"* Version %d.%d.%02d *"
|
||||||
#define LOGO6 \
|
#define LOGO6 \
|
||||||
"******************************************************************"
|
"******************************************************************"
|
||||||
#define FMT02 "\n o Retrieving network data"
|
#define FMT02 "\n o Retrieving network data"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ typedef int INT4;
|
|||||||
Various constants
|
Various constants
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
*/
|
*/
|
||||||
#define CODEVERSION 20300
|
#define CODEVERSION 20301
|
||||||
#define MAGICNUMBER 516114521
|
#define MAGICNUMBER 516114521
|
||||||
#define ENGINE_VERSION 201 // Used for binary hydraulics file
|
#define ENGINE_VERSION 201 // Used for binary hydraulics file
|
||||||
#define EOFMARK 0x1A // Use 0x04 for UNIX systems
|
#define EOFMARK 0x1A // Use 0x04 for UNIX systems
|
||||||
|
|||||||
Reference in New Issue
Block a user