pass k_bounds and k_guess instad of just k_min and k_max
This commit is contained in:
parent
86feb5461c
commit
a82d8dfc7e
@ -411,9 +411,9 @@ def find_k(
|
|||||||
epsilon: fdfield_t,
|
epsilon: fdfield_t,
|
||||||
mu: Optional[fdfield_t] = None,
|
mu: Optional[fdfield_t] = None,
|
||||||
band: int = 0,
|
band: int = 0,
|
||||||
k_min: float = 0,
|
|
||||||
k_max: float = 0.5,
|
|
||||||
solve_callback: Optional[Callable] = None
|
solve_callback: Optional[Callable] = None
|
||||||
|
k_bounds: Tuple[float, float] = (0, 0.5),
|
||||||
|
k_guess: Optional[float] = None,
|
||||||
) -> Tuple[float, float, NDArray[numpy.complex128], NDArray[numpy.complex128]]:
|
) -> Tuple[float, float, NDArray[numpy.complex128], NDArray[numpy.complex128]]:
|
||||||
"""
|
"""
|
||||||
Search for a bloch vector that has a given frequency.
|
Search for a bloch vector that has a given frequency.
|
||||||
@ -428,6 +428,8 @@ def find_k(
|
|||||||
mu: Magnetic permability distribution for the simulation.
|
mu: Magnetic permability distribution for the simulation.
|
||||||
Default None (1 everywhere).
|
Default None (1 everywhere).
|
||||||
band: Which band to search in. Default 0 (lowest frequency).
|
band: Which band to search in. Default 0 (lowest frequency).
|
||||||
|
k_bounds: Minimum and maximum values for k. Default (0, 0.5).
|
||||||
|
k_guess: Initial value for k.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`(k, actual_frequency, eigenvalues, eigenvectors)`
|
`(k, actual_frequency, eigenvalues, eigenvectors)`
|
||||||
@ -435,6 +437,12 @@ def find_k(
|
|||||||
"""
|
"""
|
||||||
direction = numpy.array(direction) / norm(direction)
|
direction = numpy.array(direction) / norm(direction)
|
||||||
|
|
||||||
|
k_bounds = tuple(sorted(k_bounds))
|
||||||
|
assert len(k_bounds) == 2
|
||||||
|
|
||||||
|
if k_guess is None:
|
||||||
|
k_guess = sum(k_bounds) / 2
|
||||||
|
|
||||||
n = None
|
n = None
|
||||||
v = None
|
v = None
|
||||||
|
|
||||||
@ -449,9 +457,9 @@ def find_k(
|
|||||||
|
|
||||||
res = scipy.optimize.minimize_scalar(
|
res = scipy.optimize.minimize_scalar(
|
||||||
lambda x: abs(get_f(x, band) - frequency),
|
lambda x: abs(get_f(x, band) - frequency),
|
||||||
(k_min + k_max) / 2,
|
k_guess,
|
||||||
method='Bounded',
|
method='Bounded',
|
||||||
bounds=(k_min, k_max),
|
bounds=k_bounds,
|
||||||
options={'xatol': abs(tolerance)},
|
options={'xatol': abs(tolerance)},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user