ui
lx
2025-07-04 597ca2fb14bb204f27aeb04089d6c87f19774916
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using ErrorAnalysis.Repository;
using System;
using System.Collections.Generic;
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;
 
        const int _cWinStartIndex = (int)(3.3 / _gg + _offset); //C窗口index
        const int _cWinEndIndex = (int)(4.78 / _gg + _offset); // width= 4.78-3.3  = 1.48
 
        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 GetInterplolateResult(RepositoryBase repos, string modelId, double porosity, double sw, double speed)
        {
 
        }
 
        public static double GetFarMergeCResult(string connectionString, string modelId, double porosity, double sw, double speed)
        {
            if (porosity > 40)
                throw new InvalidDataException("Porosity value out of range!");
 
            var repository = new COFarResultRepository(connectionString);
            double result = 0;
            if (porosity % 5 == 0)
            {
                var cResult = repository.GetCOFarResult(modelId, (int)porosity, 0);
                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 originC = cArr.Skip(_cWinStartIndex).Take(length).Sum();
                var coef = originC * 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6 * speed*depth*0.07;
                if (sw > 0)
                    result = Utility.Interpolate(sw, 100, 0, 0, coef);
 
            }
            else
            {
                double ceilingResult = 0;
                var ceilingPorosity = Math.Ceiling(porosity / 5) * 5;
                var ceilingCResult = repository.GetCOFarResult(modelId, (int)ceilingPorosity, 0);
                if (ceilingCResult == null)
                    throw new InvalidDataException("COFarResult not found");
                var ceilingCArr = ceilingCResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
                if (ceilingCArr == null)
                    throw new InvalidDataException("COFarResult InelasticSpec is null");
 
                var ceilingLength = _cWinEndIndex - _cWinStartIndex + 1;
                var ceilingOriginC = ceilingCArr.Skip(_cWinStartIndex).Take(ceilingLength).Sum();
                var ceilingCoef = ceilingOriginC * 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6 * speed;
                if (sw > 0)
                    ceilingResult = Utility.Interpolate(sw, 100, 0, 0, ceilingCoef);
 
                double floorResult = 0;
                var floorPorosity = Math.Floor(porosity / 5) * 5;
                var floorCResult = repository.GetCOFarResult(modelId, (int)floorPorosity, 0);
                if (floorCResult == null)
                    throw new InvalidDataException("COFarResult not found");
                var floorCArr = floorCResult.InelasticSpec?.Split(',').Select(v => Convert.ToDouble(v)).ToArray();
                if (floorCArr == null)
                    throw new InvalidDataException("COFarResult InelasticSpec is null");
 
                var floorLength = _cWinEndIndex - _cWinStartIndex + 1;
                var floorOriginC = floorCArr.Skip(_cWinStartIndex).Take(floorLength).Sum();
                var floorCoef = floorOriginC * 1e8 * 2.54 * 2.54 * 4 * 6 * 2 * 11 * 77 * 0.2 / 0.6 * speed;
                if (sw > 0)
                    floorResult = Utility.Interpolate(sw, 100, 0, 0, floorCoef);
 
                result = Utility.Interpolate(porosity, floorPorosity, floorResult, ceilingPorosity, ceilingResult);
            }
            return result;
        }
 
        public static double GetFarMergeOResult(string connectionString, string modelId, double porosity, double sw, double speed)
        {
            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, double porosity, double sw, double speed)
        {
            var repository = new CONearResultRepository(connectionString);
            var cResult = repository.GetCONearResult(modelId, porosity, 0);
            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();
 
            return result;
        }
 
        public static double GetNearMergeOResult(string connectionString, string modelId, double porosity, double sw, double speed)
        {
            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");
 
            var length = _oWinEndIndex - _oWinStartIndex + 1;
            var result = cArr.Skip(_oWinStartIndex).Take(length).Sum();
 
            return result;
        }
 
    }
}