DFN#

This is the DFN module that contains the DFN class. The DFN class is used to create a Discrete Fracture Network (DFN) object.

Notes

This module contains the DFN class.

The DFN class is the main class for the AnDFN package. It contains the fractures and elements of the DFN and methods to solve the DFN.

class andfn.dfn.DFN(label, discharge_int=10, **kwargs)[source]#

Bases: Constants

__init__(label, discharge_int=10, **kwargs)[source]#

Initializes the DFN class.

Parameters:
  • label (str or int) – The label of the DFN.

  • discharge_int (int) – The number of points to use for the discharge integral.

__str__()[source]#

Returns the string representation of the DFN.

Returns:

The string representation of the DFN.

Return type:

str

add_fracture(new_fracture)[source]#

Adds a fracture to the DFN.

Parameters:

new_fracture (Fracture | list) – The fracture to add to the DFN.

build_discharge_matrix()[source]#

Builds the discharge matrix for the DFN and adds it to the DFN.

static check_streamline_exit(z0, z1, discharge_elements, frac, backward)[source]#

Function that checks if the streamline has exited the DFN

consolidate_dfn(hpc=False)[source]#
delete_fracture(fracture)[source]#

Deletes a fracture from the DFN.

Parameters:

fracture (Fracture) – The fracture to delete from the DFN.

generate_connected_dfn(num_fracs, radius_factor, center_factor, ncoef_i, nint_i, ncoef_b, nint_b, frac_surface=None)[source]#

Generates a connected DFN and adds it and the intersections to the DFN.

Parameters:
  • num_fracs (int) – Number of fractures to generate.

  • radius_factor (float) – The factor to multiply the radius by.

  • center_factor (float) – The factor to multiply the center by.

  • ncoef_i (int) – The number of coefficients to use for the intersection elements.

  • nint_i (int) – The number of integration points to use for the intersection elements.

  • ncoef_b (int) – The number of coefficients to use for the bounding elements.

  • nint_b (int) – The number of integration points to use for the bounding elements.

  • frac_surface (Fracture) – The fracture to use as the surface fracture.

get_dfn_center()[source]#

Gets the center of the DFN.

get_dfn_discharge()[source]#
get_discharge_elements()[source]#

Gets the discharge elements from the fractures and add store them in the DFN.

get_elements()[source]#

Gets the elements from the fractures and add store them in the DFN.

static get_exit_intersection(z3d, element, frac, frac_old, elevation, dchi=1e-06)[source]#
get_flow_fractures(cond=0.2)[source]#
get_fracture_intersections(ncoef=5, nint=10, new_frac=None)[source]#

Finds the intersections between the fractures in the DFN and adds them to the DFN.

Parameters:
  • ncoef (int) – The number of coefficients to use for the intersection elements.

  • nint (int) – The number of integration points to use for the intersection elements

  • new_frac (Fracture) – The fracture to calculate the intersections for.

static get_travel_time_and_length(streamline, velocity)[source]#

Returns the travel time for a streamline.

Parameters:
  • streamline (list | ndarray) – The streamline.

  • velocity (ndarray) – The velocity along the streamline.

Returns:

  • time (float) – The travel time for the streamline.

  • length (float) – The length of the streamline.

import_fractures_from_file(path, radius_str, x_str, y_str, z_str, t_str, e_str=None, strike_str=None, dip_str=None, trend_str=None, plunge_str=None, starting_frac=None)[source]#

Imports fractures from a csv file. More formatting options can be added later.

Parameters:
  • path (str) – The path to the file containing the fractures.

  • radius_str (str) – The name of the column containing the radius of the fractures.

  • x_str (str) – The name of the column containing the x coordinate of the center of the fractures.

  • y_str (str) – The name of the column containing the y coordinate of the center of the fractures.

  • z_str (str) – The name of the column containing the z coordinate of the center of the fractures.

  • t_str (str) – The name of the column containing the transmissivity of the fractures.

  • e_str (str, optional) – The name of the column containing the aperture of the fractures. The default is None.

  • strike_str (str, optional) – The name of the column containing the strike of the fractures. The default is None.

  • dip_str (str, optional) – The name of the column containing the dip of the fractures. The default is None.

  • trend_str (str, optional) – The name of the column containing the trend of the fractures. The default is None.

  • plunge_str (str, optional) – The name of the column containing the plunge of the fractures. The default is None.

  • starting_frac (Fracture, optional) – The fracture to use as the starting point for the connected fractures. The default is None.

Returns:

The fractures are added to the DFN.

Return type:

None

initiate_plotter(window_size=(800, 800), grid=False, lighting='light kit', title=True, off_screen=False, scale=1.0, axis=True, notebook=False)[source]#

Initiates the plotter for the DFN.

