pydfnworks: dfnGraph

DFN Class functions used in graph analysis and pipe-network simulations

General Graph Functions

add_fracture_source(self, G, source)[source]
Parameters
  • G (NetworkX Graph) – NetworkX Graph based on a DFN

  • source_list (list) – list of integers corresponding to fracture numbers

  • remove_old_source (bool) – remove old source from the graph

Returns

G

Return type

NetworkX Graph

Notes

bipartite graph not supported

add_fracture_target(self, G, target)[source]
Parameters
  • G (NetworkX Graph) – NetworkX Graph based on a DFN

  • target (list) – list of integers corresponding to fracture numbers

Returns

G

Return type

NetworkX Graph

Notes

bipartite graph not supported

create_graph(self, graph_type, inflow, outflow)[source]

Header function to create a graph based on a DFN. Particular algorithms are in files.

Parameters
  • self (object) – DFN Class object

  • graph_type (string) – Option for what graph representation of the DFN is requested. Currently supported are fracture, intersection, and bipartitie

  • inflow (string) – Name of inflow boundary (connect to source)

  • outflow (string) – Name of outflow boundary (connect to target)

Returns

G – Graph based on DFN

Return type

NetworkX Graph

Notes

dump_fractures(self, G, filename)[source]

Write fracture numbers assocaited with the graph G out into an ASCII file inputs

Parameters
  • self (object) – DFN Class

  • G (NetworkX graph) – NetworkX Graph based on the DFN

  • filename (string) – Output filename

Notes

dump_json_graph(self, G, name)[source]

Write graph out in json format

Parameters
  • self (object) – DFN Class

  • G (networkX graph) – NetworkX Graph based on the DFN

  • name (string) – Name of output file (no .json)

Notes

load_json_graph(self, name)[source]

Read in graph from json format

Parameters
  • self (object) – DFN Class

  • name (string) – Name of input file (no .json)

Returns

G – NetworkX Graph based on the DFN

Return type

networkX graph

plot_graph(self, G, source='s', target='t', output_name='dfn_graph')[source]

Create a png of a graph with source nodes colored blue, target red, and all over nodes black

Parameters
  • G (NetworkX graph) – NetworkX Graph based on the DFN

  • source (node) – Starting node

  • target (node) – Ending node

  • output_name (string) – Name of output file (no .png)

Notes

Image is written to output_name.png

greedy_edge_disjoint(self, G, source='s', target='t', weight='None', k='')[source]

Greedy Algorithm to find edge disjoint subgraph from s to t. See Hyman et al. 2018 SIAM MMS

Parameters
  • self (object) – DFN Class Object

  • G (NetworkX graph) – NetworkX Graph based on the DFN

  • source (node) – Starting node

  • target (node) – Ending node

  • weight (string) – Edge weight used for finding the shortest path

  • k (int) – Number of edge disjoint paths requested

Returns

H – Subgraph of G made up of the k shortest of all edge-disjoint paths from source to target

Return type

NetworkX Graph

Notes

  1. Edge weights must be numerical and non-negative.

  2. See Hyman et al. 2018 “Identifying Backbones in Three-Dimensional Discrete Fracture Networks: A Bipartite Graph-Based Approach” SIAM Multiscale Modeling and Simulation for more details

k_shortest_paths_backbone(self, G, k, source='s', target='t', weight=None)[source]

Returns the subgraph made up of the k shortest paths in a graph

Parameters
  • G (NetworkX Graph) – NetworkX Graph based on a DFN

  • k (int) – Number of requested paths

  • source (node) – Starting node

  • target (node) – Ending node

  • weight (string) – Edge weight used for finding the shortest path

Returns

H – Subgraph of G made up of the k shortest paths

Return type

NetworkX Graph

Notes

See Hyman et al. 2017 “Predictions of first passage times in sparse discrete fracture networks using graph-based reductions” Physical Review E for more details

Graph-Based Flow and Transport

run_graph_flow(self, inflow, outflow, pressure_in, pressure_out, fluid_viscosity=0.00089, phi=1, G=None)[source]

Solve for pressure driven steady state flow on a graph representation of the DFN.

Parameters
  • self (object) – DFN Class

  • inflow (string) – name of file containing list of DFN fractures on inflow boundary

  • outflow (string) – name of file containing list of DFN fractures on outflow boundary

  • pressure_in (double) – Value of pressure at inlet [Pa]

  • pressure_out (double) – Value of pressure at outlet [Pa]

  • fluid_viscosity (double) – optional, default is for water. [Pa*s]

  • phi (double) – Fracture porosity, default is 1 [-]

  • G (Input Graph) –

Returns

Gtilde – Gtilde is a directed acyclic graph with vertex pressures, fluxes, velocities, volumetric flow rates, and travel times

Return type

NetworkX graph

run_graph_transport(self, G, nparticles, partime_file, frac_id_file=None, format='hdf5', initial_positions='uniform', dump_traj=False, tdrw_flag=False, matrix_porosity=None, matrix_diffusivity=None, fracture_spacing=None, control_planes=None, direction=None, cp_filename='control_planes')[source]

Run particle tracking on the given NetworkX graph

Parameters
  • self (object) – DFN Class

  • G (NetworkX graph) – obtained from graph_flow

  • nparticles (int) – number of particles

  • initial_positions (str) – distribution of initial conditions. options are uniform and flux (flux-weighted)

  • partime_file (string) – name of file to which the total travel times and lengths will be written for each particle

  • frac_id_file (string) – name of file to which detailed information of each particle’s travel will be written

  • dump_flag (bool) – on/off to write full trajectory information to file

  • tdrw_flag (Bool) – if False, matrix_porosity and matrix_diffusivity are ignored

  • matrix_porosity (float) – Matrix Porosity used in TDRW

  • matrix_diffusivity (float) – Matrix Diffusivity used in TDRW (SI units m^2/s)

  • fracture_spaceing (float) – finite block size for limited matrix diffusion

  • control_planes (list of floats) – list of control plane locations to dump travel times. Only in primary direction of flow.

  • direction (primary) – string indicating primary direction of flow

Returns

particles – list of particles objects

Return type

list

Notes

Information on individual functions is found therein