ogs5py.OGS

class ogs5py.OGS(task_root=None, task_id='model', output_dir=None)[source]

Bases: object

Class for an OGS5 model.

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

Parameters:
  • task_root (str, optional) – Path to the destiny model folder. Default: cwd+”ogs5model”

  • task_id (str, optional) – Name for the ogs task. Default: “model”

  • output_dir (str or None, optional) – Path to the output directory. Default: None

Notes

The following Classes are present as attributes
bcBoundary Condition

Information of the Boundary Conditions for the model.

cctCommunication Table

Information of the Communication Table for the model.

fctFunction

Information of the Function definitions for the model.

gemgeochemical thermodynamic modeling coupling

Information of the geochemical thermodynamic modeling coupling for the model.

gliGeometry

Information of the Geometry for the model.

icInitial Condition

Information of the Initial Conditions for the model.

krcKinetric Reaction

Information of the Kinetric Reaction for the model.

mcpreactive components for modelling chemical processes

Information of the reactive components for modelling chemical processes for the model.

mfpFluid Properties

Information of the Fluid Properties for the model.

mmpMedium Properties

Information of the Medium Properties for the model.

mshMesh

Information of the Mesh for the model.

mspSolid Properties

Information of the Solid Properties for the model.

numSettings for the numerical solver

Information of the numerical solver for the model.

outOutput Settings

Information of the Output Settings for the model.

pcsProcess settings

Information of the Process settings for the model.

pctParticle Definition for Random walk

Information of the Particles defined for Randomwalk setting.

pqcPhreqqc coupling (not supported yet)

Information of the Boundary Conditions for the model.

pqcdatPhreqqc coupling (the phreeqc.dat file)

phreeqc.dat file for the model. (just a line-wise file with no comfort)

reiReaction Interface

Information of the Reaction Interface for the model.

rfddefinition of time-curves for variing BCs or STs

Information of the time curves for the model.

stSource Term

Information of the Source Term for the model.

timTime settings

Information of the Time settings for the model.

Additional
mpdDistributed Properties (list of files)

Information of the Distributed Properties for the model.

gli_extlist for external Geometry definition

External definition of surfaces (TIN) or polylines (POINT_VECTOR)

rfrlist of restart files

RESTART files as defined in the INITIAL_CONDITION

gem_initlist of GEMS3K input files (lst file)

given as GEMinit classes

asclist of ogs ASC files

This file type comes either from .tim .pcs or .gem

copy_fileslist of path-strings

Files that should be copied to the destiny folder.

Attributes:
bot_com

Get and set the bottom comment for the ogs files.

has_output_dir

bool: State if the model has a output directory.

output_dir

str: output directory path of the ogs model.

task_id

str: task_id (name) of the ogs model.

task_root

Get and set the task_root path of the ogs model.

top_com

Get and set the top comment for the ogs files.

Methods

add_asc(asc_file)

Method to add a ASC file.

add_copy_file(path)

Method to add an arbitrary file that should be copied.

add_gem_init(gem_init_file)

Method to add a GEMS3K input file.

add_gli_ext(gli_ext_file)

Method to add an external Geometry definition file to the model.

add_mpd(mpd_file)

Method to add an ogs MEDIUM_PROPERTIES_DISTRIBUTED file to the model.

add_rfr(rfr_file)

Method to add an ogs RESTART file to the model.

del_asc([index])

Method to delete a ASC file.

del_copy_file([index])

Method to delete a copy-file.

del_gem_init([index])

Method to delete GEMS3K input file.

del_gli_ext([index])

Method to delete external Geometry file.

del_mpd([index])

Method to delete MEDIUM_PROPERTIES_DISTRIBUTED file.

del_rfr([index])

Method to delete RESTART file.

gen_script([script_dir, script_name, ...])

Generate a python script for the given model.

load_model(task_root[, task_id, ...])

Load an existing OGS5 model.

output_files([pcs, typ, element, output_dir])

Get a list of output file paths.

readpvd([pcs, output_dir])

Read the paraview pvd files of this OGS5 model.

readtec_point([pcs, output_dir])

Collect TECPLOT point output from this OGS5 model.

readtec_polyline([pcs, trim, output_dir])

Collect TECPLOT polyline output from this OGS5 model.

