Skip to content

Commit 9d3e037

Browse files
committed
v2.7.3
1 parent a5ddef9 commit 9d3e037

File tree

26 files changed

+674
-150
lines changed

26 files changed

+674
-150
lines changed

src/ltrace/ltrace/pore_networks/functions.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,7 @@ def geo2pnf(
314314
input_x = pore_dict["pore.coords_0"][i] * scale_factor
315315
input_y = pore_dict["pore.coords_1"][i] * scale_factor
316316
input_z = pore_dict["pore.coords_2"][i] * scale_factor
317-
if axis == "x":
318-
p_z, p_y, p_x = input_x, input_y, input_z
319-
elif axis == "y":
320-
p_y, p_z, p_x = input_x, input_y, input_z
321-
elif axis == "z":
322-
p_x, p_y, p_z = input_x, input_y, input_z
317+
p_z, p_y, p_x = input_x, input_y, input_z
323318
coordinate_number = len(pores_conns_pores[i])
324319
is_inlet = int(pore_dict[f"pore.{axis}max"][i])
325320
is_outlet = int(pore_dict[f"pore.{axis}min"][i])

src/ltrace/ltrace/pore_networks/functions_simulation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ def single_phase_permeability(
371371
pore_network,
372372
in_face="xmin",
373373
out_face="xmax",
374+
pressure_drop=101325, # Pa
375+
viscosity=0.001, # Pa.s
374376
subresolution_function=None,
375377
subres_porositymodifier=1.0,
376378
subres_shape_factor=0.041,
@@ -424,6 +426,7 @@ def single_phase_permeability(
424426

425427
water = openpnm.phase.Water(network=sub_proj.network)
426428
water.add_model_collection(openpnm.models.collections.physics.standard)
429+
water["pore.viscosity"] = viscosity
427430
sub_proj["throat.hydraulic_conductance"] = sub_proj["throat.conductance"]
428431
sub_proj["pore.phase"][...] = 1
429432
perm = openpnm.algorithms.StokesFlow(
@@ -434,7 +437,7 @@ def single_phase_permeability(
434437
perm.settings["x_rtol"] = 1e-11
435438
# print("\n\n############## OpenPNM flow ###########\n\n", perm, "\n\n##############################\n\n")
436439
perm.set_value_BC(
437-
pores=sub_proj.pores(in_face), values=101325, mode="overwrite"
440+
pores=sub_proj.pores(in_face), values=pressure_drop, mode="overwrite"
438441
) # pressure in pa: 101325 pa = 1 atm
439442
perm.set_value_BC(pores=sub_proj.pores(out_face), values=0, mode="overwrite")
440443
inlets = perm.network[f"pore.{in_face}"].astype(np.int32)

src/ltrace/ltrace/pore_networks/krel_result.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,19 @@ def _linspace(max_x, number_of_points=201):
363363

364364
@staticmethod
365365
def _interpolate(interpolated_x, x_values, y_values):
366-
return np.interp(interpolated_x, x_values, y_values, left=np.nan, right=np.nan)
366+
interpolated_y = np.interp(interpolated_x, x_values, y_values, left=np.nan, right=np.nan)
367+
368+
# Ensure first and last data are represented in the interpolated data
369+
extra_x_over_limit = interpolated_x > x_values[-1]
370+
if np.any(extra_x_over_limit):
371+
first_out_of_bounds = np.where(extra_x_over_limit == True)[0][0]
372+
interpolated_y[first_out_of_bounds] = y_values[-1]
373+
extra_x_under_limit = interpolated_x < x_values[0]
374+
if np.any(extra_x_under_limit):
375+
last_out_of_bounds = np.where(extra_x_under_limit == True)[0][-1]
376+
interpolated_y[last_out_of_bounds] = y_values[0]
377+
378+
return interpolated_y
367379

368380
@staticmethod
369381
def _interpolate_table(table, id, interpolated_x, cycles_id_list):
@@ -435,9 +447,9 @@ def _get_prefixes(table_dict):
435447

436448
class KrelParameterParser:
437449
def __init__(self):
438-
self.input_regex = re.compile(f"{INPUT_PREFIX}(\S+)")
439-
self.result_regex = re.compile(f"{RESULT_PREFIX}(\S+)")
440-
self.error_regex = re.compile(f"{ERROR_PREFIX}(\S+)")
450+
self.input_regex = re.compile(f"{INPUT_PREFIX}(\\S+)")
451+
self.result_regex = re.compile(f"{RESULT_PREFIX}(\\S+)")
452+
self.error_regex = re.compile(f"{ERROR_PREFIX}(\\S+)")
441453

442454
def get_input_name(self, column_name):
443455
match = self.input_regex.match(column_name)

src/ltrace/ltrace/pore_networks/pnflow_parameter_defs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@
340340
"Model 3 (Morrow curve)": "3",
341341
},
342342
}
343+
PARAMETERS[f"{i}_contact_distribution"] = {
344+
"display_name": "Distribution",
345+
"layout": i,
346+
"dtype": "combobox",
347+
"default_value": 1,
348+
"display_names": {
349+
"Weibull": "weibull",
350+
"Gaussian": "gaussian",
351+
},
352+
}
343353
PARAMETERS[f"{i}_contact_angle"] = {
344354
"display_name": "CA center (deg)",
345355
"tooltip": "Contact angle distribution center (degrees)",
@@ -358,6 +368,12 @@
358368
"max_value": 180.0,
359369
"layout": i,
360370
}
371+
PARAMETERS[f"{i}_contact_angle_sig"] = {
372+
"display_name": "Standard deviation",
373+
"dtype": "multifloat",
374+
"default_value": 5.0,
375+
"layout": i,
376+
}
361377
PARAMETERS[f"{i}_contact_angle_del"] = {
362378
"display_name": "Delta",
363379
"dtype": "multifloat",

src/ltrace/ltrace/pore_networks/visualization_model.py

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ARROW_TYPE = 3
1313

1414

15-
def visualize_vtu(
15+
def _visualize_vtu(
1616
filepath,
1717
cycle,
1818
scale_factor=10**3,
@@ -30,6 +30,19 @@ def visualize_vtu(
3030
Must be 'w' for wetting phase (usually waater) injection cycles and 'o'
3131
for non-wetting phase (usually oil) injection cycles
3232
"""
33+
if axis == "x":
34+
arrow_x = 0
35+
arrow_y = 0
36+
arrow_z = 1
37+
elif axis == "y":
38+
arrow_x = 0
39+
arrow_y = 1
40+
arrow_z = 0
41+
elif axis == "z":
42+
arrow_x = 1
43+
arrow_y = 0
44+
arrow_z = 0
45+
3346
reader = vtk.vtkXMLUnstructuredGridReader()
3447
reader.SetFileName(filepath)
3548
reader.Update()
@@ -116,7 +129,7 @@ def visualize_vtu(
116129
arrows_saturations.InsertTuple1(i, arrow_saturation)
117130
arrows_condW.InsertTuple1(i, 0)
118131
arrows_condO.InsertTuple1(i, 0)
119-
arrows_direction.InsertTuple3(i, 0, 0, 1)
132+
arrows_direction.InsertTuple3(i, arrow_x, arrow_y, arrow_z)
120133
arrows_position.InsertTuple3(i, *arrow_position)
121134
arrows_type.InsertTuple1(i, ARROW_TYPE)
122135
arrows_id.InsertTuple1(i, object_id)
@@ -193,13 +206,17 @@ def visualize_vtu(
193206
return pressure, merger
194207

195208

196-
def generate_model_variable_scalar(temp_folder, is_multiscale=False):
209+
def generate_model_variable_scalar(temp_folder, is_multiscale=False, **kwargs):
197210
file_names = sorted([i for i in os.listdir(temp_folder) if i[-4:] == ".vtu"])
198211

199212
pressures = []
200213
base_filepath = os.path.join(temp_folder, file_names[0])
201-
pressure, pore_mesh = visualize_vtu(
202-
base_filepath, create_model=False, cycle=file_names[0][2].lower(), normalize_radius=is_multiscale
214+
pressure, pore_mesh = _visualize_vtu(
215+
base_filepath,
216+
create_model=False,
217+
cycle=file_names[0][2].lower(),
218+
normalize_radius=is_multiscale,
219+
**kwargs,
203220
)
204221
point_data = pore_mesh.GetOutput().GetPointData()
205222
pressures.append(pressure)
@@ -214,8 +231,12 @@ def generate_model_variable_scalar(temp_folder, is_multiscale=False):
214231

215232
for data_point, file_name in enumerate(file_names[1:], start=1):
216233
filepath = os.path.join(temp_folder, file_name)
217-
pressure, poly_data = visualize_vtu(
218-
filepath, cycle=file_name[2].lower(), create_model=False, normalize_radius=is_multiscale
234+
pressure, poly_data = _visualize_vtu(
235+
filepath,
236+
cycle=file_name[2].lower(),
237+
create_model=False,
238+
normalize_radius=is_multiscale,
239+
**kwargs,
219240
)
220241
saturation = poly_data.GetOutput().GetPointData().GetArray("saturation")
221242
new_array = vtk.util.numpy_support.vtk_to_numpy(saturation)
@@ -285,6 +306,13 @@ def _unstructured_grid_to_dict(
285306
Returns:
286307
dict: model elements data
287308
"""
309+
if axis == "x":
310+
arrow_displacement_axis = 2
311+
elif axis == "y":
312+
arrow_displacement_axis = 1
313+
elif axis == "z":
314+
arrow_displacement_axis = 0
315+
288316
n_points = unstructured_grid.GetNumberOfPoints()
289317
n_cells = unstructured_grid.GetNumberOfCells()
290318

@@ -347,8 +375,7 @@ def _unstructured_grid_to_dict(
347375
radius = unstructured_grid.GetPointData().GetArray("radius").GetComponent(pore_id, 0)
348376
sw = unstructured_grid.GetPointData().GetArray("Sw").GetComponent(pore_id, 0)
349377

350-
if axis == "x":
351-
position = position[-1::-1]
378+
position = position[-1::-1]
352379

353380
is_inlet = unstructured_grid.GetPointData().GetArray("inlets").GetComponent(pore_id, 0)
354381
if is_inlet == 1:
@@ -400,9 +427,11 @@ def _unstructured_grid_to_dict(
400427
volume_side = volume ** (1.0 / 3.0)
401428

402429
inlet_arrows_positions = position_list[inlet_bool_list] * scale_factor
403-
inlet_arrows_positions[:, 2] -= volume_side * arrow_scale + pore_radius_list[inlet_bool_list] / 2
430+
inlet_arrows_positions[:, arrow_displacement_axis] -= (
431+
volume_side * arrow_scale + pore_radius_list[inlet_bool_list] / 2
432+
)
404433
outlet_arrows_positions = position_list[outlet_bool_list] * scale_factor
405-
outlet_arrows_positions[:, 2] += pore_radius_list[outlet_bool_list] / 2
434+
outlet_arrows_positions[:, arrow_displacement_axis] += pore_radius_list[outlet_bool_list] / 2
406435

407436
arrows = []
408437
for i, sw in enumerate(sw_list[inlet_bool_list]):

0 commit comments

Comments
 (0)