public static string ParseStr(this PressUnitsType value) { switch (value) { case PressUnitsType.KPA: return(Keywords.w_KPA); case PressUnitsType.METERS: return(Keywords.w_METERS); case PressUnitsType.PSI: return(Keywords.w_PSI); default: return(null); } }
public static double ConvertPressure(PressUnitsType type, double spGrav, double value) { switch (type) { case PressUnitsType.PSI: return(value); case PressUnitsType.KPA: return(value / (Constants.KPAperPSI * Constants.PSIperFT * spGrav)); case PressUnitsType.METERS: return(value / (Constants.MperFT * spGrav)); } return(value); }
public double GetNuRoughness( FlowUnitsType fType, PressUnitsType pType, double spGrav) { switch (Type) { case LinkType.FCV: return(NUConvert.RevertFlow(fType, Kc)); case LinkType.PRV: case LinkType.PSV: case LinkType.PBV: return(NUConvert.RevertPressure(pType, spGrav, Kc)); } return(Kc); }
public static bool TryParse(string text, out PressUnitsType result) { if (text.Match(Keywords.w_PSI)) { result = PressUnitsType.PSI; } else if (text.Match(Keywords.w_KPA)) { result = PressUnitsType.KPA; } else if (text.Match(Keywords.w_METERS)) { result = PressUnitsType.METERS; } else { result = (PressUnitsType)(-1); return(false); } return(true); }
///<summary>Update fields and units, after loading the INP.</summary> public void Prepare( UnitsType targetUnits, FlowUnitsType flowFlag, PressUnitsType pressFlag, QualType qualFlag, string chemUnits, double spGrav, long hstep) { double dcf, ccf, qcf, hcf, pcf, wcf; if (targetUnits == UnitsType.SI) { GetField(FieldType.DEMAND).Units = flowFlag.ToString(); GetField(FieldType.ELEV).Units = Keywords.u_METERS; GetField(FieldType.HEAD).Units = Keywords.u_METERS; GetField(FieldType.PRESSURE).Units = pressFlag == PressUnitsType.METERS ? Keywords.u_METERS : Keywords.u_KPA; GetField(FieldType.LENGTH).Units = Keywords.u_METERS; GetField(FieldType.DIAM).Units = Keywords.u_MMETERS; GetField(FieldType.FLOW).Units = flowFlag.ToString(); GetField(FieldType.VELOCITY).Units = Keywords.u_MperSEC; GetField(FieldType.HEADLOSS).Units = "m" + Keywords.u_per1000M; GetField(FieldType.FRICTION).Units = ""; GetField(FieldType.POWER).Units = Keywords.u_KW; dcf = 1000.0 * Constants.MperFT; qcf = Constants.LPSperCFS; if (flowFlag == FlowUnitsType.LPM) { qcf = Constants.LPMperCFS; } if (flowFlag == FlowUnitsType.MLD) { qcf = Constants.MLDperCFS; } if (flowFlag == FlowUnitsType.CMH) { qcf = Constants.CMHperCFS; } if (flowFlag == FlowUnitsType.CMD) { qcf = Constants.CMDperCFS; } hcf = Constants.MperFT; if (pressFlag == PressUnitsType.METERS) { pcf = Constants.MperFT * spGrav; } else { pcf = Constants.KPAperPSI * Constants.PSIperFT * spGrav; } wcf = Constants.KWperHP; } else { GetField(FieldType.DEMAND).Units = flowFlag.ToString(); GetField(FieldType.ELEV).Units = Keywords.u_FEET; GetField(FieldType.HEAD).Units = Keywords.u_FEET; GetField(FieldType.PRESSURE).Units = Keywords.u_PSI; GetField(FieldType.LENGTH).Units = Keywords.u_FEET; GetField(FieldType.DIAM).Units = Keywords.u_INCHES; GetField(FieldType.FLOW).Units = flowFlag.ToString(); GetField(FieldType.VELOCITY).Units = Keywords.u_FTperSEC; GetField(FieldType.HEADLOSS).Units = "ft" + Keywords.u_per1000FT; GetField(FieldType.FRICTION).Units = ""; GetField(FieldType.POWER).Units = Keywords.u_HP; dcf = 12.0; qcf = 1.0; if (flowFlag == FlowUnitsType.GPM) { qcf = Constants.GPMperCFS; } if (flowFlag == FlowUnitsType.MGD) { qcf = Constants.MGDperCFS; } if (flowFlag == FlowUnitsType.IMGD) { qcf = Constants.IMGDperCFS; } if (flowFlag == FlowUnitsType.AFD) { qcf = Constants.AFDperCFS; } hcf = 1.0; pcf = Constants.PSIperFT * spGrav; wcf = 1.0; } GetField(FieldType.QUALITY).Units = ""; ccf = 1.0; switch (qualFlag) { case QualType.CHEM: ccf = 1.0 / Constants.LperFT3; GetField(FieldType.QUALITY).Units = chemUnits; GetField(FieldType.REACTRATE).Units = chemUnits + Keywords.t_PERDAY; break; case QualType.AGE: GetField(FieldType.QUALITY).Units = Keywords.u_HOURS; break; case QualType.TRACE: GetField(FieldType.QUALITY).Units = Keywords.u_PERCENT; break; } SetUnits(FieldType.DEMAND, qcf); SetUnits(FieldType.ELEV, hcf); SetUnits(FieldType.HEAD, hcf); SetUnits(FieldType.PRESSURE, pcf); SetUnits(FieldType.QUALITY, ccf); SetUnits(FieldType.LENGTH, hcf); SetUnits(FieldType.DIAM, dcf); SetUnits(FieldType.FLOW, qcf); SetUnits(FieldType.VELOCITY, hcf); SetUnits(FieldType.HEADLOSS, hcf); SetUnits(FieldType.LINKQUAL, ccf); SetUnits(FieldType.REACTRATE, ccf); SetUnits(FieldType.FRICTION, 1.0); SetUnits(FieldType.POWER, wcf); SetUnits(FieldType.VOLUME, hcf * hcf * hcf); if (hstep < 1800) { SetUnits(FieldType.TIME, 1.0 / 60.0); GetField(FieldType.TIME).Units = Keywords.u_MINUTES; } else { SetUnits(FieldType.TIME, 1.0 / 3600.0); GetField(FieldType.TIME).Units = Keywords.u_HOURS; } }