ogs6py.ogs

ogs6py is a python-API for the OpenGeoSys finite element sofware. Its main functionalities include creating and altering OGS6 input files as well as executing OGS.

Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
Distributed under a Modified BSD License.

See accompanying file LICENSE or http://www.opengeosys.org/project/license

class ogs6py.ogs.OGS(**args)

Bases: object

Class for an OGS6 model.

In this class everything for an OGS5 model can be specified.

Parameters:
  • PROJECT_FILE (str, optional) – Filename of the output project file Default: default.prj

  • INPUT_FILE (str, optional) – Filename of the input project file

  • XMLSTRING (str,optional) –

  • OMP_NUM_THREADS (int, optional) – Sets the environmentvariable before OGS execution to restrict number of OMP Threads

  • VERBOSE (bool, optional) – Default: False

add_block(blocktag, block_attrib=None, parent_xpath='./', taglist=None, textlist=None)

General method to add a Block

A block consists of an enclosing tag containing a number of subtags retaining a key-value structure

Parameters:
  • blocktag (str) – name of the enclosing tag

  • block_attrib ('dict', optional) –

  • parent_xpath (str, optional) – XPath of the parent tag

  • taglist (list) – list of strings containing the keys

  • textlist (list) – list of strings retaining the corresponding values

add_element(parent_xpath='./', tag=None, text=None, attrib=None, attrib_value=None)

General method to add an Entry

An element is a single tag containing ‘text’, attributes and anttribute values

Parameters:
  • parent_xpath (str, optional) – XPath of the parent tag

  • tag (str) – tag name

  • text (str) – content

  • attrib (str) – attribute keyword

  • attrib_value (str) – value of the attribute keyword

add_include(parent_xpath='./', file='')

add include element

Parameters:
  • parent_xpath (str, optional) – XPath of the parent tag

  • file (str) – file name

build_tree()
parse_out(logfile=None, filter=None, maximum_lines=None, reset_index=True)

Parses the logfile

Parameters:
  • logfile (str, optional) – name of the log file Default: File specified already as logfile by runmodel

  • maximum_lines (int) – maximum number of lines to be evaluated

  • filter (str, optional) – can be “by_time_step”. “convergence_newton_iteration”, “convergence_coupling_iteration”, or “time_step_vs_iterations” if filter is None, the raw dataframe is returned.

remove_element(xpath)

Removes an element

Parameters:

xpath (str) –

replace_block_by_include(xpath='./', filename='include.xml', occurrence=0)

General method for replacing a block by an include

Parameters:
  • xpath (str, optional) – XPath of the tag

  • filename (str, optional) –

  • occurrence (int, optional) – Addresses nonunique XPath by their occurece Default: 0

replace_medium_property_value(mediumid=None, name=None, value=None, propertytype=None, valuetag='value')

Replaces properties in medium (not belonging to any phase)

Parameters:
  • mediumid (int) – id of the medium

  • name (str) – property name

  • value (str/any) – value

  • propertytype (str) – type of the property

  • valuetag (str/any) – name of the tag containing the value, e.g., values Default: value

replace_mesh(oldmesh, newmesh)

Method to replace meshes

Parameters:
  • oldmesh (str) –

  • newmesh (str) –

replace_parameter(name=None, parametertype=None, taglist=None, textlist=None)

Replacing parametertypes and values

Parameters:
  • name (str) – parametername

  • parametertype (str) – parametertype

  • taglist (list) – list of tags needed for parameter spec

  • textlist (list) – values of parameter

replace_parameter_value(name=None, value=None, valuetag='value')

Replacing parameter values

Parameters:
  • name (str) – parametername

  • value (str) – value

  • parametertype (str) – parameter type

  • valuetag (str, optional) – name of the tag containing the value, e.g., values Default: value

replace_phase_property_value(mediumid=None, phase='AqueousLiquid', name=None, value=None, propertytype=None, valuetag='value')

Replaces properties in medium phases

Parameters:
  • mediumid (int) – id of the medium

  • phase (str) – name of the phase

  • name (str) – property name

  • value (str/any) – value

  • propertytype (str) – type of the property

  • valuetag (str/any) – name of the tag containing the value, e.g., values Default: value

replace_text(value, xpath='.', occurrence=-1)

General method for replacing text between opening and closing tags

Parameters:
  • value (str/any) – Text

  • xpath (str, optional) – XPath of the tag

  • occurrence (int, optional) – Easy way to adress nonunique XPath addresses by their occurence from the top of the XML file Default: -1

restart(restart_suffix='_restart', t_initial=None, t_end=None, zero_displacement=False)

Prepares the project file for a restart.

Takes the last time step from the PVD file mentioned in the PRJ file. Sets initial conditions accordingly.

Parameters:
  • restart_suffix (str,) – suffix by which the output prefix is appended

  • t_initial (float, optional) – first time step, takes the last from previous simulation if None

  • t_end (float, optional) – last time step, the same as in previous run if None

  • zero_displacement (bolean, False) – sets the initial displacement to zero if True

run_model(logfile='out.log', path=None, args=None, container_path=None, wrapper=None, write_logs=True)

Command to run OGS.

Runs OGS with the project file specified as PROJECT_FILE

Parameters:
  • logfile (str, optional) – Name of the file to write STDOUT of ogs Default: out

  • path (str, optional) – Path of the directory in which the ogs executable can be found. If container_path is given: Path to the directory in which the Singularity executable can be found

  • args (str, optional) – additional arguments for the ogs executable

  • container_path (str, optional) – Path of the OGS container file.

  • wrapper (str, optional) – add a wrapper command. E.g. mpirun

  • write_logs (bolean, optional) – set False to omit logging

set(**args)

Sets directly a uniquely defined property List of properties is given in the dictory below

write_input(keep_includes=False)

Writes the projectfile to disk

Parameters:

keep_includes (boolean, optional) –