readvtk([pcs, output_dir])

Reader for vtk outputfiles of this OGS5 model.

reset()

Delete every content.

run_model([ogs_exe, ogs_name, print_log, ...])

Run the defined OGS5 model.

write_input()

Method to call all write_file() methods that are initialized.

add_asc(asc_file)[source]

Method to add a ASC file.

See ogs5py.ASC for further information

add_copy_file(path)[source]

Method to add an arbitrary file that should be copied.

The base-name of the file will be keept and it will be copied to the task-root when the “write” routine is called.

add_gem_init(gem_init_file)[source]

Method to add a GEMS3K input file.

This is usually generated by GEM-SELEKTOR.

See ogs5py.GEM and ogs5py.GEMinit for further information

add_gli_ext(gli_ext_file)[source]

Method to add an external Geometry definition file to the model.

This is used for TIN definition in SURFACE or POINT_VECTOR definition in POLYLINE in the GLI file.

See ogs5py.GLI for further information

add_mpd(mpd_file)[source]

Method to add an ogs MEDIUM_PROPERTIES_DISTRIBUTED file to the model.

This is used for disributed information in the MMP file.

See ogs5py.MPD for further information

add_rfr(rfr_file)[source]

Method to add an ogs RESTART file to the model.

This is used for disributed information in the IC file.

See ogs5py.IC for further information

del_asc(index=None)[source]

Method to delete a ASC file.

Parameters:

index (int or None, optional) – The index of the ASC file that should be deleted. If None, all ASC files are deleted. Default: None

del_copy_file(index=None)[source]

Method to delete a copy-file.

Parameters:

index (int or None, optional) – The index of the copy-file that should be deleted. If None, all copy-files are deleted. Default: None

del_gem_init(index=None)[source]

Method to delete GEMS3K input file.

Parameters:

index (int or None, optional) – The index of the GEMS3K file that should be deleted. If None, all GEMS3K files are deleted. Default: None

del_gli_ext(index=None)[source]

Method to delete external Geometry file.

Parameters:

index (int or None, optional) – The index of the external gli file that should be deleted. If None, all external gli files are deleted. Default: None

del_mpd(index=None)[source]

Method to delete MEDIUM_PROPERTIES_DISTRIBUTED file.

Parameters:

index (int or None, optional) – The index of the mpd-file that should be deleted. If None, all mpd-files are deleted. Default: None

del_rfr(index=None)[source]

Method to delete RESTART file.

Parameters:

index (int or None, optional) – The index of the RESTART file that should be deleted. If None, all RESTART files are deleted. Default: None

gen_script(script_dir='/home/docs/checkouts/readthedocs.org/user_builds/ogs5py/checkouts/latest/docs/source/ogs_script', script_name='model.py', ogs_cls_name='model', task_root=None, task_id=None, output_dir=None, separate_files=None)[source]

Generate a python script for the given model.

Parameters:
  • script_dir (str) – target directory for the script

  • script_name (str) – name for the script file (including .py ending)

  • ogs_cls_name (str) – name of the model in the script

  • task_root (str) – used task_root in the script

  • task_id (str) – used task_id in the script

  • output_dir (str) – used output_dir in the script

  • separate_files (list of str or None) – list of files, that should be written to separate files and then loaded from the script

Notes

This will only create BlockFiles from the script. GLI and MSH files as well as every other file are stored separately.

load_model(task_root, task_id=None, use_task_root=False, use_task_id=False, skip_files=None, skip_ext=None, encoding=None, verbose=False, search_ext=None)[source]

Load an existing OGS5 model.

Parameters:
  • task_root (str) – Path to the destiny folder.

  • task_id (str or None, optional) – Task ID of the model to load. If None is given, it will be determind by the found files. If multiple possible task_ids were found, the first one in alphabetic order will be used. Default: None

  • use_task_root (Bool, optional) – State if the given task_root should be used for this model. Default: False

  • use_task_id (Bool, optional) – State if the given task_id should be used for this model. Default: False

  • skip_files (list or None, optional) – List of file-names, that should not be read. Default: None

  • skip_ext (list or None, optional) – List of file-extensions, that should not be read. Default: None

  • encoding (str or None, optional) – encoding of the given files. If None is given, the system standard is used. Default: None

  • verbose (bool, optional) – Print information of the reading process. Default: False

  • search_ext (str) – OGS extension that should be searched for. Default: “.pcs”

