From 1a8a81785470302fc7fbd6914a9df5d1094dac2a Mon Sep 17 00:00:00 2001
From: Shuxia Ning <NingShuxia0927@outlook.com>
Date: 星期三, 28 八月 2024 17:31:07 +0800
Subject: [PATCH] 调度修改

---
 IStation.Service/08-algorithm/02-schedule/ScheduleHelper.cs |  235 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 230 insertions(+), 5 deletions(-)

diff --git a/IStation.Service/08-algorithm/02-schedule/ScheduleHelper.cs b/IStation.Service/08-algorithm/02-schedule/ScheduleHelper.cs
index 42fa4b4..df8ef8b 100644
--- a/IStation.Service/08-algorithm/02-schedule/ScheduleHelper.cs
+++ b/IStation.Service/08-algorithm/02-schedule/ScheduleHelper.cs
@@ -36,6 +36,7 @@
 
         private readonly Service.AnalysisConclusion _service_analysis_conclusion = new();
         private readonly Service.AnalysisDeviation _service_analysis_deviation = new();
+        private readonly Service.AnalysisFactor _service_analysis_factor = new();
 
         private int _min_open_count;//鏈�灏忓紑娉垫暟閲�
         private int _max_open_count;//鏈�澶у紑娉垫暟閲�
@@ -230,7 +231,7 @@
                             exist_limit = true;
                         }
                     }
-                } 
+                }
                 if (!exist_limit)
                 {
                     var opt_ana_combine = GetOptAnaCombine
@@ -479,7 +480,7 @@
                 //杩涘彛姘翠綅
                 var inlet_water_level = flag_inlet_water_level_dict[flag];
 
-                //缁勫悎淇绯绘暟
+                //缁勫悎鍋忓樊绯绘暟
                 var combine_deviation_factor = combine_deviation_factor_dict[flag];
                 var current_target_head = target_head - inlet_water_level + combine_deviation_factor + _sel_opt_pump_head_excess;
                 current_target_head = Math.Round(current_target_head, 1);
@@ -673,7 +674,7 @@
         /// <returns></returns>
         public Dictionary<int, List<int[]>> GetSameSectionCombineDict(List<List<int>> same_section_flag_combine_list, int pump_list_count)
         {
-            Dictionary<int, List<int[]>> same_section_combine_dict = new(); 
+            Dictionary<int, List<int[]>> same_section_combine_dict = new();
             for (int pump_count = 1; pump_count <= pump_list_count; pump_count++)
             {
                 same_section_combine_dict[pump_count] = new List<int[]>();
@@ -738,7 +739,7 @@
                     default:
                         break;
                 }
-            } 
+            }
 
             return same_section_combine_dict;
         }
@@ -918,7 +919,7 @@
 
 
         #endregion
-         
+
         #region Expand
 
         /// <summary>
@@ -1020,6 +1021,230 @@
             return opt;
         }
 
