using IStation.Epanet.Enums;
namespace IStation.Epanet.Network.Structures
{
///Hydraulic pump structure.
public class Pump : Link
{
public Pump(string name) : base(name)
{
// Link attributes
Kc = 1.0;
Status = StatusType.OPEN;
// Pump attributes
Ptype = PumpType.NOCURVE;
}
public override LinkType LinkType => LinkType.Pump;
public override void InitResistance(HeadLossFormulaType formflag, double hexp)
{
FlowResistance = Constants.CBIG;
}
public override void ConvertUnits(Network nw)
{
FieldsMap fMap = nw.FieldsMap;
if (Ptype == PumpType.CONST_HP)
{
if (nw.UnitsFlag == UnitsType.SI)
FlowCoefficient /= fMap.GetUnits(FieldType.POWER);
}
else
{
if (Ptype == PumpType.POWER_FUNC)
{
H0 /= fMap.GetUnits(FieldType.HEAD);
FlowCoefficient *=
Math.Pow(fMap.GetUnits(FieldType.FLOW), N) /
fMap.GetUnits(FieldType.HEAD);
}
Q0 /= fMap.GetUnits(FieldType.FLOW);
Qmax /= fMap.GetUnits(FieldType.FLOW);
Hmax /= fMap.GetUnits(FieldType.HEAD);
}
}
///Unit energy cost.
public double ECost { get; set; }
///Effic. v. flow curve reference.
public Curve ECurve { get; set; }
///Energy usage statistics.
public double[] Energy { get; } = { 0, 0, 0, 0, 0, 0 };
///Energy cost pattern.
public Pattern EPat { get; set; }
///Flow coefficient.
public double FlowCoefficient { get; set; }
///Shutoff head (feet)
public double H0 { get; set; }
///Head v. flow curve reference.
public Curve HCurve { get; set; }
///Maximum head (feet)
public double Hmax { get; set; }
///Flow exponent.
public double N { get; set; }
///Pump curve type.
public PumpType Ptype { get; set; }
///Initial flow (feet^3/s).
public double Q0 { get; set; }
///Maximum flow (feet^3/s).
public double Qmax { get; set; }
///Utilization pattern reference.
public Pattern UPat { get; set; }
#if NUCONVERT
public double GetNuFlowCoefficient(UnitsType utype)
{
return NUConvert.RevertPower(utype, FlowCoefficient);
}
public double GetNuInitialFlow(FlowUnitsType utype)
{
return NUConvert.RevertFlow(utype, Q0);
}
public double GetNuMaxFlow(FlowUnitsType utype)
{
return NUConvert.RevertFlow(utype, Qmax);
}
public double GetNuMaxHead(UnitsType utype)
{
return NUConvert.RevertDistance(utype, Hmax);
}
public double GetNuShutoffHead(UnitsType utype)
{
return NUConvert.RevertDistance(utype, Hmax);
}
public void SetNuFlowCoefficient(UnitsType utype, double value)
{
FlowCoefficient = NUConvert.ConvertPower(utype, value);
}
public void SetNuInitialFlow(FlowUnitsType utype, double value)
{
Q0 = NUConvert.ConvertFlow(utype, value);
}
public void SetNuMaxFlow(FlowUnitsType utype, double value)
{
Qmax = NUConvert.ConvertFlow(utype, value);
}
public void SetNuMaxHead(UnitsType utype, double value)
{
Hmax = NUConvert.ConvertDistance(utype, value);
}
public void SetNuShutoffHead(UnitsType utype, double value)
{
H0 = NUConvert.ConvertDistance(utype, value);
}
#endif
}
}