lx
2025-08-04 e0279fe6db39d1071ef04ad0080b887cb6a0d335
upload
已修改5个文件
260 ■■■■■ 文件已修改
ErrorAnalysis.Service/COMergeCalcService.cs 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/ErrorRatioCalc.cs 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/PDEVCalcService.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/FrmMain.Designer.cs 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.UI/FrmMain.cs 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ErrorAnalysis.Service/COMergeCalcService.cs
@@ -22,52 +22,78 @@
        const int _oWinStartIndex = (int)(4.88 / _gg + _offset); // org
        const int _oWinEndIndex = (int)(6.36 / _gg + _offset); // width = 6.36-4.88=1.48
        private static double GetFarInterplolateResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
        {
            double result = 0;
            var cResult = RepositoryInstance.Instance.COFarResultRepository?.GetCOFarResult(modelId, (int)porosity, readSw);
            if (cResult == null)
                throw new InvalidDataException("COFarResult not found");
            var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            if (cArr == null)
                throw new InvalidDataException("COFarResult InelasticSpec is null");
        const double _coef = 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6;
            var length = readSw == 0 ? _cWinEndIndex - _cWinStartIndex + 1 : _oWinEndIndex - _oWinStartIndex + 1;
            var originC = cArr.Skip(readSw == 0 ? _cWinStartIndex : _oWinStartIndex).Take(length).Sum();
            var coef = originC * 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6 / speed * depth * 0.07;
            result = coef;
            if (sw > 0 && sw < 100)
        private static (double, double) GetFarInterplolateResult(string modelId, double porosity, double sw, double speed, double depth)
        {
            var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
            var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
            var oilLine = RepositoryInstance.Instance.COFarResultRepository?.GetCOFarResult(modelId, (int)porosity, 0);
            var waterLine = RepositoryInstance.Instance.COFarResultRepository?.GetCOFarResult(modelId, (int)porosity, 100);
            if (oilLine == null || waterLine == null)
                throw new InvalidDataException("COFarResult Line is null");
            var oilLineValArr = oilLine.InelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            var waterLineValArr = waterLine.InelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            var oilLineC = oilLineValArr.Skip(_cWinStartIndex).Take(cWinLength).Sum() * _coef / speed * depth * 0.07;
            var oilLineO = oilLineValArr.Skip(_oWinStartIndex).Take(oWinLength).Sum() * _coef / speed * depth * 0.07;
            var waterLineC = waterLineValArr.Skip(_cWinStartIndex).Take(cWinLength).Sum() * _coef / speed * depth * 0.07;
            var waterLineO = waterLineValArr.Skip(_oWinStartIndex).Take(oWinLength).Sum() * _coef / speed * depth * 0.07;
            double cRes = 0, oRes = 0;
            if (sw == 0)
            {
                if (readSw == 0)
                    result = Utility.Interpolate(sw, 100, 0, 0, coef);
                else
                    result = Utility.Interpolate(sw, 0, 0, 100, coef);
                cRes = waterLineC;
                oRes = waterLineO;
            }
            return result;
            else if (sw == 100)
            {
                cRes = waterLineC;
                oRes = waterLineO;
            }
            else if (sw > 0 && sw < 100)
            {
                cRes = Utility.Interpolate(sw, 100, waterLineC, 0, oilLineC);
                oRes = Utility.Interpolate(sw, 0, oilLineO, 100, waterLineO);
            }
            return (cRes, oRes);
        }
        private static double GetNearInterplolateResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
        private static (double, double) GetNearInterplolateResult(string modelId, double porosity, double sw, double speed, double depth)
        {
            double result = 0;
            var cResult = RepositoryInstance.Instance.CONearResultRepository?.GetCONearResult(modelId, (int)porosity, readSw);
            if (cResult == null)
                throw new InvalidDataException("CONearResult not found");
            var cArr = cResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            if (cArr == null)
                throw new InvalidDataException("CONearResult InelasticSpec is null");
            var cWinLength = _cWinEndIndex - _cWinStartIndex + 1;
            var oWinLength = _oWinEndIndex - _oWinStartIndex + 1;
            var oilLine = RepositoryInstance.Instance.CONearResultRepository?.GetCONearResult(modelId, (int)porosity, 0);
            var waterLine = RepositoryInstance.Instance.CONearResultRepository?.GetCONearResult(modelId, (int)porosity, 100);
            if (oilLine == null || waterLine == null)
                throw new InvalidDataException("COFarResult Line is null");
            var oilLineValArr = oilLine.InelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            var waterLineValArr = waterLine.InelasticSpec.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
            var length = readSw == 0 ? _cWinEndIndex - _cWinStartIndex + 1 : _oWinEndIndex - _oWinStartIndex + 1;
            var originC = cArr.Skip(readSw == 0 ? _cWinStartIndex : _oWinStartIndex).Take(length).Sum();
            var coef = originC * 1e8 * 2.54 * 2.54 * 2 * 6 * 11 * 2 * 77 * 0.2 / 0.6 / speed * depth * 0.07;
            result = coef;
            if (sw > 0 && sw < 100)
            var oilLineC = oilLineValArr.Skip(_cWinStartIndex).Take(cWinLength).Sum() * _coef / speed * depth * 0.07;
            var oilLineO = oilLineValArr.Skip(_oWinStartIndex).Take(oWinLength).Sum() * _coef / speed * depth * 0.07;
            var waterLineC = waterLineValArr.Skip(_cWinStartIndex).Take(cWinLength).Sum() * _coef / speed * depth * 0.07;
            var waterLineO = waterLineValArr.Skip(_oWinStartIndex).Take(oWinLength).Sum() * _coef / speed * depth * 0.07;
            double cRes = 0, oRes = 0;
            if (sw == 0)
            {
                if (readSw == 0)
                    result = Utility.Interpolate(sw, 100, 0, 0, coef);
                else
                    result = Utility.Interpolate(sw, 0, 0, 100, coef);
                cRes = waterLineC;
                oRes = waterLineO;
            }
            return result;
            else if (sw == 100)
            {
                cRes = waterLineC;
                oRes = waterLineO;
            }
            else if (sw > 0 && sw < 100)
            {
                cRes = Utility.Interpolate(sw, 100, waterLineC, 0, oilLineC);
                oRes = Utility.Interpolate(sw, 0, oilLineO, 100, waterLineO);
            }
            return (cRes, oRes);
        }
        /// <summary>
@@ -80,30 +106,28 @@
        /// <param name="readSw">读取含水饱和度(0为碳,100为氧)</param>
        /// <param name="speed">测速</param>
        /// <param name="depth">深度</param>
        /// <returns>碳或氧值</returns>
        /// <returns>碳和氧值</returns>
        /// <exception cref="InvalidDataException">孔隙度超过范围</exception>
        public static double GetFarMergeCOResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
        public static (double, double) GetFarMergeCOResult(string modelId, double porosity, double sw, double speed, double depth)
        {
            if (porosity > 40)
                throw new InvalidDataException("Porosity value out of range!");
            double result = 0;
            (double, double) result = (0, 0);
            if (porosity % 5 == 0)
            {
                result = GetFarInterplolateResult(modelId, porosity, sw, readSw, speed, depth);
                result = GetFarInterplolateResult(modelId, porosity, sw, speed, depth);
            }
            else
            {
                double ceilingResult = 0;
                var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
                ceilingResult = GetFarInterplolateResult(modelId, ceilingPorosity, sw, readSw, speed, depth);
                var ceilingResult = GetFarInterplolateResult(modelId, ceilingPorosity, sw, speed, depth);
                double floorResult = 0;
                var floorPorosity = Math.Floor(porosity / 5) * 5;
                floorResult = GetFarInterplolateResult(modelId, floorPorosity, sw, readSw, speed, depth);
                var floorResult = GetFarInterplolateResult(modelId, floorPorosity, sw, speed, depth);
                result = Utility.Interpolate(porosity, floorPorosity, floorResult, ceilingPorosity, ceilingResult);
                result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);
            }
            return result;
        }
