What is PyTOUGH? - acroucher/PyTOUGH GitHub Wiki

PyTOUGH is a tool for making it easier to use the TOUGH2 simulator. As well as making conventional simulations easier, it aims to make new simulations possible with TOUGH2 that would be difficult or impossible to do using other means.

Preparing TOUGH2 input

TOUGH2 takes its input for a simulation from a model input data file, which is a fixed-format text file that is not very easy for humans to read. The positions of the data on each line of the file are important, so that small errors like the accidental omission or insertion of an extra character or even a space can mean the difference between a model that runs correctly, and one that doesn't run at all (or perhaps worse, does run but contains subtle errors that are hard to detect).

Using PyTOUGH, it is possible to create TOUGH2 data input files without having to know anything about TOUGH2's data file format.

Graphical interfaces have been written for TOUGH2, which can also help prepare data input files. However, because TOUGH2 is a complex simulator, such interfaces usually end up limiting its full potential- otherwise, the interface itself would have to be impossibly complicated. PyTOUGH, on the other hand, does not limit the capabilities of TOUGH2 at all, but rather extends them.

Post-processing and analysis of TOUGH2 results

Like its input, TOUGH2's output is in the form of text files with their own unique format. The tables of results are human-readable, but are not easily read in any automatic way except via software written specially for the job.

PyTOUGH contains such software, so that results files from TOUGH2 can be read directly into arrays in computer memory, where they can be manipulated, post-processed, analysed, compared with field data, used to modify input for further runs, plotted and so on.

Automating TOUGH2 simulations

Increasingly, it is necessary to carry out complex TOUGH2 simulations, involving for example numerous linked model runs carried out in batches, with the input for one run possibly depending on the output of a previous one. This can't be done efficiently either by preparing data input files manually or via a graphical interface. However, it can be done relatively easily using PyTOUGH.

Scripting

PyTOUGH enables TOUGH2 simulations to be done using a scripting approach. A script is a simple program written in a high-level scripting language, in which things like model grids, data input files, or model output are all treated as variables which can be manipulated by the script. A script can automate some or all of the preparation, running, post-processing and analysis of model results.

The scripting approach has various advantages, including:

  • you can get a script to do complex things that would take a long time to do any other way
  • once you have written the script, you can run it as many times as you like, with no extra effort
  • you can save time by making copies of old scripts and editing them to solve new problems
  • a script provides an exact record of what you did to solve the problem- useful if you have to re-visit it later

PyTOUGH uses the Python scripting language. A brief introduction to Python can be found in the next section of this tutorial.

Back to Contents page