Exemple #1
0
    def disabled_test_mono_equals_multi(self):
        """
        test that the mono_dimensional elliptic solver gives the same answer as
        the grid bucket elliptic
        """
        g = pp.CartGrid([10, 10])
        g.compute_geometry()
        gb = pp.meshing.cart_grid([], [10, 10])
        param_g = pp.Parameters(g)

        def bc_val(g):
            left = g.face_centers[0] < 1e-6
            right = g.face_centers[0] > 10 - 1e-6

            bc_val = np.zeros(g.num_faces)
            bc_val[left] = -1
            bc_val[right] = 1
            return bc_val

        def bc_labels(g):
            bound_faces = g.tags["domain_boundary_faces"].nonzero()[0]
            bound_face_centers = g.face_centers[:, bound_faces]
            left = bound_face_centers[0] < 1e-6
            right = bound_face_centers[0] > 10 - 1e-6

            labels = np.array(["neu"] * bound_faces.size)
            labels[np.logical_or(right, left)] = "dir"
            bc_labels = pp.BoundaryCondition(g, bound_faces, labels)

            return bc_labels

        param_g.set_bc_val("flow", bc_val(g))
        param_g.set_bc("flow", bc_labels(g))

        gb.add_node_props(["param"])
        for sub_g, d in gb:
            d["param"] = pp.Parameters(sub_g)
            d["param"].set_bc_val("flow", bc_val(g))
            d["param"].set_bc("flow", bc_labels(sub_g))

        for e, d in gb.edges():
            gl, _ = gb.nodes_of_edge(e)
            d_l = gb.node_props(gl)
            d["kn"] = 1.0 / np.mean(d_l["param"].get_aperture())

        problem_mono = pp.EllipticModel(g, {"param": param_g})
        problem_mult = pp.EllipticModel(gb)

        p_mono = problem_mono.solve()
        p_mult = problem_mult.solve()

        self.assertTrue(np.allclose(p_mono, p_mult))
Exemple #2
0
    def disabled_test_elliptic_uniform_flow_cart(self):
        gb = setup_2d_1d([10, 10])
        problem = pp.EllipticModel(gb)
        p = problem.solve()
        problem.split()

        for g, d in gb:
            pressure = d[problem.keyword]
            p_analytic = g.cell_centers[1]
            p_diff = pressure - p_analytic
            self.assertTrue(np.max(np.abs(p_diff)) < 2e-2)
Exemple #3
0
    def disabled_test_elliptic_dirich_neumann_source_sink_cart(self):
        gb = setup_3d(np.array([4, 4, 4]), simplex_grid=False)
        problem = pp.EllipticModel(gb)
        p = problem.solve()
        problem.split("pressure")

        for g, d in gb:
            if g.dim == 3:
                p_ref = elliptic_dirich_neumann_source_sink_cart_ref_3d()
                self.assertTrue(np.allclose(d[problem.keyword], p_ref))
            if g.dim == 0:
                p_ref = [-10681.52153285]
                self.assertTrue(np.allclose(d[problem.keyword], p_ref))
        return gb
Exemple #4
0
    def disabled_test_elliptic_uniform_flow_simplex(self):
        """
        Unstructured simplex grid. Note that the solution depends
        on the grid quality. Also sensitive to the way in which
        the tpfa half transmissibilities are computed.
        """
        gb = setup_2d_1d(np.array([10, 10]), simplex_grid=True)
        problem = pp.EllipticModel(gb)
        p = problem.solve()
        problem.split()

        for g, d in gb:
            pressure = d[problem.keyword]
            p_analytic = g.cell_centers[1]
            p_diff = pressure - p_analytic
            self.assertTrue(np.max(np.abs(p_diff)) < 0.033)
Exemple #5
0
def solve_elliptic_problem(gb):
    for g, d in gb:
        if g.dim == 2:
            d["param"].set_source("flow", source(g, 0.0))

        dir_bound = g.tags["domain_boundary_faces"].nonzero()[0]
        bc_cond = pp.BoundaryCondition(g, dir_bound, ["dir"] * dir_bound.size)
        d["param"].set_bc("flow", bc_cond)

    gb.add_edge_props("param")
    for e, d in gb.edges():
        g_h = gb.nodes_of_edge(e)[1]
        d["param"] = pp.Parameters(g_h)
    flux = pp.EllipticModel(gb)
    p = flux.solve()
    flux.split("pressure")
    pp.fvutils.compute_discharges(gb)
Exemple #6
0
    def __init__(self, pb):

        pb["theta_ref"] = pb["temperature_at_depth"]
        pb["water"] = pp.Water(pb["theta_ref"])
        pb["rock"] = pp.Granite(pb["theta_ref"])

        # create the computational grid
        gb = create_grid(pb)

        # Darcy problem
        self.assign_data(gb, pb, FlowData, "problem")
        pb["file_name"] = "hydraulic_head"
        flow = pp.EllipticModel(gb, **pb)

        # transport problem
        self.assign_data(gb, pb, TransportData, "transport_data")
        pb["file_name"] = "temperature"
        transport = TransportSolver(gb, **pb)

        darcy_and_transport.DarcyAndTransport.__init__(self, flow, transport)