@@ -120,28 +144,26 @@
        /// <param name="depth">深度</param>
        /// <returns>碳或氧值</returns>
        /// <exception cref="InvalidDataException">孔隙度超过范围</exception>
        public static double GetNearMergeCOResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
        public static (double, double) GetNearMergeCOResult(string modelId, double porosity, double sw, double speed, double depth)
        {
            if (porosity > 40)
                throw new InvalidDataException("Porosity value out of range!");
            double result = 0;
            (double, double) result = (0, 0);
            if (porosity % 5 == 0)
            {
                result = GetNearInterplolateResult(modelId, porosity, sw, readSw, speed, depth);
                result = GetNearInterplolateResult(modelId, porosity, sw, speed, depth);
            }
            else
            {
                double ceilingResult = 0;
                var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
                ceilingResult = GetNearInterplolateResult(modelId, ceilingPorosity, sw, readSw, speed, depth);
                var ceilingResult = GetNearInterplolateResult(modelId, ceilingPorosity, sw, speed, depth);
                double floorResult = 0;
                var floorPorosity = Math.Floor(porosity / 5) * 5;
                floorResult = GetNearInterplolateResult(modelId, floorPorosity, sw, readSw, speed, depth);
                var floorResult = GetNearInterplolateResult(modelId, floorPorosity, sw, speed, depth);
                result = Utility.Interpolate(porosity, floorPorosity, floorResult, ceilingPorosity, ceilingResult);
                result.Item1 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item1, ceilingPorosity, ceilingResult.Item1);
                result.Item2 = Utility.Interpolate(porosity, floorPorosity, floorResult.Item2, ceilingPorosity, ceilingResult.Item2);
            }
            return result;
        }
