lx
2025-07-02 cc63c8a1bf8f7f017f2f05c34f0d86f8acdfc295
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
using ErrorAnalysis.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ErrorAnalysis.Service
{
    public class COMergeCalcService
    {
        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
 
        public static double GetFarMergeCResult(string connectionString, string modelId, int porosity)
        {
            var repository = new COFarResultRepository(connectionString);
            var cResult = repository.GetCOFarResult(modelId, 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 result = cArr.Skip(_cWinStartIndex).Take(length).Sum();
 
            return result;
        }
 
        public static double GetFarMergeOResult(string connectionString, string modelId, int porosity)
        {
            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);
            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, int porosity)
        {
            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;
        }
 
    }
}