From 69f942b58a5924e34e6c2bfdadefdcb8e6313edb Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期二, 15 十月 2024 14:34:45 +0800 Subject: [PATCH] 增加对泵属性的增加修改快捷方式 --- WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/01-calculate/PumpCalcHelper.cs | 202 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 199 insertions(+), 3 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/01-calculate/PumpCalcHelper.cs b/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/01-calculate/PumpCalcHelper.cs index dc54bfe..022e110 100644 --- a/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/01-calculate/PumpCalcHelper.cs +++ b/WinFrmUI/Yw.WinFrmUI.Phart.Core/00-core/01-calculate/PumpCalcHelper.cs @@ -1,11 +1,12 @@ 锘縰sing NPOI.Util; +using Yw.Geometry; namespace Yw.WinFrmUI.Phart { /// <summary> /// 鎬ц兘璁$畻杈呭姪绫� /// </summary> - public class PumpCalcHelper + public static class PumpCalcHelper { #region 甯歌璁$畻 @@ -699,6 +700,8 @@ return similar_point; } + + #endregion #region 璁$畻鎺ㄨ崘鍙傛暟 @@ -1500,7 +1503,200 @@ #endregion - + #endregion - } + + + #region 鏇茬嚎涓嶩=K*Q^i鐨勪氦鐐� + + /// <summary> + /// 鏍规嵁鐩镐技鐐硅缃浉浼兼洸绾�,鐩镐技鐐�(閫夋嫨鐐�)鐨剎:娴侀噺y:鏉ㄧ▼ + /// </summary> + public static double GetSimuValue(Yw.Geometry.CubicSpline2d cubic_spline, Yw.Geometry.Point2d simular_pt, double origin_value, double extend_ratio = 1) + { + if (cubic_spline == null) + return -3; + if (simular_pt.X < 0.1 || simular_pt.Y < 0.1) + return -2; + if (simular_pt.X > cubic_spline.MaxX * extend_ratio * 1.5) + return -4; + + Yw.Geometry.Point2d sect_pt = GetSectPoint(cubic_spline, simular_pt, extend_ratio); + if (sect_pt == null || sect_pt.IsZeroPoint()) + return -5; + + //璁$畻鐩镐技鐐圭殑杞��/鐩村緞 + return CalculateSimuByH(origin_value, sect_pt.Y, simular_pt.Y); + } + + //ratioIgnore:浣滅敤 褰搒imularPoint瓒呭嚭鏇茬嚎鑼冨洿鏃�,鏇茬嚎鎵╁ぇ鐨勫�嶆暟 + public static Yw.Geometry.Point2d GetSectPoint(Yw.Geometry.CubicSpline2d cubic_spline, Yw.Geometry.Point2d simular_pt, double ratioIgnore) + { + return GetSectPointGeneral(cubic_spline, simular_pt, 2, ratioIgnore); + } + + public static Yw.Geometry.Point2d GetSectPointParabola(Yw.Geometry.CubicSpline2d cubic_spline, Yw.Geometry.Point2d simular_pt) + { + var sect_pt = new Yw.Geometry.Point2d(0, 0); + if (cubic_spline == null) + return sect_pt; + var pt_list = cubic_spline.GetPointListByXRatioRange(1,1.2, 50); + return GetSectPointParabola(pt_list, simular_pt); + } + + //閫氳繃鐐箂imular_pt鍜岀偣(0,0)鐨勭洿绾�,涓庢洸绾緾urve鐨勪氦鐐�(娌℃湁,杩斿洖Point(0,0)) + public static Yw.Geometry.Point2d GetSectPointLine(List<Yw.Geometry.Point2d> CurvePoints, Yw.Geometry.Point2d simular_pt) + { + Yw.Geometry.Point2d sect_pt = new Yw.Geometry.Point2d(0, 0); + if (CurvePoints == null || CurvePoints.Count < 2) + return sect_pt; + + //璁$畻鐩寸嚎鐨凨 + if (simular_pt.X < 1) + return sect_pt; + double a = simular_pt.Y / simular_pt.X; + if (a < 0.0001) + return sect_pt; + + //涓�2鐐硅繛鎴愮洿绾跨殑浜ょ偣,鍒ゆ柇浜ょ偣鏄惁鍦�2鐐逛箣闂�,鍗冲彲鏄洸绾跨殑浜ょ偣 + double b, c; + double x; + for (int i = 0; i < CurvePoints.Count - 1; i++) + { + LineHelper.GetKandB(CurvePoints[i], CurvePoints[i + 1], out b, out c); + + /*瑙f柟绋� + * y=ax + * y=bx+c + */ + if (Math.Abs(a - b) < 0.001) + continue; + + x = c / (a - b); + if (UtilsHelper.IsMiddle(CurvePoints[i].X, CurvePoints[i + 1].X, x)) + { + sect_pt.X = x; + sect_pt.Y = a * x; + return sect_pt; + } + } + + return sect_pt; + } + + //閫氳繃鐐箂imular_pt鍜岀偣(0,0)鐨勬姏鐗╃嚎,涓庢洸绾緾urve鐨勪氦鐐�(娌℃湁,杩斿洖Point(0,0)) + //鏇茬嚎鍏紡:H=K*Q^2 + public static Yw.Geometry.Point2d GetSectPointParabola(List<Yw.Geometry.Point2d> pt_list, Yw.Geometry.Point2d simular_pt) + { + return ParabolaCurveHelper.GetSectPoint(pt_list, simular_pt, 0); + } + + public static Yw.Geometry.Point2d GetSectPointLine(this Yw.Geometry.CubicSpline2d cubic_spline, Yw.Geometry.Point2d simular_pt) + { + Yw.Geometry.Point2d sect_pt = new Yw.Geometry.Point2d(0, 0); + if (cubic_spline == null) + return sect_pt; + + //璁$畻鐩寸嚎鐨凨 + if (simular_pt.X < 1) + return sect_pt; + double a = simular_pt.Y / simular_pt.X; + if (a < 0.0001) + return sect_pt; + + //鐐硅秺澶氳秺绮剧‘ + return GetSectPointLine(cubic_spline.GetPointList(100), simular_pt); + } + + //鏇茬嚎H=K*Q^i 涓庢洸绾緾urve鐨勪氦鐐�(娌℃湁,杩斿洖Point(0,0)) + public static Yw.Geometry.Point2d GetSectPointGeneral(List<Yw.Geometry.Point2d> pt_list, Yw.Geometry.Point2d simular_pt, double index) + { + Yw.Geometry.Point2d sect_pt = new Yw.Geometry.Point2d(0, 0); + if (pt_list == null || pt_list.Count < 2) + return sect_pt; + + if (simular_pt.X < 0.1) + return sect_pt; + + if (Math.Abs(index - 1) < 0.01) + return GetSectPointLine(pt_list, simular_pt); + if (Math.Abs(index - 2) < 0.01) + return GetSectPointParabola(pt_list, simular_pt); + + //璁$畻绯绘暟K + double fixK = simular_pt.Y / Math.Pow(simular_pt.X, index); + if (fixK < 0.000001) + return sect_pt; + + //鎬濊矾鏄粠simular_pt寮�濮嬮�愪釜澧炲姞0.1,鐩村埌k鍊兼渶鎺ヨ繎fixK + double space = (pt_list.Last().X - simular_pt.X) / 1200; + double x = simular_pt.X; + double y, k; + do + { + x = x + space; + y = 0; + var y_pt_list = pt_list.GetInterPointsY(x); + if (y_pt_list==null|| !y_pt_list.Any()) + { + break; + } + y = y_pt_list.Last(); + k = y / Math.Pow(x, index); + } while (k > fixK); + + sect_pt.X = x; + sect_pt.Y = y; + return sect_pt; + } + + + //ratioIgnore:浣滅敤 褰搒imular_pt瓒呭嚭鑼冨洿鏃�,鎵╁ぇ鐨勫�嶆暟 + public static Yw.Geometry.Point2d GetSectPointGeneral(this Yw.Geometry.CubicSpline2d cubic_spline, Yw.Geometry.Point2d simular_pt, double index, double ratioIgnore) + { + Yw.Geometry.Point2d sect_pt = new Yw.Geometry.Point2d(0, 0); + if (cubic_spline == null) + return sect_pt; + + if (simular_pt.X < 1) + return sect_pt; + var cubic_spline_ex = cubic_spline.Copy(); + //妫�鏌ユ槸鍚﹀湪鏇茬嚎鐨勫尯鍩熻寖鍥村唴 + double maxQ = cubic_spline_ex.MaxX; + double maxH = cubic_spline_ex.GetPointY(maxQ); + double k1 = maxH / Math.Pow(maxQ, index); + double k2 = simular_pt.Y / Math.Pow(simular_pt.X, index); + if (k1 > k2) + { + cubic_spline_ex.MaxX = cubic_spline_ex.MaxX * ratioIgnore;//鏀惧ぇ1.2鍊� + } + + if (Math.Abs(index - 1) < 0.01) + return GetSectPointLine(cubic_spline_ex, simular_pt); + if (Math.Abs(index - 2) < 0.01) + return GetSectPointParabola(cubic_spline_ex, simular_pt); + + //璁$畻绯绘暟K + double fixK = simular_pt.Y / Math.Pow(simular_pt.X, index); + if (fixK < 0.000001) + return sect_pt; + + //鎬濊矾鏄粠simular_pt寮�濮嬮�愪釜澧炲姞0.1,鐩村埌k鍊兼渶鎺ヨ繎fixK + double space = (cubic_spline_ex.MaxX - simular_pt.X) / 1000; + double x = simular_pt.X; + double y, k; + do + { + x = x + space; + y = cubic_spline_ex.GetPointY(x); + k = y / Math.Pow(x, index); + } while (k > fixK); + + sect_pt.X = x; + sect_pt.Y = y; + return sect_pt; + } + + #endregion 鏇茬嚎涓嶩=K*Q^i鐨勪氦鐐� protect绫诲瀷,缁欏瓙绫昏皟鐢�,鎬庝箞瑕嗙洊GetSectPoint + } } -- Gitblit v1.9.3