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 True) – Only if file_format = "tough". Add an empty record between blocks.

  • space_between_blocks – 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, 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 (str ('csv', 'petrasim', 'save', 'tecplot', 'tough') or None, optional, default None) – Input file format.

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

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

Returns:

namedtuple (type, format, time, labels, data) or list of namedtuple for each time step.

Return type:

namedtuple or list of namedtuple

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 (namedtuple, list of namedtuple, str, pathlike or None, optional, default None) – Element outputs to export.

  • connections (namedtuple, list of namedtuple, str, pathlike 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 (namedtuple or list of namedtuple) – namedtuple (type, format, time, labels, data) or list of namedtuple for each time step to export.

  • file_format (str ('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.