ogs5py.fileclasses.gem

Class for the ogs GEOCHEMICAL THERMODYNAMIC MODELING COUPLING file.

File Classes

GEM(**OGS_Config) Class for the ogs GEOCHEMICAL THERMODYNAMIC MODELING COUPLING file.
GEMinit([lst_name, dch, ipm, dbr, …]) Class for GEMS3K input file.

class GEM(**OGS_Config)[source]

Bases: ogs5py.fileclasses.base.BlockFile

Class for the ogs GEOCHEMICAL THERMODYNAMIC MODELING COUPLING file.

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”

Notes

Main-Keywords (#):
  • GEM_PROPERTIES
Sub-Keywords ($) per Main-Keyword:
  • GEM_PROPERTIES

    • CALCULATE_BOUNDARY_NODES
    • DISABLE_GEMS
    • FLAG_COUPLING_HYDROLOGY
    • FLAG_DISABLE_GEM
    • FLAG_POROSITY_CHANGE
    • GEM_CALCULATE_BOUNDARY_NODES
    • GEM_INIT_FILE
    • GEM_THREADS
    • ITERATIVE_SCHEME
    • KINETIC_GEM
    • MAX_FAILED_NODES
    • MAX_POROSITY
    • MIN_POROSITY
    • MY_SMART_GEMS
    • PRESSURE_GEM
    • TEMPERATURE_GEM
    • TRANSPORT_B
Standard block:
None
Keyword documentation:
https://ogs5-keywords.netlify.com/ogs/wiki/public/doc-auto/by_ext/gem
Reading routines:
https://github.com/ufz/ogs5/blob/master/FEM/rf_REACT_GEM.cpp#L2644

See also

add_block

Attributes:
block_no

Number of blocks in the file.

file_name

str: base name of the file with extension.

file_path

str: save path of the file.

force_writing

bool: state if the file is written even if empty.

is_empty

State if the OGS file is empty.

name

str: name of the file without extension.

Methods

add_block(self[, index, main_key]) Add a new Block to the actual file.
add_content(self, content[, main_index, …]) Add single-line content to the actual file.
add_copy_link(self, path[, symlink]) Add a link to copy a file instead of writing.
add_main_keyword(self, key[, main_index]) Add a new main keyword (#key) to the actual file.
add_multi_content(self, content[, …]) Add multiple content to the actual file.
add_sub_keyword(self, key[, main_index, …]) Add a new sub keyword ($key) to the actual file.
append_to_block(self[, index]) Append data to an existing Block in the actual file.
check(self[, verbose]) Check if the given file is valid.
del_block(self[, index, del_all]) Delete a block by its index.
del_content(self[, main_index, sub_index, …]) Delete content by its position.
del_copy_link(self) Remove a former given link to an external file.
del_main_keyword(self[, main_index, del_all]) Delete a main keyword (#key) by its position.
del_sub_keyword(self[, main_index, …]) Delete a sub keyword ($key) by its position.
get_block(self[, index, as_dict]) Get a Block from the actual file.
get_block_no(self) Get the number of blocks in the file.
get_file_type(self) Get the OGS file class name.
get_multi_keys(self[, index]) State if a block has a unique set of sub keywords.
is_block_unique(self[, index]) State if a block has a unique set of sub keywords.
read_file(self, path[, encoding, verbose]) Read an existing OGS input file.
reset(self) Delete every content.
save(self, path, \*\*kwargs) Save the actual OGS input file in the given path.
update_block(self[, index, main_key]) Update a Block from the actual file.
write_file(self) Write the actual OGS input file to the given folder.
add_block(self, index=None, main_key=None, **block)

Add a new Block to the actual file.

Keywords are the sub keywords of the actual file type:

#MAIN_KEY
$SUBKEY1
content1 …
$SUBKEY2
content2 …

which looks like the following:

FILE.add_block(SUBKEY1=content1, SUBKEY2=content2)

Parameters:
  • index (int or None, optional) – Positional index, where to insert the given Block. As default, it will be added at the end. Default: None.
  • main_key (string, optional) – Main keyword of the block that should be added (see: MKEYS) Default: the first main keyword of the file-type
  • **block (keyword dict) – here the dict-keywords are the ogs-subkeywords and the value is the content that should be added with this ogs-subkeyword If a block should contain content directly connected to a main keyword, use this main keyword as input-keyword and the content as value: SUBKEY=content
add_content(self, content, main_index=None, sub_index=None, line_index=None)

Add single-line content to the actual file.

Parameters:
  • content (list) – list containing one line of content given as a list of single statements
  • main_index (int, optional) – index of the corresponding main keyword where the sub keyword should be added. As default, the last main keyword is taken.
  • sub_index (int, optional) – index of the corresponding sub keyword where the content should be added. As default, the last sub keyword is taken.
  • line_index (int, optional) – position, where the new line of content should be added between the existing ones. As default, it is placed at the end.

Notes

There needs to be at least one main keyword, otherwise the content is not added.

If no sub keyword is present, a blank one (“”) will be added and the content is then directly connected to the actual main keyword.

Add a link to copy a file instead of writing.

Instead of writing a file, you can give a path to an existing file, that will be copied/linked to the target folder.

Parameters:
  • path (str) – path to the existing file that should be copied
  • symlink (bool, optional) – on UNIX systems it is possible to use a symbolic link to save time if the file is big. Default: False
add_main_keyword(self, key, main_index=None)

Add a new main keyword (#key) to the actual file.

Parameters:
  • key (string) – key name
  • main_index (int, optional) – position, where the new main keyword should be added between the existing ones. As default, it is placed at the end.
add_multi_content(self, content, main_index=None, sub_index=None)

Add multiple content to the actual file.

Parameters:
  • content (list) – list containing lines of content, each given as a list of single statements
  • main_index (int, optional) – index of the corresponding main keyword where the sub keyword should be added. As default, the last main keyword is taken.
  • sub_index (int, optional) – index of the corresponding sub keyword where the content should be added. As default, the last sub keyword is taken.

Notes

There needs to be at least one main keyword, otherwise the content is not added.

The content will be added at the end of the actual subkeyword.

If no sub keyword is present, a blank one (“”) will be added and the content is then directly connected to the actual main keyword.

add_sub_keyword(self, key, main_index=None, sub_index=None)

Add a new sub keyword ($key) to the actual file.

Parameters:
  • key (string) – key name
  • main_index (int, optional) – index of the corresponding main keyword where the sub keyword should be added. As default, the last main keyword is taken.
  • sub_index (int, optional) – position, where the new sub keyword should be added between the existing ones. As default, it is placed at the end.

Notes

There needs to be at least one main keyword, otherwise the subkeyword is not added.

append_to_block(self, index=None, **block)

Append data to an existing Block in the actual file.

Keywords are the sub keywords of the actual file type:

#MAIN_KEY
$SUBKEY1
content1 …
$SUBKEY2
content2 …

which looks like the following:

FILE.append_to_block(SUBKEY1=content1, SUBKEY2=content2)

Parameters:
  • index (int or None, optional) – Positional index, where to insert the given Block. As default, it will be added at the end. Default: None.
  • **block (keyword dict) – here the dict-keywords are the ogs-subkeywords and the value is the content that should be added with this ogs-subkeyword If a block should contain content directly connected to a main keyword, use this main keyword as input-keyword and the content as value: SUBKEY=content
check(self, verbose=True)

Check if the given file is valid.

Parameters:verbose (bool, optional) – Print information for the executed checks. Default: True
Returns:result – Validity of the given file.
Return type:bool
del_block(self, index=None, del_all=False)

Delete a block by its index.

Parameters:
  • index (int or None, optional) – Positional index of the block of interest. As default, the last one is returned. Default: None
  • del_all (bool, optional) – State, if all blocks shall be deleted. Default: False
del_content(self, main_index=-1, sub_index=-1, line_index=-1, del_all=False)

Delete content by its position.

Parameters:
  • main_index (int, optional) – index of the corresponding main keyword where the sub keyword should be deleted. As default, the last main keyword is taken.
  • sub_index (int, optional) – index of the corresponding sub keyword where the content should be deleted. As default, the last sub keyword is taken.
  • line_index (int, optional) – position of the content line, that should be deleted. Default: -1
  • del_all (bool, optional) – State, if all content shall be deleted. Default: False

Remove a former given link to an external file.

del_main_keyword(self, main_index=None, del_all=False)

Delete a main keyword (#key) by its position.

Parameters:
  • main_index (int, optional) – position, which main keyword should be deleted. Default: -1
  • del_all (bool, optional) – State, if all main keywords shall be deleted. Default: False
del_sub_keyword(self, main_index=-1, sub_index=-1, del_all=False)

Delete a sub keyword ($key) by its position.

Parameters:
  • main_index (int, optional) – index of the corresponding main keyword where the sub keyword should be deleted. As default, the last main keyword is taken.
  • pos (int, optional) – position, which sub keyword should be deleted. Default: -1
  • del_all (bool, optional) – State, if all sub keywords shall be deleted. Default: False
get_block(self, index=None, as_dict=True)

Get a Block from the actual file.

Parameters:
  • index (int or None, optional) – Positional index of the block of interest. As default, the last one is returned. Default: None
  • as_dict (bool, optional) – Here you can state of you want the output as a dictionary, which can be used as key-word-arguments for add_block. If False, you get the main-key, a list of sub-keys and a list of content. Default: True
get_block_no(self)

Get the number of blocks in the file.

get_file_type(self)

Get the OGS file class name.

get_multi_keys(self, index=None)

State if a block has a unique set of sub keywords.

is_block_unique(self, index=None)

State if a block has a unique set of sub keywords.

read_file(self, path, encoding=None, verbose=False)

Read an existing OGS input file.

Parameters:
  • path (str) – path to the existing file that should be read
  • encoding (str or None, optional) – encoding of the given file. If None is given, the system standard is used. Default: None
  • verbose (bool, optional) – Print information of the reading process. Default: False
reset(self)

Delete every content.

save(self, path, **kwargs)

Save the actual OGS input file in the given path.

Parameters:
  • path (str) – path to where to file should be saved
  • update (bool, optional) – state if the content should be updated before saving. Default: True
update_block(self, index=None, main_key=None, **block)

Update a Block from the actual file.

Parameters:
  • index (int or None, optional) – Positional index of the block of interest. As default, the last one is used. Default: None
  • main_key (string, optional) – Main keyword of the block that should be updated (see: MKEYS) This shouldn’t be done. Default: None
  • **block (keyword dict) – here the dict-keywords are the ogs-subkeywords and the value is the content that should be added with this ogs-subkeyword If a block should contain content directly connected to a main keyword, use this main keyword as input-keyword and the content as value: SUBKEY=content
write_file(self)

Write the actual OGS input file to the given folder.

Its path is given by “task_root+task_id+file_ext”.

MKEYS = ['GEM_PROPERTIES']
SKEYS = [['GEM_INIT_FILE', 'GEM_THREADS', 'TRANSPORT_B', 'FLAG_POROSITY_CHANGE', 'MIN_POROSITY', 'MAX_POROSITY', 'FLAG_COUPLING_HYDROLOGY', 'ITERATIVE_SCHEME', 'CALCULATE_BOUNDARY_NODES', 'TEMPERATURE_GEM', 'PRESSURE_GEM', 'MAX_FAILED_NODES', 'MY_SMART_GEMS', 'FLAG_DISABLE_GEM', 'KINETIC_GEM', 'DISABLE_GEMS', 'GEM_CALCULATE_BOUNDARY_NODES', 'GEM_SMART', 'FLAG_NODE_ELEMENT', 'FLAG_CALCULATE_BOUNDARY_NODE']]
STD = {}
block_no

Number of blocks in the file.

file_name

base name of the file with extension.

Type:str
file_path

save path of the file.

Type:str
force_writing

state if the file is written even if empty.

Type:bool
is_empty

State if the OGS file is empty.

name

name of the file without extension.

Type:str
class GEMinit(lst_name='model-dat.lst', dch=None, ipm=None, dbr=None, task_root=None, task_id='model')[source]

Bases: object

Class for GEMS3K input file.

lst file that contains the names of

  • the GEMS data file (dch file),
  • the GEMS numerical settings (ipm file)
  • the example setup (dbr file)

used to initialize the GEMS3K kernel.

Parameters:
  • lst_name (str or None, optional) – name of the lst file
  • dch (LineFile or None) – the GEMS data file
  • ipm (LineFile or None) – the GEMS data file
  • dbr (LineFile or None) – the GEMS data file
  • task_root (str, optional) – Path to the destiny model folder. Default: cwd+”ogs5model”
  • task_id (str, optional) – Name for the ogs task. Default: “model”
Attributes:
file_ext

The extension of the lst file.

file_names

The names of the included files.

files

List of the included files: dch, ipm, dbr.

is_empty

State if the file is empty.

name

The name of the lst file.

task_root

Get and set the task_root path of the ogs model.

Methods

check(self[, verbose]) Check if the GEM external file is valid.
get_file_type(self) Get the OGS file class name.
read_file(self, path[, encoding, verbose]) Read a given GEM external input lst-file.
reset(self) Delete every content.
save(self, path) Save the actual GEM external file in the given path.
write_file(self) Write the actual OGS input file to the given folder.
check(self, verbose=True)[source]

Check if the GEM external file is valid.

Parameters:verbose (bool, optional) – Print information for the executed checks. Default: True
Returns:result – Validity.
Return type:bool
get_file_type(self)[source]

Get the OGS file class name.

read_file(self, path, encoding=None, verbose=False)[source]

Read a given GEM external input lst-file.

Parameters:path (str) – path to the file

Notes

This also reads the given files in the lst-file. (dch, ipm, dbr)

reset(self)[source]

Delete every content.

save(self, path)[source]

Save the actual GEM external file in the given path.

lst file containing: dch, ipm, dbr

Parameters:path (str) – path to where to file should be saved
write_file(self)[source]

Write the actual OGS input file to the given folder.

Its path is given by “task_root+task_id+file_ext”.

file_ext

The extension of the lst file.

file_names

The names of the included files.

files

dch, ipm, dbr.

Type:List of the included files
is_empty

State if the file is empty.

name

The name of the lst file.

task_root

Get and set the task_root path of the ogs model.