Parameters:
  • window_size (tuple) – The size of the plot window.

  • grid (bool) – Whether to add a grid to the plot.

  • lighting (str) – The type of lighting to use.

  • title (bool or str) – Whether to add a title to the plot.

  • off_screen (bool) – Whether to plot off-screen.

  • scale (float) – The scale of the plot.

  • axis (bool) – Whether to add the axis to the plot.

  • notebook (bool) – Whether to plot in a notebook. Set this to true when using Jupyter notebooks.

Returns:

pl – The plotter object.

Return type:

pyvista.Plotter

load_dfn(filename)[source]#

Loads the DFN from a h5 file.

Parameters:

filename (str) – The name of the file to load the DFN from.

number_of_elements()[source]#

Returns the number of elements in the DFN.

number_of_fractures()[source]#

Returns the number of fractures in the DFN.

plot_elements(pl, elements=None, line_width=3.0, const_elements=False)[source]#

Plots the elements in the DFN.

Parameters:
  • pl (pyvista.Plotter) – The plotter object.

  • elements (list) – The list of elements to plot. If None, all elements are plotted.

  • line_width (float) – The line width of the elements.

plot_fractures(pl, num_side=50, filled=True, color='#FFFFFF', opacity=1.0, show_edges=True, line_width=2.0, fracs=None)[source]#

Plots the fractures in the DFN.

Parameters:
  • pl (pyvista.Plotter) – The plotter object.

  • num_side (int) – The number of sides to use for the fractures.

  • filled (bool) – Whether to fill the fractures.

  • color (str | tuple) – The color of the fractures.

  • opacity (float) – The opacity of the fractures.

  • show_edges (bool) – Whether to show the edges of the fractures.

  • line_width (float) – The line width of the lines.

  • fracs (list) – The list of fractures to plot. If None, all fractures are plotted.

Returns:

fracs – The list of fractures that have been plotted.

Return type:

list

plot_fractures_flow_net(pl, lvs=20, n_points=100, line_width=2, margin=0.01, only_flow=False)[source]#

Plots the flow net for the fractures in the DFN.

Parameters:
  • pl (pyvista.Plotter) – The plotter object.

  • lvs (int) – The number of levels to contour for the flow net.

  • n_points (int) – The number of points to use for the flow net (n_points x n_points).

  • line_width (float) – The line width of the flow net.

  • margin (float) – The margin around the fracture to use for the flow net.

  • only_flow (bool) – Whether to plot only the fractures with flow.

plot_fractures_head(pl, lvs=20, n_points=100, line_width=2, margin=0.001, opacity=1.0, only_flow=False, color_map='jet', limits=None, color_fracs=True, contour=True, colorbar=True)[source]#

Plots the flow net for the fractures in the DFN.

Parameters:
  • pl (pyvista.Plotter) – The plotter object.

  • lvs (int) – The number of levels to contour for the flow net.

  • n_points (int) – The number of points to use for the flow net (n_points x n_points).

  • line_width (float) – The line width of the flow net.

  • margin (float) – The margin around the fracture to use for the flow net.

  • opacity (float) – The opacity of the fractures in the flownet.

  • only_flow (bool) – Whether to plot only the fractures with flow.

  • color_map (str) – The color map to use for the flow net. For a constant color, use a string with the same value for the color.

  • limits (list | tuple) – Custom limits for the flow net, overwrites the calculated limits.

  • color_fracs (bool) – Whether to color the fractures according to their mean head.

  • contour (bool) – Whether to plot the contour lines.

  • colorbar (bool) – Whether to plot the color bar.

plot_ncoef(save=False, name='ncoef.png')[source]#

Plots the number of coefficients for the elements in the DFN.

Parameters:
  • save (bool) – Whether to save the plot.

  • name (str) – The name of the plot.

Return type:

None

plot_sparse_matrix(save=False, name='sparse_matrix.png')[source]#

Plots the sparse matrix of the DFN.

Parameters:
  • save (bool) – Whether to save the plot.

  • name (str) – The name of the plot.

Return type:

None

plot_streamline_tracking(pl, z0, frac, ds=0.01, max_length=1000, line_width=2.0, elevation=0.0, remove_false=True, color='black', backward=False)[source]#

Plots the streamline tracking for a given fracture.

Parameters:
  • pl (pyvista.Plotter) – The plotter object.

  • z0 (complex | np.ndarray) – The starting point for the streamline tracking.

  • frac (Fracture) – The fracture where to start the streamline tracking.

  • ds (float) – The step size for the streamline tracking.

  • max_length (int) – The maximum length of the streamline.

  • line_width (float) – The line width of the streamlines.

  • elevation (float | np.ndarray) – The elevation of the starting point.

  • remove_false (bool) – Whether to remove the streamlines that exit the DFN on flase locations.

static runge_kutta(z0, frac, ds, backward, tolerance=1e-06, max_it=10)[source]#

Runge-Kutta method for streamline tracing.

