Beispiel #1
0
def _create_solver(solver_name: str, dims: Tuple[int, int, int]) -> Callable:
    """Instantiates a Maxwell solver.

    Args:
        solver_name: Name of the solver.
        simspace: Simulation space.

    Returns:
         A callable solver object.
    """
    if solver_name == "maxwell_cg":
        from spins.fdfd_solvers.maxwell import MaxwellSolver
        solver = MaxwellSolver(dims, solver="CG")
    elif solver_name == "maxwell_bicgstab":
        from spins.fdfd_solvers.maxwell import MaxwellSolver
        solver = MaxwellSolver(dims, solver="biCGSTAB")
    elif solver_name == "maxwell_eig":
        from spins.fdfd_solvers.maxwell import MaxwellSolver
        solver = MaxwellSolver(dims, solver="Jacobi-Davidson")
    elif solver_name == "local_direct":
        solver = DIRECT_SOLVER
    else:
        raise ValueError("Unknown solver, got {}".format(solver_name))

    return solver
Beispiel #2
0
 def __init__(self, solver: DirectSolver, dims: Tuple[int, int,
                                                      int]) -> None:
     from spins.fdfd_solvers.maxwell import MaxwellSolver
     server = solver.server
     if server is None:
         server = os.getenv("MAXWELL_SERVER", "localhost:9041")
     self._solver = MaxwellSolver(dims,
                                  solver=solver.solver,
                                  server=server,
                                  err_thresh=solver.err_thresh,
                                  max_iters=solver.max_iters)