コード例 #1
0
ファイル: main.py プロジェクト: fangohr/nmag-src
def laplace_solver(prematrix, dirichlet_bcs=[], mwe_mid=None, interface_coeffs=[], petsc_name=""):
    log.log(15, "Creating laplace_solver")
    opt_mid = []
    if mwe_mid:
        opt_mid = [mwe_mid]
    solver = ocaml.laplace_solver(interface_coeffs, dirichlet_bcs, opt_mid, petsc_name, prematrix)
    # We also wrap up this ml-generated solver in a more palatable way:
    def py_solver(source, dbc_values=dirichlet_bc_zero, target=None):
        opt_target = []
        if target:
            opt_target = [target]
        return solver(opt_target, dbc_values, source)

    return py_solver
コード例 #2
0
ファイル: fem-rings.py プロジェクト: Venkat004/nmag-doc
def update_sigma(the_field_sigma):
    compute_grad_phi = ocaml.prematrix_to_applicator(
        [],  # interface_coeffs
        [the_field_sigma],
        "",
        prematrix_grad_phi)
    #
    #
    laplace_solver = ocaml.laplace_solver(
        [],  # if coeffs
        [(-1, 1, laplace_dbc)],  # dbcs
        [the_field_sigma],  # mid field
        "",  # Petsc name
        prematrix_laplace)
    #
    #
    result_field_phi = laplace_solver([], laplace_dbc_value,
                                      cofield_drho_by_dt)
    last_field_phi[0] = result_field_phi
    #
    #
    field_J = ocaml.cofield_to_field(
        [],
        compute_grad_phi(
            [],  # no target
            result_field_phi))
    #
    #
    # Next, let us compute the new condictivity by site-wise operation on
    # field_J. We just overwrite field_sigma:
    #
    recompute_conductivity = ocaml.site_wise_applicator(
        [mwe_sigma, mwe_J],  # all the fields we use
        [],
        ["H_x", "H_y", "sigma0", "alpha"],
        # all the names of extra parameters
        "",
        code_recompute_conductivity,
        True)
    #
    #
    recompute_conductivity([h_x, h_y, sigma0, alpha],
                           [the_field_sigma, field_J], [])
    return the_field_sigma
コード例 #3
0
def laplace_solver(prematrix,
                   dirichlet_bcs=[],
                   mwe_mid=None,
                   interface_coeffs=[],
                   petsc_name=""):
    log.log(15, "Creating laplace_solver")
    opt_mid = []
    if mwe_mid:
        opt_mid = [mwe_mid]
    solver = ocaml.laplace_solver(interface_coeffs, dirichlet_bcs, opt_mid,
                                  petsc_name, prematrix)

    # We also wrap up this ml-generated solver in a more palatable way:
    def py_solver(source, dbc_values=dirichlet_bc_zero, target=None):
        opt_target = []
        if target:
            opt_target = [target]
        return solver(opt_target, dbc_values, source)

    return py_solver
コード例 #4
0
ファイル: fem-rings.py プロジェクト: fangohr/nmag-doc
def update_sigma(the_field_sigma):
    compute_grad_phi = ocaml.prematrix_to_applicator([], [the_field_sigma], "", prematrix_grad_phi)  # interface_coeffs
    #
    #
    laplace_solver = ocaml.laplace_solver(
        [],  # if coeffs
        [(-1, 1, laplace_dbc)],  # dbcs
        [the_field_sigma],  # mid field
        "",  # Petsc name
        prematrix_laplace,
    )
    #
    #
    result_field_phi = laplace_solver([], laplace_dbc_value, cofield_drho_by_dt)
    last_field_phi[0] = result_field_phi
    #
    #
    field_J = ocaml.cofield_to_field([], compute_grad_phi([], result_field_phi))  # no target
    #
    #
    # Next, let us compute the new condictivity by site-wise operation on
    # field_J. We just overwrite field_sigma:
    #
    recompute_conductivity = ocaml.site_wise_applicator(
        [mwe_sigma, mwe_J],  # all the fields we use
        [],
        ["H_x", "H_y", "sigma0", "alpha"],
        # all the names of extra parameters
        "",
        code_recompute_conductivity,
        True,
    )
    #
    #
    recompute_conductivity([h_x, h_y, sigma0, alpha], [the_field_sigma, field_J], [])
    return the_field_sigma