-
Notifications
You must be signed in to change notification settings - Fork 2
/
classPNM.h
284 lines (239 loc) · 10.4 KB
/
classPNM.h
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
#pragma once
#include "framework.h"
#include "utils.h"
class classPNM
{
public:
//process variables
//subclass for network constants and settings
class classSettings
{
public:
//constants
int seed = 100;
double tol; //tolerance for lables definition as a fraction of the cubic domain size
//input variables
double domain; //nanometers
double coordination; //2x nodes/pores
double anisotropy; //(0, 1]
double Pinit; //initial domain pressure for initialsation of properties
double Tinit; //domain temperature
double _Pin;
double _dP;
int n_linear_iterations; //number of iterations for the PARDISO solver
vector<vector<std::string>> poreSizeDist_raw;
vector<vector<double>> poreSizeDist;
double expectedP;
};
classSettings settings;
vector<vector<std::string>> poreSizeDist_raw;
vector<vector<double>> poreSizeDist;
double expectedP;
//subclass for network and geometry parameters
class classNetwork
{
public:
vector<bool> left, right, back, front, top, bottom; //label faces (true or false)
vector<vector<double>> pores; //{ X, Y, Z, diameter}
vector<vector<double>> throats; //{beginning, end, diameter}
vector<double> diameter_pore, diameter_throat; //pore and throat diameters
vector<double> area_pore, area_troat; //cross-section area
vector<double> length_throat;
vector<vector<double>> conduit_length_throat; //conduit length for each throat {pore1, throat, pore2}
vector<vector<double>> shape_factor_throat; //shape factor for each throat {pore1, throat, pore2}
vector<vector<vector<double>>> endpoints_throat; //end coordinates for each throat {pore1: {x, y, z}, pore2: {x, y, z}}
//functions
/*classPNM length_throat_piecewise(classPNM PNM, classUtils utils);
classPNM endpoints_spherical(classPNM PNM, classUtils utils);
classPNM cross_sectional_area_simple(classPNM PNM, classUtils utils);
classPNM conduit_length_throat_def(classPNM PNM, classUtils utils);
classPNM shape_factor_cone_stick(classPNM PNM, classUtils utils);
classPNM generate_network_properties(classPNM PNM, classUtils utils);*/
};
classNetwork network;
//subclasses for Phase properties calculation
class classMethane
{
public:
//constants
double MW = 0.016; //molecular weight [mol/kg]
double Pc = 4599200;
double Tc = 190.564;
double Vc = 1 / 162.66;
double d_mol = 0.38e-9; //m
//network phase properties
vector<double> pressure_pore, pressure_throat, temperature_pore, temperature_throat;
vector<double> density_throat, density_pore, viscosity_throat, viscosity_pore, knudsen_throat, knudsen_pore;
//phase functions
//classPNM density_Peng_Robinson_Methane(classPNM PNM, classUtils utils);
//classPNM viscosity_natural_gas_Lee(classPNM PNM, classUtils utils);
//classPNM knudsen_number(classPNM PNM, classUtils utils);
//classPNM generate_phase_properties(classPNM PNM, classUtils utils);
};
class classCarbonDioxide
{
public:
//constants
double MW = 0.016; //molecular weight [mol/hg]
double Pc = 4599200;
double Tc = 190.564;
double Vc = 1 / 162.66;
//network phase properties
vector<double> pressure_pore, pressure_throat, temperature_pore, temperature_throat;
vector<double> density_throat, density_pore, viscosity_throat, viscosity_pore, knudsen_throat, knudsen_pore;
//phase functions
/*classPNM density_Peng_Robinson_Methane(classPNM PNM, classUtils utils);
classPNM viscosity_natural_gas_Lee(classPNM PNM, classUtils utils);
classPNM knudsen_number(classPNM PNM, classUtils utils);*/
};
//phase selection
classMethane phase;
//classCarbonDioxide phase;
class classPhysics
{
public:
//physics properties
vector<double> hydraulic_conductance_throat;
//physics functions
/*classPNM hydraulic_conductance_Ma_2014(classPNM PNM, classUtils utils);
classPNM hydraulic_conductance_Song_2018(classPNM PNM, classUtils utils);
classPNM generate_physics_properties(classPNM PNM, classUtils utils);*/
};
classPhysics physics;
class classSinglePhaseStokesFlow
{
public:
//variables
vector<bool> inlets, outlets;
double Pin, dP;
vector<double> conductance;
vector<double> flow_rate_pore, flow_rate_throat;
vector<double> effective_permeability;
//ALL in MTL4 datatypes
//Matrix A
compressed2D<double> A;
//RHS vector b
dense_vector<double> b;
//current and previous solution vectors X, Xold
dense_vector<double> X, Xold;
dense_vector<double> pressure_BC;
//functions
/*classPNM create_A_b(classPNM PNM, classUtils utils);
dense_vector<double> populate_A_b(compressed2D<double>& A, dense_vector<double> b, classPNM PNM);
double laplacian_A(compressed2D<double>& A, classPNM PNM);
classPNM solve_A_b(classPNM PNM, classUtils utils);
classPNM pass_result_to_phase(classPNM PNM, classUtils utils);
classPNM calculate_flow_rate(classPNM PNM, classUtils utils);
classPNM calculate_effective_permeability(classPNM PNM, classUtils utils);
classPNM run_once(classPNM PNM, classUtils utils);
classPNM run_linear_iterative(classPNM PNM, classUtils utils);*/
};
classSinglePhaseStokesFlow algorithm;
//functions
double actualPorosity(classPNM PNM);
classPNM propertyCorrection(classPNM PNM, classUtils utils);
vector<int> poresPsize(classPNM PNM);
classPNM label_faces(classPNM PNM, classUtils utils);
classPNM initial_conditions(classPNM PNM, classUtils utils);
classPNM test(classPNM PNM, classUtils utils);
classPNM csvReadNetwork_python(string loadPath, classPNM PNM, classUtils utils);
class classMethods
{
public:
class classMethodsGeneration
{
public:
void poresGeneration2(classPNM::classNetwork& network, classPNM::classSettings& settings);
void throatsGeneration(classPNM::classNetwork& network, classPNM::classSettings& settings);
void throatsGeneration2(classPNM::classNetwork& network, classPNM::classSettings& settings);
void connectedComponents(classPNM::classNetwork& network);
};
classMethodsGeneration methodsGeneration;
class classMethodsNetwork
{
public:
//functions
void length_throat_piecewise(classPNM::classNetwork& network);
void endpoints_spherical(classPNM::classNetwork& network);
void cross_sectional_area_simple(classPNM::classNetwork& network);
void conduit_length_throat_def(classPNM::classNetwork& network);
void shape_factor_cone_stick(classPNM::classNetwork& network);
void generate_network_properties(classPNM::classNetwork& network, classPNM::classMethods::classMethodsNetwork& methodsNetwork);
};
classMethodsNetwork methodsNetwork;
class classMethodsMethane
{
public:
//phase functions
void density_Peng_Robinson_Methane(classPNM::classMethane& phase, classPNM::classNetwork& network);
void viscosity_natural_gas_Lee(classPNM::classMethane& phase, classPNM::classNetwork& network);
void knudsen_number(classPNM::classMethane& phase, classPNM::classNetwork& network);
void generate_phase_properties(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classMethods::classMethodsMethane& methodsPhase);
};
//choose phase here too!!
classMethodsMethane methodsPhase;
class classMethodsPhysics
{
public:
void hydraulic_conductance_Ma_2014(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics);
void hydraulic_conductance_Song_2018(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics);
void generate_physics_properties(classPNM::classNetwork& network, classPNM::classMethane& phase, classPNM::classPhysics& physics, classPNM::classMethods::classMethodsPhysics& methodsPhysics);
};
classMethodsPhysics methodsPhysics;
class classMethodsSinglePhaseStokesFlow
{
public:
//functions
void create_A_b(classPNM::classNetwork& network,
classPNM::classPhysics& physics,
classPNM::classSinglePhaseStokesFlow& algorithm,
classPNM::classMethods::classMethodsSinglePhaseStokesFlow& methodsAlgorithm);
dense_vector<double> populate_A_b(compressed2D<double>& A,
dense_vector<double>& b,
classPNM::classNetwork& network,
classPNM::classSinglePhaseStokesFlow& algorithm,
classPNM::classMethods::classMethodsSinglePhaseStokesFlow& methodsAlgorithm);
double laplacian_A(compressed2D<double>& laplacian_A,
classPNM::classNetwork& network,
classPNM::classSinglePhaseStokesFlow& algorithm);
void solve_A_b(classPNM::classNetwork& network,
classPNM::classSinglePhaseStokesFlow& algorithm);
void solve_A_b_pypardiso(classPNM::classNetwork& network,
classPNM::classSinglePhaseStokesFlow& algorithm);
void pass_result_to_phase(classPNM::classNetwork& network,
classPNM::classMethane& phase,
classPNM::classSinglePhaseStokesFlow& algorithm);
void calculate_flow_rate(classPNM::classNetwork& network,
classPNM::classMethane& phase,
classPNM::classSinglePhaseStokesFlow& algorithm);
void calculate_effective_permeability(classPNM::classNetwork& network,
classPNM::classSettings& settings,
classPNM::classMethane& phase,
classPNM::classSinglePhaseStokesFlow& algorithm);
void run_once(classPNM::classNetwork& network,
classPNM::classSettings& settings,
classPNM::classMethane& phase,
classPNM::classPhysics& physics,
classPNM::classSinglePhaseStokesFlow& algorithm,
classPNM::classMethods::classMethodsSinglePhaseStokesFlow& methodsAlgorithm);
void run_linear_iterative(classPNM::classNetwork& network,
classPNM::classSettings& settings,
classPNM::classMethane& phase,
classPNM::classPhysics& physics,
classPNM::classSinglePhaseStokesFlow& algorithm,
classPNM::classMethods& methods);
};
//choose algorythm here too!!
classMethodsSinglePhaseStokesFlow methodsAlgorithm;
};
classMethods methods;
class classIO
{
public:
void csvWriteNetwork(string savePath, classPNM::classNetwork& network, classPNM::classSettings& settings);
void csvReadNetwork(string loadPath, classPNM::classNetwork& network, classPNM::classSettings& settings, classUtils utils);
void readSettings(classPNM::classSettings& settings);
void readSetupFile(classPNM::classSettings& settings, classUtils utils);
};
classIO IO;
};