clean up comments and some types
This commit is contained in:
parent
36431cd0e4
commit
e459b5e61f
@ -40,7 +40,7 @@ __author__ = 'Jan Petykiewicz'
|
|||||||
def e_full(
|
def e_full(
|
||||||
omega: complex,
|
omega: complex,
|
||||||
dxes: dx_lists_t,
|
dxes: dx_lists_t,
|
||||||
epsilon: vfdfield_t,
|
epsilon: vfdfield_t | vcfdfield_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,
|
||||||
|
@ -35,9 +35,9 @@ def _scipy_qmr(
|
|||||||
Guess for solution (returned even if didn't converge)
|
Guess for solution (returned even if didn't converge)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
'''
|
#
|
||||||
Report on our progress
|
#Report on our progress
|
||||||
'''
|
#
|
||||||
ii = 0
|
ii = 0
|
||||||
|
|
||||||
def log_residual(xk: ArrayLike) -> None:
|
def log_residual(xk: ArrayLike) -> None:
|
||||||
@ -56,10 +56,9 @@ def _scipy_qmr(
|
|||||||
else:
|
else:
|
||||||
kwargs['callback'] = log_residual
|
kwargs['callback'] = log_residual
|
||||||
|
|
||||||
'''
|
#
|
||||||
Run the actual solve
|
# Run the actual solve
|
||||||
'''
|
#
|
||||||
|
|
||||||
x, _ = scipy.sparse.linalg.qmr(A, b, **kwargs)
|
x, _ = scipy.sparse.linalg.qmr(A, b, **kwargs)
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
@ -845,13 +845,13 @@ def solve_modes(
|
|||||||
ability to find the correct mode. Default 2.
|
ability to find the correct mode. Default 2.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
e_xys: list of vfdfield_t specifying fields
|
e_xys: NDArray of vfdfield_t specifying fields. First dimension is mode number.
|
||||||
wavenumbers: list of wavenumbers
|
wavenumbers: list of wavenumbers
|
||||||
"""
|
"""
|
||||||
|
|
||||||
'''
|
#
|
||||||
Solve for the largest-magnitude eigenvalue of the real operator
|
# Solve for the largest-magnitude eigenvalue of the real operator
|
||||||
'''
|
#
|
||||||
dxes_real = [[numpy.real(dx) for dx in dxi] for dxi in dxes]
|
dxes_real = [[numpy.real(dx) for dx in dxi] for dxi in dxes]
|
||||||
mu_real = None if mu is None else numpy.real(mu)
|
mu_real = None if mu is None else numpy.real(mu)
|
||||||
A_r = operator_e(numpy.real(omega), dxes_real, numpy.real(epsilon), mu_real)
|
A_r = operator_e(numpy.real(omega), dxes_real, numpy.real(epsilon), mu_real)
|
||||||
@ -859,10 +859,10 @@ def solve_modes(
|
|||||||
eigvals, eigvecs = signed_eigensolve(A_r, max(mode_numbers) + mode_margin)
|
eigvals, eigvecs = signed_eigensolve(A_r, max(mode_numbers) + mode_margin)
|
||||||
e_xys = eigvecs[:, -(numpy.array(mode_numbers) + 1)]
|
e_xys = eigvecs[:, -(numpy.array(mode_numbers) + 1)]
|
||||||
|
|
||||||
'''
|
#
|
||||||
Now solve for the eigenvector of the full operator, using the real operator's
|
# Now solve for the eigenvector of the full operator, using the real operator's
|
||||||
eigenvector as an initial guess for Rayleigh quotient iteration.
|
# eigenvector as an initial guess for Rayleigh quotient iteration.
|
||||||
'''
|
#
|
||||||
A = operator_e(omega, dxes, epsilon, mu)
|
A = operator_e(omega, dxes, epsilon, mu)
|
||||||
for nn in range(len(mode_numbers)):
|
for nn in range(len(mode_numbers)):
|
||||||
eigvals[nn], e_xys[:, nn] = rayleigh_quotient_iteration(A, e_xys[:, nn])
|
eigvals[nn], e_xys[:, nn] = rayleigh_quotient_iteration(A, e_xys[:, nn])
|
||||||
|
@ -53,9 +53,9 @@ def solve_mode(
|
|||||||
|
|
||||||
slices = tuple(slices)
|
slices = tuple(slices)
|
||||||
|
|
||||||
'''
|
#
|
||||||
Solve the 2D problem in the specified plane
|
# Solve the 2D problem in the specified plane
|
||||||
'''
|
#
|
||||||
# Define rotation to set z as propagation direction
|
# Define rotation to set z as propagation direction
|
||||||
order = numpy.roll(range(3), 2 - axis)
|
order = numpy.roll(range(3), 2 - axis)
|
||||||
reverse_order = numpy.roll(range(3), axis - 2)
|
reverse_order = numpy.roll(range(3), axis - 2)
|
||||||
@ -73,9 +73,10 @@ def solve_mode(
|
|||||||
}
|
}
|
||||||
e_xy, wavenumber_2d = waveguide_2d.solve_mode(mode_number, **args_2d)
|
e_xy, wavenumber_2d = waveguide_2d.solve_mode(mode_number, **args_2d)
|
||||||
|
|
||||||
'''
|
#
|
||||||
Apply corrections and expand to 3D
|
# Apply corrections and expand to 3D
|
||||||
'''
|
#
|
||||||
|
|
||||||
# Correct wavenumber to account for numerical dispersion.
|
# Correct wavenumber to account for numerical dispersion.
|
||||||
wavenumber = 2 / dx_prop * numpy.arcsin(wavenumber_2d * dx_prop / 2)
|
wavenumber = 2 / dx_prop * numpy.arcsin(wavenumber_2d * dx_prop / 2)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ vcfdfield_t = NDArray[complexfloating]
|
|||||||
"""Linearized complex vector field (single vector of length 3*X*Y*Z)"""
|
"""Linearized complex vector field (single vector of length 3*X*Y*Z)"""
|
||||||
|
|
||||||
|
|
||||||
dx_lists_t = Sequence[Sequence[NDArray[floating]]]
|
dx_lists_t = Sequence[Sequence[NDArray[floating | complexfloating]]]
|
||||||
"""
|
"""
|
||||||
'dxes' datastructure which contains grid cell width information in the following format:
|
'dxes' datastructure which contains grid cell width information in the following format:
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ dx_lists_t = Sequence[Sequence[NDArray[floating]]]
|
|||||||
and `dy_h[0]` is the y-width of the `y=0` cells, as used when calculating dH/dy, etc.
|
and `dy_h[0]` is the y-width of the `y=0` cells, as used when calculating dH/dy, etc.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dx_lists_mut = MutableSequence[MutableSequence[NDArray[floating]]]
|
dx_lists_mut = MutableSequence[MutableSequence[NDArray[floating | complexfloating]]]
|
||||||
"""Mutable version of `dx_lists_t`"""
|
"""Mutable version of `dx_lists_t`"""
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user