ErrorAnalysis.Service/ErrorRatioCalc.cs
@@ -43,7 +43,7 @@
                List<double[]> cWOL;
                List<double[]> oWOL;
                var firstErrorPass = new ErrorRatio();
                speed = 0.6;
                speed = 2;
                do
                {
                    firstErrorPass = GetFirstErrorRatio(modelID, porosity, sw, speed, depth, out cWOL, out oWOL);
@@ -80,31 +80,31 @@
            var wolResType = cWolRes?.GetType();
            try
            {
                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);
                            //}
                //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())
                {
ErrorAnalysis.Service/PDEVCalcService.cs
@@ -10,13 +10,11 @@
    {
        public static double GetMergePDEV(string modelId, double porosity, double sw, double speed, double depth)
        {
            var farC = COMergeCalcService.GetFarMergeCOResult( modelId, porosity, sw, 0, speed, depth);
            var farO = COMergeCalcService.GetFarMergeCOResult( modelId, porosity, sw, 100, speed, depth);
            var farPDEV = CalcPDEV(farC, farO);
            var farResult = COMergeCalcService.GetFarMergeCOResult(modelId, porosity, sw, speed, depth);
            var farPDEV = CalcPDEV(farResult.Item1, farResult.Item2);
            var nearC = COMergeCalcService.GetNearMergeCOResult( modelId, porosity, sw, 0, speed, depth);
            var nearO = COMergeCalcService.GetNearMergeCOResult( modelId, porosity, sw, 100, speed, depth);
            var nearPDEV = CalcPDEV(nearC, nearO);
            var nearResult = COMergeCalcService.GetNearMergeCOResult(modelId, porosity, sw, speed, depth);
            var nearPDEV = CalcPDEV(nearResult.Item1, nearResult.Item2);
            return nearPDEV * 0.65 + farPDEV * 0.35;
        }
ErrorAnalysis.UI/FrmMain.Designer.cs
@@ -49,10 +49,10 @@
            rdoLockSpeed = new RadioButton();
            rdoLockPass = new RadioButton();
            gbResult = new GroupBox();
            txtAnalysisResult = new RichTextBox();
            tableLayoutPanel1 = new TableLayoutPanel();
            pnlCOPic = new Panel();
            pnlErrorRatioPic = new Panel();
            txtAnalysisResult = new TextBox();
            btnReport = new Button();
            label24 = new Label();
            txtDataPath = new TextBox();
@@ -346,14 +346,26 @@
            // gbResult
            // 
            gbResult.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            gbResult.Controls.Add(tableLayoutPanel1);
            gbResult.Controls.Add(txtAnalysisResult);
            gbResult.Controls.Add(tableLayoutPanel1);
            gbResult.Location = new Point(17, 364);
            gbResult.Name = "gbResult";
            gbResult.Size = new Size(851, 210);
            gbResult.TabIndex = 3;
            gbResult.TabStop = false;
            gbResult.Text = "Result";
            //
            // txtAnalysisResult
            //
            txtAnalysisResult.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
            txtAnalysisResult.BackColor = SystemColors.Control;
            txtAnalysisResult.BorderStyle = BorderStyle.FixedSingle;
            txtAnalysisResult.Location = new Point(526, 22);
            txtAnalysisResult.Name = "txtAnalysisResult";
            txtAnalysisResult.ReadOnly = true;
            txtAnalysisResult.Size = new Size(324, 182);
            txtAnalysisResult.TabIndex = 3;
            txtAnalysisResult.Text = "";
            // 
            // tableLayoutPanel1
            // 
@@ -385,16 +397,6 @@
            pnlErrorRatioPic.Name = "pnlErrorRatioPic";
            pnlErrorRatioPic.Size = new Size(254, 176);
            pnlErrorRatioPic.TabIndex = 3;
            //
            // txtAnalysisResult
            //
            txtAnalysisResult.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
            txtAnalysisResult.Location = new Point(529, 22);
            txtAnalysisResult.Multiline = true;
            txtAnalysisResult.Name = "txtAnalysisResult";
            txtAnalysisResult.ReadOnly = true;
            txtAnalysisResult.Size = new Size(317, 182);
            txtAnalysisResult.TabIndex = 1;
            // 
            // btnReport
            // 
@@ -1242,7 +1244,6 @@
            panel1.ResumeLayout(false);
            panel1.PerformLayout();
            gbResult.ResumeLayout(false);
            gbResult.PerformLayout();
            tableLayoutPanel1.ResumeLayout(false);
            tabEditInfo.ResumeLayout(false);
            tpBorehole.ResumeLayout(false);
@@ -1372,10 +1373,10 @@
        private Label label5;
        private ComboBox cmbTargetLoggingIntervalUnit;
        private NumericUpDown nudTargetLoggingInterval;
        private TextBox txtAnalysisResult;
        private Panel pnlErrorRatioPic;
        private Panel pnlCOPic;
        private TableLayoutPanel tableLayoutPanel1;
        private ProgressBar pbLoadDB;
        private RichTextBox txtAnalysisResult;
    }
}
ErrorAnalysis.UI/FrmMain.cs
@@ -138,7 +138,7 @@
            if (!decimal.TryParse(nudOilDensity.Value.ToString(), out decimal oilDensity) || nudOilDensity.Value <= 0)
            {
                MessageBox.Show("Please select a oil density");
                MessageBox.Show("Please enter a oil density");
                return;
            }
@@ -155,7 +155,7 @@
            if (cmbTargetLoggingIntervalUnit.Text == "ft")
                targetLoggingInterval = UnitConvert.Ft2M(targetLoggingInterval);
            txtAnalysisResult.Clear();
            if (rdoLockSpeed.Checked)
            {
                if (!double.TryParse(nudSpeed.Value.ToString(), out double speed) || nudSpeed.Value <= 0)
@@ -170,7 +170,15 @@
                double totalTime = Math.Round((targetLoggingInterval / calcSpeed / 60), 2);
                var errorRate = Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {errorRate}% error rate. With the tool operating at {speed} {cmbSpeedUnit.Text}, the estimated total job duration is {totalTime.ToString()} hours.";
                txtAnalysisResult.AppendText("A total of ");
                AppendText(txtAnalysisResult, result.ErrorRatios.Count.ToString(), ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" passes are recommended to maintain a ");
                AppendText(txtAnalysisResult, $"{errorRate}%", ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" error rate. With the tool operating at ");
                AppendText(txtAnalysisResult, $"{speed} {cmbSpeedUnit.Text}", ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" the estimated total job duration is ");
                AppendText(txtAnalysisResult, $"{totalTime} hours.", ColorTranslator.FromHtml("#8B0000"));
                _reportModel = CreateReportModel(totalTime.ToString(), result.ErrorRatios.Count.ToString(), Math.Round(UnitConvert.MMin2FtHr(calcSpeed), 2).ToString(), errorRate.ToString());
            }
            else
@@ -188,7 +196,14 @@
                var errorRate = Math.Round(result.ErrorRatios.Min(r => r.ErrorRatioValue) * 100, 2);
                var speedFr = Math.Round(UnitConvert.MMin2FtHr(speed), 2);
                txtAnalysisResult.Text = $"A total of {result.ErrorRatios.Count} passes are recommended to maintain a {errorRate}% error rate. With the tool operating at {speedFr} ft/hr, the estimated total job duration is {totalTime.ToString()} hours.";
                txtAnalysisResult.AppendText("A total of ");
                AppendText(txtAnalysisResult, result.ErrorRatios.Count.ToString(), ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" passes are recommended to maintain a ");
                AppendText(txtAnalysisResult, $"{errorRate}%", ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" error rate. With the tool operating at ");
                AppendText(txtAnalysisResult, $"{speedFr} ft/hr", ColorTranslator.FromHtml("#8B0000"));
                txtAnalysisResult.AppendText(" the estimated total job duration is ");
                AppendText(txtAnalysisResult, $"{totalTime} hours.", ColorTranslator.FromHtml("#8B0000"));
                _reportModel = CreateReportModel(totalTime.ToString(), result.ErrorRatios.Count.ToString(), speedFr.ToString(), errorRate.ToString());
            }
@@ -583,6 +598,20 @@
            };
        }
        private void AppendText(RichTextBox rtb, string text, Color color, Font font = null, bool isNewLine = false)
        {
            rtb.SuspendLayout();
            rtb.SelectionStart = rtb.TextLength;
            rtb.SelectionLength = 0;
            rtb.SelectionColor = color;
            if (font != null)
                rtb.SelectionFont = font;
            rtb.AppendText(isNewLine ? $"{text}{Environment.NewLine}" : text);
            rtb.SelectionColor = rtb.ForeColor;
            rtb.ScrollToCaret();
            rtb.ResumeLayout();
        }
    }
}