def test_normalize_nonlinpart_wo_hypo( swl, dswcr, dswlhigh, sorw, nw1, krwend1, now1, kroend1, nw2, krwend2, now2, kroend2 ): # pylint: disable=too-many-arguments,too-many-locals """Test the normalization code in utils. In particular the fill_value argument to scipy has been tuned to fulfill this code""" wo_low = WaterOil(swl=swl, swcr=swl + dswcr, sorw=sorw) wo_high = WaterOil( swl=swl + dswlhigh, swcr=swl + dswlhigh + dswcr, sorw=max(sorw - 0.01, 0) ) wo_low.add_corey_water(nw=nw1, krwend=krwend1) wo_high.add_corey_water(nw=nw2, krwend=krwend2) wo_low.add_corey_oil(now=now1, kroend=kroend1) wo_high.add_corey_oil(now=now2, kroend=kroend2) krwn1, kron1 = normalize_nonlinpart_wo(wo_low) assert np.isclose(krwn1(0), 0) assert np.isclose(krwn1(1), krwend1) assert np.isclose(kron1(0), 0) assert np.isclose(kron1(1), kroend1) krwn2, kron2 = normalize_nonlinpart_wo(wo_high) assert np.isclose(krwn2(0), 0) assert np.isclose(krwn2(1), krwend2) assert np.isclose(kron2(0), 0) assert np.isclose(kron2(1), kroend2)
def test_normalize_nonlinpart_wo(): """Manual tests for normalize_nonlinpart_wo""" wateroil = WaterOil(swl=0.1, swcr=0.12, sorw=0.05, h=0.05) wateroil.add_corey_water(nw=2.1, krwend=0.9) wateroil.add_corey_oil(now=3, kroend=0.8) krwn, kron = normalize_nonlinpart_wo(wateroil) assert np.isclose(krwn(0), 0) assert np.isclose(krwn(1), 0.9) # kron is normalized on son assert np.isclose(kron(0), 0) assert np.isclose(kron(1), 0.8) # Test with tricky endpoints h = 0.01 wateroil = WaterOil(swl=h, swcr=h, sorw=h, h=h) wateroil.add_corey_water(nw=2.1, krwend=0.9) wateroil.add_corey_oil(now=3, kroend=0.8) krwn, kron = normalize_nonlinpart_wo(wateroil) assert np.isclose(krwn(0), 0.0) assert np.isclose(krwn(1), 0.9) assert np.isclose(kron(0), 0) assert np.isclose(kron(1), 0.8) # Test again with zero endpoints: wateroil = WaterOil(swl=0, swcr=0, sorw=0, h=0.01) wateroil.add_corey_water(nw=2.1, krwend=0.9) wateroil.add_corey_oil(now=3, kroend=0.8) krwn, kron = normalize_nonlinpart_wo(wateroil) assert np.isclose(krwn(0), 0.0) assert np.isclose(krwn(1), 0.9) assert np.isclose(kron(0), 0) assert np.isclose(kron(1), 0.8) # Test when endpoints are messed up: wateroil = WaterOil(swl=0.1, swcr=0.2, sorw=0.1, h=0.1) wateroil.add_corey_water(nw=2.1, krwend=0.6) wateroil.add_corey_oil(now=3, kroend=0.8) wateroil.swl = 0 wateroil.swcr = 0 wateroil.sorw = 0 krwn, kron = normalize_nonlinpart_wo(wateroil) # These go well still, since we are at zero assert np.isclose(krwn(0), 0.0) assert np.isclose(kron(0), 0) # These do not match when endpoints are wrong assert not np.isclose(krwn(1), 0.6) # This is ok, as kro is anchored at swl assert np.isclose(kron(1), 0.8) # So fix endpoints! wateroil.swl = wateroil.table["sw"].min() wateroil.swcr = wateroil.estimate_swcr() wateroil.sorw = wateroil.estimate_sorw() # Try again krwn, kron = normalize_nonlinpart_wo(wateroil) assert np.isclose(krwn(0), 0.0) assert np.isclose(kron(0), 0) assert np.isclose(krwn(1), 0.6) assert np.isclose(kron(1), 0.8)