pyopmspe11.utils.inputvalues module#

Read, validate, and initialize pyopmspe11 configuration values.

The module loads TOML or legacy text input, validates types and case-dependent requirements, converts physical units, and derives grid dimensions, benchmark regions, sensor locations, and other runtime settings stored in Config.

build_config(cli)[source]#

Build the shared runtime configuration.

Read the selected TOML or legacy text file, merge command-line selections, validate values, and derive case-dependent settings.

Parameters:
cliargparse.Namespace

Parsed command-line arguments.

Returns:
Config

Initialized runtime configuration.

Raises:
SystemExit

If an input value is invalid or required input cannot be used.

Parameters:

cli (Namespace)

Return type:

Config

_parse_legacy_config(lines)[source]#

Parse the legacy text configuration format.

Parameters:
lineslist

Rows read from a legacy configuration file.

Returns:
dict[str, Any]

Configuration values parsed from the legacy text input.

Parameters:

lines (list)

Return type:

dict

_finalize_config(cfg, time, msg)[source]#

Convert units and populate derived configuration values.

The function derives grid dimensions, transforms depth coordinates, normalizes physical properties, and separates optional TUNING values.

Parameters:
cfgConfig

Initialized runtime configuration.

timefloat

Case-dependent time conversion factor.

msgstr

Error message used for invalid injection settings.

Parameters:
Return type:

None

_set_case_properties(cfg)[source]#

Set case-dependent time scales, boxes, and sensor coordinates.

Parameters:
cfgConfig

Initialized runtime configuration.

Returns:
float

Calculated scalar value.

Parameters:

cfg (Config)

Return type:

float

check_flow_version(cfg)[source]#

Check that the configured OPM Flow release is supported.

Parameters:
cfgConfig

Initialized runtime configuration.

Raises:
SystemExit

If an input value is invalid or required input cannot be used.

Parameters:

cfg (Config)

Return type:

None

_is_finite_number(value)[source]#

Return whether a value is a finite non-Boolean number.

Parameters:
valueAny

Value to inspect.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:

value (Any)

Return type:

bool

_is_integer(value)[source]#

Return whether a value is a non-Boolean integer.

Parameters:
valueAny

Value to inspect.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:

value (Any)

Return type:

bool

_add_validation_error(errors, message)[source]#

Add a TOML validation error.

Parameters:
errorslist[str]

Validation messages collected so far.

messagestr

Validation message to append.

Parameters:
Return type:

None

_validate_string(cfg_file, key, errors)[source]#

Check that a TOML variable is a non-empty string.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:
Return type:

bool

_validate_number(cfg_file, key, errors, minimum=None, strict=False)[source]#

Check that a TOML variable is a finite number in the expected range.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

minimumfloat | None, optional

Optional lower bound for accepted values.

strictbool, optional

Whether the lower bound is exclusive.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:
Return type:

bool

_validate_array(cfg_file, key, errors, length=None, integer=False, minimum=None, strict=False, nonempty=False)[source]#

Check the type, length, and values of a TOML array.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

lengthint | None, optional

Required array length, if specified.

integerbool, optional

Whether every array entry must be an integer.

minimumfloat | None, optional

Optional lower bound for accepted values.

strictbool, optional

Whether the lower bound is exclusive.

nonemptybool, optional

Whether the array must contain at least one entry.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:
Return type:

bool

_validate_matrix(cfg_file, key, errors, rows, columns)[source]#

Check the dimensions and numeric values of a TOML matrix.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

rowsint

Required number of matrix rows.

columnsint

Required number of matrix columns.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:
Return type:

bool

_validate_coordinates(cfg_file, key, errors)[source]#

Check that well coordinates are inside the model dimensions.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

Parameters:
Return type:

None

_validate_expression(cfg_file, key, errors)[source]#

Check that a TOML variable contains a valid Python expression.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

keystr

Name of the TOML variable.

errorslist[str]

Validation messages collected so far.

Parameters:
Return type:

None

_validate_saturation_properties(cfg_file, errors)[source]#

Check saturation-function properties.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

errorslist[str]

Validation messages collected so far.

Parameters:
Return type:

None

_validate_rock_properties(cfg_file, errors)[source]#

Check rock properties.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

errorslist[str]

Validation messages collected so far.

Parameters:
Return type:

None

_validate_injection_schedule(cfg_file, errors)[source]#

Check injection values and return whether TUNING values are defined.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

errorslist[str]

Validation messages collected so far.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:
Return type:

bool

_validate_drsdtcon(cfg_file, errors)[source]#

Check convective-dissolution properties.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

errorslist[str]

Validation messages collected so far.

Parameters:
Return type:

None

_is_tuning_enabled(flow)[source]#

Return whether TUNING is enabled in the Flow command.

Parameters:
flowAny

Flow.

Returns:
bool

Whether the requested condition is satisfied.

Parameters:

flow (Any)

Return type:

bool

_validate_toml(cfg_file)[source]#

Validate and normalize TOML configuration values.

The function checks required and case-dependent variables, removes ignored values, reports all validation failures together, and returns values suitable for Config.

Parameters:
cfg_filedict[str, Any]

TOML values to validate or normalize.

Returns:
dict[str, Any]

Validated configuration values.

Raises:
SystemExit

If an input value is invalid or required input cannot be used.

Parameters:

cfg_file (dict[str, Any])

Return type:

dict[str, Any]