-
Notifications
You must be signed in to change notification settings - Fork 2
/
classPhysics.cpp
339 lines (316 loc) · 13.1 KB
/
classPhysics.cpp
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#include "classPNM.h"
//
//PHYSICS
//
//classPNM classPNM::classPhysics::hydraulic_conductance_Ma_2014(classPNM PNM, classUtils utils)
//{
// PNM.physics.hydraulic_conductance_throat.clear();
//
// int p1, p2; //pore indices
// double A1, At, A2, d1, dt, d2, L1, Lt, L2, T1, Tt, T2, P1, Pt, P2, rho1, rhot, rho2, D1, Dt, D2, k1, kt, k2, SF1, SFt, SF2; //input variables
// double g1, gt, g2; //individual conductances
//
// //internal consts
// double alpha = 1; //TMAC (0;1]
// double pi = 3.1415926;
//
// //calculate for throats
// for (int i = 0; i < PNM.network.throats.size(); i++)
// {
//
// p1 = PNM.network.throats[i][0];
// p2 = PNM.network.throats[i][1];
//
// //Getting equivalent areas
// A1 = PNM.network.area_pore[p1];
// At = PNM.network.area_troat[i];
// A2 = PNM.network.area_pore[p2];
// //getting diameter
// d1 = PNM.network.diameter_pore[p1];
// dt = PNM.network.diameter_throat[i];
// d2 = PNM.network.diameter_pore[p2];
// //Getting conduit lengths
// L1 = PNM.network.conduit_length_throat[i][0];
// Lt = PNM.network.conduit_length_throat[i][1];
// L2 = PNM.network.conduit_length_throat[i][2];
// //Getting throat shape factors
// SF1 = PNM.network.shape_factor_throat[i][0];
// SFt = PNM.network.shape_factor_throat[i][1];
// SF2 = PNM.network.shape_factor_throat[i][2];
// //getting temperature
// T1 = PNM.phase.temperature_pore[p1];
// Tt = PNM.phase.temperature_throat[i];
// T2 = PNM.phase.temperature_pore[p2];
// //getting pressure
// P1 = PNM.phase.pressure_pore[p1];
// Pt = PNM.phase.pressure_throat[i];
// P2 = PNM.phase.pressure_pore[p2];
// //getting density
// rho1 = PNM.phase.density_pore[p1];
// rhot = PNM.phase.density_throat[i];
// rho2 = PNM.phase.density_pore[p2];
// //getting viscosity
// D1 = PNM.phase.viscosity_pore[p1];
// Dt = PNM.phase.viscosity_throat[i];
// D2 = PNM.phase.viscosity_pore[p2];
// //getting knudsen number
// k1 = PNM.phase.knudsen_pore[p1];
// kt = PNM.phase.knudsen_throat[i];
// k2 = PNM.phase.knudsen_pore[p2];
//
// //if Li = 0, gi is infinity
// if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
// else { g1 = (A1 * pow((d1 / 2), 2) / (8 * D1 * L1)) * ((1 + 1) / 2 + 16 * k1 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k1); }
// if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
// else { gt = (At * pow((dt / 2), 2) / (8 * Dt * Lt)) * ((1 + 1) / 2 + 16 * kt * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * kt); }
// if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
// else { g2 = (A2 * pow((d2 / 2), 2) / (8 * D2 * L2)) * ((1 + 1) / 2 + 16 * k2 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k2); }
//
// PNM.physics.hydraulic_conductance_throat.push_back((L1 + Lt + L2) / (L1 / g1 / SF1 + Lt / gt / SFt + L2 / g2 / SF2));
//
// }
//
// return PNM;
//}
//
//classPNM classPNM::classPhysics::hydraulic_conductance_Song_2018(classPNM PNM, classUtils utils)
//{
// PNM.physics.hydraulic_conductance_throat.clear();
//
// int p1, p2; //pore indices
// double A1, At, A2, d1, dt, d2, L1, Lt, L2, T1, Tt, T2, P1, Pt, P2, rho1, rhot, rho2, D1, Dt, D2, k1, kt, k2, SF1, SFt, SF2; //input variables
// double g1, gt, g2; //individual conductances
//
// //internal consts
// double alpha = 1; //TMAC (0;1]
// double pi = 3.1415926;
//
// //calculate for throats
// for (int i = 0; i < PNM.network.throats.size(); i++)
// {
//
// p1 = PNM.network.throats[i][0];
// p2 = PNM.network.throats[i][1];
//
// //Getting equivalent areas
// A1 = PNM.network.area_pore[p1];
// At = PNM.network.area_troat[i];
// A2 = PNM.network.area_pore[p2];
// //getting diameter
// d1 = PNM.network.diameter_pore[p1];
// dt = PNM.network.diameter_throat[i];
// d2 = PNM.network.diameter_pore[p2];
// //Getting conduit lengths
// L1 = PNM.network.conduit_length_throat[i][0];
// Lt = PNM.network.conduit_length_throat[i][1];
// L2 = PNM.network.conduit_length_throat[i][2];
// //Getting throat shape factors
// SF1 = PNM.network.shape_factor_throat[i][0];
// SFt = PNM.network.shape_factor_throat[i][1];
// SF2 = PNM.network.shape_factor_throat[i][2];
// //getting temperature
// T1 = PNM.phase.temperature_pore[p1];
// Tt = PNM.phase.temperature_throat[i];
// T2 = PNM.phase.temperature_pore[p2];
// //getting pressure
// P1 = PNM.phase.pressure_pore[p1];
// Pt = PNM.phase.pressure_throat[i];
// P2 = PNM.phase.pressure_pore[p2];
// //getting density
// rho1 = PNM.phase.density_pore[p1];
// rhot = PNM.phase.density_throat[i];
// rho2 = PNM.phase.density_pore[p2];
// //getting viscosity
// D1 = PNM.phase.viscosity_pore[p1];
// Dt = PNM.phase.viscosity_throat[i];
// D2 = PNM.phase.viscosity_pore[p2];
// //getting knudsen number
// k1 = PNM.phase.knudsen_pore[p1];
// kt = PNM.phase.knudsen_throat[i];
// k2 = PNM.phase.knudsen_pore[p2];
//
// //if Li = 0, gi is infinity
// /*if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
// else { g1 = (A1 * pow((d1 / 2), 2) / (8 * D1 * L1)) * ((1 + 1) / 2 + 16 * k1 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k1); }
// if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
// else { gt = (At * pow((dt / 2), 2) / (8 * Dt * Lt)) * ((1 + 1) / 2 + 16 * kt * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * kt); }
// if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
// else { g2 = (A2 * pow((d2 / 2), 2) / (8 * D2 * L2)) * ((1 + 1) / 2 + 16 * k2 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k2); }*/
//
// //Song et al 2018
// if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
// else
// {
// g1 = (pi * pow(d1 / 2, 4) / (8 * D1 * L1)) * (1 + 128 * atan(4.0 * pow(k1, 0.4)) * k1 / (15 * pow(pi, 2))) * (1 + 4 * k1 / (1 + k1));
// }
// if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
// else
// {
// gt = (pi * pow(dt / 2, 4) / (8 * Dt * Lt)) * (1 + 128 * atan(4.0 * pow(kt, 0.4)) * kt / (15 * pow(pi, 2))) * (1 + 4 * kt / (1 + kt));
// }
// if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
// else
// {
// g2 = (pi * pow(d2 / 2, 4) / (8 * D2 * L2)) * (1 + 128 * atan(4.0 * pow(k2, 0.4)) * k2 / (15 * pow(pi, 2))) * (1 + 4 * k2 / (1 + k2));
// }
//
// PNM.physics.hydraulic_conductance_throat.push_back((L1 + Lt + L2) / (L1 / g1 / SF1 + Lt / gt / SFt + L2 / g2 / SF2));
//
// }
//
// return PNM;
//}
//
//classPNM classPNM::classPhysics::generate_physics_properties(classPNM PNM, classUtils utils)
//{
// //PNM = PNM.physics.hydraulic_conductance_Ma_2014(PNM, utils);
// PNM = PNM.physics.hydraulic_conductance_Song_2018(PNM, utils);
// utils.writeLine("Physics Properties calculated");
// //utils.emptyLine();
// return PNM;
//}
//
void classPNM::classMethods::classMethodsPhysics::hydraulic_conductance_Ma_2014(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics)
{
physics.hydraulic_conductance_throat.clear();
int p1, p2; //pore indices
double A1, At, A2, d1, dt, d2, L1, Lt, L2, T1, Tt, T2, P1, Pt, P2, rho1, rhot, rho2, D1, Dt, D2, k1, kt, k2, SF1, SFt, SF2; //input variables
double g1, gt, g2; //individual conductances
//internal consts
double alpha = 1; //TMAC (0;1]
double pi = 3.1415926;
//calculate for throats
for (int i = 0; i < network.throats.size(); i++)
{
p1 = network.throats[i][0];
p2 = network.throats[i][1];
//Getting equivalent areas
A1 = network.area_pore[p1];
At = network.area_troat[i];
A2 = network.area_pore[p2];
//getting diameter
d1 = network.diameter_pore[p1];
dt = network.diameter_throat[i];
d2 = network.diameter_pore[p2];
//Getting conduit lengths
L1 = network.conduit_length_throat[i][0];
Lt = network.conduit_length_throat[i][1];
L2 = network.conduit_length_throat[i][2];
//Getting throat shape factors
SF1 = network.shape_factor_throat[i][0];
SFt = network.shape_factor_throat[i][1];
SF2 = network.shape_factor_throat[i][2];
//getting temperature
T1 = phase.temperature_pore[p1];
Tt = phase.temperature_throat[i];
T2 = phase.temperature_pore[p2];
//getting pressure
P1 = phase.pressure_pore[p1];
Pt = phase.pressure_throat[i];
P2 = phase.pressure_pore[p2];
//getting density
rho1 = phase.density_pore[p1];
rhot = phase.density_throat[i];
rho2 = phase.density_pore[p2];
//getting viscosity
D1 = phase.viscosity_pore[p1];
Dt = phase.viscosity_throat[i];
D2 = phase.viscosity_pore[p2];
//getting knudsen number
k1 = phase.knudsen_pore[p1];
kt = phase.knudsen_throat[i];
k2 = phase.knudsen_pore[p2];
//if Li = 0, gi is infinity
if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
else { g1 = (A1 * pow((d1 / 2), 2) / (8 * D1 * L1)) * ((1 + 1) / 2 + 16 * k1 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k1); }
if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
else { gt = (At * pow((dt / 2), 2) / (8 * Dt * Lt)) * ((1 + 1) / 2 + 16 * kt * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * kt); }
if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
else { g2 = (A2 * pow((d2 / 2), 2) / (8 * D2 * L2)) * ((1 + 1) / 2 + 16 * k2 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k2); }
physics.hydraulic_conductance_throat.push_back((L1 + Lt + L2) / (L1 / g1 / SF1 + Lt / gt / SFt + L2 / g2 / SF2));
}
}
void classPNM::classMethods::classMethodsPhysics::hydraulic_conductance_Song_2018(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics)
{
physics.hydraulic_conductance_throat.clear();
int p1, p2; //pore indices
double A1, At, A2, d1, dt, d2, L1, Lt, L2, T1, Tt, T2, P1, Pt, P2, rho1, rhot, rho2, D1, Dt, D2, k1, kt, k2, SF1, SFt, SF2; //input variables
double g1, gt, g2; //individual conductances
//internal consts
double alpha = 1; //TMAC (0;1]
double pi = 3.1415926;
//calculate for throats
for (int i = 0; i < network.throats.size(); i++)
{
p1 = network.throats[i][0];
p2 = network.throats[i][1];
//Getting equivalent areas
A1 = network.area_pore[p1];
At = network.area_troat[i];
A2 = network.area_pore[p2];
//getting diameter
d1 = network.diameter_pore[p1];
dt = network.diameter_throat[i];
d2 = network.diameter_pore[p2];
//Getting conduit lengths
L1 = network.conduit_length_throat[i][0];
Lt = network.conduit_length_throat[i][1];
L2 = network.conduit_length_throat[i][2];
//Getting throat shape factors
SF1 = network.shape_factor_throat[i][0];
SFt = network.shape_factor_throat[i][1];
SF2 = network.shape_factor_throat[i][2];
//getting temperature
T1 = phase.temperature_pore[p1];
Tt = phase.temperature_throat[i];
T2 = phase.temperature_pore[p2];
//getting pressure
P1 = phase.pressure_pore[p1];
Pt = phase.pressure_throat[i];
P2 = phase.pressure_pore[p2];
//getting density
rho1 = phase.density_pore[p1];
rhot = phase.density_throat[i];
rho2 = phase.density_pore[p2];
//getting viscosity
D1 = phase.viscosity_pore[p1];
Dt = phase.viscosity_throat[i];
D2 = phase.viscosity_pore[p2];
//getting knudsen number
k1 = phase.knudsen_pore[p1];
kt = phase.knudsen_throat[i];
k2 = phase.knudsen_pore[p2];
//if Li = 0, gi is infinity
/*if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
else { g1 = (A1 * pow((d1 / 2), 2) / (8 * D1 * L1)) * ((1 + 1) / 2 + 16 * k1 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k1); }
if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
else { gt = (At * pow((dt / 2), 2) / (8 * Dt * Lt)) * ((1 + 1) / 2 + 16 * kt * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * kt); }
if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
else { g2 = (A2 * pow((d2 / 2), 2) / (8 * D2 * L2)) * ((1 + 1) / 2 + 16 * k2 * ((2 - alpha) / alpha) / 3 + (16 * 16 / (3 * 3 * pi)) * k2); }*/
//Song et al 2018
if (L1 <= 0) { g1 = numeric_limits<double>::infinity(); }
else
{
g1 = (pi * pow(d1 / 2, 4) / (8 * D1 * L1)) * (1 + 128 * atan(4.0 * pow(k1, 0.4)) * k1 / (15 * pow(pi, 2))) * (1 + 4 * k1 / (1 + k1));
}
if (Lt <= 0) { gt = numeric_limits<double>::infinity(); }
else
{
gt = (pi * pow(dt / 2, 4) / (8 * Dt * Lt)) * (1 + 128 * atan(4.0 * pow(kt, 0.4)) * kt / (15 * pow(pi, 2))) * (1 + 4 * kt / (1 + kt));
}
if (L2 <= 0) { g2 = numeric_limits<double>::infinity(); }
else
{
g2 = (pi * pow(d2 / 2, 4) / (8 * D2 * L2)) * (1 + 128 * atan(4.0 * pow(k2, 0.4)) * k2 / (15 * pow(pi, 2))) * (1 + 4 * k2 / (1 + k2));
}
physics.hydraulic_conductance_throat.push_back((L1 + Lt + L2) / (L1 / g1 / SF1 + Lt / gt / SFt + L2 / g2 / SF2));
}
}
void classPNM::classMethods::classMethodsPhysics::generate_physics_properties(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics, classPNM::classMethods::classMethodsPhysics& methodsPhysics)
{
//methodsPhysics.hydraulic_conductance_Ma_2014(network, phase, physics)
methodsPhysics.hydraulic_conductance_Song_2018(network, phase, physics);
//utils.writeLine("Physics Properties calculated");
cout << "Physics Properties calculated" << endl;
//utils.emptyLine();
}