Notes

This method will search for all known OGS5 file-extensions in the given path (task_root). Additional files from:

  • GLI (POINT_VECTOR + TIN)

  • MMP (distributed media properties)

  • IC (RESTART)

  • GEM (GEM3SK init file)

will be read automatically.

If you get an UnicodeDecodeError try loading with:

encoding="ISO-8859-15"

output_files(pcs=None, typ='VTK', element=None, output_dir=None)[source]

Get a list of output file paths.

Parameters:
  • pcs (string or None, optional) – specify the PCS type that should be collected Possible values are:

    • None/”” (no PCS_TYPE specified in *.out)

    • “NO_PCS”

    • “GROUNDWATER_FLOW”

    • “LIQUID_FLOW”

    • “RICHARDS_FLOW”

    • “AIR_FLOW”

    • “MULTI_PHASE_FLOW”

    • “PS_GLOBAL”

    • “HEAT_TRANSPORT”

    • “DEFORMATION”

    • “MASS_TRANSPORT”

    • “OVERLAND_FLOW”

    • “FLUID_MOMENTUM”

    • “RANDOM_WALK”

    Default : None

  • typ (string, optional) – Type of the output (“VTK”, “PVD”, “TEC_POINT” or “TEC_POLYLINE”). Default : “VTK”

  • element (string or None, optional) – For tecplot output you can specify the name of the output element. (Point-name of Line-name from GLI file) Default: None

readpvd(pcs='ALL', output_dir=None)[source]

Read the paraview pvd files of this OGS5 model.

All concerned files are converted to a dictionary containing their data

Parameters:
  • pcs (string or None, optional) – specify the PCS type that should be collected Possible values are:

    • None/”” (no PCS_TYPE specified in *.out)

    • “NO_PCS”

    • “GROUNDWATER_FLOW”

    • “LIQUID_FLOW”

    • “RICHARDS_FLOW”

    • “AIR_FLOW”

    • “MULTI_PHASE_FLOW”

    • “PS_GLOBAL”

    • “HEAT_TRANSPORT”

    • “DEFORMATION”

    • “MASS_TRANSPORT”

    • “OVERLAND_FLOW”

    • “FLUID_MOMENTUM”

    • “RANDOM_WALK”

    You can get a list with all known PCS-types by setting PCS=”ALL” Default : “ALL”

  • output_dir (:any:’None’ or :class:’str’, optional) – Sometimes OGS5 doesn’t put the output in the right directory. You can specify a separate output directory here in this case. Default: :any:’None’

Returns:

result – keys are the point names and the items are the data from the corresponding files if pcs=”ALL”, the output is a dictionary with the PCS-types as keys

Return type:

dict

readtec_point(pcs='ALL', output_dir=None)[source]

Collect TECPLOT point output from this OGS5 model.

Parameters:
  • pcs (string or None, optional) – specify the PCS type that should be collected Possible values are:

    • None/”” (no PCS_TYPE specified in *.out)

    • “NO_PCS”

    • “GROUNDWATER_FLOW”

    • “LIQUID_FLOW”

    • “RICHARDS_FLOW”

    • “AIR_FLOW”

    • “MULTI_PHASE_FLOW”

    • “PS_GLOBAL”

    • “HEAT_TRANSPORT”

    • “DEFORMATION”

    • “MASS_TRANSPORT”

    • “OVERLAND_FLOW”

    • “FLUID_MOMENTUM”

    • “RANDOM_WALK”

    You can get a list with all known PCS-types by setting PCS=”ALL” Default : “ALL”

  • output_dir (:any:’None’ or :class:’str’, optional) – Sometimes OGS5 doesn’t put the output in the right directory. You can specify a separate output directory here in this case. Default: :any:’None’

Returns:

result – Keys are the point names and the items are the data from the corresponding files. If pcs=”ALL”, the output is a dictionary with the PCS-types as keys.

Return type:

dict

readtec_polyline(pcs='ALL', trim=True, output_dir=None)[source]

Collect TECPLOT polyline output from this OGS5 model.

