using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
namespace IStation.Common
|
{
|
public class LxpFeatCurveHelper
|
{
|
#region 计算效率曲线 Q用m^3/h H为m ,P为kw,density密度为kg/m^3,gavity用重力加速度m/s^2,效率用百分数
|
public static List<IStation.Model.CurvePoint> CalculateE(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP)
|
{
|
return CalculateE(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP, bool isFromZero)
|
{
|
return CalculateE(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQP, IStation.Model.ConstantParas.WaterDensity, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP, double midu)
|
{
|
return CalculateE(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQP, midu);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP, double midu, bool isFromZero)
|
{
|
return CalculateE(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQP, midu, isFromZero);
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP)
|
{
|
return CalculateE(
|
CurveFitTypeQH,
|
CurveFitTypeQE,
|
CurveFitTypeQP,
|
pointQH, pointQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP, bool isFromZero)
|
{
|
return CalculateE(
|
CurveFitTypeQH,
|
CurveFitTypeQE,
|
CurveFitTypeQP,
|
pointQH, pointQP, IStation.Model.ConstantParas.WaterDensity, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP,
|
double midu)
|
{
|
if (pointQH == null || pointQH.Count() <= 2)
|
return null;
|
|
bool isFromZero = true;
|
if (pointQH.First().X > 500 || pointQH.First().X > pointQH.Last().X * 0.1)
|
{
|
isFromZero = false;
|
}
|
else
|
{
|
isFromZero = true;
|
}
|
|
return CalculateE(CurveFitTypeQH, CurveFitTypeQE, CurveFitTypeQP, pointQH, pointQP, midu, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP,
|
double midu, bool isFromZero)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQP == null || pointQP.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQE = new List<IStation.Model.CurvePoint>();
|
|
double Q, H, Eff, Power;
|
IStation.Model.FitCurveHelper fitCurve = new IStation.Model.FitCurveHelper(pointQH, CurveFitTypeQH);
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
Q = pointQP[i].X;
|
Power = pointQP[i].Y;
|
H = fitCurve.GetFitPointY(Q);
|
Eff = IStation.Common.PumpParaHelper.CalculateE(Q, H, Power, midu);
|
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
|
//保证Q=0时,Eff=0;
|
if (isFromZero)
|
{
|
pointQE[0] = new IStation.Model.CurvePoint(0, 0);
|
var fitCurve1 = IStation.Model.FitCurveHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count());
|
return IStation.Common.AmendCurveHelper.ByZeroPointY(fitCurve1, pointQE[3].X, 0);
|
}
|
else
|
{
|
return IStation.Model.FitCurveHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count());
|
}
|
}
|
|
public static IStation.Model.CurveExpress CalculateE(Model.eCurveFitType fitType, IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP)
|
{
|
return CalculateE(fitType, expressQH, expressQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
public static IStation.Model.CurveExpress CalculateE(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP)
|
{
|
return CalculateE(expressQH, expressQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
public static IStation.Model.CurveExpress CalculateE(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQP,
|
bool isFromZero)
|
{
|
return CalculateE(expressQH, expressQP, IStation.Model.ConstantParas.WaterDensity, isFromZero);
|
}
|
|
public static IStation.Model.CurveExpress CalculateE(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP, double midu)
|
{
|
if (expressQH == null)
|
return null;
|
|
return CalculateE(expressQH.FitType, expressQH, expressQP, midu);
|
}
|
public static IStation.Model.CurveExpress CalculateE(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP, double midu, bool isFromZero)
|
{
|
if (expressQH == null)
|
return null;
|
return CalculateE(expressQH.FitType, expressQH, expressQP, midu, isFromZero);
|
}
|
|
public static IStation.Model.CurveExpress CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQP,
|
double midu)
|
{
|
if (expressQH == null)
|
return null;
|
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.1)
|
{
|
isFromZero = false;
|
}
|
else
|
{
|
isFromZero = true;
|
}
|
|
return CalculateE(CurveFitTypeQE, expressQH, expressQP, midu, isFromZero);
|
}
|
|
public static IStation.Model.CurveExpress CalculateE(
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQP,
|
double midu, bool isFromZero)
|
{
|
if (expressQH == null)
|
return null;
|
if (expressQP == null)
|
return null;
|
int PointNumber = 12;
|
List<IStation.Model.CurvePoint> pointQE = new List<IStation.Model.CurvePoint>();
|
List<IStation.Model.CurvePoint> pointQP = IStation.Model.FitCurveHelper.GetFitPoints(expressQP, PointNumber);
|
|
double Q, H, Eff, Power;
|
IStation.Model.FitCurveHelper fitCurve = new IStation.Model.FitCurveHelper(expressQH);
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
Q = pointQP[i].X;
|
Power = pointQP[i].Y;
|
H = fitCurve.GetFitPointY(Q);
|
Eff = IStation.Common.PumpParaHelper.CalculateE(Q, H, Power, midu);
|
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
|
//保证Q=0时,Eff=0;
|
if (isFromZero)
|
{
|
pointQE[0] = new IStation.Model.CurvePoint(0, 0);
|
var fitCurve1 = IStation.Model.FitCurveHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count());
|
pointQE = IStation.Common.AmendCurveHelper.ByZeroPointY(fitCurve1, pointQE[3].X, 0);
|
return new Model.CurveExpress(pointQE, CurveFitTypeQE);
|
}
|
else
|
{
|
return new Model.CurveExpress(pointQE, CurveFitTypeQE);
|
}
|
}
|
|
|
public static List<IStation.Model.CurvePoint> CalculateEpoint(
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQP,
|
int PointNumber,
|
double midu)
|
{
|
if (expressQH == null)
|
return null;
|
if (expressQP == null)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQE = new List<IStation.Model.CurvePoint>();
|
List<IStation.Model.CurvePoint> pointQP = IStation.Model.FitCurveHelper.GetFitPoints(expressQP, PointNumber);
|
|
double Q, H, Eff, Power;
|
IStation.Model.FitCurveHelper fitCurve = new IStation.Model.FitCurveHelper(expressQH);
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
Q = pointQP[i].X;
|
Power = pointQP[i].Y;
|
H = fitCurve.GetFitPointY(Q);
|
Eff = IStation.Common.PumpParaHelper.CalculateE(Q, H, Power, midu);
|
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
|
bool isFromZero = true;
|
if (pointQE.First().X > 500 || pointQE.First().X > pointQE.Last().X * 0.1)
|
{
|
isFromZero = false;
|
}
|
else
|
{
|
isFromZero = true;
|
}
|
|
//保证Q=0时,Eff=0;
|
if (isFromZero)
|
{
|
pointQE[0] = new IStation.Model.CurvePoint(0, 0);
|
var fitCurve1 = IStation.Model.FitCurveHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count());
|
return IStation.Common.AmendCurveHelper.ByZeroPointY(fitCurve1, pointQE[3].X, 0);
|
}
|
else
|
{
|
return IStation.Model.FitCurveHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count());
|
}
|
}
|
|
|
//注意此方法 返回的点没有拟合
|
public static List<IStation.Model.CurvePoint> CalculateE_AlignPointP(
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP,
|
double midu, bool isFromZero)
|
{
|
return CalculateE_AlignPointP(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQP, midu, isFromZero);
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateE_AlignPointP(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQP,
|
double midu, bool isFromZero)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQP == null || pointQP.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQE = new List<IStation.Model.CurvePoint>();
|
|
if (IStation.Model.CurvePointList.IsEqualValueX(pointQH, pointQP))
|
{//x都一致
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
double Q, H, Eff, Power;
|
Q = pointQP[i].X;
|
Power = pointQP[i].Y;
|
H = pointQH[i].Y;
|
Eff = IStation.Common.PumpParaHelper.CalculateE(Q, H, Power, midu);
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
}
|
else
|
{
|
IStation.Model.FitCurveHelper fitCurve_QP = new IStation.Model.FitCurveHelper(pointQP, CurveFitTypeQP);
|
IStation.Model.FitCurveHelper fitCurve_QH = new IStation.Model.FitCurveHelper(pointQH, CurveFitTypeQH);
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
double Q, H, Eff, Power;
|
Q = pointQP[i].X;
|
Power = fitCurve_QP.GetFitPointY(Q);
|
H = fitCurve_QH.GetFitPointY(Q);
|
Eff = IStation.Common.PumpParaHelper.CalculateE(Q, H, Power, midu);
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
}
|
|
|
//pointQE = IStation.Model.FitCurveHelper.GetFitPointsByExtend(pointQE);
|
|
//保证Q=0时,Eff=0;
|
if (isFromZero)
|
{
|
pointQE[0] = new IStation.Model.CurvePoint(0, 0);
|
}
|
|
return pointQE;
|
}
|
#endregion
|
|
|
#region 计算效率曲线 Q用L/s H为MPa ,P为kw,density密度为kg/m^3,gavity用重力加速度m/s^2,效率用百分数
|
public static List<IStation.Model.CurvePoint> CalculateE2(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP)
|
{
|
return CalculateE2(pointQH, pointQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
|
|
public static List<IStation.Model.CurvePoint> CalculateE2(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQP, double midu)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQP == null || pointQP.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQE = new List<IStation.Model.CurvePoint>();
|
|
double Q, H, Eff, Power;
|
IStation.Model.FitCurveHelper fitCurve = new IStation.Model.FitCurveHelper(pointQH);
|
for (int i = 0; i < pointQP.Count; i++)
|
{
|
Q = pointQP[i].X;
|
Power = pointQP[i].Y;
|
H = fitCurve.GetFitPointY(Q);
|
Eff = IStation.Common.PumpParaHelper.CalculateE2(Q, H, Power, midu);
|
pointQE.Add(new IStation.Model.CurvePoint(Q, Eff));
|
}
|
|
//pointQE = IStation.Model.FitCurveHelper.GetFitPointsByExtend(pointQE);
|
|
//保证Q=0时,Eff=0;
|
if (pointQE.First().X < 1)
|
{
|
pointQE[0] = new IStation.Model.CurvePoint(0, 0);
|
}
|
|
return IStation.Model.FitCurveHelper.GetFitPoints(pointQE);
|
}
|
|
public static IStation.Model.CurveExpress CalculateE2(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP)
|
{
|
return CalculateE2(expressQH, expressQP, IStation.Model.ConstantParas.WaterDensity);
|
}
|
|
public static IStation.Model.CurveExpress CalculateE2(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQP, double midu)
|
{
|
if (expressQH == null)
|
return null;
|
if (expressQP == null)
|
return null;
|
|
List<IStation.Model.CurvePoint> points = CalculateE2(IStation.Model.CurveExpress.ToPoints(expressQH, 15),
|
Model.CurveExpress.ToPoints(expressQP, 15), midu);
|
if (points == null)
|
return null;
|
|
return Model.CurveExpress.ToParameter(points);
|
}
|
|
#endregion
|
|
|
#region 计算功率曲线 : Q用m^3/h H为m ,P为kw,density密度为kg/m^3,gavity用重力加速度m/s^2,效率用百分数
|
|
//和效率点对齐 有时 会把零流量点功率传入 ref_zero_power
|
public static List<IStation.Model.CurvePoint> CalculateP_AlignPointE(
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double midu,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQE == null || pointQE.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQP = new List<IStation.Model.CurvePoint>();
|
|
if (IStation.Model.CurvePointList.IsEqualValueX(pointQH, pointQE))
|
{//x都一致
|
for (int i = 0; i < pointQE.Count(); i++)//前面几个点不要
|
{
|
double Q, H, E, P;
|
Q = pointQE[i].X;
|
E = pointQE[i].Y;
|
H = pointQH[i].Y;
|
if (H < 0.1 || E < 0.5)
|
continue;
|
//if (Q < 1)
|
// continue;
|
|
P = IStation.Common.PumpParaHelper.CalculateP(Q, H, E, midu);
|
if (P < 2)
|
{
|
P = Math.Round(P, 3);
|
}
|
else if (P < 30)
|
{
|
P = Math.Round(P, 2);
|
}
|
else if (P < 100)
|
{
|
P = Math.Round(P, 1);
|
}
|
else
|
{
|
P = Math.Round(P, 0);
|
}
|
pointQP.Add(new IStation.Model.CurvePoint(Q, P));
|
}
|
}
|
else
|
{
|
IStation.Model.FitCurveHelper fitCurve_QE = new IStation.Model.FitCurveHelper(pointQE);
|
IStation.Model.FitCurveHelper fitCurve_QH = new IStation.Model.FitCurveHelper(pointQH);
|
|
for (int i = 0; i < pointQE.Count(); i++)//前面几个点不要
|
{
|
double Q, H, E, P;
|
Q = pointQE[i].X;
|
E = fitCurve_QE.GetFitPointY(Q);
|
H = fitCurve_QH.GetFitPointY(Q);
|
if (H < 0.1 || E < 0.5)
|
continue;
|
//if (Q < 1)
|
// continue;
|
|
P = IStation.Common.PumpParaHelper.CalculateP(Q, H, E, midu);
|
if (P < 2)
|
{
|
P = Math.Round(P, 3);
|
}
|
else if (P < 30)
|
{
|
P = Math.Round(P, 2);
|
}
|
else if (P < 100)
|
{
|
P = Math.Round(P, 1);
|
}
|
else
|
{
|
P = Math.Round(P, 0);
|
}
|
pointQP.Add(new IStation.Model.CurvePoint(Q, P));
|
}
|
}
|
|
|
//保证Q=0时,P不是计算出来的;
|
if (isFromZero)
|
{
|
if (pointQP[0].X < 1)
|
{
|
#region 强制转化
|
if (ref_zero_power > 0)
|
{
|
pointQP[0].X = 0;
|
pointQP[0].Y = ref_zero_power;
|
}
|
else
|
{
|
pointQP.RemoveAt(0);
|
var pointQP2 = IStation.Model.FitCurveHelper.GetFitPoints(pointQP);
|
if (pointQP2[0].Y >= pointQP2[1].Y)
|
{
|
pointQP2[0].Y = pointQP2[1].Y * 0.95;
|
}
|
double startP = IStation.Model.CurveLineHelper.GetYbyX(pointQP2[0].X, pointQP2[0].Y, pointQP2[1].X, pointQP2[1].Y, 0);
|
if (startP < 0.001)
|
startP = pointQP2[0].Y;
|
|
if (startP < 2)
|
{
|
startP = Math.Round(startP, 3);
|
}
|
else if (startP < 30)
|
{
|
startP = Math.Round(startP, 2);
|
}
|
else if (startP < 100)
|
{
|
startP = Math.Round(startP, 1);
|
}
|
else
|
{
|
startP = Math.Round(startP, 0);
|
}
|
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, startP));
|
|
}
|
#endregion
|
}
|
else
|
{
|
#region 延长
|
if (ref_zero_power > 0)
|
{
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, ref_zero_power));
|
}
|
else
|
{
|
var pointQP2 = IStation.Model.FitCurveHelper.GetFitPoints(pointQP);
|
if (pointQP2[0].Y >= pointQP2[1].Y)
|
{
|
pointQP2[0].Y = pointQP2[1].Y * 0.95;
|
}
|
double startP = IStation.Model.CurveLineHelper.GetYbyX(pointQP2[0].X, pointQP2[0].Y, pointQP2[1].X, pointQP2[1].Y, 0);
|
if (startP < 0.001)
|
startP = pointQP2[0].Y;
|
|
if (startP < 2)
|
{
|
startP = Math.Round(startP, 3);
|
}
|
else if (startP < 30)
|
{
|
startP = Math.Round(startP, 2);
|
}
|
else if (startP < 100)
|
{
|
startP = Math.Round(startP, 1);
|
}
|
else
|
{
|
startP = Math.Round(startP, 0);
|
}
|
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, startP));
|
}
|
#endregion
|
}
|
}
|
return pointQP;
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateP(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQE)
|
{
|
if (pointQH == null || pointQH.Count() <= 2)
|
return null;
|
bool isFromZero = true;
|
if (pointQH.First().X > 500 || pointQH.First().X > pointQH.Last().X * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateP(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQE,
|
bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateP(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE)
|
{
|
if (pointQH == null || pointQH.Count() <= 2)
|
return null;
|
bool isFromZero = true;
|
if (pointQH.First().X > 500 || pointQH.First().X > pointQH.Last().X * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(CurveFitTypeQH, CurveFitTypeQE, CurveFitTypeQP, pointQH, pointQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateP(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE, bool isFromZero)
|
{
|
return CalculateP_RefZero(CurveFitTypeQH, CurveFitTypeQE, CurveFitTypeQP, pointQH, pointQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero);
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateP(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double midu)
|
{
|
if (pointQH == null || pointQH.Count() <= 2)
|
return null;
|
bool isFromZero = true;
|
if (pointQH.First().X > 500 || pointQH.First().X > pointQH.Last().X * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(CurveFitTypeQH, CurveFitTypeQE, CurveFitTypeQP, pointQH, pointQE, midu, -1, isFromZero);
|
}
|
public static List<IStation.Model.CurvePoint> CalculateP(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double midu, bool isFromZero)
|
{
|
return CalculateP_RefZero(CurveFitTypeQH, CurveFitTypeQE, CurveFitTypeQP, pointQH, pointQE, midu, -1, isFromZero);
|
}
|
|
|
public static IStation.Model.CurveExpress CalculateP(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero, false);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE, bool isFromZero)
|
{
|
return CalculateP_RefZero(expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero, false);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP_SavePointInExpress(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero, true);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP_SavePointInExpress(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE, bool isFromZero)
|
{
|
return CalculateP_RefZero(expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, -1, isFromZero, true);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE, double midu)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, midu, -1, isFromZero, false);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP(
|
IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE, double midu, bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, midu, -1, isFromZero, false);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP(
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE, double midu)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(CurveFitTypeQP, expressQH, expressQE, midu, -1, isFromZero, false);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP(IStation.Model.eCurveFitType CurveFitTypeQP, IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE, double midu, bool isFromZero)
|
{
|
return CalculateP_RefZero(CurveFitTypeQP, expressQH, expressQE, midu, -1, isFromZero, false);
|
}
|
|
//有时 会把零流量点扬程传入 ref_zero_power
|
public static List<IStation.Model.CurvePoint> CalculateP_RefZero(
|
IStation.Model.eCurveFitType CurveFitTypeQH,
|
IStation.Model.eCurveFitType CurveFitTypeQE,
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double midu,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQE == null || pointQE.Count < 3)
|
return null;
|
|
var expressQH = new IStation.Model.CurveExpress(pointQH, CurveFitTypeQH);
|
var expressQE = new IStation.Model.CurveExpress(pointQE, CurveFitTypeQE);
|
|
var expressQP = CalculateP_RefZero(CurveFitTypeQE, expressQH, expressQE, midu, ref_zero_power, isFromZero, false);
|
|
return IStation.Model.FitCurveHelper.GetFitPoints(expressQP, pointQE.Count());
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateP_RefZero(
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double midu,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve, IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQE, midu, ref_zero_power, isFromZero);
|
}
|
|
|
public static List<IStation.Model.CurvePoint> CalculateP_RefZero(
|
List<IStation.Model.CurvePoint> pointQH,
|
List<IStation.Model.CurvePoint> pointQE,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
return CalculateP_RefZero(
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
IStation.Model.eCurveFitType.CubicCurve,
|
pointQH, pointQE,
|
IStation.Model.ConstantParas.WaterDensity, ref_zero_power, isFromZero);
|
}
|
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double ref_zero_power)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, ref_zero_power, isFromZero, false);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, ref_zero_power, isFromZero, false);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero_SavePoint(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double ref_zero_power)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, ref_zero_power, isFromZero, true);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero_SavePoint(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double ref_zero_power,
|
bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity, ref_zero_power, isFromZero, true);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double midu, double ref_zero_power)
|
{
|
if (expressQH == null || expressQE == null)
|
return null;
|
bool isFromZero = true;
|
if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.2)
|
isFromZero = false;
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, midu, ref_zero_power, isFromZero, false);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double midu, double ref_zero_power, bool isFromZero)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, midu, ref_zero_power, isFromZero, false);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double midu, double ref_zero_power, bool isFromZero, bool isSavePointInExpress)
|
{
|
return CalculateP_RefZero(IStation.Model.eCurveFitType.CubicCurve, expressQH, expressQE, midu, ref_zero_power, isFromZero, isSavePointInExpress);
|
}
|
public static IStation.Model.CurveExpress CalculateP_RefZero(
|
IStation.Model.eCurveFitType CurveFitTypeQP,
|
IStation.Model.CurveExpress expressQH,
|
IStation.Model.CurveExpress expressQE,
|
double midu, double ref_zero_power, bool isFromZero, bool isSavePointInExpress)
|
{
|
if (expressQH == null)
|
return null;
|
if (expressQE == null)
|
return null;
|
int point_num = 16;//点不能太多
|
var pointQH = IStation.Model.FitCurveHelper.GetFitPoints(expressQH, point_num);
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
var pointQE = IStation.Model.FitCurveHelper.GetFitPoints(expressQE, point_num);
|
if (pointQE == null || pointQE.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQP = new List<IStation.Model.CurvePoint>();
|
//间距
|
double minQ = Math.Max(pointQH.First().X, pointQE.First().X);
|
double maxQ = Math.Min(pointQH.Last().X, pointQE.Last().X);
|
|
//
|
double Q, H, E, P;
|
|
double space = (maxQ - minQ) / (point_num - 1);
|
|
IStation.Model.FitCurveHelper fitCurveQE = new IStation.Model.FitCurveHelper(expressQE);
|
IStation.Model.FitCurveHelper fitCurveQH = new IStation.Model.FitCurveHelper(expressQH);
|
|
if (isFromZero)
|
{
|
#region 保证从0开始: 保证Q=0时,P不是计算出来的;
|
for (int i = 5; i < point_num; i++)//前面几个点不要
|
{
|
Q = pointQE.First().X + space * i;
|
E = fitCurveQE.GetFitPointY(Q);
|
H = fitCurveQH.GetFitPointY(Q);
|
if (H < 0.1 || E < 0.5)
|
continue;
|
|
P = IStation.Common.PumpParaHelper.CalculateP(Q, H, E, midu);
|
if (P < 2)
|
{
|
P = Math.Round(P, 3);
|
}
|
else if (P < 30)
|
{
|
P = Math.Round(P, 2);
|
}
|
else if (P < 100)
|
{
|
P = Math.Round(P, 1);
|
}
|
else
|
{
|
P = Math.Round(P, 0);
|
}
|
pointQP.Add(new IStation.Model.CurvePoint(Q, P));
|
}
|
|
pointQP = IStation.Model.FitCurveHelper.GetFitPoints(pointQP, CurveFitTypeQP, point_num);
|
if (pointQP == null)
|
return null;
|
|
|
|
if (ref_zero_power > 0.1)
|
{
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, ref_zero_power));
|
}
|
else
|
{
|
if (pointQP[0].Y >= pointQP[1].Y)
|
{
|
pointQP[0].Y = pointQP[1].Y * 0.95;
|
}
|
double startP = IStation.Model.CurveLineHelper.GetYbyX(pointQP[0].X, pointQP[0].Y, pointQP[1].X, pointQP[1].Y, 0);
|
if (startP < 0.001)
|
startP = pointQP[0].Y;
|
|
if (startP < 2)
|
{
|
startP = Math.Round(startP, 3);
|
}
|
else if (startP < 30)
|
{
|
startP = Math.Round(startP, 2);
|
}
|
else if (startP < 100)
|
{
|
startP = Math.Round(startP, 1);
|
}
|
else
|
{
|
startP = Math.Round(startP, 0);
|
}
|
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, startP));
|
}
|
|
|
return new Model.CurveExpress(pointQP, CurveFitTypeQP, isSavePointInExpress);
|
#endregion
|
}
|
else
|
{
|
#region 保证从0开始: 保证Q=0时,P不是计算出来的;
|
for (int i = 0; i < point_num; i++)//前面几个点不要
|
{
|
Q = pointQE.First().X + space * i;
|
E = fitCurveQE.GetFitPointY(Q);
|
H = fitCurveQH.GetFitPointY(Q);
|
if (H < 0.1 || E < 0.5)
|
continue;
|
|
P = IStation.Common.PumpParaHelper.CalculateP(Q, H, E, midu);
|
if (P < 2)
|
{
|
P = Math.Round(P, 3);
|
}
|
else if (P < 30)
|
{
|
P = Math.Round(P, 2);
|
}
|
else if (P < 100)
|
{
|
P = Math.Round(P, 1);
|
}
|
else
|
{
|
P = Math.Round(P, 0);
|
}
|
pointQP.Add(new IStation.Model.CurvePoint(Q, P));
|
}
|
|
pointQP = IStation.Model.FitCurveHelper.GetFitPoints(pointQP, CurveFitTypeQP, point_num);
|
if (pointQP == null)
|
return null;
|
|
return new Model.CurveExpress(pointQP, CurveFitTypeQP, isSavePointInExpress);
|
#endregion
|
}
|
|
}
|
|
|
#endregion
|
|
|
|
|
#region 计算功率曲线::Q用L/s H为MPa ,P为kw,density密度为kg/m^3,gavity用重力加速度m/s^2,效率用百分数
|
public static List<IStation.Model.CurvePoint> CalculateP2(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQE)
|
{
|
return CalculateP2(pointQH, pointQE, IStation.Model.ConstantParas.WaterDensity);
|
}
|
|
public static List<IStation.Model.CurvePoint> CalculateP2(List<IStation.Model.CurvePoint> pointQH, List<IStation.Model.CurvePoint> pointQE, double midu)
|
{
|
if (pointQH == null || pointQH.Count < 3)
|
return null;
|
if (pointQE == null || pointQE.Count < 3)
|
return null;
|
|
List<IStation.Model.CurvePoint> pointQP = new List<IStation.Model.CurvePoint>();
|
//间距
|
double minQ = Math.Max(pointQH.First().X, pointQE.First().X);
|
double maxQ = Math.Min(pointQH.Last().X, pointQE.Last().X);
|
|
//
|
double Q, H, E, P;
|
int num = 16;//点不能太多
|
double space = (maxQ - minQ) / (num - 1);
|
|
IStation.Model.FitCurveHelper fitCurveQE = new IStation.Model.FitCurveHelper(pointQE);
|
IStation.Model.FitCurveHelper fitCurveQH = new IStation.Model.FitCurveHelper(pointQH);
|
|
for (int i = 5; i < num; i++)//前面几个点不要
|
{
|
Q = pointQE.First().X + space * i;
|
E = fitCurveQE.GetFitPointY(Q);
|
H = fitCurveQH.GetFitPointY(Q);
|
if (H < 0.1 || E < 0.5)
|
continue;
|
|
P = IStation.Common.PumpParaHelper.CalculateP2(Q, H, E, midu);
|
if (P < 2)
|
{
|
P = Math.Round(P, 3);
|
}
|
else if (P < 30)
|
{
|
P = Math.Round(P, 2);
|
}
|
else if (P < 100)
|
{
|
P = Math.Round(P, 1);
|
}
|
else
|
{
|
P = Math.Round(P, 0);
|
}
|
pointQP.Add(new IStation.Model.CurvePoint(Q, P));
|
}
|
|
pointQP = IStation.Model.FitCurveHelper.GetFitPoints(pointQP);
|
if (pointQP == null)
|
return null;
|
|
//保证Q=0时,P不是计算出来的;
|
if (pointQE.First().X < 1)
|
{
|
double startP = IStation.Model.CurveLineHelper.GetYbyX(pointQP[0].X, pointQP[0].Y, pointQP[1].X, pointQP[1].Y, 0);
|
if (startP < 0.001)
|
startP = pointQP[0].Y;
|
if (startP < 2)
|
{
|
startP = Math.Round(startP, 3);
|
}
|
else if (startP < 30)
|
{
|
startP = Math.Round(startP, 2);
|
}
|
else if (startP < 100)
|
{
|
startP = Math.Round(startP, 1);
|
}
|
else
|
{
|
startP = Math.Round(startP, 0);
|
}
|
pointQP.Insert(0, new IStation.Model.CurvePoint(0, startP));
|
}
|
return IStation.Model.FitCurveHelper.GetFitPoints(pointQP, pointQH.Count());
|
}
|
|
public static IStation.Model.CurveExpress CalculateP2(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE)
|
{
|
return CalculateP2(expressQH, expressQE, IStation.Model.ConstantParas.WaterDensity);
|
}
|
public static IStation.Model.CurveExpress CalculateP2(IStation.Model.CurveExpress expressQH, IStation.Model.CurveExpress expressQE, double midu)
|
{
|
if (expressQH == null)
|
return null;
|
if (expressQE == null)
|
return null;
|
|
List<IStation.Model.CurvePoint> points = CalculateP2(expressQH.ToPoints(15),
|
IStation.Model.CurveExpress.ToPoints(expressQE, 15), midu);
|
if (points == null)
|
return null;
|
return IStation.Model.CurveExpress.ToParameter(points, expressQH.FitType);
|
}
|
#endregion
|
|
|
|
#region 单位换算
|
public static List<IStation.Model.CurvePoint> toM3H(IStation.Unit.eUnitQ unit, List<IStation.Model.CurvePoint> points)
|
{
|
if (unit == IStation.Unit.eUnitQ.M3H)
|
return points;
|
|
if (points == null)
|
return null;
|
List<IStation.Model.CurvePoint> newPoints = new List<IStation.Model.CurvePoint>();
|
for (int i = 0; i < points.Count; i++)
|
{
|
newPoints.Add(new IStation.Model.CurvePoint(IStation.Unit.UnitQHelper.toM3H(unit, points[i].X), points[i].Y));
|
}
|
|
return newPoints;
|
}
|
|
public static List<IStation.Model.CurvePoint> toLS(IStation.Unit.eUnitQ unit, List<IStation.Model.CurvePoint> points)
|
{
|
if (unit == IStation.Unit.eUnitQ.LS)
|
return points;
|
|
if (points == null)
|
return null;
|
List<IStation.Model.CurvePoint> newPoints = new List<IStation.Model.CurvePoint>();
|
for (int i = 0; i < points.Count; i++)
|
{
|
newPoints.Add(new IStation.Model.CurvePoint(IStation.Unit.UnitQHelper.Convert(unit, IStation.Unit.eUnitQ.LS, points[i].X), points[i].Y));
|
}
|
|
return newPoints;
|
}
|
|
public static List<IStation.Model.CurvePoint> toMPa(IStation.Unit.eUnitH unit, List<IStation.Model.CurvePoint> points)
|
{
|
if (unit == IStation.Unit.eUnitH.MPa)
|
return points;
|
|
if (points == null)
|
return null;
|
List<IStation.Model.CurvePoint> newPoints = new List<IStation.Model.CurvePoint>();
|
for (int i = 0; i < points.Count; i++)
|
{
|
newPoints.Add(new IStation.Model.CurvePoint(points[i].X, IStation.Unit.UnitHHelper.toMPa(unit, points[i].Y)));
|
}
|
|
return newPoints;
|
}
|
|
public static List<IStation.Model.CurvePoint> toStdUnit(
|
IStation.Unit.eUnitQ unitQ,
|
IStation.Unit.eUnitH unitH,
|
List<IStation.Model.CurvePoint> points)
|
{
|
if (unitH == IStation.Unit.eUnitH.M && unitQ == Unit.eUnitQ.M3H)
|
return points;
|
|
if (points == null)
|
return null;
|
List<IStation.Model.CurvePoint> newPoints = new List<IStation.Model.CurvePoint>();
|
for (int i = 0; i < points.Count; i++)
|
{
|
newPoints.Add(new IStation.Model.CurvePoint(
|
IStation.Unit.UnitQHelper.toM3H(unitQ, points[i].X),
|
IStation.Unit.UnitHHelper.toM(unitH, points[i].Y)));
|
}
|
|
return newPoints;
|
}
|
|
#endregion
|
|
|
|
#region 取points中Y的最大值(一定在points中)
|
public static IStation.Model.CurvePoint GetMaxPointY(List<IStation.Model.CurvePoint> points)
|
{
|
if (points == null)
|
{
|
return new IStation.Model.CurvePoint(0, 0);
|
}
|
double maxPointX = -10000;
|
double maxPointY = -10000;
|
for (int i = 0; i < points.Count(); i++)
|
{
|
if (points[i].Y > maxPointY)
|
{
|
maxPointX = points[i].X;
|
maxPointY = points[i].Y;
|
}
|
}
|
|
return new IStation.Model.CurvePoint(maxPointX, maxPointY);
|
}
|
#endregion
|
|
|
//三个点增加到5个点(主要气蚀曲线使用)
|
public static List<IStation.Model.CurvePoint> ToFivePoints(List<IStation.Model.CurvePoint> curvePoints)
|
{
|
if (curvePoints == null)
|
return null;
|
//
|
curvePoints = curvePoints.Distinct(new IStation.Model.CurvePoint.EqualComparer()).ToList();
|
curvePoints.Sort(new IStation.Model.CurvePoint.SortComparer(IStation.Model.CurvePoint.eSortType.X));
|
switch (curvePoints.Count)
|
{
|
case 0:
|
return null;
|
case 1:
|
return null;
|
case 2:
|
return curvePoints;
|
case 3:
|
List<IStation.Model.CurvePoint> newPts = new List<IStation.Model.CurvePoint>();
|
newPts.Add(curvePoints[0]);
|
newPts.Add(new IStation.Model.CurvePoint((curvePoints[0].X + curvePoints[1].X) / 2, (curvePoints[0].Y + curvePoints[1].Y) / 2));
|
newPts.Add(curvePoints[1]);
|
newPts.Add(new IStation.Model.CurvePoint((curvePoints[2].X + curvePoints[1].X) / 2, (curvePoints[2].Y + curvePoints[1].Y) / 2));
|
newPts.Add(curvePoints[2]);
|
return newPts;
|
case 4:
|
List<IStation.Model.CurvePoint> newPts2 = new List<IStation.Model.CurvePoint>();
|
newPts2.Add(curvePoints[0]);
|
newPts2.Add(new IStation.Model.CurvePoint((curvePoints[0].X + curvePoints[1].X) / 2, (curvePoints[0].Y + curvePoints[1].Y) / 2));
|
newPts2.Add(curvePoints[1]);
|
newPts2.Add(new IStation.Model.CurvePoint((curvePoints[2].X + curvePoints[1].X) / 2, (curvePoints[2].Y + curvePoints[1].Y) / 2));
|
newPts2.Add(curvePoints[2]);
|
newPts2.Add(new IStation.Model.CurvePoint((curvePoints[2].X + curvePoints[3].X) / 2, (curvePoints[2].Y + curvePoints[3].Y) / 2));
|
newPts2.Add(curvePoints[3]);
|
return newPts2;
|
default:
|
return curvePoints;
|
}
|
|
}
|
|
//曲线叠加(就是方程乘以一个系数ratio)
|
public static IStation.Model.CurveExpress Multiply(IStation.Model.CurveExpress curveExpress, double ratio)
|
{
|
if (curveExpress == null)
|
return null;
|
if (curveExpress is IStation.Model.CurveExpressStartLine)
|
{
|
IStation.Model.CurveExpressStartLine connectCurve = new IStation.Model.CurveExpressStartLine(curveExpress);
|
connectCurve.Min = curveExpress.Min;//范围不会变
|
connectCurve.Max = curveExpress.Max;
|
connectCurve.Index0 = curveExpress.Index0 * ratio;
|
connectCurve.Index1 = curveExpress.Index1 * ratio;
|
connectCurve.Index2 = curveExpress.Index2 * ratio;
|
connectCurve.Index3 = curveExpress.Index3 * ratio;
|
|
return connectCurve;
|
}
|
else
|
{
|
IStation.Model.CurveExpress connectCurve = new IStation.Model.CurveExpress(curveExpress);
|
connectCurve.Min = curveExpress.Min;//范围不会变
|
connectCurve.Max = curveExpress.Max;
|
connectCurve.Index0 = curveExpress.Index0 * ratio;
|
connectCurve.Index1 = curveExpress.Index1 * ratio;
|
connectCurve.Index2 = curveExpress.Index2 * ratio;
|
connectCurve.Index3 = curveExpress.Index3 * ratio;
|
|
return connectCurve;
|
}
|
|
}
|
|
//通过点simularPoint和点(0,0)的抛物线,与曲线Curve的交点(没有,返回Point(0,0))
|
//曲线公式:H=K*Q^2
|
public static IStation.Model.CurvePoint GetSectPointParabola(IStation.Model.CurveExpress curveExpress, IStation.Model.CurvePoint simularPoint)
|
{
|
var points = IStation.Model.FitCurveHelper.GetFitPoints(curveExpress, 50);
|
return IStation.Common.CutSimuCalculer.GetSectPointParabola(points, simularPoint);
|
}
|
public static IStation.Model.CurvePoint GetSectPointParabola(IStation.Model.CurveExpress curveExpress, IStation.Model.CurvePoint simularPoint, double ratioExtend)
|
{
|
var points = IStation.Model.FitCurveHelper.GetFitPointsByExtend(curveExpress, ratioExtend, 50);
|
return IStation.Common.CutSimuCalculer.GetSectPointParabola(points, simularPoint);
|
}
|
|
|
|
}
|
}
|