def test_wateroil_krendmax(swl, swcr, sorw, kroend, kromax, krwend, krwmax, h, fast): """Test endpoints for wateroil using hypothesis testing""" try: wateroil = WaterOil(swl=swl, swcr=swcr, sorw=sorw, h=h, fast=fast) except AssertionError: return kroend = min(kroend, kromax) krwend = min(krwend, krwmax) wateroil.add_corey_oil(kroend=kroend, kromax=kromax) wateroil.add_corey_water(krwend=krwend, krwmax=krwmax) check_table(wateroil.table) assert wateroil.selfcheck() assert 0 < wateroil.crosspoint() < 1 check_endpoints(wateroil, krwend, krwmax, kroend, kromax) #################################### # Do it over again, but with LET: wateroil.add_LET_oil(t=1.1, kroend=kroend, kromax=kromax) wateroil.add_LET_water(t=1.1, krwend=krwend, krwmax=krwmax) assert wateroil.selfcheck() check_table(wateroil.table) # Check endpoints for oil curve: check_endpoints(wateroil, krwend, krwmax, kroend, kromax) check_linear_sections(wateroil) assert 0 < wateroil.crosspoint() < 1
def test_wateroil_linear(): """Test linear wateroil curves""" wateroil = WaterOil(h=1) wateroil.add_corey_water() wateroil.add_corey_oil() swofstr = wateroil.SWOF(header=False) check_table(wateroil.table) check_linear_sections(wateroil) assert isinstance(swofstr, str) assert swofstr assert len(wateroil.table) == 2 assert np.isclose(wateroil.crosspoint(), 0.5) # What if there is no space for our choice of h? # We should be able to initialize nonetheless # (a warning could be given) wateroil = WaterOil(swl=0.1, h=1) wateroil.add_corey_water() wateroil.add_corey_oil() check_table(wateroil.table) check_linear_sections(wateroil) assert len(wateroil.table) == 2 assert np.isclose(wateroil.table["sw"].min(), 0.1) assert np.isclose(wateroil.table["sw"].max(), 1.0) assert np.isclose(wateroil.crosspoint(), 0.55)
def test_linearsegments(): """Made for testing the linear segments during the resolution of issue #163""" wateroil = WaterOil(h=0.01, swl=0.1, swcr=0.3, sorw=0.3) wateroil.add_corey_oil(now=10, kroend=0.5) wateroil.add_corey_water(nw=10, krwend=0.5) check_table(wateroil.table) check_linear_sections(wateroil)
def test_linearsegments(): """Made for testing the linear segments during the resolution of issue #163""" gasoil = GasOil(h=0.01, swl=0.1, sgcr=0.3, sorg=0.3) gasoil.add_corey_oil(nog=10, kroend=0.5) gasoil.add_corey_gas(ng=10, krgend=0.5) check_table(gasoil.table) check_linear_sections(gasoil)
def test_gasoil_krgendanchor(): """Test behaviour of the krgendanchor""" gasoil = GasOil(krgendanchor="sorg", sorg=0.2, h=0.1) assert gasoil.sorg gasoil.add_corey_gas(ng=1) gasoil.add_corey_oil(nog=1) # kg should be 1.0 at 1 - sorg due to krgendanchor == "sorg": assert (gasoil.table[np.isclose(gasoil.table["sg"], 1 - gasoil.sorg)]["krg"].values[0] == 1.0) assert gasoil.table[np.isclose(gasoil.table["sg"], 1.0)]["krg"].values[0] == 1.0 gasoil = GasOil(krgendanchor="", sorg=0.2, h=0.1) assert gasoil.sorg gasoil.add_corey_gas(ng=1) gasoil.add_corey_oil(nog=1) # kg should be < 1 at 1 - sorg due to krgendanchor being "" assert (gasoil.table[np.isclose(gasoil.table["sg"], 1 - gasoil.sorg)]["krg"].values[0] < 1.0) assert gasoil.table[np.isclose(gasoil.table["sg"], 1.0)]["krg"].values[0] == 1.0 assert gasoil.selfcheck() assert gasoil.crosspoint() > 0 # Test once more for LET curves: gasoil = GasOil(krgendanchor="sorg", sorg=0.2, h=0.1) assert gasoil.sorg gasoil.add_LET_gas(1, 1, 1.1) gasoil.add_LET_oil(1, 1, 1.1) check_linear_sections(gasoil) assert 0 < gasoil.crosspoint() < 1 # kg should be 1.0 at 1 - sorg due to krgendanchor == "sorg": assert (gasoil.table[np.isclose(gasoil.table["sg"], 1 - gasoil.sorg)]["krg"].values[0] == 1.0) assert gasoil.table[np.isclose(gasoil.table["sg"], 1.0)]["krg"].values[0] == 1.0 gasoil = GasOil(krgendanchor="", sorg=0.2, h=0.1) assert gasoil.sorg gasoil.add_LET_gas(1, 1, 1.1) gasoil.add_LET_oil(1, 1, 1.1) check_linear_sections(gasoil) assert gasoil.selfcheck() # kg should be < 1 at 1 - sorg due to krgendanchor being "" assert (gasoil.table[np.isclose(gasoil.table["sg"], 1 - gasoil.sorg)]["krg"].values[0] < 1.0) assert gasoil.table[np.isclose(gasoil.table["sg"], 1.0)]["krg"].values[0] == 1.0
def test_wateroil_let1(l, e, t, krwend, krwmax): """Test random LET parameters""" wateroil = WaterOil() try: wateroil.add_LET_oil(l, e, t, krwend, krwmax) wateroil.add_LET_water(l, e, t, krwend, krwmax) except AssertionError: # This happens for negative values f.ex. return assert "krow" in wateroil.table assert "krw" in wateroil.table assert isinstance(wateroil.krwcomment, str) check_table(wateroil.table) check_linear_sections(wateroil) swofstr = wateroil.SWOF() assert len(swofstr) > 100
def test_wateroil_corey1(nw, now): """Test random corey parameters""" wateroil = WaterOil() try: wateroil.add_corey_oil(now=now) wateroil.add_corey_water(nw=nw) except AssertionError: # This happens for "invalid" input return assert "krow" in wateroil.table assert "krw" in wateroil.table assert isinstance(wateroil.krwcomment, str) check_table(wateroil.table) check_linear_sections(wateroil) swofstr = wateroil.SWOF() assert len(swofstr) > 100
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_kromaxend(): """Manual testing of kromax and kroend behaviour""" gasoil = GasOil(swirr=0.01, sgcr=0.01, h=0.01, swl=0.1, sorg=0.05) gasoil.add_LET_gas() gasoil.add_LET_oil(2, 2, 2.1) assert gasoil.table["krog"].max() == 1 gasoil.add_LET_oil(2, 2, 2.1, kroend=0.5, kromax=0.9) check_linear_sections(gasoil) assert gasoil.table["krog"].max() == 0.9 # Second krog-value should be kroend, values in between will be linearly # interpolated in Eclipse assert gasoil.table.sort_values("krog")[-2:-1]["krog"].values[0] == 0.5 assert 0 < gasoil.crosspoint() < 1 gasoil.add_corey_oil(2) assert gasoil.table["krog"].max() == 1 gasoil.add_corey_oil(nog=2, kroend=0.5, kromax=0.9) assert gasoil.table["krog"].max() == 0.9 assert gasoil.table.sort_values("krog")[-2:-1]["krog"].values[0] == 0.5
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)
def test_gasoil_krendmax(swl, sgcr, sorg, kroend, kromax, krgend, krgmax, h, fast): """Test that krendmax gets correct in all numerical corner cases. The normalized sg-range is allowed to collapse to nothing in this test. (causes AssertionError) """ try: gasoil = GasOil(swl=swl, sgcr=sgcr, sorg=sorg, h=h, tag="", fast=fast) except AssertionError: return kroend = min(kroend, kromax) krgend = min(krgend, krgmax) gasoil.add_corey_oil(kroend=kroend, kromax=kromax) gasoil.add_corey_gas(krgend=krgend, krgmax=krgmax) check_table(gasoil.table) check_linear_sections(gasoil) assert gasoil.selfcheck() check_endpoints(gasoil, krgend, krgmax, kroend, kromax) assert 0 < gasoil.crosspoint() < 1 # Redo with krgendanchor not defaulted gasoil = GasOil(swl=swl, sgcr=sgcr, sorg=sorg, h=h, krgendanchor="", tag="") gasoil.add_corey_oil(kroend=kroend, kromax=kromax) gasoil.add_corey_gas(krgend=krgend, krgmax=krgmax) check_table(gasoil.table) check_linear_sections(gasoil) assert gasoil.selfcheck() check_endpoints(gasoil, krgend, krgmax, kroend, kromax) assert 0 < gasoil.crosspoint() < 1 # Redo with LET: gasoil = GasOil(swl=swl, sgcr=sgcr, sorg=sorg, h=h, tag="") gasoil.add_LET_oil(t=1.1, kroend=kroend, kromax=kromax) gasoil.add_LET_gas(krgend=krgend, krgmax=krgmax) check_table(gasoil.table) check_linear_sections(gasoil) assert gasoil.selfcheck() check_endpoints(gasoil, krgend, krgmax, kroend, kromax) assert 0 < gasoil.crosspoint() < 1