Skip to main content

Transport of contaminants in 1D groundwater flow system

Project description

Testing of source code Functional Testing Test Coverage Linting Build and release package
Testing of examples Testing of examples Coverage by examples
Package PyPI - Python Version PyPI - Version GitHub commits since latest release

Overview

gwtransport1d is a Python package for modeling the transport of temperature and contaminants in groundwater flow systems. It provides practical tools for analyzing advection, diffusion, deposition processes, and calculating residence time distributions in aquifer systems.

Aquifer Pore Volume Distribution

The aquifer pore volume distribution is a probability density curve that holds the fraction of flow that passes a certain pore volume between infiltration and extraction. This package relies on the estimating this distribution and uses it to compute many different transport processes related to residence time. In the examples here, the aquifer pore volume distribution is approximated by a Gamma distribution of which the two parameters are estimated from the flow rate, the temperature of the infiltration and extracted water. Alternatively, you can derive the aquifer pore volume distribution from the streamlines of your groundwater model. In all examples the assumption is made that the aquifer pore volume distribution is constant over time.

Calibration of the aquifer pore volume distribution (Example 1)

An practical approach to calibrate the two parameters of the Gamma distribution is to use the temperature response of the aquifer. This requires the following measurements over a limited time period:

  • Infiltration and extraction temperature,
  • Extraction rate or a quantity that is proportional to the extraction rate, such as the head gradient.

See: Example 1.

Examples that make use of the aquifer pore volume distribution

The aquifer pore volume distribution can be used to compute:

Installation

pip install gwtransport1d

Usage Examples

Example 1: Estimate Aquifer Pore Volume from Temperature Response

This example demonstrates how to use temperature data to estimate the aquifer pore volume distribution:

from scipy.optimize import curve_fit
from gwtransport1d import advection

# Load your temperature and flow data
# ...

# Define objective function for curve fitting
def objective(time, mean, std):
    cout = advection.gamma_forward(
        cin=temperature_data,
        flow=flow_data,
        mean=mean,
        std=std,
        n_bins=200,
        retardation_factor=2.0
    )
    return cout.values

# Perform curve fitting
(apv_gamma_mean, apv_gamma_std), pcov = curve_fit(
    objective,
    temperature_data.index,
    extracted_temperature_data,
    p0=(7000.0, 500.0),
)

# Print the fitted parameters
print(
  f"Fitted Gamma distribution for the aquifer pore volume has a mean of: {apv_gamma_mean:.1f} m³ and ",
  f"a standard deviation of: {apv_gamma_std:.1f} m³")

Example 2: Estimate Residence Time Distribution

Once you've characterized your aquifer, you can calculate residence time distributions:

import pandas as pd
from gwtransport1d import advection, gamma

# Set up your parameters
mean = 8000.0  # m3
std = 400.0  # m3
retardation_factor = 1.0
flow_data = pd.Series(...)  # Your flow data

# Calculate residence time
alpha, beta = gamma.mean_std_to_alpha_beta(mean, std)
bins = gamma.bins(alpha, beta, n_bins=1000)

# Calculate forward residence time (infiltration to extraction)
rt_forward = advection.residence_time(
    flow_data,
    bins["expected_value"],
    retardation_factor=1.0,
    direction="infiltration"
)

Example 3: Log Removal of Pathogens

Calculate the log removal of pathogens based on residence time:

import numpy as np
from gwtransport1d import logremoval

# Calculate log-removal of the extracted water
rt_alpha = 2.0  # Shape parameter of the gamma distribution for the residence time
rt_beta = 10.0  # Scale parameter of the gamma distribution for the residence time
log_removal_rate = 0.5  # Log-removal rate [1/day]
mean_removal = logremoval.gamma_mean(rt_alpha, rt_beta, log_removal_rate)
print(f"Mean log removal: {mean_removal:.2f}")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

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

gwtransport1d-0.8.0.tar.gz (65.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gwtransport1d-0.8.0-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file gwtransport1d-0.8.0.tar.gz.

File metadata

  • Download URL: gwtransport1d-0.8.0.tar.gz
  • Upload date:
  • Size: 65.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gwtransport1d-0.8.0.tar.gz
Algorithm Hash digest
SHA256 7a7d47483b9d6841db4bc71ed032a9f156f237b0dce95f14389d4634b93aa944
MD5 247a58c9f84c82409d55f0b8a3e65d4e
BLAKE2b-256 5b254ef7a54af6d8ee2c09ecd4786a73ad31b0b33827ce58fab1557f1b73d36b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gwtransport1d-0.8.0.tar.gz:

Publisher: release.yml on bdestombe/python-gwtransport1d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gwtransport1d-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: gwtransport1d-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 46.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gwtransport1d-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 778bb331ec3e97bb46e2f25a9974e86304fd6ad493992c69228954c8c6f5d005
MD5 469ac16e46872c3c40bec70718798a3f
BLAKE2b-256 cac7ddde65c3510ac4aa0a2e6a80164125b8c6f030828eb45fba95a80fd03010

See more details on using hashes here.

Provenance

The following attestation bundles were made for gwtransport1d-0.8.0-py3-none-any.whl:

Publisher: release.yml on bdestombe/python-gwtransport1d

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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