Compare commits
No commits in common. "777ecbc02463f60ae21ea2c008480340ffe22ed9" and "cd5cc9eb83493016745b765cf0937371bc3a571a" have entirely different histories.
777ecbc024
...
cd5cc9eb83
@ -44,7 +44,7 @@ def _scipy_qmr(
|
|||||||
nonlocal ii
|
nonlocal ii
|
||||||
ii += 1
|
ii += 1
|
||||||
if ii % 100 == 0:
|
if ii % 100 == 0:
|
||||||
cur_norm = norm(A @ xk - b) / norm(b)
|
cur_norm = norm(A @ xk - b)
|
||||||
logger.info(f'Solver residual at iteration {ii} : {cur_norm}')
|
logger.info(f'Solver residual at iteration {ii} : {cur_norm}')
|
||||||
|
|
||||||
if 'callback' in kwargs:
|
if 'callback' in kwargs:
|
||||||
@ -69,13 +69,11 @@ def generic(
|
|||||||
J: vcfdfield_t,
|
J: vcfdfield_t,
|
||||||
epsilon: vfdfield_t,
|
epsilon: vfdfield_t,
|
||||||
mu: vfdfield_t | None = None,
|
mu: vfdfield_t | None = None,
|
||||||
*,
|
|
||||||
pec: vfdfield_t | None = None,
|
pec: vfdfield_t | None = None,
|
||||||
pmc: vfdfield_t | None = None,
|
pmc: vfdfield_t | None = None,
|
||||||
adjoint: bool = False,
|
adjoint: bool = False,
|
||||||
matrix_solver: Callable[..., ArrayLike] = _scipy_qmr,
|
matrix_solver: Callable[..., ArrayLike] = _scipy_qmr,
|
||||||
matrix_solver_opts: dict[str, Any] | None = None,
|
matrix_solver_opts: dict[str, Any] | None = None,
|
||||||
E_guess: vcfdfield_t | None = None,
|
|
||||||
) -> vcfdfield_t:
|
) -> vcfdfield_t:
|
||||||
"""
|
"""
|
||||||
Conjugate gradient FDFD solver using CSR sparse matrices.
|
Conjugate gradient FDFD solver using CSR sparse matrices.
|
||||||
@ -102,8 +100,6 @@ def generic(
|
|||||||
which doesn't return convergence info and logs the residual
|
which doesn't return convergence info and logs the residual
|
||||||
every 100 iterations.
|
every 100 iterations.
|
||||||
matrix_solver_opts: Passed as kwargs to `matrix_solver(...)`
|
matrix_solver_opts: Passed as kwargs to `matrix_solver(...)`
|
||||||
E_guess: Guess at the solution E-field. `matrix_solver` must accept an
|
|
||||||
`x0` argument with the same purpose.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
E-field which solves the system.
|
E-field which solves the system.
|
||||||
@ -124,13 +120,6 @@ def generic(
|
|||||||
A = Pl @ A0 @ Pr
|
A = Pl @ A0 @ Pr
|
||||||
b = Pl @ b0
|
b = Pl @ b0
|
||||||
|
|
||||||
if E_guess is not None:
|
|
||||||
if adjoint:
|
|
||||||
x0 = Pr.H @ E_guess
|
|
||||||
else:
|
|
||||||
x0 = Pl @ E_guess
|
|
||||||
matrix_solver_opts['x0'] = x0
|
|
||||||
|
|
||||||
x = matrix_solver(A.tocsr(), b, **matrix_solver_opts)
|
x = matrix_solver(A.tocsr(), b, **matrix_solver_opts)
|
||||||
|
|
||||||
if adjoint:
|
if adjoint:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user