Decoupled pressure units from the flow unit system
Decoupled pressure units from the flow unit system, allowing them to be set independently to support mixed-unit conventions (e.g., using LPS for flow and PSI for pressure).
This commit is contained in:
@@ -1411,8 +1411,6 @@ int DLLEXPORT EN_setoption(EN_Project p, int option, double value)
|
||||
case EN_PRESS_UNITS:
|
||||
unit = ROUND(value);
|
||||
if (unit < 0 || unit > METERS) return 205;
|
||||
if (p->parser.Unitsflag == US && unit > PSI) return 0;
|
||||
if (p->parser.Unitsflag == SI && unit == PSI) return 0;
|
||||
p->parser.Pressflag = unit;
|
||||
|
||||
dfactor = Ucf[DEMAND];
|
||||
|
||||
22
src/input1.c
22
src/input1.c
@@ -103,7 +103,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 = PSI; // Pressure units are psi
|
||||
parser->Pressflag = UNITDEFAULT; // Pressure units set based on unit system
|
||||
out->Hydflag = SCRATCH; // No external hydraulics file
|
||||
rpt->Tstatflag = SERIES; // Generate time series output
|
||||
|
||||
@@ -269,8 +269,11 @@ void adjustdata(Project *pr)
|
||||
}
|
||||
|
||||
// Revise pressure units depending on flow units
|
||||
if (parser->Unitsflag != SI) parser->Pressflag = PSI;
|
||||
else if (parser->Pressflag == PSI) parser->Pressflag = METERS;
|
||||
if (parser->Pressflag == UNITDEFAULT)
|
||||
{
|
||||
if (parser->Unitsflag == SI) parser->Pressflag = METERS;
|
||||
else parser->Pressflag = PSI;
|
||||
}
|
||||
|
||||
// Store value of viscosity & diffusivity
|
||||
ucf = 1.0;
|
||||
@@ -404,8 +407,6 @@ void initunits(Project *pr)
|
||||
strcpy(rpt->Field[DEMAND].Units, RptFlowUnitsTxt[parser->Flowflag]);
|
||||
strcpy(rpt->Field[ELEV].Units, u_METERS);
|
||||
strcpy(rpt->Field[HEAD].Units, u_METERS);
|
||||
if (parser->Pressflag == METERS) strcpy(rpt->Field[PRESSURE].Units, u_METERS);
|
||||
else strcpy(rpt->Field[PRESSURE].Units, u_KPA);
|
||||
strcpy(rpt->Field[LENGTH].Units, u_METERS);
|
||||
strcpy(rpt->Field[DIAM].Units, u_MMETERS);
|
||||
strcpy(rpt->Field[FLOW].Units, RptFlowUnitsTxt[parser->Flowflag]);
|
||||
@@ -423,8 +424,6 @@ void initunits(Project *pr)
|
||||
if (parser->Flowflag == CMS) qcf = CMSperCFS;
|
||||
|
||||
hcf = MperFT;
|
||||
if (parser->Pressflag == METERS) pcf = MperFT * hyd->SpGrav;
|
||||
else pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
|
||||
wcf = KWperHP;
|
||||
}
|
||||
else // US units
|
||||
@@ -448,10 +447,17 @@ void initunits(Project *pr)
|
||||
if (parser->Flowflag == IMGD) qcf = IMGDperCFS;
|
||||
if (parser->Flowflag == AFD) qcf = AFDperCFS;
|
||||
hcf = 1.0;
|
||||
pcf = PSIperFT * hyd->SpGrav;
|
||||
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);
|
||||
|
||||
if (parser->Pressflag == METERS) pcf = MperFT * hyd->SpGrav;
|
||||
else if (parser->Pressflag == KPA) pcf = KPAperPSI * PSIperFT * hyd->SpGrav;
|
||||
else pcf = PSIperFT * hyd->SpGrav;
|
||||
|
||||
strcpy(rpt->Field[QUALITY].Units, "");
|
||||
ccf = 1.0;
|
||||
if (qual->Qualflag == CHEM)
|
||||
|
||||
@@ -238,7 +238,8 @@ typedef enum {
|
||||
typedef enum {
|
||||
PSI, // pounds per square inch
|
||||
KPA, // kiloPascals
|
||||
METERS // meters
|
||||
METERS, // meters
|
||||
UNITDEFAULT // default based on unit system (SI or US)
|
||||
} PressureUnitsType;
|
||||
|
||||
typedef enum {
|
||||
|
||||
Reference in New Issue
Block a user