Ejemplo n.º 1
0
def site_wise_applicator(parameter_names, code, field_mwes=[], cofield_mwes=[], strict_mwe_check=True):
    app = ocaml.site_wise_applicator(field_mwes, cofield_mwes, parameter_names, code, strict_mwe_check)

    def py_app(params, fields=[], cofields=[]):
        return app(params, fields, cofields)

    return py_app
Ejemplo n.º 2
0
def site_wise_applicator(parameter_names,
                         code,
                         field_mwes=[],
                         cofield_mwes=[],
                         strict_mwe_check=True):
    app = ocaml.site_wise_applicator(field_mwes, cofield_mwes, parameter_names,
                                     code, strict_mwe_check)

    def py_app(params, fields=[], cofields=[]):
        return app(params, fields, cofields)

    return py_app
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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