ogs5py.ogs

Base Class for an OGS5 run.

OGS Class

OGS([task_root, task_id, output_dir]) Class for an OGS5 model.

class 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
bc : Boundary Condition
Information of the Boundary Conditions for the model.
cct : Communication Table
Information of the Communication Table for the model.
fct : Function
Information of the Function definitions for the model.
gem : geochemical thermodynamic modeling coupling
Information of the geochemical thermodynamic modeling coupling for the model.
gli : Geometry
Information of the Geometry for the model.
ic : Initial Condition
Information of the Initial Conditions for the model.
krc : Kinetric Reaction
Information of the Kinetric Reaction for the model.
mcp : reactive components for modelling chemical processes
Information of the reactive components for modelling chemical processes for the model.
mfp : Fluid Properties
Information of the Fluid Properties for the model.
mmp : Medium Properties
Information of the Medium Properties for the model.
msh : Mesh
Information of the Mesh for the model.
msp : Solid Properties
Information of the Solid Properties for the model.
num : Settings for the numerical solver
Information of the numerical solver for the model.
out : Output Settings
Information of the Output Settings for the model.
pcs : Process settings
Information of the Process settings for the model.
pct : Particle Definition for Random walk
Information of the Particles defined for Randomwalk setting.
pqc : Phreqqc coupling (not supported yet)
Information of the Boundary Conditions for the model.
pqcdat : Phreqqc coupling (the phreeqc.dat file)
phreeqc.dat file for the model. (just a line-wise file with no comfort)
rei : Reaction Interface
Information of the Reaction Interface for the model.
rfd : definition of time-curves for variing BCs or STs
Information of the time curves for the model.
st : Source Term
Information of the Source Term for the model.
tim : Time settings
Information of the Time settings for the model.
Additional
mpd : Distributed Properties (list of files)
Information of the Distributed Properties for the model.
gli_ext : list for external Geometry definition
External definition of surfaces (TIN) or polylines (POINT_VECTOR)
rfr : list of restart files
RESTART files as defined in the INITIAL_CONDITION
gem_init : list of GEMS3K input files (lst file)
given as GEMinit classes
asc : list of ogs ASC files
This file type comes either from .tim .pcs or .gem
copy_files : list 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(self, asc_file) Method to add a ASC file.
add_copy_file(self, path) Method to add an arbitrary file that should be copied.
add_gem_init(self, gem_init_file) Method to add a GEMS3K input file.
add_gli_ext(self, gli_ext_file) Method to add an external Geometry definition file to the model.
add_mpd(self, mpd_file) Method to add an ogs MEDIUM_PROPERTIES_DISTRIBUTED file to the model.
add_rfr(self, rfr_file) Method to add an ogs RESTART file to the model.
del_asc(self[, index]) Method to delete a ASC file.
del_copy_file(self[, index]) Method to delete a copy-file.
del_gem_init(self[, index]) Method to delete GEMS3K input file.
del_gli_ext(self[, index]) Method to delete external Geometry file.
del_mpd(self[, index]) Method to delete MEDIUM_PROPERTIES_DISTRIBUTED file.
del_rfr(self[, index]) Method to delete RESTART file.
gen_script(self[, script_dir, script_name, …]) Generate a python script for the given model.
load_model(self, task_root[, task_id, …]) Load an existing OGS5 model.
output_files(self[, pcs, typ, element, …]) Get a list of output file paths.
readpvd(self[, pcs, output_dir]) Read the paraview pvd files of this OGS5 model.
readtec_point(self[, pcs, output_dir]) Collect TECPLOT point output from this OGS5 model.
readtec_polyline(self[, pcs, trim, output_dir]) Collect TECPLOT polyline output from this OGS5 model.
readvtk(self[, pcs, output_dir]) Reader for vtk outputfiles of this OGS5 model.
reset(self) Delete every content.
run_model(self[, ogs_exe, ogs_name, …]) Run the defined OGS5 model.
write_input(self) Method to call all write_file() methods that are initialized.
add_asc(self, asc_file)[source]

Method to add a ASC file.

See ogs5py.ASC for further information

add_copy_file(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, script_dir='/home/docs/checkouts/readthedocs.org/user_builds/ogs5py/checkouts/stable/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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self)[source]

Delete every content.

run_model(self, 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(self)[source]

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

bot_com

Get and set the bottom comment for the ogs files.

has_output_dir

State if the model has a output directory.

Type:bool
output_dir

output directory path of the ogs model.

Type:str
task_id

task_id (name) of the ogs model.

Type:str
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.