Commit 8edf45e7 authored by Kloss's avatar Kloss

change numeric tol causing problems on 32 bit

parent 8bbf6e76
......@@ -433,7 +433,7 @@ def _save_ordering(func):
return wrapper
def _match_functions(func, xmin=-1, xmax=1, tol=1E-8, min_iter=10,
def _match_functions(func, xmin=-1, xmax=1, tol=1E-10, min_iter=10,
max_iter=100000, interval_converged=None, evaluated=None):
"""Match the elements of a vector valued function, such that
each vector element describes a continous function.
......@@ -555,7 +555,7 @@ def _match_functions(func, xmin=-1, xmax=1, tol=1E-8, min_iter=10,
def spectrum(syst, args=(), *, params=None, kmin=-np.pi, kmax=np.pi,
orderpoint=0, tol=1E-8, match=_match_functions):
orderpoint=0, tol=1E-10, match=_match_functions):
r"""Interpolate the dispersion function and provide methods to
simplify curve sketching and analyzation the periodic spectrum.
......@@ -689,7 +689,7 @@ class BandSketching:
Finite accuracy of the data and possible unphysical results are taking into
account by rounding value :math:`tol`.
def __init__(self, x, y, dy, mode_function, tol=1E-8,
def __init__(self, x, y, dy, mode_function, tol=1E-10,
# type and input checks
......@@ -865,19 +865,19 @@ class BandSketching:
def intersect(self, f, band, derivative_order=0,
kmin=None, kmax=None, tol=None, ytol=None):
r"""Returns all momentum (k) points, that solves the equation:
:math:`\partial_k^{n} E(k) = f(k),\, k_{min} \leq k \leq k_{max}`.
r"""Returns all momentum (:math:`k`) points which solve the equation:
:math:`\partial_k^{m} E_n(k) = f(k),\, k_{min} \leq k \leq k_{max}`.
f : scalar numerical value or callable
Equation to solve :math:`\partial_k^{n} E(k) = f`.
Equation to solve :math:`\partial_k^{m} E_n(k) = f`.
If `f` is callable, solve equation:
:math:`\partial_k^{n} E(k) = f(k)`.
:math:`\partial_k^{m} E_n(k) = f(k)`.
band : int
band index, requirement: `0 <= band < nbands`.
band index `n`, requirement: `0 <= band < nbands`.
derivative_order : int, optional
Derivative order (n) of the band dispersion. Default is zero.
Derivative order `m` of the band dispersion. Default is zero.
kmin : scalar numeric value, optional
Lowest `k` point value. Default is `kmin` from initialization.
kmax : scalar numeric value, optional
......@@ -887,10 +887,10 @@ class BandSketching:
point. Default is the `tol` from initialization.
ytol : float, optional
Numerical tolerance to remove noise if the
spectrum :math:`\partial_k^{n} E(k)` is almost flat.
Values for the spectrum are set to thier mean value
spectrum :math:`\partial_k^{m} E_n(k)` is almost flat.
Values for the spectrum are set to their mean value
(averaged over all momentum points where the band is sampled), if
they flucutate more than `ytol`.
they flucutate less than `ytol`.
Default is the `tol` from initialization.
......@@ -911,7 +911,7 @@ class BandSketching:
if tol is None:
tol = self.tol
if ytol is None:
ytol = self.tol
ytol = self.tol * 100 # lower interpolant accuracy
# type and input checks
assert _is_type(band, 'integer')
......@@ -946,8 +946,9 @@ class BandSketching:
y_mean = np.mean(y)
if _is_zero(y_mean, ytol):
y_mean = 0
y[np.abs(y - y_mean) < ytol] = y_mean
dy[np.abs(dy) < ytol] = 0
dy[np.abs(dy) < 100 * ytol] = 0 # derivative dy less acurate than y
roots = self.interpolation(self.x, y - f, dy).roots()
roots = remove_nan(roots)
......@@ -286,7 +286,7 @@ def test_spectrum_with_flat_band():
assert spectrum.intersect(f=0, band=1, derivative_order=1).size == 0
assert_array_almost_equal([0], spectrum.intersect(f=0, band=2, derivative_order=1))
# the spectrum has also no wendepunkt
# the spectrum has also no inflection point
assert spectrum.intersect(f=0, band=0, derivative_order=2).size == 0
assert spectrum.intersect(f=0, band=1, derivative_order=2).size == 0
assert spectrum.intersect(f=0, band=2, derivative_order=2).size == 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment