namespace IStation.Curve { /// /// 泵计算辅助类 /// public class PumpCalculateHelper { #region 常规计算 #region 计算扬程 /// /// 计算扬程 /// /// 瞬时流量 m³/h /// 进口压力 mpa /// 出口压力 mpa /// 进口口径 mm /// 出口口径 mm /// 进口标高 m /// 出口标高 m /// 扬程 m public static double CalculateH(double q, double pr1, double pr2, double d1, double d2, double z1, double z2) { var qa = q / 3600; var pr1a = pr1 * 1000000; var pr2a = pr2 * 1000000; var d1a = d1 / 1000; var d2a = d2 / 1000; var v1 = qa * 4 / (Math.PI * Math.Pow(d1a, 2)); var v2 = qa * 4 / (Math.PI * Math.Pow(d2a, 2)); var distance = z2 - z1; var pg = Constant.WaterDensity * Constant.g; var g2 = 2 * Constant.g; var h = (pr2a / pg - pr1a / pg) + (Math.Pow(v2, 2) / g2 - Math.Pow(v1, 2) / g2) + distance; return h; } /// /// 计算 OtherPress (测量扬程= 压差 + 表位差 + 流速) /// /// 流量 m³/h /// 进口管径 mm /// 出口管径 mm /// 进口标高 mm /// 出口标高 mm /// public static double CalculateOtherPress(double? q, double? inletPipeDia, double? outletPipeDia, double? inletElevation, double? outletElevation) { if (q == null || q.Value < 0.05) { if (outletElevation == null || inletElevation == null) return 0; return outletElevation.Value - inletElevation.Value; } double flow = q.Value; double inPipeV = 0; if (inletPipeDia != null && inletPipeDia.Value > 0.1) { // 流速计算 pipeD =mm,pumpFlow=m3/p inPipeV = Constant.OtherPressCoeff * flow / inletPipeDia.Value / inletPipeDia.Value; } double outPipeV = 0; if (outletPipeDia != null && outletPipeDia.Value > 0.1) { // 流速计算 rPipeD =mm,rPumpFlow=m3/p outPipeV = Constant.OtherPressCoeff * flow / outletPipeDia.Value / outletPipeDia.Value; } double differV = (outPipeV * outPipeV - inPipeV * inPipeV) / Constant.g / 2.0; if (outletElevation == null || inletElevation == null) return differV; return differV + outletElevation.Value - inletElevation.Value; } #endregion #region 计算效率 /// /// 计算效率 /// /// 瞬时流量 m³/h /// 扬程 m /// 功率 kw /// 密度 kg/m^3 /// 重力加速度 m/s^2 /// 百分数 public static double CalculateE(double q, double h, double p, double ρ, double g) { var qa = q / 3600; var pa = p * 1000; double e = 0; if (pa < 0.1) { return e; } e = ρ * g * qa * h / pa; return Math.Round(e * 100, 2); } /// /// 计算效率 /// /// 瞬时流量 m³/h /// 扬程 m /// 功率 kw /// 百分数 public static double CalculateE(double q, double h, double p) { return CalculateE(q, h, p, Constant.WaterDensity, Constant.g); } /// /// 计算效率 /// /// 瞬时流量 m³/h /// 扬程 m /// 功率 kw /// 密度 kg/m^3 /// 百分数 public static double CalculateE(double q, double h, double p, double ρ) { return CalculateE(q, h, p, ρ, Constant.g); } #endregion #region 计算功率 /// /// 计算功率 /// /// 瞬时流量 m³/h /// 扬程 m /// 效率 百分数 /// 密度kg/m³ /// 重力加速度 m/s² /// kw public static double CalculateP(double q, double h, double e, double ρ, double g) { var qa = q / 3600; var ea = e / 100; double p = 0; if (ea < 0.01) { return p; } p = ρ * g * qa * h / ea; p = p / 1000;//换算成kw if (p < 2) { return Math.Round(p, 4); } if (p < 30) { return Math.Round(p, 3); } if (p < 100) { return Math.Round(p, 2); } return Math.Round(p, 1); } /// /// 计算功率 /// /// 瞬时流量 m³/h /// 扬程 m /// 效率 百分数 /// 密度kg/m³ /// kw public static double CalculateP(double q, double h, double e, double ρ) { return CalculateP(q, h, e, ρ, Constant.g); } /// /// 计算功率 /// /// 瞬时流量 m³/h /// 扬程 m /// 效率 百分数 /// kw public static double CalculateP(double q, double h, double e) { return CalculateP(q, h, e, Constant.WaterDensity, Constant.g); } #endregion #region Mpa<=>m /// /// Mpa=>m /// public static double Mpa2M(double mpa) { return mpa * Constant.WaterDensity / Constant.g; } /// /// m=>Mpa /// public static double M2Mpa(double m) { return m * Constant.g / Constant.WaterDensity; } #endregion #region 计算用电量 /// /// 计算用电量 /// /// 功率kw /// 时间h /// kw*h public static double CalculateD(double p, double t) { return p * t; } #endregion #region 计算累积流量 /// /// 计算累积流量 /// /// 瞬时流量m³/h /// 时间h /// public static double CalculateQt(double q, double t) { return q * t; } #endregion #region 计算能耗 /// /// 计算千吨能耗 /// /// 功率kW /// 瞬时流量m³/h /// kW·h/km³ public static double CalculateWP(double p, double q) { if (q < 0.1) { return default; } return p / q * 1000; } /// /// 计算单位能耗 /// /// 功率kW /// 瞬时流量m³/h /// 扬程m /// kW·h/km³ public static double CalculateUWP(double p, double q, double h) { if (q < 0.1) { return default; } if (h < 0.1) { return default; } return p / q / h * 1000; } #endregion #region 频率换算 /// /// 根据频率计算流量 /// /// 瞬时流量 m³/h /// 频率 /// 额定频率 /// public static double CalculateQByHz(double q, double hz, double hzr = 50) { if (hzr < 0.1) { return q; } if (hz < 0.1) { return q; } /* if (hz > hzr) { return q; }*/ double f_ratio = hzr / hz; return q * f_ratio; } /// /// 根据频率计算扬程 /// /// 扬程 m /// 频率 /// 额定频率 /// public static double CalculateHByHz(double h, double hz, double hzr = 50) { if (hzr < 0.1) { return h; } if (hz < 0.1) { return h; } /* if (hz > hzr) { return h; }*/ double f_ratio = hzr / hz; return h * f_ratio * f_ratio; } /// /// 根据频率计算 50hz功率 /// /// 功率 kw /// 频率 kw /// 额定频率 /// public static double CalculatePByHz(double p, double hz, double hzr = 50) { if (hzr < 0.1) { return p; } if (hz < 0.1) { return p; } /* if (hz > hzr) { return p; }*/ double f_ratio = hzr / hz; return p * f_ratio * f_ratio * f_ratio; } /// /// 根据转速计算流量 /// /// 瞬时流量 m³/h /// 转速 r/min /// 额定转速 r/min /// public static double CalculateQByN(double q, double n, double nr) { if (nr < 0.1) { return q; } if (n < 0.1) { return q; } double f_ratio = nr / n; return q * f_ratio; } /// /// 根据转速计算扬程 /// /// 扬程 m /// 转速 r/min /// 额定转速 r/min /// public static double CalculateHByN(double h, double n, double nr) { if (nr < 0.1) { return h; } if (n < 0.1) { return h; } double f_ratio = nr / n; return h * f_ratio * f_ratio; } /// /// 根据转速计算功率 /// /// 功率 kw /// 转速 r/min /// 额定转速 r/min /// public static double CalculatePByN(double p, double n, double nr) { if (nr < 0.1) { return p; } if (n < 0.1) { return p; } double f_ratio = nr / n; return p * f_ratio * f_ratio * f_ratio; } #endregion #endregion #region 复杂计算 #region Simu /// /// 知道原始速度,以及原始的杨程H以及对应的变速后的杨程,求变速后的速度 /// /// /// /// /// public static double CalculateSimuByH(double originSpeend, double originH, double changeH) { double ratio = Math.Pow(originH / changeH, 1.0 / 2.0); return originSpeend / ratio; } /// /// 知道原始速度,以及原始的流量Q以及对应的变速后的杨程,求变速后的速度 /// /// /// /// /// public static double CalculateSimuByQ(double originSpeend, double originQ, double changeQ) { double ratio = originQ / changeQ; return originSpeend / ratio; } #endregion #region 相似换算 /// /// 计算相似流量扬程曲线 /// /// 表达式 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static CurveExpress CalculateSimilarQH(CurveExpress express, double originHz, double changeHz, int pointNumber = 12) { if (express == null) return null; if (changeHz < 1) return null; List fitPoints = null; if (express.DefinePoints != null && express.DefinePoints.Any()) fitPoints = express.DefinePoints; else fitPoints = FitHelper.GetFitPoints(express, pointNumber); var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio; similarPoints.Add(similarPoint); } return FitHelper.BuildCurveExpress(similarPoints, express.FitType); } /// /// 计算相似流量功率曲线 /// /// 表达式 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static CurveExpress CalculateSimilarQP(CurveExpress curvePoints, double originHz, double changeHz, int pointNumber = 12) { if (curvePoints == null) return null; if (changeHz < 1) return null; List fitPoints = null; if (curvePoints.DefinePoints != null && curvePoints.DefinePoints.Any()) fitPoints = curvePoints.DefinePoints; else fitPoints = FitHelper.GetFitPoints(curvePoints, pointNumber); var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio * ratio; similarPoints.Add(similarPoint); } return FitHelper.BuildCurveExpress(similarPoints, curvePoints.FitType); } /// /// 计算相似流量效率曲线 /// /// 表达式 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static CurveExpress CalculateSimilarQE(CurveExpress curvePoints, double originHz, double changeHz, int pointNumber = 12) { if (curvePoints == null) return null; if (changeHz < 1) return null; List fitPoints = null; if (curvePoints.DefinePoints != null && curvePoints.DefinePoints.Any()) fitPoints = curvePoints.DefinePoints; else fitPoints = FitHelper.GetFitPoints(curvePoints, pointNumber); var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y; similarPoints.Add(similarPoint); } return FitHelper.BuildCurveExpress(similarPoints, curvePoints.FitType); } /// /// 计算相似流量扬程曲线点 /// /// 曲线点 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static List CalculateSimilarQH(List fitPoints, double originHz, double changeHz) { if (fitPoints == null || !fitPoints.Any()) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio; similarPoints.Add(similarPoint); } return similarPoints; } /// /// 计算相似流量功率曲线点 /// /// 曲线点 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static List CalculateSimilarQP(List fitPoints, double originHz, double changeHz) { if (fitPoints == null || !fitPoints.Any()) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio * ratio; similarPoints.Add(similarPoint); } return similarPoints; } /// /// 计算相似流量效率曲线点 /// /// 曲线点 /// 原始频率 /// 换算频率 /// 拟合点数量 /// public static List CalculateSimilarQE(List fitPoints, double originHz, double changeHz) { if (fitPoints == null || !fitPoints.Any()) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoints = new List(); foreach (CurvePoint fitPoint in fitPoints) { var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y; similarPoints.Add(similarPoint); } return similarPoints; } /// /// 计算相似流量扬程点 /// /// 点 /// 原始频率 /// 换算频率 /// public static CurvePoint CalculateSimilarQH(CurvePoint fitPoint, double originHz, double changeHz) { if (fitPoint == null) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio; return similarPoint; } /// /// 计算相似流量功率点 /// /// 点 /// 原始频率 /// 换算频率 /// public static CurvePoint CalculateSimilarQP(CurvePoint fitPoint, double originHz, double changeHz) { if (fitPoint == null) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y * ratio * ratio * ratio; return similarPoint; } /// /// 计算相似流量效率点 /// /// 点 /// 原始频率 /// 换算频率 /// public static CurvePoint CalculateSimilarQE(CurvePoint fitPoint, double originHz, double changeHz) { if (fitPoint == null) return null; if (changeHz < 1) return null; var ratio = changeHz / originHz; var similarPoint = new CurvePoint(); similarPoint.X = fitPoint.X * ratio; similarPoint.Y = fitPoint.Y; return similarPoint; } #endregion #region 计算比转速度 public static double CalculateNs(double Q, double H, double n) { return 3.65 * n * Math.Sqrt(Q / 3600) / Math.Pow(H, 0.75); } public static decimal CalculateNs(decimal Q, decimal H, decimal n) { return Convert.ToDecimal(3.65 * Convert.ToDouble(n) * Math.Sqrt(Convert.ToDouble(Q) / 3600) / Math.Pow(Convert.ToDouble(H), 0.75)); } #endregion #region 计算推荐参数 public enum eCalculatePumpType { 单级单吸离心泵 = 1, 多级离心泵 = 2, 双吸离心泵 = 3, 化工泵 = 4, 渣浆泵 = 5, 长轴泵 = 6 } //capacity static double[] effq = new double[33] { 5, 10, 15, 20, 25, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000 }; //1 single stage seriesEntity eff static double[] singleeff = new double[33] { 58.0, 64.0, 67.2, 69.4, 70.9, 72.0, 73.8, 74.9, 75.8, 76.5, 77.0, 77.6, 78.0, 79.8, 80.8, 82.0, 83.0, 83.7, 84.2, 84.7, 85.0, 85.3, 85.7, 86.6, 87.2, 88.0, 88.6, 89.0, 89.2, 89.5, 89.7, 89.9, 90.0 }; //2 multi stage seriesEntity eff static double[] multieff = new double[26] { 55.4, 59.4, 61.8, 63.5, 64.8, 65.9, 67.5, 68.9, 69.9, 70.9, 71.5, 72.3, 72.9, 75.3, 76.9, 79.2, 80.6, 81.5, 82.2, 82.8, 83.1, 83.5, 83.9, 84.8, 85.1, 85.5 }; //1 correct eff static double[] effcorrect1 = new double[19] { 32, 25.5, 20.6, 17.3, 14.7, 12.5, 10.5, 9.0, 7.5, 6.0, 5.0, 4.0, 3.2, 2.5, 2.0, 1.5, 1.0, 0.5, 0 }; //2 correct eff static double[] effcorrect2 = new double[10] { 0, 0.3, 0.7, 1.0, 1.3, 1.7, 1.9, 2.2, 2.7, 3.0 }; static double[] effns1 = new double[19] { 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110, 120 }; static double[] effns2 = new double[10] { 210, 220, 230, 240, 250, 260, 270, 280, 290, 300 }; /// /// 根据泵类型计算推荐效率 /// /// 流量 /// 扬程 /// 转速 /// 泵类型 /// public static double CalculateEByPumpType(double q, double h, double n, int pumpType) { double ns = CalculateNs(q, h, n); double eff, qjs1, qjs2, qjs3, effjs1, effjs2, effjs3, correct = 1; int i = 0; double dltE = 0.0; double q0 = q; double h0 = h; // double t = 1000; if (pumpType == (int)eCalculatePumpType.单级单吸离心泵) t = 10000; if (pumpType == (int)eCalculatePumpType.多级离心泵) t = 300000; if (pumpType == (int)eCalculatePumpType.双吸离心泵) t = 10000; if (pumpType == (int)eCalculatePumpType.化工泵) t = 10000; if (pumpType == (int)eCalculatePumpType.渣浆泵) t = 10000; if (pumpType == (int)eCalculatePumpType.长轴泵) t = 10000; if (q0 > t) { i = effq.Length - 1; } else if (q0 >= 1.5 && q0 <= t) { i = 0; for (i = 0; effq[i] <= q0; i++) { if (i + 1 == effq.Count()) { break; } } } else { return -1; } if (i >= effq.Length) i = effq.Length - 1; if (q0 >= 10) { qjs1 = effq[i]; qjs2 = effq[i - 1]; qjs3 = effq[i - 2]; switch (pumpType) { case 1: if (i >= singleeff.Length) i = singleeff.Length - 1; effjs1 = singleeff[i]; effjs2 = singleeff[i - 1]; effjs3 = singleeff[i - 2]; break; case 2: if (i >= multieff.Length) i = multieff.Length - 1; effjs1 = multieff[i]; effjs2 = multieff[i - 1]; effjs3 = multieff[i - 2]; break; case 3: if (i >= singleeff.Length) i = singleeff.Length - 1; effjs1 = singleeff[i]; effjs2 = singleeff[i - 1]; effjs3 = singleeff[i - 2]; dltE = -2; break; case 4: if (i >= singleeff.Length) i = singleeff.Length - 1; effjs1 = singleeff[i]; effjs2 = singleeff[i - 1]; effjs3 = singleeff[i - 2]; dltE = 5; break; case 5: effjs1 = singleeff[i]; effjs2 = singleeff[i - 1]; effjs3 = singleeff[i - 2]; dltE = 8; break; default: effjs1 = singleeff[i]; effjs2 = singleeff[i - 1]; effjs3 = singleeff[i - 2]; dltE = 3.5; break; } } else { qjs1 = effq[2]; qjs2 = effq[1]; qjs3 = effq[0]; switch (pumpType) { case 1: effjs1 = singleeff[2]; effjs2 = singleeff[1]; effjs3 = singleeff[0]; break; case 2: effjs1 = multieff[2]; effjs2 = multieff[1]; effjs3 = multieff[0]; break; case 3: effjs1 = singleeff[2]; effjs2 = singleeff[1]; effjs3 = singleeff[0]; dltE = -2; break; case 4: effjs1 = singleeff[2]; effjs2 = singleeff[1]; effjs3 = singleeff[0]; dltE = 5; break; case 5: effjs1 = singleeff[2]; effjs2 = singleeff[1]; effjs3 = singleeff[0]; dltE = 8; break; default: effjs1 = singleeff[2]; effjs2 = singleeff[1]; effjs3 = singleeff[0]; dltE = 3.5; break; } } eff = (q0 - qjs2) * (q0 - qjs3) * effjs1 / ((qjs1 - qjs2) * (qjs1 - qjs3)) + (q0 - qjs1) * (q0 - qjs3) * effjs2 / ((qjs2 - qjs1) * (qjs2 - qjs3)) + (q0 - qjs1) * (q0 - qjs2) * effjs3 / ((qjs3 - qjs1) * (qjs3 - qjs2)) - dltE; if ((ns < 120 && ns >= 20) || (ns < 300 && ns > 210)) { if (ns < 120 && ns >= 20) { for (i = 0; effns1[i] <= ns; i++) { } if (ns >= 25) { qjs1 = effns1[i]; qjs2 = effns1[i - 1]; qjs3 = effns1[i - 2]; effjs1 = effcorrect1[i]; effjs2 = effcorrect1[i - 1]; effjs3 = effcorrect1[i - 2]; } else { qjs1 = effns1[i + 1]; qjs2 = effns1[i]; qjs3 = effns1[i - 1]; effjs1 = effcorrect1[i + 1]; effjs2 = effcorrect1[i]; effjs3 = effcorrect1[i - 1]; } } if (ns < 300 && ns > 210) { for (i = 0; effns2[i] <= ns; i++) { } if (ns >= 220) { qjs1 = effns2[i]; qjs2 = effns2[i - 1]; qjs3 = effns2[i - 2]; effjs1 = effcorrect2[i]; effjs2 = effcorrect2[i - 1]; effjs3 = effcorrect2[i - 2]; } else { qjs1 = effns2[i + 1]; qjs2 = effns2[i]; qjs3 = effns2[i - 1]; effjs1 = effcorrect2[i + 1]; effjs2 = effcorrect2[i]; effjs3 = effcorrect2[i - 1]; } } correct = (ns - qjs2) * (ns - qjs3) * effjs1 / ((qjs1 - qjs2) * (qjs1 - qjs3)) + (ns - qjs1) * (ns - qjs3) * effjs2 / ((qjs2 - qjs1) * (qjs2 - qjs3)) + (ns - qjs1) * (ns - qjs2) * effjs3 / ((qjs3 - qjs1) * (qjs3 - qjs2)); } if (ns >= 300) correct = 3.0; if (ns < 20) correct = 32.0; if (ns >= 120 && ns <= 210) correct = 0; eff = eff - correct; return eff; } //计算推荐NPSHr public static double CalculateNPSHrByPumpType(double Q, double H, double n, int iPumpType) { double ns = CalculateNs(Q, H, n); double S_Q = 10; if (iPumpType == 3) S_Q = Q / 2; else S_Q = Q; double K = Math.Pow(ns, 1.3333) * 216 / 1000000; return K * H; } #endregion #region 计算功率 /// /// 计算功率 /// /// 流量扬程点 /// 流量效率点 /// 流量功率点 public static List CalculateP(List ptQHs, List ptQEs) { if (ptQHs == null || ptQHs.Count() <= 2) return null; bool isXStartZero = ptQHs.First().X > 500 || ptQHs.First().X > ptQHs.Last().X * 0.2; return CalculateP(eFitType.CubicCurve, eFitType.CubicCurve, eFitType.CubicCurve, ptQHs, ptQEs, Constant.WaterDensity, -1, isXStartZero); } /// /// 计算功率 /// /// 流量扬程线拟合方式 /// 流量效率线拟合方式 /// 流量功率线拟合方式 /// 流量扬程点 /// 流量效率点 /// 水的密度 /// 流量为0时的功率 /// 流量是否为0 /// public static List CalculateP( eFitType fitQH, eFitType fitQE, eFitType fitQP, List ptQHs, List ptQEs, double midu, double zeroPower, bool isXStartZero) { if (ptQHs == null || ptQHs.Count < 3) return null; if (ptQEs == null || ptQEs.Count < 3) return null; var curveQH = FitHelper.BuildCurveExpress(ptQHs, fitQH); var curveQE = FitHelper.BuildCurveExpress(ptQEs, fitQE); var curveQP = CalculateP(fitQP, curveQH, curveQE, midu, zeroPower, isXStartZero); return curveQP.GetFitPoints(ptQEs.Count()); } /// /// 计算功率 /// /// 流量功率线拟合方式 /// 流量扬程线 /// 流量效率线 /// 水的密度 /// 流量为0时的功率 /// 流量是否为0 /// public static CurveExpress CalculateP(eFitType fitQP, CurveExpress curveQH, CurveExpress curveQE, double midu, double zeroPower, bool isXStartZero) { if (curveQH == null || curveQE == null) return null; int pointNumber = 16;//点不能太多 var ptQHs = curveQH.GetFitPoints(pointNumber); if (ptQHs == null || ptQHs.Count < 3) return null; var ptQEs = curveQE.GetFitPoints(pointNumber); if (ptQEs == null || ptQEs.Count < 3) return null; List pointQP = new List(); //间距 double minQ = Math.Max(ptQHs.First().X, ptQEs.First().X); double maxQ = Math.Min(ptQHs.Last().X, ptQEs.Last().X); // double Q, H, E, P; double space = (maxQ - minQ) / (pointNumber - 1); //保证从0开始: 保证Q=0时,P不是计算出来的; if (isXStartZero) { for (int i = 5; i < pointNumber; i++)//前面几个点不要 { Q = ptQEs.First().X + space * i; E = curveQE.GetFitPointY(Q); H = curveQH.GetFitPointY(Q); if (H < 0.1 || E < 0.5) continue; P = 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 CurvePoint(Q, P)); } pointQP = FitHelper.GetFitPoints(pointQP, fitQP, pointNumber); if (pointQP == null) return null; if (zeroPower > 0.1) { pointQP.Insert(0, new CurvePoint(0, zeroPower)); } else { if (pointQP[0].Y >= pointQP[1].Y) { pointQP[0].Y = pointQP[1].Y * 0.95; } double startP = 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 CurvePoint(0, startP)); } return FitHelper.BuildCurveExpress(pointQP, fitQP); } else { for (int i = 0; i < pointNumber; i++)//前面几个点不要 { Q = ptQEs.First().X + space * i; E = curveQE.GetFitPointY(Q); H = curveQH.GetFitPointY(Q); if (H < 0.1 || E < 0.5) continue; P = 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 CurvePoint(Q, P)); } pointQP = FitHelper.GetFitPoints(pointQP, fitQP, pointNumber); if (pointQP == null) return null; return FitHelper.BuildCurveExpress(pointQP, fitQP); } } #endregion #region 计算效率 public static CurveExpress CalculateE(eFitType fitType, CurveExpress expressQH, CurveExpress expressQP) { return CalculateE(fitType, expressQH, expressQP, Constant.WaterDensity); } public static CurveExpress CalculateE(CurveExpress expressQH, CurveExpress expressQP) { return CalculateE(expressQH, expressQP, Constant.WaterDensity); } public static CurveExpress CalculateE(CurveExpress expressQH, CurveExpress expressQP, bool isXStartZero) { return CalculateE(expressQH, expressQP, Constant.WaterDensity, isXStartZero); } public static CurveExpress CalculateE(CurveExpress expressQH, CurveExpress expressQP, double midu) { if (expressQH == null) return null; return CalculateE(expressQH.FitType, expressQH, expressQP, midu); } public static CurveExpress CalculateE(CurveExpress expressQH, CurveExpress expressQP, double midu, bool isXStartZero) { if (expressQH == null) return null; return CalculateE(expressQH.FitType, expressQH, expressQP, midu, isXStartZero); } public static CurveExpress CalculateE(eFitType fitTypeQE, CurveExpress expressQH, CurveExpress expressQP, double midu) { if (expressQH == null) return null; bool isXStartZero = true; if (expressQH.Min > 500 || expressQH.Min > expressQH.Max * 0.1) { isXStartZero = false; } else { isXStartZero = true; } return CalculateE(fitTypeQE, expressQH, expressQP, midu, isXStartZero); } public static CurveExpress CalculateE(eFitType fitTypeQE, CurveExpress expressQH, CurveExpress expressQP, double midu, bool isXStartZero) { if (expressQH == null) return null; if (expressQP == null) return null; int PointNumber = 12; List pointQE = new List(); List pointQP = FitHelper.GetFitPoints(expressQP, PointNumber); double Q, H, Eff, Power; FitHelper fitCurve = new FitHelper(expressQH); for (int i = 0; i < pointQP.Count; i++) { Q = pointQP[i].X; Power = pointQP[i].Y; H = fitCurve.GetFitPointY(Q); Eff = CalculateE(Q, H, Power, midu); pointQE.Add(new CurvePoint(Q, Eff)); } //保证Q=0时,Eff=0; if (isXStartZero) { pointQE[0] = new CurvePoint(0, 0); var fitCurve1 = FitHelper.GetFitPoints(pointQE, fitTypeQE, pointQE.Count()); pointQE = AmendCurveHelper.ByZeroPointY(fitCurve1, pointQE[3].X, 0); return FitHelper.BuildCurveExpress(pointQE, fitTypeQE); } else { return FitHelper.BuildCurveExpress(pointQE, fitTypeQE); } } public static List CalculateEpoint( eFitType CurveFitTypeQE, CurveExpress expressQH, CurveExpress expressQP, int PointNumber, double midu) { if (expressQH == null) return null; if (expressQP == null) return null; List pointQE = new List(); List pointQP = FitHelper.GetFitPoints(expressQP, PointNumber); double Q, H, Eff, Power; FitHelper fitCurve = new FitHelper(expressQH); for (int i = 0; i < pointQP.Count; i++) { Q = pointQP[i].X; Power = pointQP[i].Y; H = fitCurve.GetFitPointY(Q); Eff = CalculateE(Q, H, Power, midu); pointQE.Add(new CurvePoint(Q, Eff)); } bool isXStartZero = true; if (pointQE.First().X > 500 || pointQE.First().X > pointQE.Last().X * 0.1) { isXStartZero = false; } else { isXStartZero = true; } //保证Q=0时,Eff=0; if (isXStartZero) { pointQE[0] = new CurvePoint(0, 0); var fitCurve1 = FitHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count()); return AmendCurveHelper.ByZeroPointY(fitCurve1, pointQE[3].X, 0); } else { return FitHelper.GetFitPoints(pointQE, CurveFitTypeQE, pointQE.Count()); } } //注意此方法 返回的点没有拟合 public static List CalculateE_AlignPointP( List pointQH, List pointQP, double midu, bool isXStartZero) { return CalculateE_AlignPointP( eFitType.CubicCurve, eFitType.CubicCurve, eFitType.CubicCurve, pointQH, pointQP, midu, isXStartZero); } public static List CalculateE_AlignPointP( eFitType CurveFitTypeQH, eFitType CurveFitTypeQE, eFitType CurveFitTypeQP, List pointQH, List pointQP, double midu, bool isXStartZero) { if (pointQH == null || pointQH.Count < 3) return null; if (pointQP == null || pointQP.Count < 3) return null; List pointQE = new List(); if (pointQH.IsEqualValueX(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 = CalculateE(Q, H, Power, midu); pointQE.Add(new CurvePoint(Q, Eff)); } } else { FitHelper fitCurve_QP = new FitHelper(pointQP, CurveFitTypeQP); FitHelper fitCurve_QH = new FitHelper(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 = CalculateE(Q, H, Power, midu); pointQE.Add(new CurvePoint(Q, Eff)); } } //pointQE = FitHelper.GetFitPointsByExtend(pointQE); //保证Q=0时,Eff=0; if (isXStartZero) { pointQE[0] = new CurvePoint(0, 0); } return pointQE; } #endregion #region 功率效率换算 /// /// 计算效率 对其功率 /// public static List CalculateELineByP(List ptQHs, List ptQPs, bool isXStartZero) { return CalculateELineByP(eFitType.CubicCurve, eFitType.CubicCurve, ptQHs, ptQPs, isXStartZero); } /// /// 计算效率 对其功率 /// public static List CalculateELineByP(eFitType fitTypeQH, eFitType fitTypeQP, List ptQHs, List ptQPs, bool isXStartZero) { if (ptQHs == null || ptQHs.Count < 3) { return null; } if (ptQPs == null || ptQPs.Count < 3) { return null; } List list = new List(); if (ptQHs.IsEqualValueX(ptQPs)) { for (int i = 0; i < ptQPs.Count; i++) { double x = ptQPs[i].X; double y = ptQPs[i].Y; double y2 = ptQHs[i].Y; double y3 = CalculateE(x, y2, y, Constant.WaterDensity); list.Add(new CurvePoint(x, y3)); } } else { FitHelper fitCurveHelper = new FitHelper(ptQPs, fitTypeQP); FitHelper fitCurveHelper2 = new FitHelper(ptQHs, fitTypeQH); for (int j = 0; j < ptQPs.Count; j++) { double x2 = ptQPs[j].X; double fitPointY = fitCurveHelper.GetFitPointY(x2); double fitPointY2 = fitCurveHelper2.GetFitPointY(x2); double y4 = CalculateE(x2, fitPointY2, fitPointY, Constant.WaterDensity); list.Add(new CurvePoint(x2, y4)); } } if (isXStartZero) { list[0] = new CurvePoint(0, 0); } return list; } /// /// 计算效率 对其效率 /// public static List CalculateP_AlignPointE(eFitType fitTypeQH, eFitType fitTypeQE, List ptQHs, List ptQEs, double midu, double ref_zero_power, bool isXStartZero) { if (ptQHs == null || ptQHs.Count < 3) { return null; } if (ptQEs == null || ptQEs.Count < 3) { return null; } List list = new List(); if (ptQHs.IsEqualValueX(ptQEs)) { for (int i = 0; i < ptQEs.Count(); i++) { double x = ptQEs[i].X; double y = ptQEs[i].Y; double y2 = ptQHs[i].Y; if (!(y2 < 0.1) && !(y < 0.5)) { double num = CalculateP(x, y2, y, midu); num = ((num < 2.0) ? Math.Round(num, 3) : ((num < 30.0) ? Math.Round(num, 2) : ((!(num < 100.0)) ? Math.Round(num, 0) : Math.Round(num, 1)))); list.Add(new CurvePoint(x, num)); } } } else { FitHelper fitCurveHelper = new FitHelper(ptQEs, fitTypeQE); FitHelper fitCurveHelper2 = new FitHelper(ptQHs, fitTypeQH); for (int j = 0; j < ptQEs.Count(); j++) { if (j == ptQEs.Count() - 2) { //测试代码 } double x2 = ptQEs[j].X; double fitPointY = fitCurveHelper.GetFitPointY(x2); double fitPointY2 = fitCurveHelper2.GetFitPointY(x2); if (!(fitPointY2 < 0.09) && !(fitPointY < 0.5)) { double num2 = CalculateP(x2, fitPointY2, fitPointY, midu); num2 = ((num2 < 2.0) ? Math.Round(num2, 3) : ((num2 < 30.0) ? Math.Round(num2, 2) : ((!(num2 < 100.0)) ? Math.Round(num2, 0) : Math.Round(num2, 1)))); list.Add(new CurvePoint(x2, num2)); } } } if (isXStartZero) { if (list[0].X < 1.0) { if (ref_zero_power > 0.0) { list[0].X = 0.0; list[0].Y = ref_zero_power; } else { list.RemoveAt(0); var fitPoints = FitHelper.GetFitPoints(list); if (fitPoints[0].Y >= fitPoints[1].Y) { fitPoints[0].Y = fitPoints[1].Y * 0.95; } double num3 = CurveLineHelper.GetYbyX(fitPoints[0].X, fitPoints[0].Y, fitPoints[1].X, fitPoints[1].Y, 0.0); if (num3 < 0.001) { num3 = fitPoints[0].Y; } num3 = ((num3 < 2.0) ? Math.Round(num3, 3) : ((num3 < 30.0) ? Math.Round(num3, 2) : ((!(num3 < 100.0)) ? Math.Round(num3, 0) : Math.Round(num3, 1)))); list.Insert(0, new CurvePoint(0.0, num3)); } } else if (ref_zero_power > 0.0) { list.Insert(0, new CurvePoint(0.0, ref_zero_power)); } else { var fitPoints2 = FitHelper.GetFitPoints(list); if (fitPoints2[0].Y >= fitPoints2[1].Y) { fitPoints2[0].Y = fitPoints2[1].Y * 0.95; } double num4 = CurveLineHelper.GetYbyX(fitPoints2[0].X, fitPoints2[0].Y, fitPoints2[1].X, fitPoints2[1].Y, 0.0); if (num4 < 0.001) { num4 = fitPoints2[0].Y; } num4 = ((num4 < 2.0) ? Math.Round(num4, 3) : ((num4 < 30.0) ? Math.Round(num4, 2) : ((!(num4 < 100.0)) ? Math.Round(num4, 0) : Math.Round(num4, 1)))); list.Insert(0, new CurvePoint(0.0, num4)); } } return list; } /// /// 计算效率 对其效率 /// public static List CalculateP_AlignPointE(List ptQHs, List ptQEs, double midu, double ref_zero_power, bool isXStartZero) { if (ptQHs == null || ptQHs.Count < 3) { return null; } if (ptQEs == null || ptQEs.Count < 3) { return null; } List list = new List(); if (ptQHs.IsEqualValueX(ptQEs)) { for (int i = 0; i < ptQEs.Count(); i++) { double x = ptQEs[i].X; double y = ptQEs[i].Y; double y2 = ptQHs[i].Y; if (!(y2 < 0.1) && !(y < 0.5)) { double num = CalculateP(x, y2, y, midu); num = ((num < 2.0) ? Math.Round(num, 3) : ((num < 30.0) ? Math.Round(num, 2) : ((!(num < 100.0)) ? Math.Round(num, 0) : Math.Round(num, 1)))); list.Add(new CurvePoint(x, num)); } } } else { FitHelper fitCurveHelper = new FitHelper(ptQEs); FitHelper fitCurveHelper2 = new FitHelper(ptQHs); for (int j = 0; j < ptQEs.Count(); j++) { double x2 = ptQEs[j].X; double fitPointY = fitCurveHelper.GetFitPointY(x2); double fitPointY2 = fitCurveHelper2.GetFitPointY(x2); if (!(fitPointY2 < 0.1) && !(fitPointY < 0.5)) { double num2 = CalculateP(x2, fitPointY2, fitPointY, midu); num2 = ((num2 < 2.0) ? Math.Round(num2, 3) : ((num2 < 30.0) ? Math.Round(num2, 2) : ((!(num2 < 100.0)) ? Math.Round(num2, 0) : Math.Round(num2, 1)))); list.Add(new CurvePoint(x2, num2)); } } } if (isXStartZero) { if (list[0].X < 1.0) { if (ref_zero_power > 0.0) { list[0].X = 0.0; list[0].Y = ref_zero_power; } else { list.RemoveAt(0); var fitPoints = FitHelper.GetFitPoints(list); if (fitPoints[0].Y >= fitPoints[1].Y) { fitPoints[0].Y = fitPoints[1].Y * 0.95; } double num3 = CurveLineHelper.GetYbyX(fitPoints[0].X, fitPoints[0].Y, fitPoints[1].X, fitPoints[1].Y, 0.0); if (num3 < 0.001) { num3 = fitPoints[0].Y; } num3 = ((num3 < 2.0) ? Math.Round(num3, 3) : ((num3 < 30.0) ? Math.Round(num3, 2) : ((!(num3 < 100.0)) ? Math.Round(num3, 0) : Math.Round(num3, 1)))); list.Insert(0, new CurvePoint(0.0, num3)); } } else if (ref_zero_power > 0.0) { list.Insert(0, new CurvePoint(0.0, ref_zero_power)); } else { var fitPoints2 = FitHelper.GetFitPoints(list); if (fitPoints2[0].Y >= fitPoints2[1].Y) { fitPoints2[0].Y = fitPoints2[1].Y * 0.95; } double num4 = CurveLineHelper.GetYbyX(fitPoints2[0].X, fitPoints2[0].Y, fitPoints2[1].X, fitPoints2[1].Y, 0.0); if (num4 < 0.001) { num4 = fitPoints2[0].Y; } num4 = ((num4 < 2.0) ? Math.Round(num4, 3) : ((num4 < 30.0) ? Math.Round(num4, 2) : ((!(num4 < 100.0)) ? Math.Round(num4, 0) : Math.Round(num4, 1)))); list.Insert(0, new CurvePoint(0.0, num4)); } } return list; } #endregion #endregion } }