From e0279fe6db39d1071ef04ad0080b887cb6a0d335 Mon Sep 17 00:00:00 2001
From: lx <ex_lixiang17@cosl.com.cn>
Date: 星期一, 04 八月 2025 17:27:47 +0800
Subject: [PATCH] upload

---
 ErrorAnalysis.Service/ErrorRatioCalc.cs |   63 ++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 22 deletions(-)

diff --git a/ErrorAnalysis.Service/ErrorRatioCalc.cs b/ErrorAnalysis.Service/ErrorRatioCalc.cs
index 9f0c95b..f34ab06 100644
--- a/ErrorAnalysis.Service/ErrorRatioCalc.cs
+++ b/ErrorAnalysis.Service/ErrorRatioCalc.cs
@@ -10,7 +10,7 @@
 {
     public class ErrorRatioCalc
     {
-        public static ErrorRatioResult GetErrorRatioResultLockSpeed(string modelID, double porosity, double sw, double depth, bool lockSpeed, double speed, double targetErrorRatio, int pass = 0)
+        public static ErrorRatioResult GetErrorRatioResult(string modelID, double porosity, double sw, double depth, bool lockSpeed, double speed, double targetErrorRatio, out double testSpeed, int pass = 0)
         {
             var result = new ErrorRatioResult
             {
@@ -24,16 +24,16 @@
             {
                 List<double[]> cWOL;
                 List<double[]> oWOL;
-                var firsErrorPass = GetFirstErrorRatio(modelID, porosity, sw, speed, depth, out cWOL, out oWOL);
+                var firstErrorPassM = GetFirstErrorRatio(modelID, porosity, sw, speed, depth, out cWOL, out oWOL);
                 result.CWOL = cWOL;
                 result.OWOL = oWOL;
-                result.ErrorRatios.Add(firsErrorPass);
-                if (firsErrorPass.ErrorRatioValue > targetErrorRatio)
+                result.ErrorRatios.Add(firstErrorPassM);
+                if (firstErrorPassM.ErrorRatioValue > targetErrorRatio)
                 {
-                    var targetPass = Convert.ToInt32(Math.Ceiling(Math.Pow(firsErrorPass.ErrorRatioValue / targetErrorRatio, 2)));
+                    var targetPass = Convert.ToInt32(Math.Ceiling(Math.Pow(firstErrorPassM.ErrorRatioValue / targetErrorRatio, 2)));
                     for (int i = 2; i <= targetPass; i++)
                     {
-                        result.ErrorRatios.Add(new ErrorRatio { Pass = i, ErrorRatioValue = firsErrorPass.ErrorRatioValue / Math.Sqrt(i) });
+                        result.ErrorRatios.Add(new ErrorRatio { Pass = i, ErrorRatioValue = firstErrorPassM.ErrorRatioValue / Math.Sqrt(i) });
                     }
                 }
             }
@@ -43,15 +43,22 @@
                 List<double[]> cWOL;
                 List<double[]> oWOL;
                 var firstErrorPass = new ErrorRatio();
-                speed = 0.6;
-                while (firstErrorPass.ErrorRatioValue != 0 && firstErrorPass.ErrorRatioValue > firstTargetErrorRatio)
+                speed = 2;
+                do
                 {
                     firstErrorPass = GetFirstErrorRatio(modelID, porosity, sw, speed, depth, out cWOL, out oWOL);
                     result.CWOL = cWOL;
                     result.OWOL = oWOL;
                     speed -= 0.01;
+                } while (firstErrorPass.ErrorRatioValue != 0 && firstErrorPass.ErrorRatioValue > firstTargetErrorRatio);
+                result.ErrorRatios.Clear();
+                result.ErrorRatios.Add(firstErrorPass);
+                for (int i = 2; i <= pass; i++)
+                {
+                    result.ErrorRatios.Add(new ErrorRatio { Pass = i, ErrorRatioValue = firstErrorPass.ErrorRatioValue / Math.Sqrt(i) });
                 }
             }
+            testSpeed = speed;
 
             return result;
 
@@ -73,19 +80,31 @@
             var wolResType = cWolRes?.GetType();
             try
             {
-                if (sw > 0 && sw < 100)
-                {
-                    foreach (var wolProperty in wolResType.GetProperties())
-                    {
-                        if (wolProperty.Name.Contains("WLPu"))
-                        {
-                            var interC = Utility.Interpolate(sw, 100, 0, 0, (double)wolProperty.GetValue(cWolRes));
-                            var interO = Utility.Interpolate(sw, 0, 0, 100, (double)wolProperty.GetValue(oWolRes));
-                            wolProperty.SetValue(cWolRes, interC);
-                            wolProperty.SetValue(oWolRes, interO);
-                        }
-                    }
-                }
+                //if (sw > 0 && sw < 100)
+                //{
+                //    foreach (var wolProperty in wolResType.GetProperties())
+                //    {
+                //        if (wolProperty.Name.Contains("WLPu"))
+                //        {
+                //            //if (wolProperty.Name != "WLPu0")
+                //            //{
+                //            var interC = Utility.Interpolate(sw, 100, 0, 0, (double)wolProperty.GetValue(cWolRes));
+                //            var interO = Utility.Interpolate(sw, 0, 0, 100, (double)wolProperty.GetValue(oWolRes));
+                //            wolProperty.SetValue(cWolRes, interC);
+                //            wolProperty.SetValue(oWolRes, interO);
+                //            //}
+                //            //else
+                //            //{
+                //            //    var interC = Utility.Interpolate(sw, 100, 0, 0, (double)wolProperty.GetValue(cWolRes));
+                //            //    var interO = Utility.Interpolate(sw, 0, 0, 100, (double)wolProperty.GetValue(oWolRes));
+                //            //    var interVal = Utility.Interpolate(sw, 0, interC, 100, interO);
+                //            //    wolProperty.SetValue(cWolRes, interVal);
+                //            //    wolProperty.SetValue(oWolRes, interVal);
+                //            //}
+
+                //        }
+                //    }
+                //}
 
                 foreach (var wolProperty in wolResType.GetProperties())
                 {
@@ -124,7 +143,7 @@
                     oRes = Utility.Interpolate(porosity, floorPorosity, floorO, ceilingPorosity, ceilingO);
                 }
 
-                var errorRatio = mergePDEV / (cRes - oRes);
+                var errorRatio = mergePDEV /( cRes > oRes ? (cRes - oRes) : (oRes - cRes));
 
                 return new ErrorRatio { Pass = 1, ErrorRatioValue = errorRatio };
             }

--
Gitblit v1.9.3