toughio

toughio: Pre- and post-processing Python library for TOUGH - Published in JOSS (2020)

https://github.com/keurfonluu/toughio

Science Score: 98.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

io postprocessing preprocessing tough2 tough3
Last synced: 4 months ago · JSON representation ·

Repository

Pre- and post-processing Python library for TOUGH

Basic Info
  • Host: GitHub
  • Owner: keurfonluu
  • License: other
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 18.6 MB
Statistics
  • Stars: 63
  • Watchers: 4
  • Forks: 8
  • Open Issues: 9
  • Releases: 45
Topics
io postprocessing preprocessing tough2 tough3
Created over 6 years ago · Last pushed 4 months ago
Metadata Files
Readme Contributing License Code of conduct Citation

README.rst

toughio
=======

|License| |Stars| |Pyversions| |Version| |Downloads| |Code style: black| |Codacy Badge| |Codecov| |Build| |Docs| |DOI| |JOSS|

`TOUGH `__ (Transport Of Unsaturated Groundwater and Heat) is a general purpose numerical simulation software designed for fluid and heat flows of multiphase, multicomponent fluid mixtures in porous and fractured media developed at Lawrence Berkeley National Laboratory. It solves mass and energy balance equations that describe fluid and heat flow in multiphase and multicomponent systems. TOUGH handles all types of multiphase and multicomponent flow systems since the governing equations for fluid and heat flow have the same mathematical form. The nature and properties of fluid mixtures are described by thermophysical variables (e.g., density, viscosity, enthalpy) which are provided by an equation-of-state (EOS) module.

**toughio** is an open-source library that provides tools to facilitate pre- and post-processing for TOUGH using the latest Python standards. It aims to make setting up of a TOUGH simulation user-friendly by relying on existing well-established Python packages:

-  `numpy `__: vectorized calculation of N-dimensional arrays,
-  `meshio `__: input/output for many mesh formats,
-  `pyvista `__: 3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK).

Note that the results of a TOUGH simulation are sensitive to the quality of the mesh (ideally, it should satisfy the orthogonality condition). A mesh that contains too many ill-shaped cells can potentially lead to unexpected results although the simulation converged successfully. **toughio** does not verify the quality of the mesh which is left to the discretion of the user.

.. figure:: https://raw.githubusercontent.com/keurfonluu/toughio/master/.github/sample.gif
   :alt: sample-co2
   :width: 50%
   :align: center

   Simulation of CO\ :sub:`2`\  leakage along a fault. Mesh generated with Gmsh and animation exported by PyVista.

Features
--------

Meshing:

-  Create simple 2D cylindric or 2D/3D structured meshes similarly to TOUGH's built-in *MESHMAKER*,
-  Import mesh generated by external softwares (e.g., `Abaqus `__, `FLAC3D `__, `Gmsh `__, `LaGriT `__),
-  Export imported or generated mesh to a *MESH* file for TOUGH assuming `conformity `__ (and optionally write initial condition file *INCON*).

Pre-processing:

-  Easily add initial conditions, boundary conditions or other physical properties (e.g., porosity, permeability) using the convenient class ``toughio.Mesh``,
-  Import previous TOUGH simulation input file into Python or define simulation parameters in a human-readable and `JSON `__\ able dictionary,
-  Export simulation parameters dictionary to a TOUGH input file.

Post-processing:

-  Import outputs of a TOUGH simulation into Python,
-  Visualize results directly in Python using `pyvista `__ or export the results to another format supported by `meshio `__ (e.g., VTK, Tecplot...),
-  Create animations (GIF or MP4) or export results for all time steps to a XDMF file to be visualized in ParaView.

Installation
------------

The recommended way to install **toughio** and all its dependencies is through the Python Package Index:

.. code:: bash

   pip install toughio[full] --user

Otherwise, clone and extract the package, then run from the package location:

.. code:: bash

   pip install .[full] --user

To test the integrity of the installed package, check out this repository and run:

.. code:: bash

   git lfs pull
   pytest

Documentation
-------------

Refer to the online `documentation `__ for detailed description of the API and examples.

Alternatively, the documentation can be built using `Sphinx `__:

.. code:: bash

   pip install -r doc/requirements.txt
   sphinx-build -b html doc/source doc/build

