def test_simple_j(): """Simple test of the simple J function correlation""" wateroil = WaterOil(swl=0.01) wateroil.add_simple_J() # swl set to zero will give infinite pc check_table(wateroil.table) assert wateroil.pccomment wateroil = WaterOil(swl=0) with pytest.raises(ValueError, match="swl must be larger than zero"): wateroil.add_simple_J() # Zero gravity: wateroil = WaterOil(swl=0.01) wateroil.add_simple_J(g=0) assert wateroil.table["PC"].unique() == 0.0 # This should give back Sw: # This ensures that density and gravity scaling is correct wateroil.add_simple_J(a=1, b=1, poro_ref=1, perm_ref=1, drho=1000, g=100) assert (wateroil.table["PC"] - wateroil.table["SW"]).sum() < 0.00001 # (check_table() will fail on this, when b > 0) # Some values seen in real life: wateroil.add_simple_J(a=100, b=-1.5, poro_ref=0.12, perm_ref=100, drho=200) check_table(wateroil.table) assert "Simplified" in wateroil.pccomment assert "a=100" in wateroil.pccomment assert "b=-1.5" in wateroil.pccomment wateroil.add_corey_oil() wateroil.add_corey_water() swof = wateroil.SWOF() assert isinstance(swof, str) assert swof sat_table_str_ok(swof) sat_table_str_ok(wateroil.SWFN())
def test_simple_j_petro(): """Simple test of the simple J petrophysical function correlation""" wateroil = WaterOil(swl=0.01) wateroil.add_simple_J_petro(a=1, b=-2) check_table(wateroil.table) assert wateroil.pccomment assert "etrophysic" in wateroil.pccomment # Zero gravity: wateroil.add_simple_J_petro(a=1, b=-2, g=0) assert wateroil.table.pc.unique() == 0.0 # Numerical test from sample numbers calculated independently in different tool: wateroil = WaterOil(swl=0.05, h=0.025) wateroil.add_simple_J_petro(a=1.45, b=-0.285, drho=143, g=9.81, perm_ref=15, poro_ref=0.27) float_df_checker(wateroil.table, "sw", 0.1, "pc", 22.36746) assert "Simplified" in wateroil.pccomment assert "etrophysic" in wateroil.pccomment wateroil.add_corey_oil() wateroil.add_corey_water() swof = wateroil.SWOF() assert isinstance(swof, str) assert swof sat_table_str_ok(swof) sat_table_str_ok(wateroil.SWFN())
def test_mock_two_satnums_via_fam2_files(tmpdir, int_param, expected_file): tmpdir.chdir() PyscalFactory.create_pyscal_list(TWO_SATNUM_PYSCAL_MOCK.loc["low"], h=0.1).dump_family_2("pess.inc") PyscalFactory.create_pyscal_list(TWO_SATNUM_PYSCAL_MOCK.loc["base"], h=0.1).dump_family_2("base.inc") PyscalFactory.create_pyscal_list(TWO_SATNUM_PYSCAL_MOCK.loc["high"], h=0.1).dump_family_2("opt.inc") config = { "base": ["base.inc"], "low": ["pess.inc"], "high": ["opt.inc"], "result_file": "outfile.inc", "interpolations": [{ "param_w": int_param, "param_g": int_param }], "family": 2, "delta_s": 0.1, } interp_relperm.process_config(config) outfile_str = Path("outfile.inc").read_text() outfile_df = satfunc.df(outfile_str) if expected_file is not None: expected_df = satfunc.df(Path(expected_file).read_text()) pd.testing.assert_frame_equal(outfile_df, expected_df) else: # Use test function from pyscal to assert that the produced file is # valid for Eclipse (not testing numerically that the interpolation # is correct) sat_table_str_ok(outfile_str)
def test_xls_factory(): """Test/demonstrate how to go from data in an excel row to pyscal objects This test function predates the load_relperm_df() function, but can still be in here. """ if "__file__" in globals(): # Easen up copying test code into interactive sessions testdir = os.path.dirname(os.path.abspath(__file__)) else: testdir = os.path.abspath(".") xlsxfile = testdir + "/data/scal-pc-input-example.xlsx" scalinput = pd.read_excel(xlsxfile).set_index(["SATNUM", "CASE"]) for ((satnum, _), params) in scalinput.iterrows(): assert satnum wog = PyscalFactory.create_water_oil_gas(params.to_dict()) swof = wog.SWOF() assert "LET krw" in swof assert "LET krow" in swof assert "Simplified J" in swof sgof = wog.SGOF() sat_table_str_ok(sgof) assert "LET krg" in sgof assert "LET krog" in sgof
def test_wateroil_tag(tag): """Test that we are unlikely to crash Eclipse by having ugly tag names""" wateroil = WaterOil(h=0.5, tag=tag) wateroil.add_corey_oil() wateroil.add_corey_water() sat_table_str_ok(wateroil.SWOF()) sat_table_str_ok(wateroil.SWFN())
def test_gaswater_tag(tag): """Test that we are unlikely to crash Eclipse by having ugly tag names""" gaswater = GasWater(h=0.5, tag=tag) gaswater.add_corey_gas() gaswater.add_corey_water() sat_table_str_ok(gaswater.SWFN()) sat_table_str_ok(gaswater.SGFN())
def test_factory_wog_gascondensate(): """Test modelling of gas condensate, which in pyscal terms is the same as wateroilgas, except that we allow for aliasing in sgrw=sorw for the underlying WaterOil object, and also there are additional parameters sgro and kromax for GasOil.""" wcg = PyscalFactory.create_water_oil_gas( dict( nw=2, now=3, ng=1, nog=2, sgrw=0.1, swl=0.1, sgcr=0.1, sgro=0.1, kroend=0.5, kromax=0.9, )) assert wcg.gasoil.sgro == 0.1 assert wcg.wateroil.sorw == 0.1 swof = wcg.SWOF() sgof = wcg.SGOF() # sgrw has been aliased to sorw, but the WaterOil object does not know that: assert "sgrw" not in swof assert "sorw=0.1" in swof assert "sgro=0.1" in sgof assert "kroend=0.5" in sgof assert "kromax=0.9" in sgof sat_table_str_ok(swof) sat_table_str_ok(sgof) # Different sorw and sgrw is a hard error: with pytest.raises(ValueError, match="must equal"): PyscalFactory.create_water_oil_gas( dict(nw=2, now=3, ng=1, nog=2, sorw=0.2, sgrw=0.1, swl=0.1)) # But it will pass if they both are supplied but are equal: wcg_2 = PyscalFactory.create_water_oil_gas( dict(nw=2, now=3, ng=1, nog=2, sorw=0.2, sgrw=0.2, swl=0.1)) assert "sorw=0.2" in wcg_2.SWOF() # kroend higher than kromax is an error: with pytest.raises(AssertionError): PyscalFactory.create_water_oil_gas( dict( nw=2, now=3, ng=1, nog=2, sgcr=0.1, sgro=0.1, kromax=0.5, kroend=0.8, swl=0.1, ))
def test_gasoil_tag(tag): """Test tagging of GasOil objects, that we are not able to produce something that can crash Eclipse""" gasoil = GasOil(h=0.5, tag=tag) gasoil.add_corey_gas() gasoil.add_corey_oil() sat_table_str_ok(gasoil.SGOF()) sat_table_str_ok(gasoil.SGFN())
def test_tag_preservation(): """Test that we can preserve tags/comments through interpolation""" wo_low = WaterOil(swl=0.1) wo_high = WaterOil(swl=0.2) wo_low.add_corey_water(nw=2) wo_high.add_corey_water(nw=3) wo_low.add_corey_oil(now=2) wo_high.add_corey_oil(now=3) interpolant1 = interpolate_wo(wo_low, wo_high, parameter=0.1, h=0.2) assert "Interpolated to 0.1" in interpolant1.tag sat_table_str_ok(interpolant1.SWOF()) wo_high.tag = "FOOBAR" interpolant2 = interpolate_wo(wo_low, wo_high, parameter=0.1, h=0.2) assert "Interpolated to 0.1" in interpolant2.tag assert "between" in interpolant2.tag assert wo_high.tag in interpolant2.tag sat_table_str_ok(interpolant2.SWOF()) # wo_low.tag was empty deliberately here. # When wo_log and wo_high has the same tag: wo_low.tag = "FOOBAR" interpolant3 = interpolate_wo(wo_low, wo_high, parameter=0.1, h=0.2) assert "Interpolated to 0.1" in interpolant3.tag assert "between" not in interpolant3.tag assert wo_high.tag in interpolant3.tag sat_table_str_ok(interpolant3.SWOF()) # Explicit tag: interpolant4 = interpolate_wo( wo_low, wo_high, parameter=0.1, h=0.2, tag="Explicit tag" ) assert interpolant4.tag == "Explicit tag" # Tag with newline interpolant6 = interpolate_wo( wo_low, wo_high, parameter=0.1, h=0.2, tag="Explicit tag\non two lines" ) assert "Explicit tag" in interpolant6.tag print(interpolant6.SWOF()) sat_table_str_ok(interpolant6.SWOF()) # Empty tag: interpolant5 = interpolate_wo(wo_low, wo_high, parameter=0.1, h=0.2, tag="") assert interpolant5.tag == "" # Also sample check for GasOil (calls the same code) go_low = GasOil() go_high = GasOil() go_low.add_corey_gas(ng=2) go_high.add_corey_gas(ng=3) go_low.add_corey_oil(nog=2) go_high.add_corey_oil(nog=3) interpolant1 = interpolate_go(go_low, go_high, parameter=0.1, h=0.2) assert "Interpolated to 0.1" in interpolant1.tag sat_table_str_ok(interpolant1.SGOF())
def test_pyscal_client_scal(tmpdir, caplog, default_loglevel): # pylint: disable=unused-argument # default_loglevel fixture is in conftest.py """Test the command line endpoint on SCAL recommendation""" scalrec_file = Path( __file__).absolute().parent / "data/scal-pc-input-example.xlsx" tmpdir.chdir() sys.argv = ["pyscal", str(scalrec_file)] with pytest.raises(SystemExit): pyscalcli.main() caplog.clear() sys.argv = [ "pyscal", str(scalrec_file), "--int_param_wo", 0, "-o", "relperm1.inc" ] pyscalcli.main() assert not any(record.levelno == logging.INFO for record in caplog.records) assert not any(record.levelno == logging.WARNING for record in caplog.records) assert not any(record.levelno == logging.ERROR for record in caplog.records) relpermlines = "\n".join(open("relperm1.inc").readlines()) assert "SWOF" in relpermlines assert "SGOF" in relpermlines assert "SLGOF" not in relpermlines assert "SOF3" not in relpermlines sat_table_str_ok(relpermlines) # assert "int_param_wo: 0\n" in relpermlines # this should be in the tag. caplog.clear() sys.argv = [ "pyscal", str(scalrec_file), "--int_param_wo", "-0.5", "-o", "relperm2.inc", ] pyscalcli.main() assert not any(record.levelno == logging.INFO for record in caplog.records) assert not any(record.levelno == logging.WARNING for record in caplog.records) assert not any(record.levelno == logging.ERROR for record in caplog.records) # assert something about -0.5 in the comments # Multiple interpolation parameters, this was supported in pyscal <= 0.7.7, # but is now an error: sys.argv = ["pyscal", str(scalrec_file), "--int_param_wo", "-0.5", "0"] with pytest.raises(SystemExit): pyscalcli.main()
def test_dump(): """Test dumping Eclipse include data to file""" testdir = Path(__file__).absolute().parent relperm_data = PyscalFactory.load_relperm_df( testdir / "data/relperm-input-example.xlsx") pyscal_list = PyscalFactory.create_pyscal_list(relperm_data) fam1 = pyscal_list.dump_family_1() sat_table_str_ok(fam1) fam2 = pyscal_list.dump_family_2() sat_table_str_ok(fam2)
def test_factory_wateroilgas_wo(): """Test making only wateroil through the wateroilgas factory""" pyscal_factory = PyscalFactory() wog = pyscal_factory.create_water_oil_gas( dict(nw=2, now=3, kroend=0.5, sorw=0.04, swcr=0.1)) swof = wog.SWOF() assert "Corey krw" in swof assert "krw" in wog.wateroil.table sat_table_str_ok(swof) check_table(wog.wateroil.table) assert wog.gasoil is None wog.SGOF()
def test_factory_wateroilgas(): """Test creating discrete cases of WaterOilGas from factory""" pyscal_factory = PyscalFactory() wog = pyscal_factory.create_water_oil_gas(dict(nw=2, now=3, ng=1, nog=2.5)) swof = wog.SWOF() sgof = wog.SGOF() sat_table_str_ok(swof) # sgof code works for swof also currently sat_table_str_ok(sgof) assert "Corey krg" in sgof assert "Corey krog" in sgof assert "Corey krw" in swof assert "Corey krow" in swof check_table(wog.gasoil.table) check_table(wog.wateroil.table) # Some users will mess up lower vs upper case: wog = pyscal_factory.create_water_oil_gas(dict(NW=2, NOW=3, NG=1, nog=2.5)) swof = wog.SWOF() sgof = wog.SGOF() sat_table_str_ok(swof) # sgof code works for swof also currently sat_table_str_ok(sgof) assert "Corey krg" in sgof assert "Corey krog" in sgof assert "Corey krw" in swof assert "Corey krow" in swof # Mangling data wateroil = pyscal_factory.create_water_oil_gas(dict(nw=2, now=3, ng=1)) assert wateroil.gasoil is None
def test_scalrecommendation(): """Testing making SCAL rec from dict of dict.""" pyscal_factory = PyscalFactory() scal_input = { "low": {"nw": 2, "now": 4, "ng": 1, "nog": 2}, "BASE": {"nw": 3, "NOW": 3, "ng": 1, "nog": 2}, "high": {"nw": 4, "now": 2, "ng": 1, "nog": 3}, } scal = pyscal_factory.create_scal_recommendation(scal_input) # (not supported yet to make WaterOil only..) interp = scal.interpolate(-0.5) sat_table_str_ok(interp.SWOF()) sat_table_str_ok(interp.SGOF()) sat_table_str_ok(interp.SLGOF()) sat_table_str_ok(interp.SOF3()) check_table(interp.wateroil.table) check_table(interp.gasoil.table) incomplete1 = scal_input.copy() del incomplete1["BASE"] with pytest.raises(ValueError): pyscal_factory.create_scal_recommendation(incomplete1) go_only = scal_input.copy() del go_only["low"]["now"] del go_only["low"]["nw"] gasoil = pyscal_factory.create_scal_recommendation(go_only) assert gasoil.low.wateroil is None assert gasoil.base.wateroil is not None assert gasoil.high.wateroil is not None # SCALrecommendation of gasoil only works as long as you # don't try to ask for water data: assert "SGFN" in gasoil.interpolate(-0.4).SGFN() assert "SWOF" not in gasoil.interpolate(-0.2).SWOF()
def test_scalrecommendation_gaswater(): """Testing making SCAL rec from dict of dict for gaswater input""" pyscal_factory = PyscalFactory() scal_input = { "low": {"nw": 2, "ng": 1}, "BASE": {"nw": 3, "ng": 1}, "high": {"nw": 4, "ng": 1}, } scal = pyscal_factory.create_scal_recommendation(scal_input, h=0.2) interp = scal.interpolate(-0.5, h=0.2) sat_table_str_ok(interp.SWFN()) sat_table_str_ok(interp.SGFN()) check_table(interp.wateroil.table) check_table(interp.gasoil.table)
def test_factory_gaswater(): """Test that we can create gas-water curves from dictionaries of parameters""" pyscal_factory = PyscalFactory() # Factory refuses to create incomplete defaulted objects. with pytest.raises(ValueError): pyscal_factory.create_gas_water() with pytest.raises(TypeError): # pylint: disable=unexpected-keyword-arg pyscal_factory.create_gas_water(swirr=0.01) # noqa with pytest.raises(TypeError): # (it must be a dictionary) # pylint: disable=unexpected-keyword-arg pyscal_factory.create_gas_water(params="swirr 0.01") gaswater = pyscal_factory.create_gas_water( dict(swirr=0.01, swl=0.03, sgrw=0.1, sgcr=0.15, tag="gassy sand", ng=2, nw=2)) assert isinstance(gaswater, GasWater) assert gaswater.swirr == 0.01 assert gaswater.swl == 0.03 assert gaswater.sgrw == 0.1 assert gaswater.sgcr == 0.15 assert gaswater.tag == "gassy sand" sgfn = gaswater.SGFN() swfn = gaswater.SWFN() sat_table_str_ok(sgfn) sat_table_str_ok(swfn) check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table) assert "sgrw=0.1" in swfn assert "swirr=0.01" in sgfn assert "swirr=0.01" in swfn assert "sgrw=0.1" in swfn assert "sgcr=0.15" in sgfn assert "nw=2" in swfn assert "ng=2" in sgfn assert "gassy sand" in sgfn gaswater = pyscal_factory.create_gas_water(dict(lg=1, eg=1, tg=1, nw=3)) sgfn = gaswater.SGFN() swfn = gaswater.SWFN() sat_table_str_ok(sgfn) sat_table_str_ok(swfn) check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table)
def test_slgof_hypo(swl, sorg, sgcr, h): """Shotgun-testing of slgof""" gasoil = GasOil(swl=swl, sorg=sorg, sgcr=sgcr, h=h) gasoil.add_corey_gas() gasoil.add_corey_oil() assert gasoil.selfcheck() slgof = gasoil.slgof_df() check_table(slgof) # Eclipse 100 requirement from manual: assert np.isclose(slgof["SL"].values[0], gasoil.swl + gasoil.sorg) # Eclipse 100 requirement from manual: assert np.isclose(slgof["SL"].values[-1], 1.0) slgof_str = gasoil.SLGOF() assert isinstance(slgof_str, str) assert slgof_str sat_table_str_ok(slgof_str)
def test_factory_wateroilgas_deprecated_krowgend(caplog): """Some users will use deprecated krowend krogend, these values should be translated to kroend""" wog = PyscalFactory.create_water_oil_gas( dict(nw=2, now=3, ng=1, nog=2.5, krowend=0.6, krogend=0.7)) assert "deprecated" in caplog.text swof = wog.SWOF() assert "kroend=0.6" in swof sgof = wog.SGOF() assert "kroend=0.7" in sgof assert not wog.threephaseconsistency() sat_table_str_ok(swof) # sgof code works for swof also currently sat_table_str_ok(sgof) assert "Corey krg" in sgof assert "Corey krog" in sgof assert "Corey krw" in swof assert "Corey krow" in swof
def test_gasoil_let1(l, e, t, krgend, krgmax): """Test the LET formulation, take 1""" gasoil = GasOil() try: gasoil.add_LET_oil(l, e, t, krgend) gasoil.add_LET_gas(l, e, t, krgend, krgmax) except AssertionError: # This happens for negative values f.ex. return assert "krog" in gasoil.table assert "krg" in gasoil.table assert isinstance(gasoil.krgcomment, str) check_table(gasoil.table) check_linear_sections(gasoil) sgofstr = gasoil.SGOF() assert len(sgofstr) > 100 sat_table_str_ok(sgofstr)
def test_dump(): """Test dumping Eclipse include data to file""" if "__file__" in globals(): # Easen up copying test code into interactive sessions testdir = os.path.dirname(os.path.abspath(__file__)) else: testdir = os.path.abspath(".") relperm_data = PyscalFactory.load_relperm_df( testdir + "/data/relperm-input-example.xlsx") pyscal_list = PyscalFactory.create_pyscal_list(relperm_data) fam1 = pyscal_list.dump_family_1() sat_table_str_ok(fam1) fam2 = pyscal_list.dump_family_2() sat_table_str_ok(fam2)
def test_factory_gasoil(): """Test that we can create curves from dictionaries of parameters""" pyscal_factory = PyscalFactory() # Factory refuses to create incomplete defaulted objects. with pytest.raises(ValueError): pyscal_factory.create_gas_oil() with pytest.raises(TypeError): # (this must be a dictionary) # pylint: disable=unexpected-keyword-arg pyscal_factory.create_gas_oil(swirr=0.01) # noqa with pytest.raises(TypeError): pyscal_factory.create_gas_oil(params="swirr 0.01") gasoil = pyscal_factory.create_gas_oil( dict(swirr=0.01, swl=0.1, sgcr=0.05, tag="Good sand", ng=1, nog=2)) assert isinstance(gasoil, GasOil) assert gasoil.sgcr == 0.05 assert gasoil.sgro == 0.0 assert gasoil.swl == 0.1 assert gasoil.swirr == 0.01 assert gasoil.tag == "Good sand" sgof = gasoil.SGOF() sat_table_str_ok(sgof) check_table(gasoil.table) assert "Corey krg" in sgof assert "Corey krog" in sgof assert "Zero capillary pressure" in sgof gasoil = pyscal_factory.create_gas_oil( dict(ng=1.2, nog=2, krgend=0.8, krgmax=0.9, krogend=0.6)) sgof = gasoil.SGOF() sat_table_str_ok(sgof) assert "kroend=0.6" in sgof assert "krgend=0.8" in sgof check_table(gasoil.table) gasoil = pyscal_factory.create_gas_oil(dict(ng=1.3, Log=2, Eog=2, Tog=2)) sgof = gasoil.SGOF() check_table(gasoil.table) sat_table_str_ok(sgof) assert "Corey krg" in sgof assert "LET krog" in sgof gasoil = pyscal_factory.create_gas_oil( dict(Lg=1, Eg=1, Tg=1, Log=2, Eog=2, Tog=2)) sgof = gasoil.SGOF() sat_table_str_ok(sgof) check_table(gasoil.table) assert "LET krg" in sgof assert "LET krog" in sgof
def test_let_pc_imb(): """Test the LET formulation for imbibition capillary pressures""" wateroil = WaterOil(swirr=0.1) wateroil.add_LET_pc_imb(Ls=1, Es=1, Ts=1, Lf=1, Ef=1, Tf=1, Pcmax=10, Pcmin=-10, Pct=3) assert np.isclose(wateroil.table["PC"].max(), 10) assert np.isclose(wateroil.table["PC"].min(), -10) wateroil = WaterOil(swirr=0.1) wateroil.add_LET_pc_imb(Ls=5, Es=5, Ts=5, Lf=5, Ef=5, Tf=5, Pcmax=5, Pcmin=1, Pct=4) assert np.isclose(wateroil.table["PC"].max(), 5) assert np.isclose(wateroil.table["PC"].min(), 1) wateroil = WaterOil(swirr=0.1, sorw=0.3) wateroil.add_LET_pc_imb(Ls=5, Es=5, Ts=5, Lf=5, Ef=5, Tf=5, Pcmax=5, Pcmin=1, Pct=4) assert np.isclose(wateroil.table["PC"].max(), 5) assert np.isclose(wateroil.table["PC"].min(), 1) wateroil.add_corey_water() wateroil.add_corey_oil() sat_table_str_ok(wateroil.SWOF())
def test_norm_j_pc_random(swirr, swl, a_pc, b_pc, poro, perm, sigma_costau): """Test many possibilities of Pc-parameters. Outside of the tested range, there are many combination of parameters that can give infinite capillary pressure""" swl = swirr + swl # No point in getting too many AssertionErrors wateroil = WaterOil(swirr=swirr, swl=swl, h=0.01) try: wateroil.add_normalized_J(a=a_pc, b=b_pc, perm=perm, poro=poro, sigma_costau=sigma_costau) except (AssertionError, ValueError): # when poro is < 0 f.ex. return check_table(wateroil.table) wateroil.add_corey_water() wateroil.add_corey_oil() sat_table_str_ok(wateroil.SWOF())
def test_factory_go_gascondensate(): """In gas condensate problems, the sgro and kromax parameters are relevant""" pyscal_factory = PyscalFactory() gasoil = pyscal_factory.create_gas_oil( dict(sgro=0.1, sgcr=0.1, tag="Good sand", ng=1, nog=2, kroend=0.5, kromax=0.9)) assert isinstance(gasoil, GasOil) assert gasoil.sgro == 0.1 assert gasoil.tag == "Good sand" sgof = gasoil.SGOF() sat_table_str_ok(sgof) check_table(gasoil.table) assert "Corey krog" in sgof assert "kroend=0.5" in sgof assert "kromax=0.9" in sgof assert "sgro=0.1" in sgof
def test_gaswater_pc(): """Test that capillary pressure can be added to GasWater. The GasWater object is calling up the code in WaterOil, which is tested more thorougly, in this test function we need to make sure the functionality is in place.""" gaswater = GasWater(swl=0.1, h=0.2) gaswater.add_corey_water() gaswater.add_corey_gas() gaswater.add_simple_J() assert gaswater.wateroil.table["pc"].abs().sum() > 0 swfn = gaswater.SWFN() assert "Simplified J-function" in swfn assert "0.1000000 0.0000000 0.23266" in swfn # this is the first row. sat_table_str_ok(swfn) sgfn = gaswater.SGFN() # Capillary pressure in SGFN must always be zero for GasWater. assert "Zero capillary pressure" in sgfn sat_table_str_ok(sgfn) # Overwrite to zero: gaswater.add_simple_J(drho=0) swfn = gaswater.SWFN() assert "0.1000000 0.0000000 0.0000000" in swfn # first row sat_table_str_ok(sgfn) # Petrophysical pc: gaswater.add_simple_J_petro(a=1, b=-1) swfn = gaswater.SWFN() assert "petrophysical version" in swfn assert "0.1000000 0.0000000 0.014715" in swfn # first row
def test_make_scalrecommendation_go(): """Test that we can make scal recommendation objects from three WaterOilGas objects, but only with GasOil objects""" go_param_names = [ "swirr", "sorg", "krgend", "krgmax", "swl", "sgcr", "Lg", "Eg", "Tg", "Log", "Eog", "Tog", "kroend", ] low_let_go = slicedict(LOW_SAMPLE_LET, go_param_names) low = PyscalFactory.create_water_oil_gas(low_let_go) base_let_go = slicedict(BASE_SAMPLE_LET, go_param_names) base = PyscalFactory.create_water_oil_gas(base_let_go) high_let_go = slicedict(HIGH_SAMPLE_LET, go_param_names) assert "Lw" not in high_let_go high = PyscalFactory.create_water_oil_gas(high_let_go) rec = SCALrecommendation(low, base, high) assert rec.type == WaterOilGas interpolant = rec.interpolate(-0.5) check_table(interpolant.gasoil.table) assert interpolant.wateroil is None sat_table_str_ok(interpolant.SGOF()) sat_table_str_ok(interpolant.SGFN()) # This should return empty string assert not interpolant.SWOF()
def test_slgof(swl, sorg, sgcr): """Test dumping SLGOF records""" wog = WaterOilGas(swl=swl, sorg=sorg, sgcr=sgcr, h=0.05) wog.wateroil.add_corey_water() wog.wateroil.add_corey_oil() wog.gasoil.add_corey_gas(krgmax=1) wog.gasoil.add_corey_oil() assert wog.selfcheck() slgof = wog.gasoil.slgof_df() assert "SL" in slgof assert "KRG" in slgof assert "KROG" in slgof assert not slgof.empty check_table(slgof) sat_table_str_ok(wog.SLGOF()) # Requirements from E100 manual: assert np.isclose(slgof["SL"].values[0], wog.gasoil.swl + wog.gasoil.sorg) assert np.isclose(slgof["KRG"].values[-1], 0) assert np.isclose(slgof["KROG"].values[0], 0)
def test_xls_factory(): """Test/demonstrate how to go from data in an excel row to pyscal objects This test function predates the load_relperm_df() function, but can still be in here. """ testdir = Path(__file__).absolute().parent xlsxfile = testdir / "data/scal-pc-input-example.xlsx" scalinput = pd.read_excel(xlsxfile, engine="openpyxl").set_index(["SATNUM", "CASE"]) for ((satnum, _), params) in scalinput.iterrows(): assert satnum wog = PyscalFactory.create_water_oil_gas(params.to_dict()) swof = wog.SWOF() assert "LET krw" in swof assert "LET krow" in swof assert "Simplified J" in swof sgof = wog.SGOF() sat_table_str_ok(sgof) assert "LET krg" in sgof assert "LET krog" in sgof
def test_let_pc_pd(): """Test LET formulation for primary drainage capillary pressure""" wateroil = WaterOil(swirr=0.1) wateroil.add_LET_pc_pd(Lp=1, Ep=1, Tp=1, Lt=1, Et=1, Tt=1, Pcmax=10, Pct=5) assert np.isclose(wateroil.table["PC"].max(), 10) assert np.isclose(wateroil.table["PC"].min(), 0) # (everything is linear) wateroil.add_LET_pc_pd(Lp=10, Ep=10, Tp=10, Lt=10, Et=10, Tt=10, Pcmax=10, Pct=5) assert np.isclose(wateroil.table["PC"].max(), 10) assert np.isclose(wateroil.table["PC"].min(), 0) # On a plot, you can see a kink at Pc=5. # wateroil.plotpc() wateroil = WaterOil(swirr=0.1, sorw=0.4) wateroil.add_LET_pc_pd(Lp=10, Ep=10, Tp=10, Lt=10, Et=10, Tt=10, Pcmax=5, Pct=2) assert np.isclose(wateroil.table["PC"].max(), 5) assert np.isclose(wateroil.table["PC"].min(), 0) # On plot: hard-to-see kink at Pc=2. . # wateroil.plotpc() wateroil.add_corey_water() wateroil.add_corey_oil() sat_table_str_ok(wateroil.SWOF())
def test_gasoil_corey1(ng, nog): """Test the Corey formulation for gasoil""" gasoil = GasOil() try: gasoil.add_corey_oil(nog=nog) gasoil.add_corey_gas(ng=ng) except AssertionError: # This happens for "invalid" input return assert "krog" in gasoil.table assert "krg" in gasoil.table assert isinstance(gasoil.krgcomment, str) check_table(gasoil.table) sgofstr = gasoil.SGOF() assert len(sgofstr) > 100 sat_table_str_ok(sgofstr) gasoil.resetsorg() check_table(gasoil.table) check_linear_sections(gasoil) sgofstr = gasoil.SGOF() assert len(sgofstr) > 100 sat_table_str_ok(sgofstr)