ogstools.ogs6py package#

class ogstools.ogs6py.Project[source]#

Bases: object

Class for handling an OGS6 project.

In this class everything for an OGS6 project can be specified.

Parameters#

output_filestr, optional

Filename of the output project file Default: default.prj

input_filestr, optional

Filename of the input project file

xml_stringstr,optional

String containing the XML tree

OMP_NUM_THREADSint, optional

Sets the environmentvariable before OGS execution to restrict number of OMP Threads

verbosebool, optional

Default: False

__init__(**args)[source]#
add_element(parent_xpath='./', tag=None, text=None, attrib_list=None, attrib_value_list=None)[source]#

General method to add an Entry.

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

Parameters#

parent_xpathstr, optional

XPath of the parent tag

tagstr

tag name

textstr, int or float

content

attribstr

attribute keyword

attrib_valuestr, int or float

value of the attribute keyword

add_include(parent_xpath='./', file='')[source]#

Add include element.

Parameters#

parent_xpathstr, optional

XPath of the parent tag

filestr

file name

add_block(blocktag, block_attrib=None, parent_xpath='./', taglist=None, textlist=None)[source]#

General method to add a Block.

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

Parameters#

blocktagstr

name of the enclosing tag

block_attrib‘dict’, optional

attributes belonging to the blocktag

parent_xpathstr, optional

XPath of the parent tag

taglistlist

list of strings containing the keys

textlistlist

list of strings, ints or floats retaining the corresponding values

deactivate_property(name, mediumid=0, phase=None)[source]#

Replaces MPL properties by a comment.

Parameters#

mediumidint

id of the medium

phasestr

name of the phase

namestr

property name

deactivate_parameter(name)[source]#

Replaces parameters by a comment.

Parameters#

namestr

property name

remove_element(xpath, tag=None, text=None)[source]#

Removes an element.

Parameters#

xpath : str tag : str text : str

replace_text(value, xpath='.', occurrence=-1)[source]#

General method for replacing text between opening and closing tags.

Parameters#

valuestr/any

Text

xpathstr, optional

XPath of the tag

occurrenceint, optional

Easy way to address nonunique XPath addresses by their occurrence from the top of the XML file Default: -1

replace_block_by_include(xpath='./', filename='include.xml', occurrence=0)[source]#

General method for replacing a block by an include.

Parameters#

xpathstr, optional

XPath of the tag

filenamestr, optional

name of the include file

occurrenceint, optional

Addresses nonunique XPath by their occurece

replace_mesh(oldmesh, newmesh)[source]#

Method to replace meshes.

Parameters#

oldmesh : str newmesh : str

replace_parameter(name='', parametertype='', taglist=None, textlist=None)[source]#

Replacing parametertypes and values.

Parameters#

namestr

parametername

parametertypestr

parametertype

taglistlist

list of tags needed for parameter spec

textlistlist

values of parameter

replace_parameter_value(name='', value=0, valuetag='value')[source]#

Replacing parameter values.

Parameters#

namestr

parametername

valuestr

value

parametertypestr

parameter type

valuetagstr, optional

name of the tag containing the value, e.g., values Default: value

replace_phase_property_value(mediumid=0, phase='AqueousLiquid', component=None, name='', value=0, propertytype='Constant', valuetag='value')[source]#

Replaces properties in medium phases.

Parameters#

mediumidint

id of the medium

phasestr

name of the phase

componentstr

name of the component

namestr

property name

valuestr/any

value

propertytypestr

type of the property

valuetagstr/any

name of the tag containing the value, e.g., values Default: value

replace_medium_property_value(mediumid=0, name='', value=0, propertytype='Constant', valuetag='value')[source]#

Replaces properties in medium (not belonging to any phase).

Parameters#

mediumidint

id of the medium

namestr

property name

valuestr/any

value

propertytypestr

type of the property

valuetagstr/any

name of the tag containing the value, e.g., values Default: value

set(**args)[source]#

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

restart(restart_suffix='_restart', t_initial=None, t_end=None, zero_displacement=False)[source]#

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_suffixstr,

suffix by which the output prefix is appended

t_initialfloat, optional

first time step, takes the last from previous simulation if None

t_endfloat, 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=Path('out.log'), path=None, args=None, container_path=None, wrapper=None, write_logs=True, write_prj_to_pvd=True)[source]#

Command to run OGS.

Runs OGS with the project file specified as output_file.

Parameters#

logfilestr, optional

Name of the file to write STDOUT of ogs Default: out

pathstr, 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.

argsstr, optional

additional arguments for the ogs executable

container_pathstr, optional

Path of the OGS container file.

wrapperstr, optional

add a wrapper command. E.g. mpirun

write_logs: bolean, optional

set False to omit logging

write_input(keep_includes=False)[source]#

Writes the projectfile to disk.

Parameters#

keep_includes : boolean, optional

property_dataframe(mediamapping=None)[source]#

Returns a dataframe containing most properties defined in the Material Property (MPL) section of the input file.

Parameters#

mediamapping : dict, optional

Return type:

DataFrame

write_property_latextable(latexfile=Path('property_dataframe.tex'), mediamapping=None, float_format='{:.2e}')[source]#

Write material properties to disc as latex table.

Parameters#

latexfile : str mediamapping : dict, optional float_format : str

Submodules#