Esempio n. 1
0
def main(id_problem, tol=1e-5, N_pts=1000, if_export=False):

    folder_export = 'example_2_1_mpfa/' + str(id_problem) + "/"
    file_export = 'mpfa'

    gb = example_2_1_create_grid.create(id_problem, tol=tol)

    # Assign parameters
    example_2_1_data.add_data(gb, tol)

    # Choose and define the solvers and coupler
    solver_flux = mpfa.MpfaDFN(gb.dim_max(), 'flow')
    A_flux, b_flux = solver_flux.matrix_rhs(gb)
    solver_source = source.IntegralDFN(gb.dim_max(), 'flow')
    A_source, b_source = solver_source.matrix_rhs(gb)

    p = sps.linalg.spsolve(A_flux + A_source, b_flux + b_source)
    solver_flux.split(gb, 'pressure', p)

    if if_export:
        save = Exporter(gb, file_export, folder_export)
        save.write_vtk(['pressure'])

    b_box = gb.bounding_box()
    z_range = np.linspace(b_box[0][2], b_box[1][2], N_pts)
    pts = np.stack((0.5 * np.ones(N_pts), 0.5 * np.ones(N_pts), z_range))
    values = example_2_1_data.plot_over_line(gb, pts, 'pressure', tol)

    arc_length = z_range - b_box[0][2]
    np.savetxt(folder_export + "plot_over_line.txt", (arc_length, values))

    # compute the flow rate
    fvutils.compute_discharges(gb, 'flow')
    diam, flow_rate = example_2_1_data.compute_flow_rate(gb, tol)
    np.savetxt(folder_export + "flow_rate.txt", (diam, flow_rate))
Esempio n. 2
0
def main(id_problem, tol=1e-5, N_pts=1000, if_export=False):

    mesh_size = 0.025  # 0.01 0.05
    folder_export = 'example_2_3_mpfa_' + str(mesh_size) + '/' + str(
        id_problem) + "/"
    file_export = 'mpfa'

    gb = example_2_3_create_grid.create(id_problem,
                                        mesh_size=mesh_size,
                                        tol=tol)

    # Assign parameters
    example_2_3_data.add_data(gb, tol)

    # Choose and define the solvers and coupler
    solver_flux = mpfa.MpfaDFN(gb.dim_max(), 'flow')
    A_flux, b_flux = solver_flux.matrix_rhs(gb)
    solver_source = source.IntegralDFN(gb.dim_max(), 'flow')
    A_source, b_source = solver_source.matrix_rhs(gb)

    p = sps.linalg.spsolve(A_flux + A_source, b_flux + b_source)
    solver_flux.split(gb, "p", p)

    if if_export:
        save = Exporter(gb, file_export, folder_export)
        save.write_vtk(["p"])

    b_box = gb.bounding_box()
    y_range = np.linspace(b_box[0][1] + tol, b_box[1][1] - tol, N_pts)
    pts = np.stack((0.35 * np.ones(N_pts), y_range, np.zeros(N_pts)))
    values = example_2_3_data.plot_over_line(gb, pts, 'p', tol)

    arc_length = y_range - b_box[0][1]
    np.savetxt(folder_export + "plot_over_line.txt", (arc_length, values))

    # compute the flow rate
    fvutils.compute_discharges(gb, 'flow')
    diam, flow_rate = example_2_3_data.compute_flow_rate(gb, tol)
    np.savetxt(folder_export + "flow_rate.txt", (diam, flow_rate))

    # compute the number of cells
    num_cells = gb.num_cells(lambda g: g.dim == 2)
    with open(folder_export + "cells.txt", "w") as f:
        f.write(str(num_cells))
Esempio n. 3
0
def main(grid_name, direction):
    file_export = 'solution'
    tol = 1e-4

    folder_grids = '/home/elle/Dropbox/Work/tipetut/'
    gb = pickle.load(open(folder_grids + grid_name, 'rb'))

    folder_export = './example_4_mpfa_' + grid_name + '_' + direction + '/'

    domain = {
        'xmin': -800,
        'xmax': 600,
        'ymin': 100,
        'ymax': 1500,
        'zmin': -100,
        'zmax': 1000
    }

    example_4_data.add_data(gb, domain, direction, tol)

    # Choose and define the solvers and coupler
    solver_flux = mpfa.MpfaDFN(gb.dim_max(), 'flow')
    A_flux, b_flux = solver_flux.matrix_rhs(gb)

    solver_source = source.IntegralDFN(gb.dim_max(), 'flow')
    A_source, b_source = solver_source.matrix_rhs(gb)

    p = sps.linalg.spsolve(A_flux + A_source, b_flux + b_source)
    solver_flux.split(gb, "p", p)

    save = Exporter(gb, file_export, folder_export)
    save.write_vtk(["p"])

    # compute the flow rate
    fvutils.compute_discharges(gb, 'flow')
    diam, flow_rate = example_4_data.compute_flow_rate(gb, direction, domain,
                                                       tol)
    np.savetxt(folder_export + "flow_rate.txt", (diam, flow_rate))

    # compute the number of cells
    num_cells = gb.num_cells(lambda g: g.dim == 2)
    with open(folder_export + "cells.txt", "w") as f:
        f.write(str(num_cells))
def main(id_problem, tol=1e-5, if_export=False):

    folder_export = "example_1_mpfa/"
    file_name_error = folder_export + "mpfa_error.txt"
    gb = example_1_create_grid.create(0.5 / float(id_problem), tol)

    if if_export:
        save = Exporter(gb, "mpfa", folder_export)

    example_1_data.assign_frac_id(gb)

    # Assign parameters
    example_1_data.add_data(gb, tol)

    # Choose and define the solvers and coupler
    solver_flow = mpfa.MpfaDFN(gb.dim_max(), "flow")
    A_flow, b_flow = solver_flow.matrix_rhs(gb)

    solver_source = source.IntegralDFN(gb.dim_max(), "flow")
    A_source, b_source = solver_source.matrix_rhs(gb)

    p = sps.linalg.spsolve(A_flow + A_source, b_flow + b_source)
    solver_flow.split(gb, "pressure", p)

    def only_max_dim(g):
        return g.dim == gb.dim_max()

    diam = gb.diameter(only_max_dim)
    error_pressure = example_1_data.error_pressure(gb, "pressure")
    print("h=", diam, "- err(p)=", error_pressure)

    with open(file_name_error, "a") as f:
        info = (str(gb.num_cells(only_max_dim)) + " " +
                str(gb.num_cells(only_max_dim)) + " " + str(error_pressure) +
                "\n")
        f.write(info)

    if if_export:
        save.write_vtk(["pressure", "err"])