Skip to main content

pycte

PYCTE (PYthon generiC inTerfacE) couples speciation solvers (PhreeqC, ORCHESTRA, xGEMS, native speciation and kinetics) with transport solvers (COMSOL, PFLOTRAN, and a native 1D transport code) by operator splitting.

PYCTE is distributed under the Apache 2.0 license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Installation

Python 3.11 or newer.

pip install pycte

This installs every Python dependency (numpy, pandas, scipy, charset-normalizer, phreeqpy, h5py, mph). From a copy of the sources, run pip install . in the folder containing pyproject.toml (pip install -e . for development).

Check the installation:

python -c "import pycte; print(pycte.examples())"

Solvers

pycte only needs the solvers you use:

Solver Setting What to install
PhreeqC chemistryModule('phreeqc') nothing more: IPhreeqc comes with phreeqpy
native speciation / kinetics chemistryModule('nativeSpeciation'), chemistryModule('nativeKinetics') nothing more
native 1D transport transportModule('nativeTransport') nothing more
ORCHESTRA chemistryModule('orchestra') PyORCHESTRA, compiled from the ORCHESTRA sources of H. Meeussen: pip install <PyORCHESTRA source folder> (needs a C++ compiler, e.g. Visual Studio Build Tools on Windows). Do not pip install PyORCHESTRA from PyPI: that name belongs to an unrelated project.
xGEMS chemistryModule('gems') not on PyPI: conda install -c conda-forge xgems
COMSOL transportModule('comsol') COMSOL Multiphysics with a valid licence (the mph Python package is installed with pycte)
PFLOTRAN transportModule('pflotran') PFLOTRAN built from source, the environment variable PFLOTRAN_DIR pointing to it (pycte runs mpirun -n 1 $PFLOTRAN_DIR/src/pflotran/pflotran) and mpirun in the PATH

Quick start

Run first the test case matching your solvers:

import pycte

pycte.load("CementClayInterface")    # PhreeqC, multi-compound transport
pycte.chemistryModule("orchestra")   # switch solver: the example's database and initial conditions follow
pycte.MCT(False)                     # multi-species transport (option of this example)
pycte.maxTime(100)                   # any setting can be overridden, before or after a solver switch
pycte.output({"coupling": [50, 100]})   # output steps must lie within the run (here 100 steps of 1 year)

if __name__ == "__main__":
    pycte.run()

The outputs are written in the current folder. When you shorten a bundled example with pycte.maxTime(...), also give output steps within the new run with pycte.output(...): the example's own output steps may lie beyond it. Keep pycte.run() under if __name__ == "__main__": on Windows as soon as several processes are used (PIDnbr > 1).

Bundled test cases

Name Speciation Transport Reference
CationExchange PhreeqC (default), ORCHESTRA, nativeSpeciation nativeTransport (default), COMSOL, PFLOTRAN ex. 11 of PhreeqC, Appelo et al. 2013
CalciteDolomite xGEMS nativeTransport (default), COMSOL Azad et al. 2016
AldicarbInfiltration nativeKinetics (default), PhreeqC, ORCHESTRA COMSOL COMSOL model of aldicarb infiltration
CementClayInterface PhreeqC (default), ORCHESTRA nativeTransport cement / clay interface benchmark, 100 000 years; option MCT(True / False): multi-compound (default) or multi-species transport

pycte.chemistryModule(...) and pycte.transportModule(...) switch to the files of the example for that solver. The settings you give after pycte.load(...) are kept whatever the order of the calls.

Your own case

Each setting read by pycte has its own function, e.g. pycte.maxTime(72000), pycte.timeStep(720), pycte.chemPath("my.dat"), pycte.initialConditions("ic.txt"); a misspelled setting raises an AttributeError. The older style, a script defining the settings as variables (chemistryModule = 'phreeqc', maxTime = 1e5, ...) and ending with pycte.run(), still works.

Outputs

  • warning.log: run description, every warning (solvers, Python, workers) and the computation times;
  • coupling/Coupling_<step>.txt: the coupled variables at the steps asked with pycte.output({'coupling': [...]});
  • orchestra_output.log: ORCHESTRA solver messages.

Post-processing:

df = pycte.postProcess(["Ca", "Cl"], "myRunFolder")                    # breakthrough curves (last cell)
dp = pycte.postProcess(columnProfile=(["Ca", "Cl"], "myRunFolder"))    # profiles at the last step
times = pycte.getTimes("myRunFolder")                                   # computation times, warnings count

PFLOTRAN runs in the folder of its input file and updates it: with a bundled example, copy the example's .in file and the files it names (e.g. its DATABASE) next to your script, and give it with pycte.trsptPath(...).

Building a release (maintainers)

python -m pip install build twine
python -m build              # dist/pycte-<version>.tar.gz and .whl, built with setuptools >= 77
python -m twine upload dist/pycte-<version>*

Remove older files from dist/ first, or upload only the new version. The version is set in pyproject.toml; data files of a new example must be declared in [tool.setuptools] (packages and package-data).

Do not hesitate to contact me ! (anatole.lafond [at] cea.fr)

Metadata

Release files for pycte 0.1.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycte 0.1.3.3
File Size Uploaded Provenance Actions
pycte-0.1.3.3.tar.gz 4.7 MB Without provenance Details for pycte-0.1.3.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycte 0.1.3.3
File Interpreter ABI Platform Actions
pycte-0.1.3.3-py3-none-any.whl Python 3 none any Details for pycte-0.1.3.3-py3-none-any.whl

Total release size: 9.3 MB

Release files / pycte-0.1.3.3.tar.gz

Download URL pycte-0.1.3.3.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
a1993c4119087e95e996498d8e2fca81288b5e784f3be0073f0d5a84b6d1ac48
BLAKE2b-256 checksum
How to use checksums
06273e80caab35e20fde2bc6a69ff51c2c45787afa5d857b6f4bed4cec9a4fca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Release files / pycte-0.1.3.3-py3-none-any.whl

Download URL pycte-0.1.3.3-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b8cbdf3120e5fa0ab5e1c25f125d10236e577e04450d5f8df3406362f1ff21dd
BLAKE2b-256 checksum
How to use checksums
f0e0fdb769855713868d1a634d9c34d656e9501b1c343f44516a67b4e6fe3163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Security for pycte 0.1.3.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page