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.4

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.4
File Size Uploaded Provenance Actions
pycte-0.1.3.4.tar.gz 4.7 MB Without provenance Details for pycte-0.1.3.4.tar.gz

Built distribution (wheel)

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

Total release size: 9.4 MB

Release files / pycte-0.1.3.4.tar.gz

Download URL pycte-0.1.3.4.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
902981cc80c404b8afcd5f9c9368534e9bb36e49350b8869bc87812c2dc7f037
BLAKE2b-256 checksum
How to use checksums
ae1250f50b7a1d0df91953caa7d1b4618871696bb1b62149883c6545a3137b88
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.4-py3-none-any.whl

Download URL pycte-0.1.3.4-py3-none-any.whl
Size 4.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
192a721a88709a475213b3129ba5e74a063bd9c5167a318b586b23e638ddf452
BLAKE2b-256 checksum
How to use checksums
b10bf2402652a8c3c06d5cf4c94b47a29e8f3b6cb3c49d237f5dac69004beaef
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.4

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