ogs5py.fileclasses.MSP

class ogs5py.fileclasses.MSP(**OGS_Config)[source]

Bases: BlockFile

Class for the ogs SOLID_PROPERTIES 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 (#):
  • SOLID_PROPERTIES

Sub-Keywords ($) per Main-Keyword:
  • SOLID_PROPERTIES

    • BIOT_CONSTANT

    • CREEP

    • DENSITY

    • ELASTICITY

    • EXCAVATION

    • E_Function

    • GRAVITY_CONSTANT

    • MICRO_STRUCTURE_PLAS

    • NAME

    • NON_REACTIVE_FRACTION

    • PLASTICITY

    • REACTIVE_SYSTEM

    • SOLID_BULK_MODULUS

    • SPECIFIC_HEAT_SOURCE

    • STRESS_INTEGRATION_TOLERANCE

    • STRESS_UNIT

    • SWELLING_PRESSURE_TYPE

    • THERMAL

    • THRESHOLD_DEV_STR

    • TIME_DEPENDENT_YOUNGS_POISSON

Standard block:

None

Keyword documentation:

https://ogs5-keywords.netlify.com/ogs/wiki/public/doc-auto/by_ext/msp

Reading routines:

https://github.com/ufz/ogs5/blob/master/FEM/rf_msp_new.cpp#L65

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([index, main_key])

Add a new Block to the actual file.

add_content(content[, main_index, ...])

Add single-line content to the actual file.

add_copy_link(path[, symlink])

Add a link to copy a file instead of writing.

add_main_keyword(key[, main_index])

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

add_multi_content(content[, main_index, ...])

Add multiple content to the actual file.

add_sub_keyword(key[, main_index, sub_index])

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

append_to_block([index])

Append data to an existing Block in the actual file.

check([verbose])

Check if the given file is valid.

del_block([index, del_all])

Delete a block by its index.

del_content([main_index, sub_index, ...])

Delete content by its position.

del_copy_link()

Remove a former given link to an external file.

del_main_keyword([main_index, del_all])

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

del_sub_keyword([main_index, sub_index, del_all])

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

get_block([index, as_dict])

Get a Block from the actual file.

get_block_no()

Get the number of blocks in the file.

get_file_type()

Get the OGS file class name.

get_multi_keys([index])

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

is_block_unique([index])

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

read_file(path[, encoding, verbose])

Read an existing OGS input file.

reset()

Delete every content.

save(path, **kwargs)

Save the actual OGS input file in the given path.

update_block([index, main_key])

Update a Block from the actual file.

write_file()

Write the actual OGS input file to the given folder.

add_block(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(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(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(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(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(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(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(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(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(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(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(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()

Get the number of blocks in the file.

get_file_type()

Get the OGS file class name.

get_multi_keys(index=None)

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

is_block_unique(index=None)

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

read_file(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()

Delete every content.

save(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(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()

Write the actual OGS input file to the given folder.

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

MKEYS = ['SOLID_PROPERTIES']

Main Keywords of this OGS-BlockFile

Type:

list

SKEYS = [['NAME', 'SWELLING_PRESSURE_TYPE', 'DENSITY', 'THERMAL', 'ELASTICITY', 'EXCAVATION', 'E_Function', 'TIME_DEPENDENT_YOUNGS_POISSON', 'CREEP', 'THRESHOLD_DEV_STR', 'BIOT_CONSTANT', 'SOLID_BULK_MODULUS', 'STRESS_INTEGRATION_TOLERANCE', 'STRESS_UNIT', 'GRAVITY_CONSTANT', 'GRAVITY_RAMP', 'PLASTICITY', 'REACTIVE_SYSTEM', 'NON_REACTIVE_FRACTION', 'SPECIFIC_HEAT_SOURCE', 'ENTHALPY_CORRECTION_REFERENCE_TEMPERATURE', 'MICRO_STRUCTURE_PLAS']]

Sub Keywords of this OGS-BlockFile

Type:

list

STD = {}

Standard Block OGS-BlockFile

Type:

dict

property block_no

Number of blocks in the file.

property file_name

base name of the file with extension.

Type:

str

property file_path

save path of the file.

Type:

str

property force_writing

state if the file is written even if empty.

Type:

bool

property is_empty

State if the OGS file is empty.

property name

name of the file without extension.

Type:

str