duheng
2025-03-18 7ee0220b5f5626deef516b6e5c417bfa201e5a88
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
namespace IStation.Epanet.Network.Structures
{
 
#if NUCONVERT
    public static class NUConvert
    {
        public static double ConvertArea(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value / (Constants.MperFT * Constants.MperFT);
 
            return value;
        }
 
        public static double ConvertDistance(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * (1 / Constants.MperFT);
 
            return value;
        }
 
        public static double ConvertFlow(FlowUnitsType flow, double value)
        {
            switch (flow)
            {
                case FlowUnitsType.CFS:
                    return value * (1 / Constants.LPSperCFS);
                case FlowUnitsType.GPM:
                    return value * (1 / Constants.GPMperCFS);
                case FlowUnitsType.MGD:
                    return value * (1 / Constants.MGDperCFS);
                case FlowUnitsType.IMGD:
                    return value * (1 / Constants.IMGDperCFS);
                case FlowUnitsType.AFD:
                    return value * (1 / Constants.AFDperCFS);
                case FlowUnitsType.LPS:
                    return value * (1 / Constants.LPSperCFS);
                case FlowUnitsType.LPM:
                    return value * (1 / Constants.LPMperCFS);
                case FlowUnitsType.MLD:
                    return value * (1 / Constants.MLDperCFS);
                case FlowUnitsType.CMH:
                    return value * (1 / Constants.CMHperCFS);
                case FlowUnitsType.CMD:
                    return value * (1 / Constants.CMHperCFS);
            }
            return value;
        }
 
        public static double ConvertPower(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * (1 / Constants.KWperHP);
 
            return value;
        }
 
        public static double ConvertPressure(PressUnitsType type, double spGrav, double value)
        {
            switch (type)
            {
                case PressUnitsType.PSI:
                    return value;
                case PressUnitsType.KPA:
                    return value / (Constants.KPAperPSI * Constants.PSIperFT * spGrav);
                case PressUnitsType.METERS:
                    return value / (Constants.MperFT * spGrav);
            }
            return value;
        }
 
        public static double ConvertVolume(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value / (Constants.M3perFT3);
 
            return value;
        }
 
        public static double RevertArea(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * (Constants.MperFT * Constants.MperFT);
 
            return value;
        }
 
        public static double RevertDistance(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * Constants.MperFT;
 
            return value;
        }
 
        public static double RevertDiameter(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * Constants.MMperFT;
            return value * Constants.INperFT;
        }
 
        public static double RevertFlow(FlowUnitsType flow, double value)
        {
            switch (flow)
            {
                case FlowUnitsType.CFS:
                    return value * Constants.LPSperCFS;
                case FlowUnitsType.GPM:
                    return value * Constants.GPMperCFS;
                case FlowUnitsType.MGD:
                    return value * Constants.MGDperCFS;
                case FlowUnitsType.IMGD:
                    return value * Constants.IMGDperCFS;
                case FlowUnitsType.AFD:
                    return value * Constants.AFDperCFS;
                case FlowUnitsType.LPS:
                    return value * Constants.LPSperCFS;
                case FlowUnitsType.LPM:
                    return value * Constants.LPMperCFS;
                case FlowUnitsType.MLD:
                    return value * Constants.MLDperCFS;
                case FlowUnitsType.CMH:
                    return value * Constants.CMHperCFS;
                case FlowUnitsType.CMD:
                    return value * Constants.CMHperCFS;
            }
            return value;
        }
 
        public static double RevertPower(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * Constants.KWperHP;
 
            return value;
        }
 
        public static double RevertPressure(PressUnitsType type, double spGrav, double value)
        {
            switch (type)
            {
                case PressUnitsType.PSI:
                    return value;
                case PressUnitsType.KPA:
                    return value * (Constants.KPAperPSI * Constants.PSIperFT * spGrav);
                case PressUnitsType.METERS:
                    return value * (Constants.MperFT * spGrav);
            }
            return value;
        }
 
        public static double RevertVolume(UnitsType type, double value)
        {
            if (type == UnitsType.SI)
                return value * (Constants.M3perFT3);
 
            return value;
        }
 
 
    }
 
#endif
 
}