예제 #1
0
def test_swl_from_height_simple_J(swlheight, swirr, a, b, poro_ref, perm_ref,
                                  expected):
    """Test the calculation of swlheight from input parameters"""
    # pylint: disable=invalid-name,too-many-arguments
    result = capillarypressure.swl_from_height_simpleJ(swlheight, swirr, a, b,
                                                       poro_ref, perm_ref)

    if isinstance(result, (list, np.ndarray)):
        assert np.isclose(result, expected).all()
    else:
        assert np.isclose(result, expected)
예제 #2
0
def test_reference_implementation_swl_from_height():
    swlheight = 300
    permref = 10
    pororef = 0.3
    a = 1
    b = -2.2
    swirr = 0.02

    # Lines copied from Drogon:
    j_swlheight = swlheight * math.sqrt(permref / pororef)  # J at swlheight
    swn_swlheight = math.pow(j_swlheight / a, 1 / b)  # swn at swlheigh_
    ref_swl = swirr + (1 - swirr) * swn_swlheight  # swl = sw at swlheight

    swl = capillarypressure.swl_from_height_simpleJ(swlheight, swirr, a, b,
                                                    pororef, permref)

    assert np.isclose(swl, ref_swl)
예제 #3
0
    def create_water_oil(params=None):
        """Create a WaterOil object from a dictionary of parameters.

        Parameterization (Corey/LET) is inferred from presence
        of certain parameters in the dictionary.

        Don't rely on behaviour of you supply both Corey and LET at
        the same time.

        Parameter names in the dictionary are case insensitive. You
        can use Swirr, swirr, sWirR, swiRR etc.

        NB: the add_LET_* methods have the names 'l', 'e' and 't'
        in their signatures, which is not precise enough in this
        context, so we require e.g. 'Lw' and 'Low' (which both will be
        translated to 'l')

        Recognized parameters:
          swirr, swl, swcr, sorw, h, tag, nw, now, krwmax, krwend,
          lw, ew, tw, low, eow, tow, lo, eo, to, kroend,
          a, a_petro, b, b_petro, poro_ref, perm_ref, drho,
          a, b, poro, perm, sigma_costau

        Args:
            params (dict): Dictionary with parameters describing the WaterOil object.
        """
        if not params:
            params = dict()
        if not isinstance(params, dict):
            raise TypeError("Parameter to create_water_oil must be a dictionary")

        check_deprecated(params)

        sufficient_water_oil_params(params, failhard=True)

        # For case insensitiveness, all keys are converted to lower case:
        params = {key.lower(): value for (key, value) in params.items()}

        # Allowing sending in NaN values, delete those keys.
        params = filter_nan_from_dict(params)

        usedparams = set()

        # Check if we should initialize swl from a swlheight parameter:
        if set(WO_SWL_FROM_HEIGHT).issubset(params):
            if "swl" in params:
                raise ValueError(
                    "Do not provide both swl and swlheight at the same time"
                )
            params_swl_from_height = slicedict(params, WO_SWL_FROM_HEIGHT)
            params["swl"] = capillarypressure.swl_from_height_simpleJ(
                **params_swl_from_height
            )
            if "swcr" in params and params["swcr"] < params["swl"]:
                raise ValueError(
                    "Provided swcr={} is lower than computed swl={}".format(
                        params["swcr"], params["swl"]
                    )
                )
        elif set(WO_SWLHEIGHT).issubset(params):
            raise ValueError(
                (
                    "Can't initialize from SWLHEIGHT without "
                    "sufficient simple-J parameters, all of: "
                    "{}".format(WO_SWL_FROM_HEIGHT)
                )
            )

        # Should we have a swcr relative to swl?
        if set(WO_SWCR_ADD).issubset(params):
            if "swl" not in params:
                raise ValueError(
                    (
                        "If swcr should be relative to swl, "
                        "both swcr_add and swl must be provided"
                    )
                )
            if "swcr" in params:
                raise ValueError(
                    "Do not provide both swcr and swcr_add at the same time"
                )
            params["swcr"] = params["swl"] + params[WO_SWCR_ADD[0]]

        # No requirements to the base objects, defaults are ok.
        wateroil = WaterOil(**slicedict(params, WO_INIT))
        usedparams = usedparams.union(set(slicedict(params, WO_INIT).keys()))
        logger.debug(
            "Initialized WaterOil object from parameters %s", str(list(usedparams))
        )

        # Water curve
        params_corey_water = slicedict(params, WO_COREY_WATER + WO_WATER_ENDPOINTS)
        params_let_water = slicedict(params, WO_LET_WATER + WO_WATER_ENDPOINTS)
        if set(WO_COREY_WATER).issubset(set(params_corey_water)):
            wateroil.add_corey_water(**params_corey_water)
            logger.debug(
                "Added Corey water to WaterOil object from parameters %s",
                str(params_corey_water.keys()),
            )
        elif set(WO_LET_WATER).issubset(set(params_let_water)):
            params_let_water["l"] = params_let_water.pop("lw")
            params_let_water["e"] = params_let_water.pop("ew")
            params_let_water["t"] = params_let_water.pop("tw")
            wateroil.add_LET_water(**params_let_water)
            logger.debug(
                "Added LET water to WaterOil object from parameters %s",
                str(params_let_water.keys()),
            )
        else:
            logger.warning(
                "Missing or ambiguous parameters for water curve in WaterOil object"
            )

        # Oil curve:
        params_corey_oil = slicedict(params, WO_COREY_OIL + WO_OIL_ENDPOINTS)
        params_let_oil = slicedict(
            params, WO_LET_OIL + WO_LET_OIL_ALT + WO_OIL_ENDPOINTS
        )
        if set(WO_COREY_OIL).issubset(set(params_corey_oil)):
            if "krowend" in params_corey_oil:
                # (deprecation warning is triggered)
                params_corey_oil["kroend"] = params_corey_oil.pop("krowend")
            wateroil.add_corey_oil(**params_corey_oil)
            logger.debug(
                "Added Corey water to WaterOil object from parameters %s",
                str(params_corey_oil.keys()),
            )
        elif set(WO_LET_OIL).issubset(set(params_let_oil)):
            params_let_oil["l"] = params_let_oil.pop("low")
            params_let_oil["e"] = params_let_oil.pop("eow")
            params_let_oil["t"] = params_let_oil.pop("tow")
            if "krowend" in params_let_oil:
                # (deprecation warning is triggered)
                params_let_oil["kroend"] = params_let_oil.pop("krowend")
            wateroil.add_LET_oil(**params_let_oil)
            logger.debug(
                "Added LET water to WaterOil object from parameters %s",
                str(params_let_oil.keys()),
            )
        elif set(WO_LET_OIL_ALT).issubset(set(params_let_oil)):
            params_let_oil["l"] = params_let_oil.pop("lo")
            params_let_oil["e"] = params_let_oil.pop("eo")
            params_let_oil["t"] = params_let_oil.pop("to")
            if "krowend" in params_let_oil:
                # (deprecation warning is triggered)
                params_let_oil["kroend"] = params_let_oil.pop("krowend")
            wateroil.add_LET_oil(**params_let_oil)
            logger.debug(
                "Added LET water to WaterOil object from parameters %s",
                str(params_let_oil.keys()),
            )
        else:
            logger.warning(
                "Missing or ambiguous parameters for oil curve in WaterOil object"
            )

        # Capillary pressure:
        params_simple_j = slicedict(params, WO_SIMPLE_J + ["g"])
        params_norm_j = slicedict(params, WO_NORM_J)
        params_simple_j_petro = slicedict(params, WO_SIMPLE_J_PETRO + ["g"])
        if set(WO_SIMPLE_J).issubset(set(params_simple_j)):
            wateroil.add_simple_J(**params_simple_j)
        elif set(WO_SIMPLE_J_PETRO).issubset(set(params_simple_j_petro)):
            params_simple_j_petro["a"] = params_simple_j_petro.pop("a_petro")
            params_simple_j_petro["b"] = params_simple_j_petro.pop("b_petro")
            wateroil.add_simple_J_petro(**params_simple_j_petro)
        elif set(WO_NORM_J).issubset(set(params_norm_j)):
            wateroil.add_normalized_J(**params_norm_j)
        else:
            logger.info(
                (
                    "Missing or ambiguous parameters for capillary pressure in "
                    "WaterOil object. Using zero."
                )
            )
        if not wateroil.selfcheck():
            raise ValueError(
                ("Incomplete WaterOil object, some parameters missing to factory")
            )
        return wateroil