Note that some sample files are stored with LFS, so you may have to run the following command beforehand:

.. code:: bash

   git lfs pull

Usage
-----

In Python, to read a mesh and write the corresponding TOUGH *MESH* file (without any pre-processing), simply do

.. code:: python

   import toughio

   mesh = toughio.read_mesh(
      filename,
      file_format="flac3d",  # Optional, inferred from file extension otherwise
   )
   mesh.write_tough()  # Write MESH file

Parameters of a TOUGH simulation can be defined as a dictionary with specific keywords following the JSON standard, for instance

.. code:: python

   parameters = {
      "title": "Sample title",
      "eos": "eco2n",
      "isothermal": False,
      "default": {  # Default rock properties
         "density": 2600.0,
         "porosity": 0.1,
         # "permeability", "conductivity", "specific_heat"...
      },
      "rocks": {
         "shale": {  # To overwrite default rock properties
            "capillarity": {
               "id": 1,
               "parameters": [0.0, 0.0, 1.0],
            },
            # same keywords as in "default"
         },
         # other materials
      },
      "options": {
         "n_cycle": 100,
         "t_max": 3.0 * 365.25 * 24.0 * 3600.0,
         # "t_ini", "t_steps", "t_step_max", "gravity", "eps1", "eps2"...
      },
      # "extra_options", "selections", "solver", "generators"...
   }
   toughio.write_input("INFILE", parameters)

TOUGH simulation output can also be imported into Python as a list of *namedtuple* (``type``, ``format``, ``time``, ``labels``, ``data``)

.. code:: python

   output = toughio.read_output(filename)

**toughio** is mainly intended to be used as a Python scripting library for TOUGH. Nevertheless, several utility command line scripts are available for users who are not familiar with Python. From a console or terminal, the user can execute the following scripts:

-  ``toughio-co2tab``: copy file *CO2TAB* to the target directory,
-  ``toughio-export``: export TOUGH simulation results to a file for visualization (VTK, VTU, Tecplot or XDMF),
-  ``toughio-extract``: extract results from TOUGH main output file and reformat as a TOUGH3 element or connection output file (mostly useful for TOUGH2 output *before* calling ``toughio-export``),
-  ``toughio-merge``: merge input file, GENER and/or MESH and/or INCON into a single file,
-  ``toughio-save2incon``: convert a *SAVE* file to an *INCON* file (mostly useful to automatically restart a simulation and reset the counters).

Contributing
------------

Please refer to the `Contributing
Guidelines `__ to see how you can help. This project is released with a `Code of Conduct `__ which you agree to abide by when contributing.

Notice
------

toughio Copyright (c) 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
If you have questions about your rights to use or distribute this software, please contact Berkeley Lab's Intellectual Property Office at `IPO@lbl.gov `__.

This Software was developed under funding from the U.S. Department of Energy and the U.S. Government consequently retains certain rights. As such, the U.S. Government has been granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software to reproduce, distribute copies to the public, prepare derivative works, and perform publicly and display publicly, and to permit others to do so.

.. |License| image:: https://img.shields.io/badge/license-BSD--3--Clause-green
   :target: https://github.com/keurfonluu/toughio/blob/master/LICENSE

.. |Stars| image:: https://img.shields.io/github/stars/keurfonluu/toughio?style=flat&logo=github
   :target: https://github.com/keurfonluu/toughio

.. |Pyversions| image:: https://img.shields.io/pypi/pyversions/toughio.svg?style=flat
   :target: https://pypi.org/pypi/toughio/

.. |Version| image:: https://img.shields.io/pypi/v/toughio.svg?style=flat
   :target: https://pypi.org/project/toughio

.. |Downloads| image:: https://pepy.tech/badge/toughio
   :target: https://pepy.tech/project/toughio

.. |Code style: black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
   :target: https://github.com/psf/black

.. |Codacy Badge| image:: https://img.shields.io/codacy/grade/037f16f4e7544afbb1b99bf0d66df4a6.svg?style=flat
   :target: https://www.codacy.com/manual/keurfonluu/toughio?utm_source=github.com&utm_medium=referral&utm_content=keurfonluu/toughio&utm_campaign=Badge_Grade

