diff --git a/docs/scripts/gen_satfunc.rst b/docs/scripts/gen_satfunc.rst deleted file mode 100644 index 2f3ef4f1f..000000000 --- a/docs/scripts/gen_satfunc.rst +++ /dev/null @@ -1,53 +0,0 @@ - -GEN_SATFUNC -=========== - -*gen_satfunc is deprecated. Switch to pyscal.* - -The gen_satfunc.py can create a SWOF/SGOF include file based on LET-parameters, -initial water saturation, residual oil saturation and Krwo. The script requires -a simple configuration file as an input (example below) and returns a SWOF/SGOF -include file that you can directly include in Eclipse. The script can both be -beneficial in a manual setting where you want to test various relative -permeabilities, or in an automatic fashion where the configuration file is used -as a template for a forward model job. - -.. argparse:: - :module: subscript.gen_satfunc.gen_satfunc - :func: get_parser - :prog: gen_satfunc - -Configuration file ------------------- - -There are only 4 keywords allowed in the configuration file: - -- ``SWOF`` *no arguments* -- ``SGOF`` *no arguments* -- ``COMMENT`` {some comment to print in the output file} -- ``RELPERM {Lw, Ew, Tw, Lo, Eo, To, Sorw, Swirr, Krwo, num_sw_steps} [PORO, a, b, sigma_costau]`` - -Required input are the LET-parameters for the oil and water (or gas) relative -permeability curves, as well as the irreducible water saturation, the remaining -oil saturations and Krwo. - -Optionally you may specify a permeability (mD), porosity (-), a & b -petrophysical J-function fitting parameters and the interfacial tension -sigma_costau (mN/m). These inputs will be used to calculated the capillary -pressure. Currently, some Heidrun specific values for the capillary pressure -calculation are hard-coded in the source code. When you require the calculation -of capillary pressure please contact the script author. In addition to these -keywords you can add comments freely throughout the config file similar to -comments in Eclipse files (that is, using to dashed --). - -The following example config file can be used to generate a SWOF file with 4 -relative permeability curves: - -Example configuration file for gen_satfunc.py:: - - COMMENT Relperm curve for fantasy field - SWOF - RELPERM 4 2 1 3 2 1 0.15 0.10 0.5 20 - RELPERM 4 1 1 4 2 1 0.14 0.12 0.3 20 - RELPERM 4 3 1 3 3 1 0.13 0.11 0.6 20 - RELPERM 4 1 0.5 3 2 0.5 0.16 0.09 0.4 20 diff --git a/setup.py b/setup.py index d46ea8b21..a3ebdd7f7 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,6 @@ "ecldiff2roff = subscript.ecldiff2roff.ecldiff2roff:main", "fmu_copy_revision = subscript.fmu_copy_revision.fmu_copy_revision:main", "fmuobs = subscript.fmuobs.fmuobs:main", - "gen_satfunc = subscript.gen_satfunc.gen_satfunc:main", "interp_relperm = subscript.interp_relperm.interp_relperm:main", "merge_schedule = subscript.merge_schedule.merge_schedule:main", "merge_rft_ertobs = subscript.merge_rft_ertobs.merge_rft_ertobs:main", diff --git a/src/subscript/gen_satfunc/__init__.py b/src/subscript/gen_satfunc/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/subscript/gen_satfunc/gen_satfunc.py b/src/subscript/gen_satfunc/gen_satfunc.py deleted file mode 100755 index f092a746a..000000000 --- a/src/subscript/gen_satfunc/gen_satfunc.py +++ /dev/null @@ -1,108 +0,0 @@ -import argparse -import logging -import sys -import warnings -from pathlib import Path - -import pyscal - -import subscript - -# Non-conforming names are in use here, as they follow a different norm. -# pylint: disable=invalid-name - - -logger = subscript.getLogger(__name__) - - -def get_parser(): - """Make a parser for command line arg parsing and for documentation""" - parser = argparse.ArgumentParser( - prog="gen_satfunc", - description="Deprecated tool for making SWOF/SGOF files for Eclipse. " - "Use pyscal instead.", - ) - parser.add_argument( - "config_file", - help=("Path to configuration file."), - ) - parser.add_argument( - "output_file", - help="Path to output file with SWOF and/or SGOF tables.", - ) - return parser - - -def main(): - """Used for invocation on the command line""" - parser = get_parser() - args = parser.parse_args() - - warnings.warn("gen_satfunc is deprecated, use pyscal", FutureWarning) - - logger.setLevel(logging.INFO) - - if not Path(args.config_file).exists(): - sys.exit(f"Could not find the configuration file: {args.config_file}") - - output = "" - - for line in open(args.config_file).readlines(): - tmp = line.strip() - if not tmp[0:2] == "--" and len(tmp) > 0: - if tmp[0:7] == "RELPERM": - - # Parse relperm parameters from the rest of the line: - relperm_input = tuple(tmp[8:].split("--")[0].split()) - relperm_input = [float(i) for i in relperm_input] - - if len(relperm_input) < 9: - logger.error("Too few relperm parameters in line:\n%s", line) - raise ValueError("Erroneous relperm parameters") - - # Unpack parameter list to explicitly named parameters: - (Lw, Ew, Tw, Lo, Eo, To, Sorw, Swl, Krwo) = relperm_input[0:9] - - if len(relperm_input) > 9: - num_sw_steps = relperm_input[9] - else: - num_sw_steps = 20 - - wo = pyscal.WaterOil(h=1.0 / (num_sw_steps + 2), sorw=Sorw, swl=Swl) - wo.add_LET_oil(Lo, Eo, To, kroend=1) - wo.add_LET_water(Lw, Ew, Tw, krwend=Krwo) - - if 10 < len(relperm_input) < 15: - logger.error("Too few parameter for pc in line:\n%s", line) - raise ValueError("Erroneous pc parameters") - - if len(relperm_input) == 15: - (PERM, PORO, a, b, sigma_costau) = relperm_input[10:15] - wo.add_normalized_J( - a=a, b=b, poro=PORO, perm=PERM, sigma_costau=sigma_costau - ) - - output += wo.SWOF(header=False) - - elif tmp[0:7] == "COMMENT": - logger.info("Printing comment") - comment = tmp[8:].split("--")[0] - output = output + "--" + comment + "\n" - elif tmp[0:4] == "SWOF": - logger.info("Generating SWOF table") - output = output + "SWOF\n" - elif tmp[0:4] == "SGOF": - logger.info("Generating SGOF table") - output = output + "SGOF\n" - else: - raise ValueError('Error while interpreting line: "%s"' % line.strip()) - - logger.info("Writing output file...") - - Path(args.output_file).write_text(output) - - logger.info("Done") - - -if __name__ == "__main__": - main() diff --git a/tests/test_gen_satfunc.py b/tests/test_gen_satfunc.py deleted file mode 100644 index 78decdcea..000000000 --- a/tests/test_gen_satfunc.py +++ /dev/null @@ -1,50 +0,0 @@ -import subprocess -from pathlib import Path - -import pytest - -from subscript.gen_satfunc import gen_satfunc - -EXAMPLE = """ --Example Configuration file for gen_satfunc.py - -COMMENT Relperm curve for fantasy field -SWOF -RELPERM 4 2 1 3 2 1 0.15 0.10 0.5 20 -RELPERM 4 1 1 4 2 1 0.14 0.12 0.3 20 -RELPERM 4 3 1 3 3 1 0.13 0.11 0.6 20 -RELPERM 4 1 0.5 3 2 0.5 0.16 0.09 0.4 20 -""" - - -@pytest.mark.integration -def test_integration(): - """Test that endpoint is installed""" - assert subprocess.check_output(["gen_satfunc", "-h"]) - - -def test_gen_satfunc(tmpdir, mocker): - """Test the main function and its args handling""" - tmpdir.chdir() - - Path("relperm.conf").write_text(EXAMPLE) - - mocker.patch("sys.argv", ["gen_satfunc", "relperm.conf", "swof.inc"]) - with pytest.warns(FutureWarning): - gen_satfunc.main() - - assert Path("swof.inc").exists() - assert len(Path("swof.inc").read_text().splitlines()) > 50 - - Path("relpermpc.conf").write_text( - """ -SWOF -RELPERM 4 2 1 3 2 1 0.15 0.10 0.5 20 100 0.2 0.22 -0.5 30 -""" - ) - mocker.patch("sys.argv", ["gen_satfunc", "relpermpc.conf", "swofpc.inc"]) - with pytest.warns(FutureWarning): - gen_satfunc.main() - assert Path("swofpc.inc").exists() - swofpclines = Path("swofpc.inc").read_text().splitlines() - assert len(swofpclines) > 20 - assert any(["sigma_costau=30" in x for x in swofpclines])