Parameters:
  • z0 (complex) – The initial point.

  • frac (Fracture) – The fracture where the streamline is traced.

  • ds (float) – The step size.

  • backward (bool) – Whether to trace the streamline backward.

  • tolerance (float) – The tolerance for the error.

  • max_it (int) – The maximum number of iterations.

Returns:

z1 – The point at the end of the streamline.

Return type:

complex

save_dfn(filename)[source]#

Saves the DFN to a h5 file.

Parameters:

filename (str) – The name of the file to save the DFN to.

set_constant_head_boundary(center, normal, radius, head, label='Constant Head Boundary', ncoef=5, nint=10)[source]#

Adds a constant head boundary to the DFN.

Parameters:
  • center (np.ndarray) – The center of the constant head boundary.

  • normal (np.ndarray) – The normal of the constant head boundary.

  • radius (float) – The radius of the constant head boundary.

  • head (float) – The head of the constant head boundary.

  • label (str) – The label of the constant head boundary.

set_kwargs(**kwargs)[source]#

Changes the attributes of the DFN.

Parameters:

kwargs (**kwargs) – The attributes to change.

solve()[source]#

Solves the DFN on a HPC.

To change the solver constants, use the set_kwargs method.

streamline_tracking(z0, frac, elevation, ds, max_length, backward)[source]#

Function that tracks the streamlines in a fracture.

Parameters:
  • z0 (complex) – Starting point for streamline tracking

  • elevation (float) – Elevation of the starting point

  • frac (Fracture) – The fracture where to start the streamline tracking

  • ds (float) – Step size for the streamline tracking

  • max_length (int) – Maximum length of the streamline

  • backward (bool) – Whether to track the streamline backward or forward

Returns:

streamlines – Array with streamline

Return type:

np.ndarray

unconsolidate_dfn(hpc=False)[source]#

Unconsolidates the DFN.

Parameters:

hpc (bool) – If True, the DFN is unconsolidated for the HPC.

andfn.dfn.generate_connected_fractures(num_fracs, radius_factor, center_factor, ncoef_i, nint_i, ncoef_b, nint_b, frac_surface=None, se_factor=1.0)[source]#

Generates connected fractures and intersections.

Parameters:
  • num_fracs (int) – The number of fractures to generate.

  • radius_factor (float) – The factor to multiply the radius by.

  • center_factor (float) – The factor to multiply the center by.

  • ncoef_i (int) – The number of coefficients to use for the intersection elements.

  • nint_i (int) – The number of integration points to use for the intersection elements.

  • ncoef_b (int) – The number of coefficients to use for the bounding elements.

  • nint_b (int) – The number of integration points to use for the bounding elements.

  • frac_surface (Fracture) – The fracture to use as the surface fracture.

  • se_factor (float, optional) – The factor to use for shortening fo the elements. Default is 1.0 (no shortening).

Returns:

frac_list – The list of fractures.

Return type:

list

andfn.dfn.get_lvs(lvs, omega_fn_list)[source]#

Gets the levels for the flow net.

Parameters:
  • lvs (int) – The number of levels for the equipotentials.

  • omega_fn_list (list | np.ndarray) – The list of complex discharge values.

Returns:

  • lvs_re (np.ndarray) – The levels for the equipotentials.

  • lvs_im (np.ndarray) – The levels for the streamlines.

andfn.dfn.plot_line_3d(seg, f, pl, color, line_width)[source]#

Plots a line in 3D for a given fracture plane.

Parameters:
  • seg (np.ndarray) – The line to plot.

  • f (Fracture) – The fracture plane.

  • pl (pyvista.Plotter) – The plotter object.

  • color (str | tuple) – The color of the line.

  • line_width (float) – The line width of the line.

Constants#

Notes

This module contains the constants used in the AnDFN model as a class.

class andfn.constants.Constants[source]#

Bases: object

__init__()[source]#

Initialize the constants

change_constants(**kwargs)[source]#

Function that changes the constants of the model. This function can either be called with keyword arguments or by loading a YAML configuration file named .andfn_config.yaml in the current directory.

The following constants can be changed:
  • RHO: Density of water in kg/m^3

  • G: Gravitational acceleration in m/s^2

  • PI: Pi

  • SE_FACTOR: Shortening element length factor

  • MAX_ITERATIONS: Maximum number of iterations

  • MAX_ERROR: Maximum error

  • MAX_COEF: Maximum number of coefficients

  • COEF_INCREASE: Coefficient increase factor

  • COEF_RATIO: Coefficient ratio

  • MAX_ELEMENTS: Maximum number of elements

  • NCOEF: Number of coefficients

  • NINT: Number of integration points

  • NUM_THREADS: Number of threads to use for Numba (default -1 = use all available threads)

Parameters:

**kwargs (dict) – The constants to change. The keys should be the names of the constants and the values should be the new values.

configure_constants()[source]#
print_constants()[source]#

Print the constants

print_solver_constants()[source]#

Print the solver constants

andfn.constants.load_yaml_config()[source]#

Load the constants from a YAML configuration file.