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.

pycopm.core.pycopm._check_cmdargs(cmdargs: dict[str, str]) None

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.

pycopm.core.pycopm._check_flow(flow_cmdargs: str, flow_toml: str, input_file: str) str

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:

The selected Flow command.

Return type:

str

Raises:

SystemExit – If neither command identifies a working Flow executable.

pycopm.core.pycopm._parse_arguments(argv: Sequence[str] | None = None) dict[str, str]

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:

Arguments keyed by their destination names.

Return type:

dict[str, str]

pycopm.core.pycopm.main(argv: Sequence[str] | None = None) None

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.

  • -i – Input .DATA deck or TOML configuration file.

  • --input_deck_path – Input .DATA deck or TOML configuration file.

  • -o – Directory for generated decks, include files, and simulation results.

  • --output_directory – Directory for generated decks, include files, and simulation results.

  • -f – Command or path used to run OPM Flow.

  • --flow_command – Command or path used to run OPM Flow.

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

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

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

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

  • -c – Uniform coarsening factors in the x, y, and z directions.

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

  • -x – Cell-specific coarsening specification along the x axis.

  • --x_coarsening – Cell-specific coarsening specification along the x axis.

  • -y – Cell-specific coarsening specification along the y axis.

  • --y_coarsening – Cell-specific coarsening specification along the y axis.

  • -z – Cell-specific coarsening specification along the z axis.

  • --z_coarsening – Cell-specific coarsening specification along the z axis.

  • -g – Uniform numbers of additional cells along the x, y, and z axes.

  • --refinement – Uniform numbers of additional cells along the x, y, and z axes.

  • -rx – Number of additional cells for each original x interval.

  • --x_refinement – Number of additional cells for each original x interval.

  • -ry – Number of additional cells for each original y interval.

  • --y_refinement – Number of additional cells for each original y interval.

  • -rz – Number of additional cells for each original z interval.

  • --z_refinement – Number of additional cells for each original z interval.

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

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

  • -n – Aggregation method for discrete properties: min, max, or mode.

  • --discrete_aggregation_method – Aggregation method for discrete properties: min, max, or mode.

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

  • --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 method. The available values are 0 through 4; supported methods depend on the selected workflow.

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

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

  • --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: 0, 1, or 2.

  • --transmissibility_coarsening_method – Transmissibility coarsening method: 0, 1, or 2.

  • -r – Level of COMPDAT data removed after coarsening: 0, 1, or 2.

  • --completion_removal_level – Level of COMPDAT data removed after coarsening: 0, 1, or 2.

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

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

  • -w – Name of the generated OPM deck.

  • --output_deck_name – Name of the generated OPM deck.

  • -l – Prefix added to generated include filenames.

  • --include_prefix – Prefix added to generated include filenames.

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

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

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

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

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

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

  • -explicit – Set to 1 to write initial solution properties explicitly instead of retaining EQUIL initialization.

  • --write_explicit_solution – Set to 1 to write initial solution properties explicitly instead of retaining EQUIL initialization.

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

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

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

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