Input and output files#

Input parameters#

toughio.read_input(filename, file_format=None, **kwargs)#

Read TOUGH input file.

Parameters:
  • filename (str, pathlike or buffer) – Input file name or buffer.

  • file_format (str ('tough', 'toughreact-flow', 'toughreact-solute', 'toughreact-chemical', 'json') or None, optional, default None) – Input file format.

  • blocks (list of str or None, optional, default None) – Only if file_format = "tough". Blocks to read. If None, all blocks are read.

  • label_length (int or None, optional, default None) – Only if file_format = "tough". Number of characters in cell labels.

  • n_variables (int or None, optional, default None) – Only if file_format = "tough". Number of primary variables.

  • eos (str or None, optional, default None) – Only if file_format = "tough". Equation of State.

  • mopr_11 (int, optional, default 0) – Only if file_format = "toughreact-solute". MOPR(11) value in file ‘flow.inp’.

Returns:

TOUGH input parameters.

Return type:

dict

Note

If file_format == 'tough', can also read MESH, INCON and GENER files.

toughio.write_input(filename, parameters, file_format=None, **kwargs)#

Write TOUGH input file.

Parameters:
  • filename (str, pathlike or buffer) – Output file name or buffer.

  • parameters (dict) – Parameters to export.

  • file_format (str ('tough', 'toughreact-flow', 'toughreact-solute', 'toughreact-chemical', 'json') or None, optional, default None) – Output file format.

  • block (str {'all', 'gener', 'mesh', 'incon'} or None, optional, default None) –

    Only if file_format = "tough". Blocks to be written:

    • ’all’: write all blocks,

    • ’gener’: only write block GENER,

    • ’mesh’: only write blocks ELEME, COORD and CONNE,

    • ’incon’: only write block INCON,

    • None: write all blocks except blocks defined in ignore_blocks.

  • ignore_blocks (list of str or None, optional, default None) – Only if file_format = "tough" and block is None. Blocks to ignore.

  • space_between_blocks (bool, optional, default False) – Only if file_format = "tough". Add an empty record between blocks.

  • space_between_values (bool, optional, default True) – Only if file_format = "tough". Add a white space between floating point values.

  • eos (str or None, optional, default None) – Only if file_format = "tough". Equation of State. If eos is defined in parameters, this option will be ignored.

  • mopr_10 (int, optional, default 0) – Only if file_format = "toughreact-solute". MOPR(10) value in file ‘flow.inp’.

  • mopr_11 (int, optional, default 0) – Only if file_format = "toughreact-solute". MOPR(11) value in file ‘flow.inp’.

  • verbose (bool, optional, default True) – Only if file_format in {“toughreact-solute”, “toughreact-chemical”}. If True, add comments to describe content of file.

toughio.register_input(file_format, extensions, reader, writer=None)#

Register a new input format.

Parameters:
  • file_format (str) – File format to register.

  • extensions (array_like) – List of extensions to associate to the new format.

  • reader (callable) – Read fumction.

  • writer (callable or None, optional, default None) – Write function.

Simulation outputs#

toughio.read_output(filename, file_format=None, labels_order=None, time_steps=None, connection=False)#

Read TOUGH SAVE or output file for each time step.

Parameters:
  • filename (str, pathlike or buffer) – Input file name or buffer.

  • file_format ({'csv', 'petrasim', 'save', 'tecplot', 'tough'} or None, optional, default None) – Input file format.

  • labels_order (sequence of array_like or None, optional, default None) – List of labels. If None, output will be assumed ordered.

  • time_steps (int or sequence of int) – List of time steps to read. If None, all time steps will be read.

  • connection (bool, optional, default False) – Only for standard TOUGH output file. If True, return data related to connections.

Returns:

Output data for each time step.

Return type:

toughio.ElementOutput, toughio.ConnectionOutput, sequence of toughio.ElementOutput or sequence of toughio.ConnectionOutput

toughio.read_table(filename, file_format=None, **kwargs)#

Read table file.

Parameters:
  • filename (str, pathlike or buffer) – Input file name or buffer.

  • file_format (str ('column', 'csv', 'tecplot') or None, optional, default None) – Input file format.

Returns:

Table data.

Return type:

dict

toughio.write_h5(filename, elements=None, connections=None, element_history=None, connection_history=None, generator_history=None, rock_history=None, labels_order=None, compression_opts=4)#

Write TOUGH outputs to a HDF5 file.

Parameters:
  • filename (str or pathlike) – Output file name.

  • elements (str, pathlike, toughio.ElementOutput, sequence of toughio.ElementOutput or None, optional, default None) – Element outputs to export.

  • connections (str, pathlike, toughio.ConnectionOutput, sequence of toughio.ConnectionOutput or None, optional, default None) – Connection outputs to export.

  • element_history (dict or None, optional, default None) – Element history to export.

  • connection_history (dict or None, optional, default None) – Connection history to export.

  • generator_history (dict or None, optional, default None) – Generator history to export.

  • rock_history (dict or None, optional, default None) – Rock history to export.

  • labels_order (list of array_like or None, optional, default None) – List of labels.

  • compression_opts (int, optional, default 4) – Compression level for gzip compression. May be an integer from 0 to 9.

toughio.write_output(filename, output, file_format=None, **kwargs)#

Write TOUGH output file.

Parameters:
  • filename (str, pathlike or buffer) – Output file name or buffer.

  • output (toughio.ElementOutput, toughio.ConnectionOutput, sequence of toughio.ElementOutput or sequence of toughio.ConnectionOutput) – Output data to export for each time step.

  • file_format ({'csv', 'petrasim', 'tecplot'} or None, optional, default None) – Output file format.

  • unit (dict or None, optional, default None) – Only if file_format = "tough". Overwrite header unit.

toughio.register_output(file_format, extensions, reader, writer=None)#

Register a new output format.

Parameters:
  • file_format (str) – File format to register.

  • extensions (array_like) – List of extensions to associate to the new format.

  • reader (callable) – Read function.

  • writer (callable or None, optional, default None) – Write function.