def test_gaswater_linear(): """Test linear gaswater curves (linear as in giving only two saturation points to Eclipse)""" gaswater = GasWater(h=1) gaswater.add_corey_water() gaswater.add_corey_gas() swfnstr = gaswater.SWFN(header=False) check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table) check_linear_sections(gaswater.wateroil) check_linear_sections(gaswater.gasoil) assert isinstance(swfnstr, str) assert swfnstr assert len(gaswater.wateroil.table) == 2 # assert np.isclose(gaswater.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) gaswater = GasWater(swl=0.1, h=1) gaswater.add_corey_water() gaswater.add_corey_gas() check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table) check_linear_sections(gaswater.wateroil) check_linear_sections(gaswater.gasoil) assert len(gaswater.wateroil.table) == 2 assert len(gaswater.gasoil.table) == 2 assert np.isclose(gaswater.wateroil.table["sw"].min(), 0.1) assert np.isclose(gaswater.wateroil.table["sw"].max(), 1.0)
def test_kroend(): """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) check_linear_sections(gasoil) assert gasoil.table["krog"].max() == 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) assert gasoil.table["krog"].max() == 0.5
def test_wateroil_let1(l, e, t, krwend, krwmax): """Test random LET parameters""" wateroil = WaterOil() try: wateroil.add_LET_oil(l, e, t, krwend) 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_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_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_gaswater_let1(l, e, t, krwend, krwmax): """Test random LET parameters""" gaswater = GasWater() try: gaswater.add_LET_gas(l, e, t, krwend) gaswater.add_LET_water(l, e, t, krwend, krwmax) except AssertionError: # This happens for negative values f.ex. return assert "krg" in gaswater.gasoil.table assert "krw" in gaswater.wateroil.table assert isinstance(gaswater.wateroil.krwcomment, str) check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table) check_linear_sections(gaswater.wateroil) check_linear_sections(gaswater.gasoil) swfnstr = gaswater.SWFN() assert len(swfnstr) > 100 sgfnstr = gaswater.SGFN() assert len(sgfnstr) > 100
def test_gaswater_corey1(nw, ng): """Test random corey parameters""" gaswater = GasWater() try: gaswater.add_corey_gas(ng=ng) gaswater.add_corey_water(nw=nw) except AssertionError: # This happens for "invalid" input return assert "krg" in gaswater.gasoil.table assert "krw" in gaswater.wateroil.table assert isinstance(gaswater.wateroil.krwcomment, str) check_table(gaswater.wateroil.table) check_table(gaswater.gasoil.table) check_linear_sections(gaswater.wateroil) check_linear_sections(gaswater.gasoil) swfnstr = gaswater.SWFN() assert len(swfnstr) > 100 sgfnstr = gaswater.SGFN() assert len(sgfnstr) > 100
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_wateroil_krendmax(swl, swcr, sorw, kroend, 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 krwend = min(krwend, krwmax) wateroil.add_corey_oil(kroend=kroend) 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) #################################### # Do it over again, but with LET: wateroil.add_LET_oil(t=1.1, kroend=kroend) 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) check_linear_sections(wateroil) assert 0 < wateroil.crosspoint() < 1
def test_gasoil_krendmax(swl, sgcr, sorg, sgrononzero, kroend, kromax, krgend, krgmax, h, fast): """Test that relperm curves are valid in all numerical corner cases.""" if sgrononzero: sgro = sgcr else: sgro = 0 try: gasoil = GasOil(swl=swl, sgcr=sgcr, sorg=sorg, sgro=sgro, h=h, tag="", fast=fast) except AssertionError: return krgend = min(krgend, krgmax) kroend = min(kroend, kromax) 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) 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
def test_gasoil_krendmax(swl, sgcr, sorg, kroend, 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 krgend = min(krgend, krgmax) gasoil.add_corey_oil(kroend=kroend) 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) 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) 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) 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) 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) assert 0 < gasoil.crosspoint() < 1