From 05946b151e7010b2b1a851892152e6b5d34151b3 Mon Sep 17 00:00:00 2001
From: lx <ex_lixiang17@cosl.com.cn>
Date: 星期五, 11 七月 2025 17:30:52 +0800
Subject: [PATCH] update
---
ErrorAnalysis.Service/COMergeCalcService.cs | 139 +++++++++++++++++++++++++++++++++------------
1 files changed, 101 insertions(+), 38 deletions(-)
diff --git a/ErrorAnalysis.Service/COMergeCalcService.cs b/ErrorAnalysis.Service/COMergeCalcService.cs
index 06861c2..c8c4645 100644
--- a/ErrorAnalysis.Service/COMergeCalcService.cs
+++ b/ErrorAnalysis.Service/COMergeCalcService.cs
@@ -4,11 +4,15 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ErrorAnalysis.Service
{
public class COMergeCalcService
{
+ //Ncoef=1e8*2.54*2.54*2*6*11*2*77*0.2/0.6*speed;
+ //Fcoef=1e8*2.54*2.54*4*6*2*11*77*0.2/0.6*speed;
+
const double _gg = (9.0 - 0.0) / 255.0;//0.03529
const double _offset = 0.0;
@@ -18,69 +22,128 @@
const int _oWinStartIndex = (int)(4.88 / _gg + _offset); // org
const int _oWinEndIndex = (int)(6.36 / _gg + _offset); // width = 6.36-4.88=1.48
- public static double GetFarMergeCResult(string connectionString, string modelId, int porosity)
+ private static double GetFarInterplolateResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
{
- var repository = new COFarResultRepository(connectionString);
- var cResult = repository.GetCOFarResult(modelId, porosity, 0);
+ 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");
- var length = _cWinEndIndex - _cWinStartIndex + 1;
- var result = cArr.Skip(_cWinStartIndex).Take(length).Sum();
-
+ 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)
+ {
+ if (readSw == 0)
+ result = Utility.Interpolate(sw, 100, 0, 0, coef);
+ else
+ result = Utility.Interpolate(sw, 0, 0, 100, coef);
+ }
return result;
}
- public static double GetFarMergeOResult(string connectionString, string modelId, int porosity)
+ private static double GetNearInterplolateResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
{
- var repository = new COFarResultRepository(connectionString);
- var cResult = repository.GetCOFarResult(modelId, porosity, 100);
- 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");
-
- var length = _oWinEndIndex - _oWinStartIndex + 1;
- var result = cArr.Skip(_oWinStartIndex).Take(length).Sum();
-
- return result;
- }
-
- public static double GetNearMergeCResult(string connectionString, string modelId, int porosity)
- {
- var repository = new CONearResultRepository(connectionString);
- var cResult = repository.GetCONearResult(modelId, porosity, 0);
+ 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 length = _cWinEndIndex - _cWinStartIndex + 1;
- var result = cArr.Skip(_cWinStartIndex).Take(length).Sum();
-
+ 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)
+ {
+ if (readSw == 0)
+ result = Utility.Interpolate(sw, 100, 0, 0, coef);
+ else
+ result = Utility.Interpolate(sw, 0, 0, 100, coef);
+ }
return result;
}
- public static double GetNearMergeOResult(string connectionString, string modelId, int porosity)
+ /// <summary>
+ /// 鑾峰彇杩滄帰澶碈鎴朞鍊�
+ /// </summary>
+ /// <param name="connectionString">鏁版嵁搴撹繛鎺ュ瓧绗︿覆</param>
+ /// <param name="modelId">绠℃煴ID</param>
+ /// <param name="porosity">瀛旈殭搴�</param>
+ /// <param name="sw">鍚按楗卞拰搴�</param>
+ /// <param name="readSw">璇诲彇鍚按楗卞拰搴︼紙0涓虹⒊锛�100涓烘哀锛�</param>
+ /// <param name="speed">娴嬮��</param>
+ /// <param name="depth">娣卞害</param>
+ /// <returns>纰虫垨姘у��</returns>
+ /// <exception cref="InvalidDataException">瀛旈殭搴﹁秴杩囪寖鍥�</exception>
+ public static double GetFarMergeCOResult(string modelId, double porosity, double sw, int readSw, double speed, double depth)
{
- var repository = new CONearResultRepository(connectionString);
- var cResult = repository.GetCONearResult(modelId, porosity, 100);
- 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");
+ if (porosity > 40)
+ throw new InvalidDataException("Porosity value out of range!");
- var length = _oWinEndIndex - _oWinStartIndex + 1;
- var result = cArr.Skip(_oWinStartIndex).Take(length).Sum();
+ double result = 0;
+ if (porosity % 5 == 0)
+ {
+ result = GetFarInterplolateResult(modelId, porosity, sw, readSw, speed, depth);
+ }
+ else
+ {
+ double ceilingResult = 0;
+ var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
+ ceilingResult = GetFarInterplolateResult(modelId, ceilingPorosity, sw, readSw, speed, depth);
+
+ double floorResult = 0;
+ var floorPorosity = Math.Floor(porosity / 5) * 5;
+ floorResult = GetFarInterplolateResult(modelId, floorPorosity, sw, readSw, speed, depth);
+
+ result = Utility.Interpolate(porosity, floorPorosity, floorResult, ceilingPorosity, ceilingResult);
+ }
return result;
}
+ /// <summary>
+ /// 鑾峰彇杩戞帰澶碈鎴朞鍊�
+ /// </summary>
+ /// <param name="connectionString">鏁版嵁搴撹繛鎺ュ瓧绗︿覆</param>
+ /// <param name="modelId">绠℃煴ID</param>
+ /// <param name="porosity">瀛旈殭搴�</param>
+ /// <param name="sw">鍚按楗卞拰搴�</param>
+ /// <param name="readSw">璇诲彇鍚按楗卞拰搴︼紙0涓虹⒊锛�100涓烘哀锛�</param>
+ /// <param name="speed">娴嬮��</param>
+ /// <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)
+ {
+ if (porosity > 40)
+ throw new InvalidDataException("Porosity value out of range!");
+
+ double result = 0;
+ if (porosity % 5 == 0)
+ {
+ result = GetNearInterplolateResult(modelId, porosity, sw, readSw, speed, depth);
+ }
+ else
+ {
+ double ceilingResult = 0;
+ var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
+ ceilingResult = GetNearInterplolateResult(modelId, ceilingPorosity, sw, readSw, speed, depth);
+
+
+ double floorResult = 0;
+ var floorPorosity = Math.Floor(porosity / 5) * 5;
+ floorResult = GetNearInterplolateResult(modelId, floorPorosity, sw, readSw, speed, depth);
+
+ result = Utility.Interpolate(porosity, floorPorosity, floorResult, ceilingPorosity, ceilingResult);
+ }
+ return result;
+ }
}
}
--
Gitblit v1.9.3