# toughio
![license](https://img.shields.io/badge/license-MIT-green)
[![version](https://img.shields.io/pypi/v/toughio.svg?style=flat)](https://pypi.org/project/toughio)
[![PyPi downloads](https://img.shields.io/pypi/dm/toughio.svg?style=flat)](https://pypistats.org/packages/toughio)
![black](https://img.shields.io/badge/style-black-black)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/037f16f4e7544afbb1b99bf0d66df4a6)](https://www.codacy.com/manual/keurfonluu/toughio?utm_source=github.com&utm_medium=referral&utm_content=keurfonluu/toughio&utm_campaign=Badge_Grade)
[![codecov](https://codecov.io/gh/keurfonluu/toughio/branch/master/graph/badge.svg)](https://codecov.io/gh/keurfonluu/toughio)
[TOUGH](https://tough.lbl.gov/) (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`**](https://numpy.org/): vectorized calculation of N-dimensional arrays,
- [**`meshio`**](https://github.com/nschloe/meshio): input/output for many mesh formats,
- [**`pyvista`**](https://github.com/pyvista/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.
<p align="center">
<img alt="sample_co2" src="https://github.com/keurfonluu/toughio/blob/master/.github/sample.gif" width="50%"><br>
<em>Simulation of CO<sub>2</sub> leakage along a fault.<br>Mesh generated with Gmsh and animation exported by PyVista.</em>
</p>
## 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](https://www.3ds.com/products-services/simulia/products/abaqus/), [FLAC3D](https://www.itascacg.com/software/flac3d), [Gmsh](http://gmsh.info/), [LaGriT](https://meshing.lanl.gov/)),
- Export imported or generated mesh to a _MESH_ file for TOUGH **assuming [conformity](https://www.quora.com/What-is-non-conformal-mesh-in-CFD)** (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](http://json.org/)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`**](https://github.com/pyvista/pyvista) or export the results to another format supported by [**`meshio`**](https://github.com/nschloe/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:
```bash
pip install toughio[full] --user
```
Otherwise, clone and extract the package, then run from the package location:
```bash
pip install .[full]
```
## Usage
In Python, to read a mesh and write the corresponding TOUGH _MESH_ file (without any pre-processing), simply do
```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
```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_ (`time`, `labels`, `data`)
```python
output = toughio.read_output(
filename,
file_format="tough", # Optional, "tough" or "tecplot"
)
```
**`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-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 output file (mostly useful for TOUGH2 output _before_ calling `toughio-export`),
- `toughio-merge`: merge input file, MESH and/or INCON into a single file (for storage or sharing).
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共86个文件
py:66个
txt:5个
out:4个
资源分类:Python库 所属语言:Python 资源全名:toughio-1.2.6.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
toughio-1.2.6.tar.gz (86个子文件)
toughio-1.2.6
MANIFEST.in 38B
PKG-INFO 8KB
test
test_mesh_properties.py 745B
test_meshmaker.py 2KB
support_files
relative_permeability_references.json 90KB
outputs
SAVE.out 81KB
tough3
OUTPUT.out 289KB
OUTPUT_ELEME.csv 739KB
OUTPUT_ELEME.tec 699KB
MESH.out 211KB
tough2
OUTPUT.out 617KB
mesh.pickle 142KB
all_cell_types.f3grid 17KB
capillarity_references.json 5KB
test_meshio.py 1021B
test_output.py 2KB
test_input.py 20KB
test_capillarity.py 1KB
test_tough.py 5KB
test_mesh_methods.py 4KB
test_relative_permeability.py 1KB
test_cli.py 8KB
test_time_series.py 2KB
toughio
__about__.py 176B
mesh
avsucd
__init__.py 79B
_avsucd.py 8KB
tecplot
_tecplot.py 14KB
__init__.py 66B
tough
_helpers.py 3KB
__init__.py 78B
_tough.py 11KB
_helpers.py 10KB
pickle
__init__.py 79B
_pickle.py 933B
__init__.py 334B
_common.py 6KB
_properties.py 8KB
flac3d
_flac3d.py 8KB
__init__.py 79B
_mesh.py 25KB
meshmaker
_cylindric_grid.py 3KB
_voxelize.py 1KB
__init__.py 266B
_structured_grid.py 4KB
_triangulate.py 1KB
_cli
_export.py 7KB
__init__.py 150B
_extract.py 5KB
_merge.py 2KB
__init__.py 849B
_io
tough
_helpers.py 9KB
__init__.py 97B
_read.py 17KB
_write.py 25KB
_common.py 4KB
json
__init__.py 77B
_json.py 2KB
_helpers.py 9KB
__init__.py 166B
_utils
capillarity
_base.py 4KB
_linear.py 1KB
_milly.py 1000B
__init__.py 254B
_trust.py 2KB
_van_genuchten.py 2KB
_pickens.py 2KB
__init__.py 118B
relative_permeability
_verma.py 1KB
_grant.py 1KB
_base.py 4KB
_fatt_klikoff.py 1KB
_linear.py 2KB
_corey.py 1KB
__init__.py 374B
_pickens.py 760B
_van_genuchten_mualem.py 2KB
_common.py 793B
toughio.egg-info
PKG-INFO 8KB
requires.txt 81B
SOURCES.txt 3KB
entry_points.txt 130B
top_level.txt 8B
dependency_links.txt 1B
setup.cfg 42B
setup.py 3KB
README.md 7KB
共 86 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功