pycopm.core.pycopm module#

Command-line entry point and top-level workflow coordination for pycopm.

pycopm supports two input workflows:

  • OPM .DATA decks can be coarsened, refined, transformed, or reduced to a submodel.

  • TOML configurations generate coarsened Norne or Drogon cases and can optionally run OPM Flow or ERT studies.

This module parses and validates command-line arguments, selects the appropriate workflow, and coordinates its major processing steps. The numerical and file-generation details are implemented in the utility modules.

main(argv=None)[source]#

Run the deck-based or TOML-based pycopm workflow.

OPM .DATA decks can be coarsened, refined, transformed, or reduced to a submodel. TOML configurations generate coarsened Norne or Drogon cases and can optionally run OPM Flow or ERT studies.

Parameters:
argv

Command-line arguments. If omitted, arguments are read from sys.argv.

Other Parameters:
-i, --input_deck_path

Input .DATA deck or TOML configuration file.

-o, --output_directory

Directory for generated decks, include files, and simulation results.

-f, --flow_command

Command or path used to run OPM Flow.

-m, --execution_mode

Deck-processing stages to run: prep, deck, dry, prep_deck, deck_dry, or all.

-v, --vicinity_specification

Submodel selection based on region values, an xy polygon, or a well-centred box, diamond, or diamondxy neighbourhood.

-c, --coarsening

Uniform coarsening factors in the x, y, and z directions.

-x, --x_coarsening

Cell-specific coarsening specification along the x axis.

-y, --y_coarsening

Cell-specific coarsening specification along the y axis.

-z, --z_coarsening

Cell-specific coarsening specification along the z axis.

-g, --refinement

Uniform numbers of additional cells along the x, y, and z axes.

-rx, --x_refinement

Number of additional cells for each original x interval.

-ry, --y_refinement

Number of additional cells for each original y interval.

-rz, --z_refinement

Number of additional cells for each original z interval.

-a, --active_cell_methods

Aggregation method for active-cell values: min, max, or mode.

-n, --discrete_aggregation_method

Aggregation method for discrete properties: min, max, or mode.

-s, --continuous_aggregation_method

Aggregation method for continuous properties: min, max, mean, or pore-volume-weighted mean (pvmean). If omitted, property-specific physical aggregation is used.

-p, --pore_volume_correction

Pore-volume correction method. The available values are 0 through 4; supported methods depend on the selected workflow.

-q, --correct_fluid_in_place

Set to 1 to adjust pore volume to match the initial oil and gas in place of the input model.

-t, --transmissibility_coarsening_method

Transmissibility coarsening method: 0, 1, or 2.

-r, --completion_removal_level

Level of COMPDAT data removed after coarsening: 0, 1, or 2.

-j, --jump_thresholds

Positive depth-jump thresholds used to prevent unwanted connections between cells grouped during coarsening.

-w, --output_deck_name

Name of the generated OPM deck.

-l, --include_prefix

Prefix added to generated include filenames.

-e, --deck_encoding

Character encoding used to read the input deck: ISO-8859-1 or utf8.

-ijk, --requested_ijk

One-based input-grid i,j,k indices to map to the modified grid.

-d, --grid_transformation

Coordinate transformation: translate [x,y,z], scale [x,y,z], or rotatexy, rotatexz, or rotateyz followed by an angle in degrees.

-explicit, --write_explicit_solution

Set to 1 to write initial solution properties explicitly instead of retaining EQUIL initialization.

-dual, --dual_porosity_criterion

Static-property criterion used to separate matrix and fracture or non-net cells during coarsening.

-precision, --significant_digits

Number of significant digits used when writing floating-point values. Set to 0 to preserve machine precision.

Parameters:

argv (list[str] | None)

Return type:

None

_parse_arguments(argv=None)[source]#

Parse supported command-line arguments.

Unknown arguments are left unprocessed for compatibility with external launchers.

Parameters:
argv

Command-line arguments. If omitted, arguments are read from sys.argv.

Returns:
dict[str, str]

Arguments keyed by their destination names.

Parameters:

argv (list[str] | None)

Return type:

Namespace

_check_cmdargs(cmdargs)[source]#

Validate command-line arguments and incompatible operations.

The checks cover input type, Flow availability, coarsening and refinement syntax, aggregation methods, vicinity selections, transformations, and options restricted to particular workflows.

Parameters:
cmdargs

Parsed arguments returned by _parse_arguments().

Raises:
SystemExit

If an argument is invalid or an incompatible combination is requested.

Parameters:

cmdargs (Namespace)

Return type:

None

_check_flow(flow_cmdargs, flow_toml, input_file)[source]#

Select an available OPM Flow command for a TOML workflow.

Parameters:
flow_cmdargs

Flow command supplied through the command line.

flow_toml

Flow command read from the TOML configuration.

input_file

TOML filename used in validation messages.

Returns:
str

The selected Flow command.

Raises:
SystemExit

If neither command identifies a working Flow executable.

Parameters:
  • flow_cmdargs (str)

  • flow_toml (str)

  • input_file (str)

Return type:

str