Add ability to set bounds for find_k
This commit is contained in:
parent
f312d73503
commit
16f97d7f6b
@ -464,7 +464,9 @@ def find_k(frequency: float,
|
|||||||
G_matrix: numpy.ndarray,
|
G_matrix: numpy.ndarray,
|
||||||
epsilon: field_t,
|
epsilon: field_t,
|
||||||
mu: field_t = None,
|
mu: field_t = None,
|
||||||
band: int = 0
|
band: int = 0,
|
||||||
|
k_min: float = 0,
|
||||||
|
k_max: float = 0.5,
|
||||||
) -> Tuple[numpy.ndarray, float]:
|
) -> Tuple[numpy.ndarray, float]:
|
||||||
"""
|
"""
|
||||||
Search for a bloch vector that has a given frequency.
|
Search for a bloch vector that has a given frequency.
|
||||||
@ -489,8 +491,10 @@ def find_k(frequency: float,
|
|||||||
f = numpy.sqrt(numpy.abs(numpy.real(n[band])))
|
f = numpy.sqrt(numpy.abs(numpy.real(n[band])))
|
||||||
return f
|
return f
|
||||||
|
|
||||||
res = scipy.optimize.minimize_scalar(lambda x: abs(get_f(x, band) - frequency), 0.25,
|
res = scipy.optimize.minimize_scalar(lambda x: abs(get_f(x, band) - frequency),
|
||||||
method='Bounded', bounds=(0, 0.5),
|
(k_min + k_max) / 2,
|
||||||
|
method='Bounded',
|
||||||
|
bounds=(k_min, k_max),
|
||||||
options={'xatol': abs(tolerance)})
|
options={'xatol': abs(tolerance)})
|
||||||
return res.x * direction, res.fun + frequency
|
return res.x * direction, res.fun + frequency
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user