Add support for bar and feet as pressure units, fix psi or m for emitters
This commit is contained in:
23
src/input1.c
23
src/input1.c
@@ -40,6 +40,7 @@ Last Updated: 04/19/2025
|
||||
// Defined in ENUMSTXT.H
|
||||
extern char *Fldname[];
|
||||
extern char *RptFlowUnitsTxt[];
|
||||
extern char *PressUnitsTxt[];
|
||||
extern void reindextanks(Project *pr);
|
||||
|
||||
|
||||
@@ -103,7 +104,7 @@ void setdefaults(Project *pr)
|
||||
pr->Warnflag = FALSE; // Warning flag is off
|
||||
parser->Unitsflag = US; // US unit system
|
||||
parser->Flowflag = GPM; // Flow units are gpm
|
||||
parser->Pressflag = UNITDEFAULT; // Pressure units set based on unit system
|
||||
parser->Pressflag = DEFAULTUNIT; // Pressure units set based on unit system
|
||||
out->Hydflag = SCRATCH; // No external hydraulics file
|
||||
rpt->Tstatflag = SERIES; // Generate time series output
|
||||
|
||||
@@ -269,7 +270,7 @@ void adjustdata(Project *pr)
|
||||
}
|
||||
|
||||
// Revise pressure units depending on flow units
|
||||
if (parser->Pressflag == UNITDEFAULT)
|
||||
if (parser->Pressflag == DEFAULTUNIT)
|
||||
{
|
||||
if (parser->Unitsflag == SI) parser->Pressflag = METERS;
|
||||
else parser->Pressflag = PSI;
|
||||
@@ -450,13 +451,12 @@ void initunits(Project *pr)
|
||||
wcf = 1.0;
|
||||
}
|
||||
|
||||
if (parser->Pressflag == METERS) strcpy(rpt->Field[PRESSURE].Units, u_METERS);
|
||||
else if (parser->Pressflag == KPA) strcpy(rpt->Field[PRESSURE].Units, u_KPA);
|
||||
else strcpy(rpt->Field[PRESSURE].Units, u_PSI);
|
||||
|
||||
strcpy(rpt->Field[PRESSURE].Units, PressUnitsTxt[parser->Pressflag]);
|
||||
pcf = PSIperFT * hyd->SpGrav; // Default to PSI
|
||||
if (parser->Pressflag == METERS) pcf = MperFT * hyd->SpGrav;
|
||||
else if (parser->Pressflag == KPA) pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
|
||||
else pcf = PSIperFT * hyd->SpGrav;
|
||||
if (parser->Pressflag == KPA) pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
|
||||
if (parser->Pressflag == BAR) pcf = BARperPSI * PSIperFT * hyd->SpGrav;
|
||||
if (parser->Pressflag == FEET) pcf = 1.0 * hyd->SpGrav;
|
||||
|
||||
strcpy(rpt->Field[QUALITY].Units, "");
|
||||
ccf = 1.0;
|
||||
@@ -514,7 +514,7 @@ void convertunits(Project *pr)
|
||||
Parser *parser = &pr->parser;
|
||||
|
||||
int i, j, k;
|
||||
double ucf; // Unit conversion factor
|
||||
double ucf, ecf; // Unit conversion factor
|
||||
Pdemand demand; // Pointer to demand record
|
||||
Snode *node;
|
||||
Stank *tank;
|
||||
@@ -545,7 +545,10 @@ void convertunits(Project *pr)
|
||||
hyd->Preq /= pr->Ucf[PRESSURE];
|
||||
|
||||
// Convert emitter discharge coeffs. to head loss coeff.
|
||||
ucf = pow(pr->Ucf[FLOW], hyd->Qexp) / pr->Ucf[PRESSURE];
|
||||
ecf = (parser->Unitsflag == US) ? (1.0 / PSIperFT) : (1.0 / MperFT);
|
||||
ecf /= hyd->SpGrav;
|
||||
|
||||
ucf = pow(pr->Ucf[FLOW], hyd->Qexp) / ecf;
|
||||
for (i = 1; i <= net->Njuncs; i++)
|
||||
{
|
||||
node = &net->Node[i];
|
||||
|
||||
Reference in New Issue
Block a user