diff --git a/pysuperconductor/os_gap_calc.py b/pysuperconductor/os_gap_calc.py index 59b362c..fc824ff 100644 --- a/pysuperconductor/os_gap_calc.py +++ b/pysuperconductor/os_gap_calc.py @@ -35,8 +35,19 @@ def find_gap(temp, mu_star, debye_frequency, nv): return sol.x +# this is n * Delta_0, calling it n in this file for brevity def n_integrand_function(xi, temp, delta, mu_star): big_e = energy(xi, delta) left = 1 / (1 + numpy.exp((big_e - mu_star) / temp)) right = 1 / (1 + numpy.exp(big_e / temp)) return left - right + + +# as above, this is brevity n * Delta_0 +def n_integral(temp, delta, mu_star): + def integrand(xi): + 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 diff --git a/tests/test_os_gap_calc.py b/tests/test_os_gap_calc.py index 61d5d24..2e6935f 100644 --- a/tests/test_os_gap_calc.py +++ b/tests/test_os_gap_calc.py @@ -55,3 +55,15 @@ def test_n_integrand_function(): decimal=7, err_msg='did not find correct n integrand value', verbose=True ) + + +def test_n_integral(): + actual = None + with pytest.warns(None) as record: + actual = pysuperconductor.os_gap_calc.n_integral(2, 2, 1) + numpy.testing.assert_almost_equal( + actual, 0.478130649727604, + decimal=7, err_msg='did not find correct n integral value', + verbose=True + ) + assert not record