Fix link InitSetting/InitStatus properties

This commit is contained in:
Lew Rossman
2025-07-25 11:02:40 -04:00
parent c8d92cdd48
commit ebafb87e6a
5 changed files with 18 additions and 20 deletions

View File

@@ -4177,8 +4177,7 @@ int DLLEXPORT EN_setlinkvalue(EN_Project p, int index, int property, double valu
{
Link[index].Kc = value;
Link[index].InitSetting = value;
valveType = Link[index].Type;
if (valveType > PUMP && valveType != GPV)
if (Link[index].Type > PUMP && Link[index].Type != GPV)
{
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]);
// Update minor loss factor & pipe flow resistance
Link[index].Km = 0.02517 * mloss / SQR(Link[index].Diam) / SQR(Link[index].Diam);
resistcoeff(p, index);
if (p->hydraul.OpenHflag)
{
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;
}

View File

@@ -41,6 +41,7 @@ void tanklevels(Project *, long);
void resetpumpflow(Project *, int);
void getallpumpsenergy(Project *);
int openhyd(Project *pr)
/*
*--------------------------------------------------------------
@@ -126,18 +127,9 @@ void inithyd(Project *pr, int initflag)
// Initialize status and setting
hyd->LinkStatus[i] = link->InitStatus;
hyd->LinkSetting[i] = link->InitSetting;
// Setting of non-ACTIVE FCV, PRV, PSV valves is "MISSING"
switch (link->Type)
if (link->Type > PUMP && link->Type != GPV && link->InitStatus != ACTIVE)
{
case FCV:
case PRV:
case PSV:
if (link->InitStatus != ACTIVE)
{
link->Kc = MISSING;
hyd->LinkSetting[i] = MISSING;
}
hyd->LinkSetting[i] = MISSING;
}
// Compute flow resistance
@@ -146,7 +138,7 @@ void inithyd(Project *pr, int initflag)
// Start active control valves in ACTIVE position
if (
(link->Type == PRV || link->Type == PSV
|| link->Type == FCV) && (link->Kc != MISSING)
|| link->Type == FCV) && (hyd->LinkSetting[i] != MISSING)
) hyd->LinkStatus[i] = ACTIVE;
// Initialize flows if necessary
@@ -475,7 +467,7 @@ void setlinksetting(Project *pr, int index, double value, StatusType *s,
else
{
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;
}
}

View File

@@ -191,6 +191,7 @@ void writelogo(Project *pr)
int version;
int major;
int minor;
int patch;
char s[80];
time_t timer; // time_t structure & functions time() &
// ctime() are defined in time.h
@@ -198,6 +199,8 @@ void writelogo(Project *pr)
version = CODEVERSION;
major = version / 10000;
minor = (version % 10000) / 100;
patch = version % 100;
//patch = version - (10000 * major) - (100 * minor);
time(&timer);
strcpy(rpt->DateStamp, ctime(&timer));
@@ -209,7 +212,7 @@ void writelogo(Project *pr)
writeline(pr, LOGO2);
writeline(pr, LOGO3);
writeline(pr, LOGO4);
sprintf(s, LOGO5, major, minor);
sprintf(s, LOGO5, major, minor, patch);
writeline(pr, s);
writeline(pr, LOGO6);
writeline(pr, "");

View File

@@ -359,7 +359,7 @@
#define LOGO4 \
"* Analysis for Pipe Networks *"
#define LOGO5 \
"* Version %d.%d *"
"* Version %d.%d.%02d *"
#define LOGO6 \
"******************************************************************"
#define FMT02 "\n o Retrieving network data"

View File

@@ -31,7 +31,7 @@ typedef int INT4;
Various constants
----------------------------------------------
*/
#define CODEVERSION 20300
#define CODEVERSION 20301
#define MAGICNUMBER 516114521
#define ENGINE_VERSION 201 // Used for binary hydraulics file
#define EOFMARK 0x1A // Use 0x04 for UNIX systems