Пример #1
0
    def set_param_flow(self, gb, no_flow=False, kn=1e3, method="mpfa"):
        # Set up flow field with uniform flow in y-direction
        kw = "flow"
        for g, d in gb:
            parameter_dictionary = {}

            perm = pp.SecondOrderTensor(kxx=np.ones(g.num_cells))
            parameter_dictionary["second_order_tensor"] = perm

            b_val = np.zeros(g.num_faces)
            if g.dim == 2:
                bound_faces = pp.face_on_side(g, ["ymin", "ymax"])
                if no_flow:
                    b_val[bound_faces[0]] = 1
                    b_val[bound_faces[1]] = 1
                bound_faces = np.hstack((bound_faces[0], bound_faces[1]))
                labels = np.array(["dir"] * bound_faces.size)
                parameter_dictionary["bc"] = pp.BoundaryCondition(
                    g, bound_faces, labels)

                y_max_faces = pp.face_on_side(g, "ymax")[0]
                b_val[y_max_faces] = 1
            else:
                parameter_dictionary["bc"] = pp.BoundaryCondition(g)
            parameter_dictionary["bc_values"] = b_val
            parameter_dictionary["mpfa_inverter"] = "python"

            d[pp.PARAMETERS] = pp.Parameters(g, [kw], [parameter_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}

        gb.add_edge_props("kn")
        for e, d in gb.edges():
            mg = d["mortar_grid"]
            flow_dictionary = {
                "normal_diffusivity": 2 * kn * np.ones(mg.num_cells)
            }
            d[pp.PARAMETERS] = pp.Parameters(keywords=["flow"],
                                             dictionaries=[flow_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}

        discretization_key = kw + "_" + pp.DISCRETIZATION

        for g, d in gb:
            # Choose discretization and define the solver
            if method == "mpfa":
                discr = pp.Mpfa(kw)
            elif method == "mvem":
                discr = pp.MVEM(kw)
            else:
                discr = pp.Tpfa(kw)

            d[discretization_key] = discr

        for _, d in gb.edges():
            d[discretization_key] = pp.RobinCoupling(kw, discr)
Пример #2
0
    def set_params(self, gb, kn, kf):

        kw = "flow"

        for g, d in gb:
            parameter_dictionary = {}

            aperture = np.power(1e-2, gb.dim_max() - g.dim)
            parameter_dictionary["aperture"] = aperture * np.ones(g.num_cells)

            b_val = np.zeros(g.num_faces)
            if g.dim == 2:
                bound_faces = pp.face_on_side(g, ["ymin", "ymax"])
                bound_faces = np.hstack((bound_faces[0], bound_faces[1]))
                labels = np.array(["dir"] * bound_faces.size)

                parameter_dictionary["bc"] = pp.BoundaryCondition(
                    g, bound_faces, labels)

                y_max_faces = pp.face_on_side(g, "ymax")[0]
                b_val[y_max_faces] = 1

                perm = pp.SecondOrderTensor(kxx=np.ones(g.num_cells))
                parameter_dictionary["second_order_tensor"] = perm

            else:
                perm = pp.SecondOrderTensor(kxx=kf * np.ones(g.num_cells))
                parameter_dictionary["second_order_tensor"] = perm

                parameter_dictionary["bc"] = pp.BoundaryCondition(g)
            parameter_dictionary["bc_values"] = b_val
            parameter_dictionary["mpfa_inverter"] = "python"

            d[pp.PARAMETERS] = pp.Parameters(g, [kw], [parameter_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}

        gb.add_edge_props("kn")
        for _, d in gb.edges():
            mg = d["mortar_grid"]
            flow_dictionary = {
                "normal_diffusivity": kn * np.ones(mg.num_cells)
            }
            d[pp.PARAMETERS] = pp.Parameters(keywords=["flow"],
                                             dictionaries=[flow_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}
Пример #3
0
    def set_params(self, gb, no_flow=False):
        # Set up flow field with uniform flow in y-direction
        kw = "flow"
        kn = 1e6
        for g, d in gb:
            parameter_dictionary = {}

            perm = pp.SecondOrderTensor(kxx=np.ones(g.num_cells))
            parameter_dictionary["second_order_tensor"] = perm

            b_val = np.zeros(g.num_faces)
            if g.dim == 2:
                bound_faces = pp.face_on_side(g, ["ymin", "ymax"])
                if no_flow:
                    b_val[bound_faces[0]] = 1
                    b_val[bound_faces[1]] = 1
                bound_faces = np.hstack((bound_faces[0], bound_faces[1]))
                labels = np.array(["dir"] * bound_faces.size)
                parameter_dictionary["bc"] = pp.BoundaryCondition(
                    g, bound_faces, labels)

                y_max_faces = pp.face_on_side(g, "ymax")[0]
                b_val[y_max_faces] = 1
            else:
                parameter_dictionary["bc"] = pp.BoundaryCondition(g)
            parameter_dictionary["bc_values"] = b_val
            parameter_dictionary["mpfa_inverter"] = "python"

            d[pp.PARAMETERS] = pp.Parameters(g, [kw], [parameter_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}

        gb.add_edge_props("kn")
        for e, d in gb.edges():
            mg = d["mortar_grid"]
            flow_dictionary = {
                "normal_diffusivity": 2 * kn * np.ones(mg.num_cells)
            }
            d[pp.PARAMETERS] = pp.Parameters(keywords=["flow"],
                                             dictionaries=[flow_dictionary])
            d[pp.DISCRETIZATION_MATRICES] = {"flow": {}}
Пример #4
0
    def set_parameters(
        self,
        neu_val_top=None,
        dir_val_top=None,
        kn: float = 1e0,
        method="mpfa",
        aperture: float = 1e-1,
        gravity_angle: float = 0,
    ) -> None:
        """
        Parameters:
            neu_val_top (float): Default None implies Dirichlet on top. If not None,
                the prescribed value will be applied as the Neumann bc value.
            dir_val_top (float): If not None, the prescribed value will be
                applied as the Dirichlet bc value. Note that neu_val_top takes precedent
                over dir_val_top.
            method: Discretization method.
            kn: Normal permeability of the fracture. Will be multiplied by aperture/2
                to yield the normal diffusivity.
            aperture: Fracture aperture.
            gravity_angle: Angle by which to rotate the applied vector source field.
        """
        # Set up flow field with uniform flow in y-direction
        kw = "flow"
        gb = self.gb
        for g, d in gb:
            a = np.power(aperture, gb.dim_max() - g.dim)
            perm = pp.SecondOrderTensor(kxx=a * np.ones(g.num_cells))
            gravity = np.zeros((gb.dim_max(), g.num_cells))
            # Angle of zero means force vector of [0, -1]
            gravity[1, :] = -np.cos(gravity_angle)
            gravity[0, :] = np.sin(gravity_angle)

            b_val = np.zeros(g.num_faces)
            if g.dim == self.gb.dim_max():
                if neu_val_top is not None:
                    dir_faces = np.atleast_1d(pp.face_on_side(g, ["ymin"])[0])
                    neu_faces = np.atleast_1d(pp.face_on_side(g, ["ymax"])[0])
                    b_val[neu_faces] = neu_val_top
                else:
                    dir_faces = pp.face_on_side(g, ["ymin", "ymax"])
                    b_val[dir_faces[0]] = 0
                    if dir_val_top is not None:
                        b_val[dir_faces[1]] = dir_val_top
                    dir_faces = np.hstack((dir_faces[0], dir_faces[1]))
                labels = np.array(["dir"] * dir_faces.size)
                bc = pp.BoundaryCondition(g, dir_faces, labels)

            else:
                bc = pp.BoundaryCondition(g)
            parameter_dictionary = {
                "bc_values": b_val,
                "bc": bc,
                "ambient_dimension": gb.dim_max(),
                "mpfa_inverter": "python",
                "second_order_tensor": perm,
                "vector_source": gravity.ravel("F"),
            }
            pp.initialize_data(g, d, "flow", parameter_dictionary)

        for e, d in gb.edges():
            g1, g2 = gb.nodes_of_edge(e)
            mg = d["mortar_grid"]
            a = aperture * np.ones(mg.num_cells)
            gravity = np.zeros((gb.dim_max(), mg.num_cells))
            # Angle of zero means force vector of [0, -1]
            gravity[1, :] = -np.cos(gravity_angle)
            gravity[0, :] = np.sin(gravity_angle)
            gravity *= a / 2
            parameter_dictionary = {
                "normal_diffusivity": 2 / a * kn,
                "ambient_dimension": gb.dim_max(),
                "vector_source": gravity.ravel("F"),
            }
            pp.initialize_data(mg, d, "flow", parameter_dictionary)

        # discretization_key = kw + "_" + pp.DISCRETIZATION

        for g, d in gb:
            # Choose discretization and define the solver
            if method == "mpfa":
                discr = pp.Mpfa(kw)
            elif method == "tpfa":
                discr = pp.Tpfa(kw)
            else:
                raise ValueError("Unexpected discretization method ")