.. |Codecov| image:: https://img.shields.io/codecov/c/github/keurfonluu/toughio.svg?style=flat
   :target: https://codecov.io/gh/keurfonluu/toughio

.. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.3961278.svg?style=flat
   :target: https://doi.org/10.5281/zenodo.3961278

.. |Build| image:: https://img.shields.io/github/actions/workflow/status/keurfonluu/toughio/ci.yml
   :target: https://github.com/keurfonluu/toughio

.. |Docs| image:: https://img.shields.io/github/actions/workflow/status/keurfonluu/toughio/doc.yml?label=docs
   :target: https://keurfonluu.github.io/toughio/

.. |JOSS| image:: https://joss.theoj.org/papers/10.21105/joss.02412/status.svg
   :target: https://doi.org/10.21105/joss.02412

Owner

  • Name: Keurfon Luu
  • Login: keurfonluu
  • Kind: user
  • Location: Wettingen, Switzerland
  • Company: INTERA Incorporated

JOSS Publication

toughio: Pre- and post-processing Python library for TOUGH
Published
July 27, 2020
Volume 5, Issue 51, Page 2412
Authors
Keurfon Luu ORCID
Energy Geosciences Division, Lawrence Berkeley National Laboratory, Berkeley, CA, USA
Editor
Jeff Gostick ORCID
Tags
tough2 tough3 preprocessing postprocessing io

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Luu"
  given-names: "Keurfon"
  orcid: "https://orcid.org/0000-0001-7927-0019"
title: "toughio: Pre- and post-processing Python library for TOUGH"
doi: 10.21105/joss.02412
url: https://github.com/keurfonluu/toughio
license: BSD-3-Clause

GitHub Events

Total
  • Issues event: 4
  • Watch event: 6
  • Issue comment event: 3
  • Push event: 37
Last Year
  • Issues event: 4
  • Watch event: 6
  • Issue comment event: 3
  • Push event: 37

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,338
  • Total Committers: 1
  • Avg Commits per committer: 1,338.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 4
  • Committers: 1
  • Avg Commits per committer: 4.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Keurfon Luu k****u@o****m 1,338

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 51
  • Total pull requests: 82
  • Average time to close issues: 2 months
  • Average time to close pull requests: 2 days
  • Total issue authors: 23
  • Total pull request authors: 2
  • Average comments per issue: 4.12
  • Average comments per pull request: 0.78
  • Merged pull requests: 81
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 1
  • Average time to close issues: 4 months
  • Average time to close pull requests: 12 minutes
  • Issue authors: 3
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • geowomen (10)
  • Alejobep (5)
  • ghost (4)
  • BourbonTiger (3)
  • Cocytus-kyon (3)
  • ma-sadeghi (3)
  • jousheinfo (2)
  • rreinecke (2)
  • PerFoamer (2)
  • nur-wijaya (2)
  • tjuCJC (2)
  • oklolo (1)
  • BinWang0213 (1)
  • mfg7 (1)
  • miraboreasumr (1)
Pull Request Authors
  • keurfonluu (84)
  • nur-wijaya (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 216 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 64
  • Total maintainers: 1
pypi.org: toughio

Pre- and post-processing Python library for TOUGH

  • Versions: 64
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 216 Last month
Rankings
Dependent packages count: 10.1%
Stargazers count: 10.3%
Downloads: 11.2%
Forks count: 11.9%
Average: 13.0%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 4 months ago

Dependencies

doc/requirements.txt pypi
  • pybtex-apa-style *
  • pydata-sphinx-theme *
  • pygmsh ==6.1.1
  • seaborn *
  • sphinx *
  • sphinx-argparse *
  • sphinx-gallery *
  • sphinxcontrib-bibtex *
requirements-dev.txt pypi
  • black *
  • build *
  • docformatter *
  • invoke *
  • isort *
  • pytest *
  • pytest-cov *
  • twine *
.github/workflows/ci.yml actions
  • actions/cache v2 composite
  • actions/setup-python v1 composite
  • nschloe/action-cached-lfs-checkout v1 composite
.github/workflows/doc.yml actions
  • actions/setup-python v4 composite
  • nschloe/action-cached-lfs-checkout v1 composite
  • peaceiris/actions-gh-pages v3 composite