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
- 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_xpath (str) – XPath of the parent tag
tag (str | None) – tag name
text (str | int | float | None) – content
attrib_list (list[str] | None) – list of attribute keywords
attrib_value_list (list[str] | None) – list of values of the attribute keywords
- add_include(parent_xpath='./', file='')[source]#
Add include element.
- Parameters:
parent_xpath (str) – XPath of the parent tag
file (str) – 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:
blocktag (str) – name of the enclosing tag
block_attrib (Any | None) – attributes belonging to the blocktag
parent_xpath (str) – XPath of the parent tag
taglist (list[str] | None) – list of strings containing the keys
textlist (list[Any] | None) – list retaining the corresponding values
- deactivate_property(name, mediumid=0, phase=None)[source]#
Replaces MPL properties by a comment.
- Parameters:
mediumid (int) – id of the medium
phase (str | None) – name of the phase
name (str) – property name
- deactivate_parameter(name)[source]#
Replaces parameters by a comment.
- Parameters:
name (str) – property name
- remove_element(xpath, tag=None, text=None)[source]#
Removes an element.
- Parameters:
xpath (str)
tag (str | None)
text (str | None)
- replace_text(value, xpath='.', occurrence=-1)[source]#
General method for replacing text between opening and closing tags.
- Parameters:
value (str | int) – Text
xpath (str) – XPath of the tag
occurrence (int) – Easy way to address nonunique XPath addresses by their occurrence from the top of the XML file
- replace_block_by_include(xpath='./', filename='include.xml', occurrence=0)[source]#
General method for replacing a block by an include.
- Parameters:
xpath (str) – XPath of the tag
filename (str) – name of the include file
occurrence (int) – 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:
name (str) – parametername
parametertype (str) – parametertype
taglist (list[str] | None) – list of tags needed for parameter spec
textlist (list[str] | None) – values of parameter
- replace_parameter_value(name='', value=0, valuetag='value')[source]#
Replacing parameter values.
- Parameters:
name (str) – parametername
value (int) – value
parametertype – parameter type
valuetag (str) – name of the tag containing the value, e.g., values
- replace_phase_property_value(mediumid=0, phase='AqueousLiquid', component=None, name='', value=0, propertytype='Constant', valuetag='value')[source]#
Replaces properties in medium phases.
- Parameters:
mediumid (int) – id of the medium
phase (str) – name of the phase
component (str | None) – name of the component
name (str) – property name
value (int) – value
propertytype (str) – type of the property
valuetag (str) – name of the tag containing the value, e.g., values
- replace_medium_property_value(mediumid=0, name='', value=0, propertytype='Constant', valuetag='value')[source]#
Replaces properties in medium (not belonging to any phase).
- Parameters:
mediumid (int) – id of the medium
name (str) – property name
value (int) – value
propertytype (str) – type of the property
valuetag (str) – name of the tag containing the value, e.g., values
- 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_suffix (str) – suffix by which the output prefix is appended
t_initial (float | None) – first time step, takes the last from previous simulation if None
t_end (float | None) – last time step, the same as in previous run if None
zero_displacement (bool) – 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:
logfile (Path) – Name of the file to write STDOUT of ogs
path (Path | None) – 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 (Any | None) – additional arguments for the ogs executable
container_path (Path | str | None) – Path of the OGS container file.
wrapper (Any | None) – add a wrapper command. E.g. mpirun
write_logs (bool) – set False to omit logging
write_prj_to_pvd (bool) – write the prj file as a comment in the pvd
- write_input(prjfile_path=None, keep_includes=False)[source]#
Writes the projectfile to disk.
- Parameters:
prjfile_path (Path | None) – Path to write the project file to. If not specified, the initialised path is used.
keep_includes (bool)
Submodules#
- ogstools.ogs6py.build_tree module
- ogstools.ogs6py.curves module
- ogstools.ogs6py.display module
- ogstools.ogs6py.geo module
- ogstools.ogs6py.linsolvers module
- ogstools.ogs6py.local_coordinate_system module
- ogstools.ogs6py.media module
- ogstools.ogs6py.mesh module
- ogstools.ogs6py.nonlinsolvers module
- ogstools.ogs6py.parameters module
- ogstools.ogs6py.processes module
- ogstools.ogs6py.processvars module
- ogstools.ogs6py.project module
Project
Project.__init__()
Project.add_element()
Project.add_include()
Project.add_block()
Project.deactivate_property()
Project.deactivate_parameter()
Project.remove_element()
Project.replace_text()
Project.replace_block_by_include()
Project.replace_mesh()
Project.replace_parameter()
Project.replace_parameter_value()
Project.replace_phase_property_value()
Project.replace_medium_property_value()
Project.set()
Project.restart()
Project.run_model()
Project.write_input()
Project.property_dataframe()
Project.write_property_latextable()
- ogstools.ogs6py.properties module
- ogstools.ogs6py.python_script module
- ogstools.ogs6py.timeloop module