Generates doublyperiodic random 2D Darcy flow fields with arbitrary mean flow direction
Project description
periodicgw
This is a Python package for generating 2D periodic random groundwater flux fields with any user specified mean flow vector. Periodic random hydraulic conductivity fields are generated that are locally multiGaussian with userselectable semivariograms and anisotropy structures. Darcy flux fields are solved exactly using a finite volume approach on these conductivity fields with periodic boundary conditions and an enforced mean flow angle. Intercell fluxes are directly reported for compatibility with particle tracking algorithms based on the Pollock method.
Overview
This package generates random, periodic, locally Gaussian conductivity fields by use of the fast Fourier transform approach. It solves the steadystate groundwater flow equation on a random heterogeneous conductivity field, with periodic boundary conditions in both directions. Solution is finite volume, and formulated directly for the interfacial fluxes rather than for heads.
Two classes and three functions are exposed, whose usage details are illustrated below.
Classes:

DomainData(nr, nc, dr, dc)
constructs an object representing annr
bync
rectangular structured grid whose cells have dimensiondr
bydc
. Internally, the code works with coordinate axes r ("row") and c ("column"). r is the 0based row index for interacting with external codes, increasing r corresponds to increasing y. c is the 0based column index for interacting with external codes, increasing c corresponds to increasing x. 
RandomKField(dd, model_ref, var, corr_len, f_lambda, azimuth)
constructs an object representing a lognormal K field defined on theDomainData
griddd
, with userdefined structural parameters.model_ref
represents the reference number of chosen covariance model (1
indicates exponential covariance and2
indicates Gaussian covariance).var
is the logvariance of the field, andcorr_len
is its correlation length (in the direction of the principal axis of anisotropy). Geometric anisotropy is defined byf_lambda
, the ratio of major axis correlation length to minor axis correlation length, andazimuth
, the angle of the major axis of anisotropy above the caxis (i.e., xaxis).
Functions:

solve_q(K, angle=0)
returns a tuple(qr, qc)
, each component of which is a Numpy array of the same shape as theRandomKField
K
. Element (i,j) of arrayqr
represents the positivedirected outwardbound flux in the rdirection originating in cell (i,j) of fieldK
. This is to say the flux from domain grid cell (i,j) to (i+1,j), assuming both cells are in the interior of the domain. Fluxes wrap around due to periodicity, so that if R is the largest row index, element (R,j) ofqr
represents the flux from grid cell (R,j) to (0,j) of the domain.qc
is similarly defined, but contains the positivedirected outwardbound flux in the cdirection for each domain grid cell.qr
andqc
are normalized so that the mean Darcy flux has unit norm.angle
represents the mean flow angle (in radians) above the caxis (i.e., xaxis). 
plot_lognormal_field(K)
generates a colormap plot of the base10 logarithm ofRandomKField
objectK
. 
plot_quiver(K, qr, qc)
generates a quiver plot of interpolated cellcentre Darcy fluxes contained in the Numpy arraysqr
andqc
(discussed above). theRandomKField
objectK
must be passed as a way of indirectly accessing theDomainData
grid dimension parameters.
Usage
The package is imported into your Python namespace by the command: import periodicgw
The example code below demonstrates how to generate a random, periodic, locally Gaussian conductivity field with userselectable semivariograms and anisotropy structures and solve the steadystate groundwater flow equation on a previously saved conductivity field. Note that the defined correlation length in both the major and minor direction should be larger than the grid cell size.
from numpy import pi
from pickle import dump, load
from periodicgw import DomainData, RandomKField, solve_q, plot_lognormal_field, plot_quiver
# Generate a random, periodic, lognormal conductivity field locally Gaussian semivariogram
dd = DomainData(nr=50, nc=100, dr=2, dc=2)
K = RandomKField(dd, model_ref=2, var=.5, corr_len=dd.num_cols*dd.dc/20, f_lambda=.5, azimuth=0*pi/2)
plot_lognormal_field(K)
with open('k_field_test.pickle',"wb") as dump_file:
dump(K, dump_file)
# Read the previously saved conductivity field with exponential covariance
with open("k_field_test.pickle", "rb") as read_file:
saved_K = load(read_file)
# Compute the periodic Darcy flow field resulting from enforcing mean flow in the +c (xaxis) direction
q_r, q_c = solve_q(saved_K, angle=0)
plot_quiver(saved_K, q_r, q_c)
Project details
Release history Release notifications  RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.