using IStation.Epanet.Enums;
|
|
namespace IStation.Epanet.Network.Structures
|
{
|
|
///<summary>Hydraulic link structure (pipe)</summary>
|
public abstract class Link : Element
|
{
|
|
///<summary>Init links flow resistance values.</summary>
|
public abstract void InitResistance(HeadLossFormulaType formflag, double hexp);
|
|
public abstract void ConvertUnits(Network nw);
|
|
protected Link(string name) : base(name)
|
{
|
Vertices = new List<EnPoint>();
|
Status = StatusType.XHEAD;
|
}
|
|
public override ElementType ElementType => ElementType.LINK;
|
|
///<summary>Link subtype.</summary>
|
public abstract LinkType LinkType { get; }
|
|
///<summary>Initial species concentrations.</summary>
|
public double C0 { get; set; }
|
|
///<summary>Link diameter (feet).</summary>
|
public double Diameter { get; set; }
|
|
///<summary>First node.</summary>
|
public Node FirstNode { get; set; }
|
|
///<summary>Flow resistance.</summary>
|
public double FlowResistance { get; protected set; }
|
|
///<summary>Bulk react. coeff.</summary>
|
public double Kb { get; set; }
|
|
///<summary>Minor loss coeff.</summary>
|
public double Km { get; set; }
|
|
///<summary>Wall react. coeff.</summary>
|
public double Kw { get; set; }
|
|
///<summary>Link length (feet).</summary>
|
public double Lenght { get; set; }
|
|
///<summary>Kinetic parameter values.</summary>
|
public double[] Param { get; set; }
|
|
///<summary>Roughness factor.</summary>
|
public double Kc { get; set; }
|
|
///<summary>Second node.</summary>
|
public Node SecondNode { get; set; }
|
|
///<summary>Link status.</summary>
|
public StatusType Status { get; set; }
|
|
///<summary>List of points for link path rendering.</summary>
|
public List<EnPoint> Vertices { get; }
|
|
///<summary>Link report flag.</summary>
|
public bool RptFlag { get; set; }
|
|
public void SetDiameterAndUpdate(double diameter, Network net)
|
{
|
double realkm = Km * Math.Pow(Diameter, 4.0) / 0.02517;
|
Diameter = diameter;
|
Km = 0.02517 * realkm / Math.Pow(diameter, 4);
|
InitResistance(net.FormFlag, net.HExp);
|
}
|
|
/// <summary>Returns string with length of pipe with given index.</summary>
|
|
public double GetPipeLength(UnitsType type)
|
{
|
double length = 0;
|
|
EnPoint pt1 = FirstNode.Coordinate;
|
|
foreach (var pt in Vertices)
|
{
|
length += pt1.DistanceTo(pt);
|
pt1 = pt;
|
}
|
|
length += pt1.DistanceTo(SecondNode.Coordinate);
|
|
// length = MapDimensions.LengthUCF * length;
|
if (type == UnitsType.SI)
|
length *= 1 / Constants.MperFT;
|
|
return Lenght = length;
|
}
|
|
#if NUCONVERT
|
public double GetNuDiameter(UnitsType utype)
|
{
|
return NUConvert.RevertDiameter(utype, Diameter);
|
}
|
|
public double GetNuLength(UnitsType utype)
|
{
|
return NUConvert.RevertDistance(utype, Lenght);
|
}
|
|
public void SetNuDiameter(UnitsType utype, double value)
|
{
|
Diameter = NUConvert.ConvertDistance(utype, value);
|
}
|
|
public void SetNuLenght(UnitsType utype, double value)
|
{
|
Lenght = NUConvert.ConvertDistance(utype, value);
|
}
|
|
public virtual double GetNuRoughness(FlowUnitsType fType, PressUnitsType pType, double spGrav)
|
{
|
return Kc;
|
}
|
|
#endif
|
}
|
|
}
|