+
+        /// <summary>
+        /// 鑾峰彇鍙橀娉靛垪琛� 鏍规嵁宸ュ喌璁$畻
+        /// </summary>
+        /// <param name="pumps"></param>
+        /// <param name="flag_rpm_dic"></param>
+        /// <param name="flag_inlet_water_level_dict"></param>
+        /// <param name="flag_head_dic"></param>
+        /// <param name="total_flow"></param>
+        /// <param name="ues_deviation_factor"></param>
+        /// <returns></returns>
+        public List<AnaFrePump> GetAnaFrePumpListByWorking(
+            List<Model.Pump> pumps,
+            Dictionary<int, double> flag_rpm_dic,
+            Dictionary<int, double> flag_inlet_water_level_dict,
+            Dictionary<int, double> flag_head_dic,
+            double total_flow,
+            bool ues_deviation_factor = false
+            )
+        {
+            if (pumps == null || !pumps.Any())
+            {
+                return default;
+            }
+
+            if (flag_rpm_dic == null || !flag_rpm_dic.Any())
+            {
+                return default;
+            }
+
+            var run_flag_list = flag_rpm_dic.Where(x => x.Value > 1).Select(x => x.Key).OrderBy(x => x).ToList();
+            var ana_fre_pump_list = new List<AnaFrePump>();
+            foreach (var flag in run_flag_list)
+            {
+                var pump = pumps.Find(x => x.Flag == flag);
+                if (pump == null)
+                    continue;
+                var rpm = flag_rpm_dic[flag];
+                if (rpm < 1)
+                    continue;
+
+                var curveQH = Curve.PumpCalculateHelper.CalculateSimilarQH(pump.CurveQH, pump.Nr, rpm);
+                var curveQP = Curve.PumpCalculateHelper.CalculateSimilarQP(pump.CurveQP, pump.Nr, rpm);
+
+                double flow = 0, head = 0;
+                if (flag_head_dic != null && flag_head_dic.ContainsKey(pump.Flag))
+                {
+                    head = flag_head_dic[pump.Flag];
+                }
+
+                if (flag_inlet_water_level_dict != null && flag_inlet_water_level_dict.ContainsKey(pump.Flag))
+                {
+                    head -= flag_inlet_water_level_dict[pump.Flag];
+                }
+
+                if (ues_deviation_factor)
+                {
+                    var combine_deviation_factor_dict = GetCombineDeviationFactorDict(total_flow, run_flag_list);//淇缁勫悎鏇茬嚎鍜屾ā鍨嬬殑鍋忓樊鎵▼ 
+                    if (combine_deviation_factor_dict != null && combine_deviation_factor_dict.ContainsKey(flag))
+                    {
+                        var combine_deviation_factor = combine_deviation_factor_dict[flag];  //缁勫悎鍋忓樊绯绘暟
+                        head -= combine_deviation_factor;
+                    }
+                }
+
+                flow = curveQH.GetInterPointLastX(head) ?? 0;
+                if (flow < 0)
+                    continue;
+
+
+                var fre_pump = new AnaFrePump();
+                fre_pump.Flag = flag;
+                fre_pump.Flow = flow;
+                fre_pump.Head = head;
+                fre_pump.Power = curveQP.GetFitPointY(flow);
+                fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
+                fre_pump.Frequency = rpm / pump.Nr * 50;
+                fre_pump.Speed = rpm;
+
+                ana_fre_pump_list.Add(fre_pump);
+            }
+
+
+            return ana_fre_pump_list;
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍙橀娉靛垪琛� 鏍规嵁宸ュ喌璁$畻
+        /// </summary>
+        /// <param name="pumps"></param>
+        /// <param name="flag_rpm_dic"></param>
+        /// <param name="flag_inlet_water_level_dict"></param>
+        /// <param name="flag_flow_dic"></param>
+        /// <param name="flag_head_dic"></param>
+        /// <param name="flag_curve_head_dic"></param>
+        /// <param name="total_flow"></param>
+        /// <param name="ues_deviation_factor"></param>
+        /// <returns></returns>
+        public List<AnaFrePump> GetAnaFrePumpListByWorking(
+            List<Model.Pump> pumps,
+            Dictionary<int, double> flag_rpm_dic,
+            Dictionary<int, double> flag_inlet_water_level_dict,
+            Dictionary<int, double> flag_flow_dic,
+            Dictionary<int, double> flag_head_dic,
+            double total_flow,
+            out Dictionary<int, double> flag_curve_head_dic,
+            bool ues_deviation_factor = false
+            )
+        {
+            flag_curve_head_dic = new Dictionary<int, double>();
+            if (pumps == null || !pumps.Any())
+            {
+                return default;
+            }
+
+            if (flag_rpm_dic == null || !flag_rpm_dic.Any())
+            {
+                return default;
+            }
+
+            var run_flag_list = flag_rpm_dic.Where(x => x.Value > 1).Select(x => x.Key).OrderBy(x => x).ToList();
+            var ana_fre_pump_list = new List<AnaFrePump>();
+            foreach (var flag in run_flag_list)
+            {
+                var pump = pumps.Find(x => x.Flag == flag);
+                if (pump == null)
+                    continue;
+                var rpm = flag_rpm_dic[flag];
+                if (rpm < 1)
+                    continue;
+
+                var hz = Math.Round(rpm / pump.Nr * 50, 1);
+                var factor = _service_analysis_factor.GetByFlagAndHz(flag, hz);
+
+
+                var CurveQH50 = pump.CurveQH;
+                var CurveQP50 = pump.CurveQP;
+                if (ues_deviation_factor)
+                {
+                    //if (pump.Flag == 22)
+                    //{
+                    //    var def_points = CurveQH50.DefinePoints.Select(x => new IStation.Curve.CurvePoint(x.X, x.Y + -0.0398)).ToList();
+                    //    var update_curve = IStation.Curve.FitHelper.BuildCurveExpress(def_points, eFitType.FourM);
+                    //    CurveQH50 = update_curve;
+                    //}
+                    //else
+                    //if (pump.Flag == 23)
+                    //{
+                    //    //4.6
+                    //    var def_points = CurveQH50.DefinePoints.Select(x => new IStation.Curve.CurvePoint(x.X, x.Y - 2.17)).ToList();
+                    //    //var def_points = CurveQH50.DefinePoints.Select(x => new IStation.Curve.CurvePoint(x.X, x.Y - 2.8)).ToList();
+                    //    var update_curve = IStation.Curve.FitHelper.BuildCurveExpress(def_points, eFitType.FourM);
+                    //    CurveQH50 = update_curve;
+                    //}
+                    //else if (pump.Flag == 26)
+                    //{
+                    //    var def_points = CurveQH50.DefinePoints.Select(x => new IStation.Curve.CurvePoint(x.X, x.Y + 0.0887)).ToList();
+                    //    var update_curve = IStation.Curve.FitHelper.BuildCurveExpress(def_points, eFitType.FourM);
+                    //    CurveQH50 = update_curve;
+
+                    //}
+
+                    var head_diff_factor = 0d;
+                    if (factor != null)
+                    {
+                        head_diff_factor = factor.HeadDeviation ?? 0;
+                    }
+
+                    var def_points = CurveQH50.DefinePoints.Select(x => new IStation.Curve.CurvePoint(x.X, x.Y + head_diff_factor)).ToList();
+                    var update_curve = IStation.Curve.FitHelper.BuildCurveExpress(def_points, eFitType.FourM);
+                    CurveQH50 = update_curve;
+                }
+
+
+                var curveQH = Curve.PumpCalculateHelper.CalculateSimilarQH(CurveQH50, pump.Nr, rpm);
+                var curveQP = Curve.PumpCalculateHelper.CalculateSimilarQP(CurveQP50, pump.Nr, rpm);
+
+                double flow = 0, head = 0;
+                if (flag_head_dic != null && flag_head_dic.ContainsKey(pump.Flag))
+                {
+                    head = flag_head_dic[pump.Flag];
+                }
+
+                if (flag_inlet_water_level_dict != null && flag_inlet_water_level_dict.ContainsKey(pump.Flag))
+                {
+                    head -= flag_inlet_water_level_dict[pump.Flag];
+                }
+
+                if (ues_deviation_factor)
+                {
+                    //var combine_deviation_factor_dict = GetCombineDeviationFactorDict(total_flow, run_flag_list);//淇缁勫悎鏇茬嚎鍜屾ā鍨嬬殑鍋忓樊鎵▼ 
+                    //if (combine_deviation_factor_dict != null && combine_deviation_factor_dict.ContainsKey(flag))
+                    //{
+                    //    var combine_deviation_factor = combine_deviation_factor_dict[flag];  //缁勫悎鍋忓樊绯绘暟
+                    //    head -= combine_deviation_factor;
+                    //}
+                }
+
+                flow = curveQH.GetInterPointLastX(head) ?? 0;
+                if (flow < 0)
+                    continue;
+
+                var working_flow = flag_flow_dic[flag];
+                flag_curve_head_dic[flag] = curveQH.GetFitPointY(working_flow);
+
+                var fre_pump = new AnaFrePump();
+                fre_pump.Flag = flag;
+                fre_pump.Flow = flow;
+                fre_pump.Head = head;
+                fre_pump.Power = curveQP.GetFitPointY(flow);
+                fre_pump.Efficiency = Curve.PumpCalculateHelper.CalculateE(fre_pump.Flow, fre_pump.Head, fre_pump.Power);
+                fre_pump.Frequency = rpm / pump.Nr * 50;
+                fre_pump.Speed = rpm;
+
+                ana_fre_pump_list.Add(fre_pump);
+
+            }
+
+
+            return ana_fre_pump_list;
+        }
+
+
+
         #endregion
 
 

--
Gitblit v1.9.3