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_make_scalrecommendation_wo(): """Test that we can make scal recommendation objects from three WaterOilGas objects, but only with WaterOil objects""" wo_param_names = [ "swirr", "sorw", "krwend", "krwmax", "swl", "swcr", "Lw", "Ew", "Tw", "Lo", "Eo", "To", "krowend", ] low_let_wo = slicedict(LOW_SAMPLE_LET, wo_param_names) low = PyscalFactory.create_water_oil_gas(low_let_wo) base_let_wo = slicedict(BASE_SAMPLE_LET, wo_param_names) base = PyscalFactory.create_water_oil_gas(base_let_wo) high_let_wo = slicedict(HIGH_SAMPLE_LET, wo_param_names) assert "Lg" not in high_let_wo high = PyscalFactory.create_water_oil_gas(high_let_wo) rec = SCALrecommendation(low, base, high) interpolant = rec.interpolate(-0.5) check_table(interpolant.wateroil.table) assert interpolant.gasoil is None assert sat_table_str_ok(interpolant.SWOF()) assert sat_table_str_ok(interpolant.SWFN()) # This should return empty string assert not interpolant.SGOF()
def interpolateplottest(): """Demonstration of interpolation pointwise between LET curves""" import matplotlib.pyplot as plt import matplotlib matplotlib.style.use("ggplot") rec = SCALrecommendation(lowsample(), basesample(), highsample(), "foo", h=0.001) _, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) # Choosing logarithmic spaced interpolation parameters # is not the same as interpolating in log(kr)-space # check the effect by setting # for t in -2 + np.logspace(1e-5,1e-1,15): # and # for t in -1 + np.logspace(1e-5,1e-1,15) # in the loops below. Curves get clustered to the bottom # in both linear and log(kr) spaces, but there # still might be some other distribution for the interpolants # that yields something that spans nicely both the linear and the # logarithmic kr space (?) for t in np.arange(-1, 0, 0.2): interp = rec.interpolate(t, h=0.001) interp.wateroil.plotkrwkrow(ax1, "r") interp.wateroil.plotkrwkrow(ax2, "r") for t in np.arange(0, 1, 0.2): interp = rec.interpolate(t, h=0.001) interp.wateroil.plotkrwkrow(ax1, "g") interp.wateroil.plotkrwkrow(ax2, "g") rec.low.wateroil.plotkrwkrow(ax1, linewidth=2, linestyle=":") rec.base.wateroil.plotkrwkrow(ax1, linewidth=2) rec.high.wateroil.plotkrwkrow(ax1, linewidth=2, linestyle="--") rec.low.wateroil.plotkrwkrow(ax2, linewidth=2, linestyle=":") rec.base.wateroil.plotkrwkrow(ax2, linewidth=2) rec.high.wateroil.plotkrwkrow(ax2, linewidth=2, linestyle="--") ax2.set_yscale("log") ax2.set_ylim([1e-10, 1]) ax1.set_title("Water-oil, low, base, high and interpolants") ax2.set_title("Water-oil, low, base, high and interpolants") for t in np.arange(-1, 0, 0.2): interp = rec.interpolate(t, h=0.001) interp.gasoil.plotkrgkrog(ax3, "r") interp.gasoil.plotkrgkrog(ax4, "r") for t in np.arange(0, 1, 0.2): interp = rec.interpolate(t, h=0.001) interp.gasoil.plotkrgkrog(ax3, "g") interp.gasoil.plotkrgkrog(ax4, "g") rec.low.gasoil.plotkrgkrog(ax3, linewidth=2, linestyle=":") rec.base.gasoil.plotkrgkrog(ax3, linewidth=2) rec.high.gasoil.plotkrgkrog(ax3, linewidth=2, linestyle="--") rec.low.gasoil.plotkrgkrog(ax4, linewidth=2, linestyle=":") rec.base.gasoil.plotkrgkrog(ax4, linewidth=2) rec.high.gasoil.plotkrgkrog(ax4, linewidth=2, linestyle="--") ax3.set_title("Gas-oil, low, base, high and interpolants") ax4.set_title("Gas-oil, low, base, high and interpolants") ax4.set_yscale("log") ax4.set_ylim([1e-05, 1]) plt.subplots_adjust(hspace=0.3) plt.show()
def test_boundary_cases(): rec = SCALrecommendation(low_sample_let, base_sample_let, high_sample_let, "foo", h=0.1) # Object reference equivalence is a little bit strict, # because it would be perfectly fine if interpolate() # retured copied objects. But we don't have an equivalence operator # implemented. assert rec.interpolate(0).wateroil == rec.base.wateroil assert rec.interpolate(-1).wateroil == rec.low.wateroil assert rec.interpolate(1).wateroil == rec.high.wateroil assert rec.interpolate(0).gasoil == rec.base.gasoil assert rec.interpolate(-1).gasoil == rec.low.gasoil assert rec.interpolate(1).gasoil == rec.high.gasoil assert rec.interpolate(0, 1).wateroil == rec.base.wateroil assert rec.interpolate(-1, 1).wateroil == rec.low.wateroil assert rec.interpolate(1, 1).wateroil == rec.high.wateroil assert rec.interpolate(0, 1).gasoil == rec.high.gasoil assert rec.interpolate(-1, 1).gasoil == rec.high.gasoil assert rec.interpolate(1, 1).gasoil == rec.high.gasoil assert rec.interpolate(0, 0).gasoil == rec.base.gasoil assert rec.interpolate(-1, 0).gasoil == rec.base.gasoil assert rec.interpolate(1, 0).gasoil == rec.base.gasoil assert rec.interpolate(0, -1).gasoil == rec.low.gasoil assert rec.interpolate(-1, -1).gasoil == rec.low.gasoil assert rec.interpolate(1, -1).gasoil == rec.low.gasoil