Parameters:
  • pcs (string or None, optional) – specify the PCS type that should be collected Possible values are:

    • None/”” (no PCS_TYPE specified in *.out)

    • “NO_PCS”

    • “GROUNDWATER_FLOW”

    • “LIQUID_FLOW”

    • “RICHARDS_FLOW”

    • “AIR_FLOW”

    • “MULTI_PHASE_FLOW”

    • “PS_GLOBAL”

    • “HEAT_TRANSPORT”

    • “DEFORMATION”

    • “MASS_TRANSPORT”

    • “OVERLAND_FLOW”

    • “FLUID_MOMENTUM”

    • “RANDOM_WALK”

    You can get a list with all known PCS-types by setting pcs=”ALL” Default : “ALL”

  • output_dir (:any:’None’ or :class:’str’, optional) – Sometimes OGS5 doesn’t put the output in the right directory. You can specify a separate output directory here in this case. Default: :any:’None’

  • trim (Bool, optional) – if the ply_ids are not continuous, there will be “None” values in the output list. If trim is “True” these values will be eliminated. If there is just one output for a polyline, the list will be eliminated and the output will be the single dict. Default : True

Returns:

result – keys are the Polyline names and the items are lists sorted by the ply_id (it is assumed, that the ply_ids are continuous, if not, the corresponding list entries are “None”) if pcs=”ALL”, the output is a dictionary with the PCS-types as keys

Return type:

dict

readvtk(pcs='ALL', output_dir=None)[source]

Reader for vtk outputfiles of this OGS5 model.

Parameters:
  • pcs (string or None, optional) – specify the PCS type that should be collected Possible values are:

    • None/”” (no PCS_TYPE specified in *.out)

    • “NO_PCS”

    • “GROUNDWATER_FLOW”

    • “LIQUID_FLOW”

    • “RICHARDS_FLOW”

    • “AIR_FLOW”

    • “MULTI_PHASE_FLOW”

    • “PS_GLOBAL”

    • “HEAT_TRANSPORT”

    • “DEFORMATION”

    • “MASS_TRANSPORT”

    • “OVERLAND_FLOW”

    • “FLUID_MOMENTUM”

    • “RANDOM_WALK”

    You can get a list with all known PCS-types by setting PCS=”ALL” Default : None

  • output_dir (:any:’None’ or :class:’str’, optional) – Sometimes OGS5 doesn’t put the output in the right directory. You can specify a separate output directory here in this case. Default: :any:’None’

Returns:

result – keys are the point names and the items are the data from the corresponding files if pcs=”ALL”, the output is a dictionary with the PCS-types as keys

Return type:

dict

reset()[source]

Delete every content.

run_model(ogs_exe=None, ogs_name='ogs', print_log=True, save_log=True, log_path=None, log_name=None, timeout=None)[source]

Run the defined OGS5 model.

Parameters:
  • ogs_exe (str or None, optional) – path to the ogs executable. If None is given, the default sys path will be searched with which. Can be a folder containing the exe with basename: ogs_name. It will first look in the OGS5PY_CONFIG folder. Default: None

  • ogs_name (str or None, optional) – Name of to the ogs executable to search for. Just used if ,ogs_exe is None. Default: "ogs"

  • print_log (bool, optional) – state if the ogs output should be displayed in the terminal. Default: True

  • save_log (bool, optional) – state if the ogs output should be saved to a file. Default: True

  • log_path (str or None, optional) – Path, where the log file should be saved. Default: None (the defined output directory or the task_root directory)

  • log_name (str or None, optional) – Name of the log file. Default: None (task_id+time+”_log.txt”)

  • timeout (int or None, optional) – Time to wait for OGS5 to finish in seconds. Default: None

Returns:

success – State if OGS5 terminated ‘normally’. (Allways true on Windows.)

Return type:

bool

write_input()[source]

Method to call all write_file() methods that are initialized.

property bot_com

Get and set the bottom comment for the ogs files.

property has_output_dir

State if the model has a output directory.

Type:

bool

property output_dir

output directory path of the ogs model.

Type:

str

property task_id

task_id (name) of the ogs model.

Type:

str

property task_root

Get and set the task_root path of the ogs model.

property top_com

Get and set the top comment for the ogs files.