pydfnworks: dfnGen
DFN Class functions used in network generation and meshing
dfnGen
Adding Fracture Families
- add_fracture_family(self, shape, distribution, orientation_distribution='fisher', kappa=None, kappa1=None, kappa2=None, family_number=None, probability=None, p32=None, layer=0, region=0, number_of_points=8, aspect=1, beta_distribution=0, beta=0, theta=None, phi=None, strike=None, dip=None, trend=None, plunge=None, alpha=None, log_mean=None, log_std=None, exp_mean=None, constant=None, min_radius=None, max_radius=None, hy_variable=None, hy_function=None, hy_params=None)[source]
Generates a fracture family
- Parameters:
self (DFN object)
shape ('rect' or 'ell' deines the fracture family shape)
distribution ('tpl', 'log_normal', 'exp', or 'constant' defines the sample distribution for the fracture radius)
orientation_distribution ('fisher' (default) or 'bingham'. Distribution used to sample fracture normals around the mean orientation)
kappa (concentration param of the von Mises-Fisher distribution. use if orientation_distribution = 'fisher')
kappa1 (first concentration param of the Bingham distribution. use if orientation_distribution = 'bingham'. default = None)
kappa2 (second concentration param of the Bingham distribution. use if orientation_distribution = 'bingham'. default = None)
family_number (fracutre family id. default = None)
probability (probabily of a fracture belonging to this family. default = None. use if stopCondition = 0)
p32 (fracture intensity for the family. default = None. use if stopCondition = 1. The value is interpreted using DFN.params['p32_convention'] (0: double-sided / wetted surface area, P32 = 2A/V, default. 1: single-sided, P32 = A/V))
layer (assigns fracture family to a layer in the domain. default = 0)
region (assigns fracture family to a region in the domain. default = 0)
number_of_points (specifies the number of vertices defining th eboundary of each fracture. default = 8)
aspect (the aspect ratio of the fractures. default = 1)
beta_distribution (0 (uniform distribtuion [0,2pi) or 1 (constant rotation specfied by ebeta) rotation of each fractures normal vector. default 0)
beta (angle fo constant rotation. use if beta_distribution = 1. default = 0)
theta (use if orientationOption = 0 (default). default = None)
phi (use if orientationOption = 0 (default). default = None)
strike (use if orientationOption = 2. default = None)
dip (use if orientationOption = 2. default = None)
trend (use if orientationOption = 1. default = None)
plunge (use if orientationOption = 1. default = None)
alpha (parameter for 'tpl'. default = None)
log_mean (parameter for 'log_normal'. Mean of ln(radius), i.e., of the underlying normal distribution (not the mean radius). default = None)
log_std (parameter for 'log_normal'. Standard deviation of ln(radius) (not a variance). The mean radius before truncation is exp(log_mean + log_std^2/2). default = None)
exp_mean (parameter for 'exp'. default = None)
constant (parameter for 'constant'. default = None)
min_radius (minimum fracture radius for 'tpl' 'log_normal' or 'exp'. default = None)
max_radius (maximum fracture radius for 'tpl' 'log_normal' or 'exp'. default = None)
hy_variable (hydraulic variable to assign values to. options are 'aperture', 'permeability', 'transmissivity',)
hy_function (relationship between hydraulic variable and fracture radius. options are 'correlated', 'semi-correlated', 'constant', 'log-normal', 'exponential')
hy_params (parameters for the hydraulic function. see next lines for syntax and options) – if ‘correlated’ –> {“alpha”:value, “beta”:value} if ‘semi-correlated’ –> {“alpha”:value, “beta”:value, “sigma”:value} (alpha*r^beta = median, sigma = variance of ln(value)) if ‘constant’ –> {“mu”:value} if ‘log-normal’ –> {“mu”:value, “sigma”:value} (mu = median in physical units, sigma = variance of ln(value)) if ‘exponential’ –> {“lam”:value}
- Return type:
Populated fracture family dictionary for specified family
Notes
See https://dfnworks.lanl.gov/dfngen.html#domain-parameters for more information about parameters
Example:
DFN.add_fracture_family(shape="ell",
distribution="tpl",
alpha=1.8,
min_radius=1.0,
max_radius=5.0,
kappa=1.0,
theta=0.0,
phi=0.0,
aspect=2,
beta_distribution=1,
beta=45.0,
p32=1.1,
hy_variable='aperture',
hy_function='correlated',
hy_params={
"alpha": 10**-5,
"beta": 0.5
})
Adding User Fractures
- add_user_fract(self, shape, radii, translation, filename=None, aspect_ratio=1, beta=0, angle_option='degree', orientation_option='normal', normal_vector=None, trend_plunge=None, dip_strike=None, number_of_vertices=None, permeability=None, transmissivity=None, aperture=None)[source]
Specifies user defined fracture parameters for the DFN.
- Parameters:
self (DFN object)
shape (string) – The desired shape of the fracture options are ‘rect’, ‘ell’, and ‘poly’ - Required
radii (float) – 1/2 size of the fracture in meters - Required
translation (list of floats [3]) – Fracture center
filename (string) – The name of the user defined fracture file. Default is user_defined_{shape}.dat
aspect_ratio (float) – Fracture aspect ratio
beta (float) – Rotation angle around center of the fracture
angle_option (string) – Angle option ‘degree’ or ‘radian’. Default is degree
orientation_option (string) – Choice of fracture orienation ‘normal’, ‘trend_plunge’, ‘dip_strike’
normal_vector (list [3]) – normal vector of the fracture
trend_plunge (list [2]) – trend and plunge of the fracture
dip_strike (list [2]) – dip and strike of the fracture
number_of_vertices (int) – Number of vertices on the fracture boundary.
permeability (float) – Permeability of the fracture
transmissivity (float) – Fracture Tramsmissivity
aperture (float) – Hydraulic aperture of the fracture
- Return type:
None - fracture dictionaries are attached to the DFN object
Notes
Please be aware, the user fracture files can only be automatically written for ellipses and rectangles not specified by coordinate.
See
https://dfnworks.lanl.gov/dfngen.html#user-defined-fracture-generation-parameters
for additional information
Example:
DFN.add_user_fract(shape='ell',
radii=.4,
aspect_ratio=1,
translation=[0.2, 0, 0.2],
normal_vector=[0, 0, 1],
number_of_vertices=8,
aperture=1.0e-5)
Adding User Fractures From a File
- add_user_fract_from_file(self, filename, shape, nPolygons, by_coord=False, aperture=None, transmissivity=None, permeability=None)[source]
Sets up paths for fractures defined in user input file. When inserting user fractures from file, hydraulic properties must be provided as a list of length nPolygons (number of fractures defined in the file)
- Parameters:
self (DFN object)
filename (string) – path to source file
shape (string) – The shape of the fracture options are ‘rect’, ‘ell’, and ‘poly’ - Required
by_coord (boolean) – True / False of file format for coordinate or general input
nPolygons (int) – The number of polygons specified in the file
permeability (list or array) – Permeabilities of the fractures
transmissivity (list or array) – Fracture Tramsmissivities
aperture (list or array) – Hydraulic apertures of the fracture
- Return type:
None
Notes
Does not write the file, only sets up paths
~/src/dfnworks-aidan/pydfnworks/pydfnworks/
Example:
DFN.add_user_fract_from_file(shape="poly",
filename = f'{src_path}/polygons.dat',
permeability = 1e-12)
Print Parameter Information
Note: Some of these functions are automatically called when processing the input.
- print_user_fracture_information(self, shape, frac_number=None)[source]
Prints information about a user defined fracture to screen
- Parameters:
self (DFN object)
shape (string) – The shape of the fracture options are ‘rect’, ‘ell’, and ‘poly’ - Required
fracture_number (int) – Index of fracture. If none (default), then information about all user fractures of input shape are printed to screen
- Return type:
None
Notes
None
- print_domain_parameters(self, print_all=False)[source]
Prints domain parameters to screen :param self: :type self: DFN Class Object :param print_all: If True, all parameters will be printed to screen, even those without a value. If False (default), only those with a value will be printed to screen. :type print_all: bool
- Return type:
None
Processing Generator Input
- check_input(self, from_file=False)[source]
Checks input file for DFNGen to make sure all necessary parameters are defined. Then writes out a “clean” version of the input file
- Input Format Requirements:
Each parameter must be defined on its own line (separate by newline)
A parameter (key) MUST be separated from its value by a colon ‘:’ (ie. –> key: value)
Values may also be placed on lines after the ‘key’
Comment Format: On a line containing // or /
*, nothing after*/ or // will be processed but text before a comment will be processed
- Parameters:
self (DFN Class Object)
from_file (Bool, default False. Checking for file. (See Note))
- Return type:
None
Notes
There are warnings and errors raised in this function. Warning will let you continue while errors will stop the run. Continue past warnings are your own risk.
From File feature is no longer maintained. Functions should be removed in the near future.
Running the Generator
- dfn_gen(self, output=True)[source]
- Wrapper script the runs the dfnGen workflow:
make_working_directory: Create a directory with name of job
check_input: Check input parameters and create a clean version of the input file
create_network: Create network. DFNGEN v2.0 is called and creates the network
output_report: Generate a PDF summary of the DFN generation
mesh_network: calls module dfnGen_meshing and runs LaGriT to mesh the DFN
- Parameters:
self – DFN object
output (bool) – If True, output pdf will be created. If False, no pdf is made
- Return type:
None
Notes
Details of each portion of the routine are in those sections
- make_working_directory(self, delete=False)[source]
Make working directory for dfnWorks Simulation
- Parameters:
self – DFN object
delete (bool) – If True, deletes the existing working directory. Default = False
- Return type:
None
Notes
If directory already exists, user is prompted if they want to overwrite and proceed. If not, program exits.
Processing Generator Output
After the generator runs, dfn_gen reads its output into the DFN object (fracture centers, radii, normals, polygons, families, and hydraulic properties). These functions are called automatically but can also be used to reload a network.
- parse_params_file(self, quiet=False)[source]
Reads params.txt file from DFNGen and parses information
- Parameters:
self – DFN object
quiet (bool) – If True details are not printed to screen, if False they area
- Return type:
None
Notes
None
- gather_dfn_gen_output(self)[source]
Reads in information about fractures and add them to the DFN object. Information is taken from radii.dat, translations.dat, normal_vectors.dat, and surface_area_Final.dat files. Information for each fracture is stored in a dictionary created by create_fracture_dictionary() that includes the fracture id, radius, normal vector, center, family number, surface area, and if the fracture was removed due to being isolated
- Parameters:
None
- Returns:
fractures – List of fracture dictionaries with information.
- Return type:
list
Notes
Both fractures in the final network and those removed due to being isolated are included in the list.
- assign_hydraulic_properties(self)[source]
Assigns hydraulic properties for each familiy and user defined fractures
- Parameters:
self (DFN object)
- Return type:
None
Notes
None
- grab_polygon_data(self)[source]
If flag self.store_polygon_data is set to True, the information stored in polygon.dat is written to a dictionary self.polygons. To access the points that define an individual polygon, call self.polygons[f’poly{i}’] where i is a number between 1 and the number of defined polygons. This returns an array of coordinates in the format np.array([x1,y1,z1],[x2,y2,z2],…[xn,yn,zn])
- Parameters:
self (DFN object)
- Return type:
None
Notes
None
Analysis of Generated DFN
- filename:
gen_output.py
- synopsis:
Main driver for dfnGen output report
- version:
1.0
- maintainer:
Jeffrey Hyman
- moduleauthor:
Jeffrey Hyman <jhyman@lanl.gov>
- output_report(self, verbose=True, output_dir='dfnGen_output_report')[source]
Creates a PDF output report for the network created by DFNGen. Plots of the fracture lengths, locations, orientations are produced for each family. Files are written into “output_dir/family_{id}/”. Information about the whole network are also created and written into “output_dir/network/”
- Parameters:
self (object) – DFN Class object
verbose (bool) – Toggle for the amount of information printed to screen. If true, progress information printed to screen
output_dir (string) – Name of directory where all plots are saved
- Return type:
None
Notes
Final output report is named “jobname”_output_report.pdf User defined fractures (ellipses, rectangles, and polygons) are not supported at this time.
The report includes, for each family, stereonets of the fracture normals and equal-area rose diagrams of strike and dip.
Fracture Orientations
The strike, dip, dip direction, trend, and plunge of every fracture normal are computed from DFN.normal_vectors when the network is loaded and stored as DFN.strike, DFN.dip, DFN.dip_direction, DFN.trend, and DFN.plunge (in degrees).
All functions use a right-handed ENU coordinate system (x = East, y = North, z = Up), and report the lower-hemisphere representation, which is the standard convention for stereonet plotting.
- get_fracture_orientations(self)[source]
Compute the orientation of every fracture in the network and attach the results to the DFN object.
- Parameters:
self (object) – DFN Class
- Return type:
None
Notes
Sets the following attributes, each a numpy array with one entry per fracture, ordered to match self.normal_vectors:
self.strike : strike azimuth of the fracture plane [degrees, 0 - 360]
self.dip : dip of the fracture plane below horizontal [degrees, 0 - 90]
self.dip_direction : azimuth of the down-dip line [degrees, 0 - 360]
self.trend : trend of the pole (normal) [degrees, 0 - 360]
self.plunge : plunge of the pole (normal) [degrees, 0 - 90]
Uses the lower-hemisphere convention, so plunge = 90 - dip. The fracture normals are not modified.
Fracture Intensity (P21)
- compute_fracture_p21(self)[source]
Compute P21 per fracture: P21[i] = (sum of intersection lengths involving fracture i+1) / surface_area[i] Assumes fracture IDs are 1..self.num_frac.
Example:
DFN.compute_fracture_p21()
print(DFN.p21_table)
Additional Information on the Modification of Hydraulic Properties of the DFN
Hydraulic properties can be assigned to fractures based on five different models. One can assign hydraulic aperture
, permeability,
, or transmissivity
. Below we present the functions for hydraulic aperture, but the equations for other values are the same.
The first is a perfectly correlated model where the hydraulic property is a function of the fracture radius

The keyword for this model is correlated.
The second is a semi-correlated correlated model where the hydraulic property is a function of the fracture radius

where a stochastic term is included into the correlated model
to account for uncertainty and variability between fractures of the same size. The stochastic term is an independent identically distributed random variable sampled from a normal distribution with mean 0 and variance 1,
, and its strength is set by
, the variance of
(the log-variance). Note that the standard deviation of
is
. This model results in a log-normal distribution of fracture apertures around the power law
, which is the median, not the mean, for a fracture of radius
. We refer to this model as semicorrelated.
The keyword for this model is semi-correlated and the parameter dictionary is {"alpha": value, "beta": value, "sigma": value}.
The third model assumes that there is no correlation between the fracture size and transmissivity and all values are independent identically distributed random variables from a log-normal distribution,

where
is the median value (given in physical units, e.g., meters for aperture, not as a logarithm) and
is the variance of
. That is,
. The arithmetic mean and coefficient of variation (standard deviation divided by mean) of
are

To obtain a target mean
and coefficient of variation CV, set
and
.
The keyword for this model is log-normal and the parameter dictionary is {"mu": value, "sigma": value}.
The fourth model represents an assumption that in addition to no relationship between size and hydraulic properties, there is no variation between fractures

The keyword for this model is constant.
The fifth model draws values that are independent of fracture size from an exponential distribution with rate parameter
,

so the mean value is
. The keyword for this model is exponential and the parameter dictionary is {"lam": value}.
Notes:
See Hyman et al. 2016 “Fracture size and transmissivity correlations: Implications for transport simulations in sparse three-dimensional discrete fracture networks following a truncated power law distribution of fracture size” Water Resources Research for more details
Changes in hydraulic properties are assigned when defining a fracture family or user defined fracture. User defined fractures currently only support constant hydraulic properties.
Hydraulic properties can also be regenerated or overwritten after the network is created. generate_hydraulic_values draws new values for the whole network or for one family, set_fracture_hydraulic_values sets values on a list of fractures, and the dump_* functions write the current values to file.
DFN class methods for hydraulic property generation and assignment.
- set_fracture_hydraulic_values(self, variable, fracture_list, value_list)[source]
Assigns hydraulic properties to a list of provided fractures.
- Parameters:
self (object) – DFN Class
variable (string) – base variable in relationship. Options are: aperture, permeability, transmissivity
fracture_list (list) – List of fracture indices whose variables are being assigned. Note Fractures are indexed starting at 1.
value_list (list) – values to be assigned.
- Return type:
None
- generate_hydraulic_values(self, variable, relationship, params, family_id=None)[source]
Generates hydraulic property values.
- Parameters:
self (object) – DFN Class
variable (string) – base variable in relationship. Options are: aperture, permeability, transmissivity
relationship (string) – name of functional relationship for apertures. options are log-normal, correlated, semi-correlated, constant, and exponential
params (dictionary) –
- dictionary of parameters for functional relationship
if correlated –> {“alpha”:value, “beta”:value} if semi-correlated –> {“alpha”:value, “beta”:value, “sigma”:value} (alpha*r^beta = median, sigma = variance of ln(value)) if constant –> {“mu”:value} if log-normal –> {“mu”:value, “sigma”:value} (mu = median in physical units, sigma = variance of ln(value)) if exponential –> {“lam”:value}
family_id (int) – family id of fractures
- Return type:
None
Notes
See Hyman et al. 2016 “Fracture size and transmissivity correlations: Implications for transport simulations in sparse three-dimensional discrete fracture networks following a truncated power law distribution of fracture size” Water Resources Research for more details.
Changes in hydraulic properties are added to DFN object.
File I/O functions for hydraulic property data.
- dump_aperture(self, filename, format=None)[source]
Write aperture values to file.
- Parameters:
self (DFN object)
filename (string) – name of file
format (string) – format type with options None, fehm, FEHM. Default is None
- dump_perm(self, filename, format=None)[source]
Write permeability values to file.
- Parameters:
self (DFN object)
filename (string) – name of file
format (string) – format type with options None, fehm, FEHM. Default is None
- dump_transmissivity(self, filename, format=None)[source]
Write transmissivity values to file.
- Parameters:
self (DFN object)
filename (string) – name of file
format (string) – format type with options None, fehm, FEHM. Default is None
- dump_fracture_info(self, filename)[source]
Write fracture info (connections, perm, aperture) to file.
- Parameters:
self (DFN object)
filename (string) – name of file
- dump_hydraulic_values(self, prefix=None, format=None)[source]
Writes all hydraulic property values to files.
- Parameters:
self (DFN object)
prefix (string) – prefix of aperture.dat and perm.dat file names prefix_aperture.dat and prefix_perm.dat
format (string) – format type. Default is None
Example:
# draw new log-normal apertures for family 1, then write all values to file
DFN.generate_hydraulic_values(variable="aperture",
relationship="log-normal",
params={"mu": 1e-4, "sigma": 0.5},
family_id=1)
DFN.dump_hydraulic_values()
Modification of hydraulic properties of the DFN based on background stress field
- stress_based_apertures(self, sigma_mat, friction_angle=25.0, dilation_angle=5, critical_shear_displacement=0.003, shear_modulus=10000000000.0, min_b=1e-10, shear_stiffness=400000000000.0)[source]
Takes stress tensor as input (defined in dfn run file) and calculates new apertures based on Bandis equations. New aperture and permeability values are written to files.
- Parameters:
self (object) – DFN Class
sigma_mat (array) – 3 x 3 stress tensor (units in Pa)
friction_angle (float) – Friction angle (Degrees)
dilation_angle (float) – Dilation angle (Degrees)
critical_shear_displacement (float) – Critical shear displacement
shear_modulus (float) – Shear modulus (Pa)
min_b (float) – Minimum aperture (m)
shear_stiffness (float) – Shear stiffness (Pa/m)
- Return type:
None
Notes
For details of implementation see
“Sweeney, Matthew Ryan, and J. D. Hyman. “Stress effects on flow and transport in three‐dimensional fracture networks.” Journal of Geophysical Research: Solid Earth 125.8 (2020): e2020JB019754.”
and
Baghbanan, Alireza, and Lanru Jing. “Stress effects on permeability in a fractured rock mass with correlated fracture length and aperture.” International journal of rock mechanics and mining sciences 45.8 (2008): 1320-1334.
and
Zhao, Zhihong, et al. “Impact of stress on solute transport in a fracture network: A comparison study.” Journal of Rock Mechanics and Geotechnical Engineering 5.2 (2013): 110-123.
Meshing - LaGriT
Primary DFN meshing driver
- mesh_network(self, uniform_mesh=False, min_dist=0.5, max_dist=10, max_resolution_factor=10, well=False, cleanup=True, strict=True, quiet=True)[source]
Mesh fracture network using LaGriT
- Parameters:
self (object) – DFN Class
uniform_mesh (bool) – toggle for uniform or variable mesh. Default : False
min_dist (float) – Defines the minimum distance from the intersections with resolution h/2. This value is the factor of h, distance = min_dist * h
max_dist (float) – Defines the minimum distance from the intersections with resolution max_resolution * h. This value is the factor of h, distance = max_dist * h
max_resolution_factor (float) – Maximum factor of the mesh resolution (max_resolution_factor * h). Depending on the slope of the linear function and size of the fracture, this may not be realized in the mesh.
well (bool) – Toggle well points. Default : False
cleanup (bool) – toggle to clean up directory (remove meshing files after a run). Default : True
strict (bool) – Toggle if a few mesh errors are acceptable. default is true
quiet (bool) – Toggle to turn on/off verbose information to screen about meshing. Default is true, does not print to screen
- Return type:
None
Notes
All fractures in self.prune_file must intersect at least 1 other fracture
Meshing helper methods
- create_mesh_links(self, path)[source]
Makes symlinks for files in path required for meshing
- Parameters:
self (DFN object)
path (string) – Path to where meshing files are located
- Return type:
None
Notes
None
- inp2gmv(self, inp_file=None)[source]
Convert inp file to gmv file, for general mesh viewer. Name of output file for base.inp is base.gmv
- Parameters:
self (object) – DFN Class
inp_file (str) – Name of inp file if not an attribure of self
- Return type:
None
Notes
- inp2vtu(self, inp_file='', binary=True)[source]
Convert an AVS/UCD (.inp) mesh to an XML VTK unstructured-grid (.vtu) file.
- Parameters:
self (object) – DFN Class
inp_file (string) – Mesh to convert. Default is
self.inp_file(full_mesh.inp).binary (bool) – If True (default), data arrays are base64-encoded binary. If False, they are written as ASCII.
- Return type:
None
Notes
For a mesh
base.inpthis writesbase.vtu(orself.vtu_fileif it is set) and setsself.vtu_file. All AVS cell types (line, tri, quad, tet, hex, prism, pyramid) are kept, and the material ID of each cell is written as the cell arraymaterial_id.
- run_lagrit_script(lagrit_file, output_file=None, quiet=False)[source]
Runs LaGriT
- Parameters:
lagrit_file (string) – Name of LaGriT script to run
output_file (string) – Name of file to dump LaGriT output
quiet (bool) – If false, information will be printed to screen.
- Returns:
failure – If the run was successful, then 0 is returned.
- Return type:
int
Notes
- add_variable_to_mesh(self, variable, variable_file, mesh_file_in, mesh_file_out=None, node_based=False)[source]
Adds a variable to the nodes of a mesh. Can be either fracture (material) based or node based.
- Parameters:
self (object) – DFN Class
variable (string) – name of variable
variable_file (string) – name of file containing variable files. Must be a single column where each line corresponds to that node number in the mesh
mesh_file_in (string) – Name of source mesh file
mesh_file_out (string) – Name of Target mesh file. If no name if provide, mesh_file_in will be used
node_based (bool) – Set to True if variable_file contains node-based values, Set to False if variable_file provide fracture based values
- Returns:
lagrit_file – Name of LaGriT output file
- Return type:
string
UDFM
Creating an upscaled mesh of the DFN (UDFM)
- map_to_continuum(self, l, orl, path='./', dir_name='octree')[source]
This function generates an octree-refined continuum mesh using the reduced_mesh.inp as input. To generate the reduced_mesh.inp, one must turn visualization mode on in the DFN input card.
- Parameters:
self (object) – DFN Class
l (float) – Size (m) of level-0 mesh element in the continuum mesh
orl (int) – Number of total refinement levels in the octree
path (string) – path to primary DFN directory
dir_name (string) – name of directory where the octree mesh is created
- Return type:
None
Notes
- octree_dfn.inpMesh file
Octree-refined continuum mesh
- fracX.inpMesh files
Octree-refined continuum meshes, which contain intersection areas
- upscale(self, mat_perm, mat_por, tag_mesh=True, path='../')[source]
Generate permeabilities and porosities based on output of map2continuum.
- Parameters:
self (object) – DFN Class
mat_perm (float) – Matrix permeability (in m^2)
mat_por (float) – Matrix porosity
- Returns:
perm_fehm.dat (text file) – Contains permeability data for FEHM input
rock_fehm.dat (text file) – Contains rock properties data for FEHM input
mesh_permeability.h5 (h5 file) – Contains permeabilites at each node for PFLOTRAN input
mesh_porosity.h5 (h5 file) – Contains porosities at each node for PFLOTRAN input
Notes
None
upscale writes an anisotropic permeability field. mesh_permeability.h5 contains PermeabilityX, PermeabilityY, and PermeabilityZ datasets (for PFLOTRAN, use PERMEABILITY ANISOTROPIC in the material property card), and perm_fehm.dat contains directional
values for FEHM.
- check_false_connections(self, path='../')[source]
- Parameters:
self (object) – DFN Class
fmc_filname (string) – name of the pickled dictionary of mesh and fracture intersections
- Returns:
num_false_connections (int) – number of false connections
num_false_cells (int) – number of Voronoi cells with false connections
false_connections (list) – list of tuples of false connections created by upscaling
Notes
map2continuum and upscale must be run first to create the fracture/mesh intersection dictionary. Thus must be run in the main job directory which contains connectivity.dat
Map-DFN upscaling
mapdfn2pflotran.py
Call methods in mapdfn.py to take output of dfnWorks-Version2.0, create equivalent continuous porous medium representation, and write parameters (permeability, porosity, tortuosity) to files for use with PFLOTRAN.
- Usage: Edit values for origin, nx, ny, nz, d, k_background, bulk_por,
tortuosity factor, and h5origin. Paths and filenames are hardwired and may also need to be checked. As written, they assume script is being called from a subdirectory. Then: python mapdfn2pflotran.py
- Dependencies: mapdfn.py
numpy h5py
Author:
Date: 07/13/18 SAND Number: SAND2018-7605 O
- mapdfn_ecpm(self, matrix_perm, matrix_porosity, cell_size, matrix_on=False, tortuosity_factor=0.001, lump_diag_terms=False, correction_factor=True, output_dir='mapdfn_ecpm')[source]
This script takes the top-level directory of the dfn and maps it to an ecpm, saving the ecpm files in that directory
- Parameters:
self (dfnWorks object)
matrix_perm (float) – permeability of the matrix cells without fratures
cell_size (float) – The cell size (meters) to use for the meshing
matrix_on (bool) – Default is False
tortuosity_factor (float)
lump_diag_terms (bool) – Deault is False
correction_factor (boolean) – Apply stairstep correction from EDFM to not applied to permeability
output_dir (string) – output directory
- Return type:
None
mapdfn_ecpm calls the following steps, which can also be run individually.
mapdfn.py
Take output of dfnWorks-Version2.0: normal_vectors.dat, translations.dat, radii_Final.dat, perm.dat, aperture.dat and map dfn into a regular grid for continuous porous medium representation
Usage: Call the methods in this script with map.py
- Dependencies: transformations.py copyright Christoph Gohlke and UC Regents
numpy h5py time
- Authors: Emily Stein (ergiamb@sandia.gov)
Kris Kuhlman (klkuhl@sandia.gov) Applied Systems Analysis and Research, 8844 Sandia National Laboratories
Date: 07/13/18 SAND Number: SAND2018-7604 O
Modified by Teresa Portone (tporton@sandia.gov) Dec 1, 2021 to have porosity() take list of apertures instead of aperture filename. readApertures() method added.
Modified by Rosie Leone (rleone@sandia.gov) Dec 16, 2021 to have permAniso() apply a stair step correction factor to the ECPM when conditional set to True
Modified by Jeffrey Hyman
- mapdfn_tag_cells(self, origin, num_cells, nx, ny, nz, cell_size)[source]
Identify intersecting fractures for each cell of the ECPM domain. Extent of ECPM domain is determined by nx,ny,nz, and d (see below). ECPM domain can be smaller than the DFN domain. Return numpy array (fracture) that contains for each cell: number of intersecting fractures followed by each intersecting fracture id.
- Parameters:
self (dfnWorks object)
origin (list) – [x,y,z] float coordinates of lower left front corner of DFN domain
num_cells (int) – Number of cells in the domain
nx (int) – number of cells in x in ECPM domain
ny (int) – number of cells in y in ECPM domain
nz (int) – number of cells in z in ECPM domain
cell_size (float) – discretization length in ECPM domain
- Returns:
cell_fracture_id – Dictionary num_cells long. Keys: cell number, Entries: List of the fractures that intersect that cell
- Return type:
dict
Notes
None
- mapdfn_upscale(self, num_cells, cell_fracture_id, cell_size, matrix_porosity, matrix_perm, lump_diag_terms, correction_factor)[source]
- Parameters:
self (dfnWorks object)
num_cells (int) – Total number of cells in the domain
cell_fracture_id (dict) – Dictionary num_cells long. Keys: cell number, Entries: List of the fractures that intersect that cell
cell_size (float) – discretization length in ECPM domain
matrix_porosity (float) – perosity of the matrix
matrix_perm (float) – permeability of the matrix cells without fratures
lump_diag_terms (bool) – Default is False
correction_factor (bool) – Default is True
- Returns:
porosity (numpy array) – porosity values in the domain cells
k_iso (numpy array) – numpy array of isotropic permeability for each cell in the ECPM.
k_aniso (numpy array) – Return numpy array of anisotropic permeability (3 components) for each cell in the ECPM.
Notes
- mapdfn_effective_perm(self, inflow_pressure, outflow_pressure, mas_filename, direction)[source]
Reads <pflotran-file>-mas.dat file to get outflow mass flow rate from a pflotran run. Converts the values to volumetric flow rates in m^3/s, then inverts Darcy’s Law to get the effective permeability of the block
- Parameters:
self (object) – DFN Class
inflow_pressure (float) – Pressure at the inflow boundary face. Units are Pascal
outflow_pressure (float) – Pressure at the outflow boundary face. Units are Pascal
mas_filename (string) – name of -mas.dat filename.
direction (string) – Primary direction of flow, x, y, or z
- Returns:
keff – effective permeability of the block
- Return type:
float
Notes
Information is written to screen and to the file self.local_jobname_effective_perm.txt
Currently, only PFLOTRAN solutions are supported
Assumes density of water at 20c
MASS_BALANCE output option in PFLOTRAN must be turned on.
DFM
Creating a conforming DFM mesh DFN
- mesh_dfm(self, dirname='dfm_mesh', allowed_percentage=1, psets=False, cleanup=True)[source]
“ Creates a conforming mesh of a DFN using a uniform background tetrahedron mesh. The DFN must be meshed using a uniform triangular mesh. (DFN.mesh_network(uniform_mesh = True))
- Parameters:
self (DFN object)
dirname (string) – name of working directory. Default : dfm_mesh
allowed_percentage (float) – Percentage of the mesh allowed to be missing and still continue
psets (bool) – Default is False
cleanup (bool) – Clean up working directory. If true dep files are moved into subdirectories. Default is True
- Return type:
None
Notes
The final mesh is output in exodus format. This requires that LaGriT is built against exodus.