diff --git a/pysuperconductor/os_gap_calc.py b/pysuperconductor/os_gap_calc.py index 668a0c8..12aa692 100644 --- a/pysuperconductor/os_gap_calc.py +++ b/pysuperconductor/os_gap_calc.py @@ -2,6 +2,7 @@ import numpy # type: ignore import scipy.integrate as integrate # type: ignore import scipy.optimize # type: ignore import logging +import warnings from typing import Tuple @@ -69,8 +70,10 @@ def n_integral(temp: float, delta: float, mu_star: float) -> float: return n_integrand_function(xi, temp, delta, mu_star) intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2) lower = integrate.quad(integrand, 0, intermediate)[0] - upper = integrate.quad(integrand, intermediate, numpy.inf)[0] - return lower + upper + # upper = integrate.quad(integrand, intermediate, numpy.inf)[0] + # This upper portion of the integral will typically be completely + # negligible, because we're 20x the relevant scale here. + return lower def find_gap_for_n( @@ -81,12 +84,17 @@ def find_gap_for_n( ) -> Tuple[float, float]: n = n_bare * find_gap(0, 0, debye_frequency, nv) nv_inv = 1 / nv - sol = scipy.optimize.root( - lambda x: [ - gap_integral(temp, x[0], x[1], debye_frequency) - nv_inv, - n_integral(temp, x[0], x[1]) - n - ], - x0=[debye_frequency / (numpy.sinh(nv_inv)), 0] - ) - logging.debug(sol) - return sol.x + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", + message="Creating an ndarray from ragged nested" + ) + sol = scipy.optimize.root( + lambda x: [ + gap_integral(temp, x[0], x[1], debye_frequency) - nv_inv, + n_integral(temp, x[0], x[1]) - n + ], + x0=[debye_frequency / (numpy.sinh(nv_inv)), 0] + ) + logging.debug(sol) + return sol.x diff --git a/tests/test_os_gap_calc.py b/tests/test_os_gap_calc.py index 57e168e..9cb097c 100644 --- a/tests/test_os_gap_calc.py +++ b/tests/test_os_gap_calc.py @@ -70,9 +70,12 @@ def test_n_integral(): def test_find_n_gap(): - actual = pysuperconductor.os_gap_calc.find_gap_for_n(.3, .1, 100, .2) + actual = None + with pytest.warns(None) as record: + actual = pysuperconductor.os_gap_calc.find_gap_for_n(.3, .1, 100, .2) numpy.testing.assert_almost_equal( actual[0], 1.0296692197710933, decimal=7, err_msg="did not find correct delta", verbose=True ) + assert not record