Skip to main content

Generates doubly-periodic 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 multi-Gaussian with user-selectable semi-variograms 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. Inter-cell 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 steady-state 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 an nr by nc rectangular structured grid whose cells have dimension dr by dc. Internally, the code works with coordinate axes r ("row") and c ("column"). r is the 0-based row index for interacting with external codes, increasing r corresponds to increasing y. c is the 0-based 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 the DomainData grid dd, with user-defined structural parameters. model_ref represents the reference number of chosen covariance model (1 indicates exponential covariance and 2 indicates Gaussian covariance). var is the log-variance of the field, and corr_len is its correlation length (in the direction of the principal axis of anisotropy). Geometric anisotropy is defined by f_lambda, the ratio of major axis correlation length to minor axis correlation length, and azimuth, the angle of the major axis of anisotropy above the c-axis (i.e., x-axis).

Functions:

  • solve_q(K, angle=0) returns a tuple (qr, qc), each component of which is a Numpy array of the same shape as the RandomKField K. Element (i,j) of array qr represents the positive-directed outward-bound flux in the r-direction originating in cell (i,j) of field K. 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) of qr represents the flux from grid cell (R,j) to (0,j) of the domain. qc is similarly defined, but contains the positive-directed outward-bound flux in the c-direction for each domain grid cell. qr and qc are normalized so that the mean Darcy flux has unit norm. angle represents the mean flow angle (in radians) above the c-axis (i.e., x-axis).

  • plot_lognormal_field(K) generates a colormap plot of the base-10 logarithm of RandomKField object K.

  • plot_quiver(K, qr, qc) generates a quiver plot of interpolated cell-centre Darcy fluxes contained in the Numpy arrays qr and qc (discussed above). the RandomKField object K must be passed as a way of indirectly accessing the DomainData 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 user-selectable semi-variograms and anisotropy structures and solve the steady-state 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, log-normal conductivity field locally Gaussian semi-variogram
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 (x-axis) direction          
q_r, q_c = solve_q(saved_K, angle=0)
plot_quiver(saved_K, q_r, q_c) 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

periodicgw-1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

periodicgw-1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file periodicgw-1.1.tar.gz.

File metadata

  • Download URL: periodicgw-1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for periodicgw-1.1.tar.gz
Algorithm Hash digest
SHA256 0c83bf0d2c5a7b082ad543d4225f89f97e00b1a717b2b2247f04345f5ea57be7
MD5 545eb13d5d76d566a9e80e3c826f2428
BLAKE2b-256 95c70119dab681c53bcab97edb4432f2d0994df7aabe854401a1459951a39f84

See more details on using hashes here.

File details

Details for the file periodicgw-1.1-py3-none-any.whl.

File metadata

  • Download URL: periodicgw-1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for periodicgw-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 74a35fe2494f5f893a6411025d7064d92eb4bc604920be92bfe9ddb524a1f49c
MD5 715b3d56ccf4e6f9cc9b006e28824de3
BLAKE2b-256 feda7da93acfdb9284fc4cd91b6317a1c0e01b9e259f1c128cf7860415ac2ac0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page