pyopmnearwell.utils.writefile module#

Generate OPM Flow decks, include files, grids, and property tables.

The module derives grid coordinates and layer metadata, evaluates validated saturation and porosity-permeability expressions, renders model templates, and writes the files required by OPM Flow.

reservoir_files(dic, **kwargs)[source]#

Write the OPM Flow deck and its required include files.

The generated files depend on the selected physical model, template, grid, and optional recalculation controls. When flow is omitted, the function generates property tables only.

Parameters:
  • dic (dict) -- Shared pyopmnearwell configuration dictionary containing the validated model, grid, property, output, and template settings.

  • **kwargs -- Optional file-reuse controls.

  • recalc_grid (bool, optional) -- Recalculate grid include files. The default is True.

  • recalc_tables (bool, optional) -- Recalculate TABLES.INC. The default is True.

  • recalc_sections (bool, optional) -- Recalculate geology, region, and boundary-property include files. The default is True.

  • inc_folder (pathlib.Path, optional) -- Directory containing previously generated include files that should be reused. The default is pathlib.Path("").

Returns:

Names of the generated .DATA and .INC files.

Return type:

list[str]

Notes

The recalculation controls currently support the co2store model with the no_disgas_no_diffusion template on a cake grid. Other model, template, or grid combinations may not support reuse of previously generated files.

generate_fluxnum(dic)[source]#

Generate the FLUXNUM include-file contents.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Generated OPM keyword text.

Return type:

Any

generate_multpv(dic)[source]#

Generate boundary pore-volume multiplier contents.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Generated OPM keyword text.

Return type:

Any

generate_geology(dic)[source]#

Generate grid geometry and rock-property keyword contents.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Generated OPM keyword text.

Return type:

Any

manage_sections(dic)[source]#

Write geology, region, pore-volume, and porosity-permeability include files.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

generate_permfact_pcfact(dic)[source]#

Write PERMFACT and optional PCFACT include files.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

generate_pcfact(dic)[source]#

Generate capillary-pressure multiplier table lines.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Formatted lines for the generated include file.

Return type:

Any

generate_permfact(dic)[source]#

Generate porosity-permeability multiplier table lines.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Formatted lines for the generated include file.

Return type:

Any

get_spaces(dic)[source]#

Calculate field widths used to align generated deck values.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

manage_tables(dic)[source]#

Select and write the saturation-table format required by the model.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

generate_saturation_functions_gsf_wsf(dic)[source]#

Generate separate gas and water saturation-function tables.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Lines forming the generated saturation tables.

Return type:

Any

generate_saturation_functions_format_2(dic)[source]#

Generate SGFN and SWFN saturation-function tables.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Lines forming the generated saturation tables.

Return type:

Any

generate_saturation_functions_format_1(dic)[source]#

Generate an SGOF saturation-function table.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Lines forming the generated saturation tables.

Return type:

Any

manage_grid(dic)[source]#

Generate grid include files for the selected grid type.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

round_like_e(v)[source]#

Round numeric values to the precision used by scientific notation.

Parameters:

v (NDArray) -- Numeric values to format.

Returns:

Result produced by the operation.

Return type:

NDArray

get_2dgrid(dic)[source]#

Generate a two-dimensional corner-point grid include file.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

compact_format(v)[source]#

Convert repeated numeric values to OPM compact n*value notation.

Parameters:

v (NDArray) -- Numeric values to format.

Returns:

Formatted lines for the generated include file.

Return type:

list[str]

handle_core(dic)[source]#

Derive active cells and geometry for a cylindrical core model.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any

d3_grids(dic, dxarray)[source]#

Generate the second stage of three-dimensional grid include files.

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

  • dxarray (Any) -- Cell widths along the x direction.

Returns:

Result produced by the operation.

Return type:

Any

create_3dgrid(dic)[source]#

Create initial three-dimensional grid coordinates.

Parameters:

dic (Any) -- Shared pyopmnearwell configuration dictionary.

Returns:

Result produced by the operation.

Return type:

Any