pyopmnearwell.utils.inputvalues module#

Read, validate, and initialize pyopmnearwell configuration values.

The module loads TOML input, applies defaults, validates full simulations and table-only configurations, reports ineffective values, checks expressions used by table generation, normalizes optional TUNING records, and derives grid and runtime values stored in the shared configuration dictionary.

process_input(dic, in_file)[source]#

Load, validate, and initialize the shared configuration dictionary.

Parameters:
  • dic (Any) -- Shared pyopmnearwell configuration dictionary.

  • in_file (Any) -- Path to the TOML configuration file.

Returns:

Result produced by the operation.

Return type:

Any

Raises:

SystemExit -- If the documented validation or operation fails.

process_tuning(dic)[source]#

Detect Flow TUNING support and normalize TUNING records in the injection schedule.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

_is_finite_number(value)[source]#

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

Parameters:

value (Any) -- Value used by the operation.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

_is_integer(value)[source]#

Return whether a value is a non-Boolean integer.

Parameters:

value (Any) -- Value used by the operation.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

_add_validation_error(errors, message)[source]#

Append a TOML validation message to the collected errors.

Parameters:
  • errors (list[str]) -- Validation messages collected so far.

  • message (str) -- Value used by the operation.

Return type:

None

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

Validate a non-empty TOML string.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • key (str) -- Name of the TOML variable.

  • errors (list[str]) -- Validation messages collected so far.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

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

Validate a finite TOML number and its optional lower bound.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • key (str) -- Name of the TOML variable.

  • errors (list[str]) -- Validation messages collected so far.

  • minimum (float | None, optional) -- Optional inclusive or exclusive lower bound.

  • strict (bool, optional) -- Whether minimum is an exclusive bound.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

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

Validate a numeric TOML array, its shape, and its entries.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • key (str) -- Name of the TOML variable.

  • errors (list[str]) -- Validation messages collected so far.

  • length (int | None, optional) -- Required array length.

  • integer (bool, optional) -- Whether every array entry must be an integer.

  • minimum (float | None, optional) -- Optional inclusive or exclusive lower bound.

  • strict (bool, optional) -- Whether minimum is an exclusive bound.

  • nonempty (bool, optional) -- Whether at least one array entry is required.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

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

Validate a saturation expression with a restricted Python AST.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • key (str) -- Name of the TOML variable.

  • errors (list[str]) -- Validation messages collected so far.

Return type:

None

_validate_rock(cfg_file, errors)[source]#

Validate rock-property records.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • errors (list[str]) -- Validation messages collected so far.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

_validate_safu(cfg_file, errors)[source]#

Validate saturation-function parameter records.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • errors (list[str]) -- Validation messages collected so far.

Return type:

None

_validate_injection(cfg_file, errors)[source]#

Validate injection schedule records and detect TUNING values.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • errors (list[str]) -- Validation messages collected so far.

Returns:

Whether at least one injection record defines TUNING values.

Return type:

bool

_validate_records(cfg_file, key, errors, columns, minimum=None)[source]#

Validate a non-empty matrix of fixed-width numeric records.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • key (str) -- Name of the TOML variable.

  • errors (list[str]) -- Validation messages collected so far.

  • columns (int) -- Required number of values in each record.

  • minimum (float | None, optional) -- Optional inclusive or exclusive lower bound.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

_validate_popevals(cfg_file, errors)[source]#

Validate porosity-permeability evaluation properties.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • errors (list[str]) -- Validation messages collected so far.

Return type:

None

_is_tuning_enabled(flow)[source]#

Return whether the Flow command enables TUNING.

Parameters:

flow (Any) -- OPM Flow command and command-line options.

Returns:

Whether the requested validation condition is satisfied.

Return type:

bool

_warn_ignored(cfg_file, keys, reason)[source]#

Warn about ineffective TOML variables and remove them.

Parameters:
  • cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

  • keys (set[str]) -- Candidate variables to warn about and remove.

  • reason (str) -- Explanation included in the warning.

Return type:

None

_validate_toml(cfg_file)[source]#

Validate and normalize all supported TOML configuration values.

Parameters:

cfg_file (dict[str, Any]) -- TOML values to validate or normalize.

Returns:

Whether the requested validation condition is satisfied.

Return type:

dict[str, Any]

Raises:

SystemExit -- If the documented validation or operation fails.