Skip to content

Commit b3c69fe

Browse files
authored
Merge pull request #1 from EMSL-Computing/flow-lal
updating codes and markdowns
2 parents cd365c6 + e133823 commit b3c69fe

File tree

2 files changed

+96
-86
lines changed

2 files changed

+96
-86
lines changed

examples/example_6_flow_2d_numerical_on_XCT.ipynb

Lines changed: 35 additions & 33 deletions
Large diffs are not rendered by default.

examples/example_7_flow_2d_pinn_on_XCT.ipynb

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"cell_type": "code",
39-
"execution_count": 1,
39+
"execution_count": 3,
4040
"id": "1a7cff2d-f2ab-41a5-a5cf-402c6e32c54a",
4141
"metadata": {},
4242
"outputs": [],
@@ -65,13 +65,18 @@
6565
"id": "3bac17eb-240a-4fc6-9bd6-72c651691210",
6666
"metadata": {},
6767
"source": [
68-
"## Loading XCT Data\n",
69-
"In this section, we load the XCT data from the file for domain and variable declarations and plot normalized XCT data."
68+
"## Loading and Processing XCT Data\n",
69+
"In this section, we load the X-ray computed tomography (XCT) data from the specified file and perform several preprocessing steps necessary for subsequent analysis. ### Steps Involved:\n",
70+
"1. *Loading XCT Data*\n",
71+
"2. *Normalization*\n",
72+
"3. *Plotting the Normalized XCT Data*\n",
73+
"4. *Determining Data Dimensions*\n",
74+
"5. *Generating Spatial Grid*"
7075
]
7176
},
7277
{
7378
"cell_type": "code",
74-
"execution_count": 2,
79+
"execution_count": 5,
7580
"id": "3cd0029a-3f2e-4b48-b0e0-11704e54c178",
7681
"metadata": {},
7782
"outputs": [
@@ -87,15 +92,15 @@
8792
}
8893
],
8994
"source": [
90-
"# Loading XCT data from the file for domain and variable declarations\n",
95+
"#%% loading XCT data from the file for domain and variable declarations\n",
9196
"data_dir = \"../example_outputs/\"\n",
9297
"results_dir = \"../example_outputs/flow/\"\n",
93-
"data = np.load(data_dir + 'micromodel.npy')\n",
9498
"\n",
95-
"normalized_xct_data = data/np.max(data)\n",
96-
"plot_2d_xct_data_seg(normalized_xct_data, results_dir)\n",
99+
"data = np.load(data_dir + 'micromodel.npy') # Load the XCT data\n",
100+
"normalized_xct_data = data/np.max(data) # Normalize the data to [0, 1]\n",
101+
"plot_2d_xct_data_seg(normalized_xct_data, results_dir) # Plot the normalized XCT data\n",
97102
"\n",
98-
"# Dimensions of the data\n",
103+
"# Determine the dimensions of the data\n",
99104
"data_width, data_height = len(normalized_xct_data), len(normalized_xct_data) \n",
100105
"\n",
101106
"# Generate evenly spaced points in the interval [0, 1] for both dimensions\n",
@@ -115,13 +120,14 @@
115120
"id": "2ee2bebb-6488-4b55-877e-a721df0ebdbb",
116121
"metadata": {},
117122
"source": [
118-
"## Define Boundary Conditions and Input Parameters"
123+
"## Permeability Field Generation Based on XCT Data\n",
124+
"In this section, we generate a permeability field from the XCT data. Permeability is a key property in modeling fluid flow through porous media, and it varies depending on the material's structure, which is captured by the XCT data. The XCT data provides a spatial representation of the material, and we translate this into a spatially varying permeability field based on predefined permeability values for different regions (e.g., pores and soil matrix)."
119125
]
120126
},
121127
{
122128
"cell_type": "code",
123-
"execution_count": 3,
124-
"id": "024e83f8-4ecc-4d75-97c3-a7256eb76b98",
129+
"execution_count": 10,
130+
"id": "c374e26f-ca83-4b87-b583-2fe8b2e890e7",
125131
"metadata": {},
126132
"outputs": [
127133
{
@@ -135,6 +141,44 @@
135141
"output_type": "display_data"
136142
}
137143
],
144+
"source": [
145+
"# Define the minimum permeability (soil matrix) and maximum permeability (pores)\n",
146+
"k_min = 1E-25 # Assigned Permeability of soil matrix corresponding to the lower XCT values (1 𝑚^2/s)\n",
147+
"k_max = 1E-2 # Assigned Permeability of pores corresponding to the higher XCT values (1 𝑚^2/s)\n",
148+
"\n",
149+
"# Find the minimum and maximum values in the normalized XCT data\n",
150+
"xct_val_min = np.min(normalized_xct_data)\n",
151+
"xct_val_max = np.max(normalized_xct_data)\n",
152+
"\n",
153+
"# Initialize a permeability field with the same dimensions as the XCT data,\n",
154+
"#and assign the minimum permeability value (k_min) to all elements\n",
155+
"perm_field_as_XCT = np.full_like(normalized_xct_data, fill_value = k_min) \n",
156+
"\n",
157+
"# Assign the maximum permeability value (k_max) to elements in the field \n",
158+
"# that corresponds to the maximum XCT values (pores)\n",
159+
"perm_field_as_XCT[normalized_xct_data == np.max(normalized_xct_data)] = k_max \n",
160+
"\n",
161+
"# Flip the permeability field upside down to match the required orientation\n",
162+
"perm_field = np.flipud(perm_field_as_XCT)\n",
163+
"\n",
164+
"# Plot the final permeability field\n",
165+
"plot_2d_permeability_seg(X, Y, perm_field, results_dir)"
166+
]
167+
},
168+
{
169+
"cell_type": "markdown",
170+
"id": "51e225c3-740e-4014-9cc4-ac312993870b",
171+
"metadata": {},
172+
"source": [
173+
"## Define Boundary Conditions and Input Parameters for PINN solution"
174+
]
175+
},
176+
{
177+
"cell_type": "code",
178+
"execution_count": 9,
179+
"id": "024e83f8-4ecc-4d75-97c3-a7256eb76b98",
180+
"metadata": {},
181+
"outputs": [],
138182
"source": [
139183
"# Define the boundary conditions and input parameters\n",
140184
"P1 = 2.0 # at x = 0 for all y_b1, Dirichlet boundary at the left (kPa)  \n",
@@ -147,39 +191,25 @@
147191
"norm_P1 = P1 / max_P\n",
148192
"norm_P2 = P2 / max_P\n",
149193
"\n",
150-
"# Permeability field generation based on the XCT data: \n",
151-
"k_min = 1E-25 # Assigned Permeability of soil matrix corresponding to the lower XCT values (1 𝑚^2/s)\n",
152-
"k_max = 1E-2 # Assigned Permeability of pores corresponding to the higher XCT values (1 𝑚^2/s)\n",
153-
"\n",
154-
"# Find the minimum and maximum values of xct_xy_slice\n",
155-
"xct_val_min = np.min(normalized_xct_data)\n",
156-
"xct_val_max = np.max(normalized_xct_data)\n",
157-
"\n",
158-
"perm_field_as_XCT = np.full_like(normalized_xct_data, fill_value = k_min) \n",
159-
"perm_field_as_XCT[normalized_xct_data == np.max(normalized_xct_data)] = k_max \n",
160-
"perm_field = np.flipud(perm_field_as_XCT)\n",
161-
"plot_2d_permeability_seg(X, Y, perm_field, results_dir)\n",
162-
"\n",
163194
"# Input parameters: Dynamic viscosity (mu), Density of water (rho), and Permeability (k). \n",
164195
"rho = 998 # Density of water in kg/m³\n",
165196
"mu = 1.002E-6 # Dynamic viscosity (kPa·s)\n",
166197
"coeff = perm_field * rho / mu # Coefficient of Permeability calcualtions (k*rho/mu)\n",
167198
"max_coeff = np.max(coeff) # Coefficient of Permeability calcualtions (k*rho/mu)\n",
168-
"norm_coeff = coeff/max_coeff\n",
169-
"#coeff = np.ones((nx, ny)) # check with uniform permeability distribution"
199+
"norm_coeff = coeff/max_coeff"
170200
]
171201
},
172202
{
173203
"cell_type": "markdown",
174204
"id": "7a7d55e5-d839-4e9b-83f8-8d39b1d874a7",
175205
"metadata": {},
176206
"source": [
177-
"## Plot for Boundary Conditions and Collocation for Training"
207+
"## Plot for Boundary Conditions and Collocation points associated with PINN"
178208
]
179209
},
180210
{
181211
"cell_type": "code",
182-
"execution_count": 4,
212+
"execution_count": 11,
183213
"id": "e91923e4-1822-497c-bb4b-ba6aa8a0dd16",
184214
"metadata": {},
185215
"outputs": [
@@ -221,7 +251,7 @@
221251
},
222252
{
223253
"cell_type": "code",
224-
"execution_count": 5,
254+
"execution_count": null,
225255
"id": "95f713ab-d991-4d16-b252-b545943db5e5",
226256
"metadata": {},
227257
"outputs": [
@@ -236,29 +266,7 @@
236266
"epoch = 2000\n",
237267
"-------------------------------------------------------\n",
238268
"PINN training started...\n",
239-
" Epoch=0\t loss=6.020e-01\n",
240-
" Epoch=100\t loss=2.993e-02\n",
241-
" Epoch=200\t loss=3.168e-03\n",
242-
" Epoch=300\t loss=6.665e-04\n",
243-
" Epoch=400\t loss=1.915e-04\n",
244-
" Epoch=500\t loss=8.662e-05\n",
245-
" Epoch=600\t loss=5.082e-05\n",
246-
" Epoch=700\t loss=3.547e-05\n",
247-
" Epoch=800\t loss=2.796e-05\n",
248-
" Epoch=900\t loss=2.355e-05\n",
249-
" Epoch=1000\t loss=2.049e-05\n",
250-
" Epoch=1100\t loss=1.816e-05\n",
251-
" Epoch=1200\t loss=1.631e-05\n",
252-
" Epoch=1300\t loss=1.482e-05\n",
253-
" Epoch=1400\t loss=1.361e-05\n",
254-
" Epoch=1500\t loss=1.261e-05\n",
255-
" Epoch=1600\t loss=1.176e-05\n",
256-
" Epoch=1700\t loss=1.103e-05\n",
257-
" Epoch=1800\t loss=1.038e-05\n",
258-
" Epoch=1900\t loss=9.782e-06\n",
259-
" Epoch=2000\t loss=9.231e-06\n",
260-
"PINN training done!\n",
261-
" Best Epoch = 2000\tBest Loss = 9.231e-06\n"
269+
" Epoch=0\t loss=6.020e-01\n"
262270
]
263271
}
264272
],

0 commit comments

Comments
 (0)