From c60c31d7e2b8c322f1dbd43a099dce322c860bae Mon Sep 17 00:00:00 2001 From: Deepak Date: Sun, 22 Nov 2020 14:33:40 -0600 Subject: [PATCH] adds gap integrator --- do.sh | 1 + pysuperconductor/os_gap_calc.py | 9 +++++++++ tests/test_os_gap_calc.py | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/do.sh b/do.sh index 43e7061..bfd0c5c 100644 --- a/do.sh +++ b/do.sh @@ -10,6 +10,7 @@ build() { } test() { + echo "I am ${FUNCNAME[0]}ing" poetry run flake8 poetry run pytest tests --cov pysuperconductor } diff --git a/pysuperconductor/os_gap_calc.py b/pysuperconductor/os_gap_calc.py index 3a7fe5f..dd25fa1 100644 --- a/pysuperconductor/os_gap_calc.py +++ b/pysuperconductor/os_gap_calc.py @@ -1,4 +1,5 @@ import numpy +import scipy.integrate as integrate def energy(freq, delta): @@ -8,3 +9,11 @@ def energy(freq, delta): def gap_integrand_function(xi, temp, delta, mu_star): big_e = energy(xi, delta) return numpy.tanh((big_e - mu_star) / (2 * temp)) / (2 * big_e) + + +def gap_integral(temp, delta, mu_star, debye_frequency): + def integrand(xi): + # the 2 here is to account for the symmetry in the integration range + # to cut the integral to zero to omega_debyeh + return 2 * gap_integrand_function(xi, temp, delta, mu_star) + return integrate.quad(integrand, 0, debye_frequency)[0] diff --git a/tests/test_os_gap_calc.py b/tests/test_os_gap_calc.py index 31b1d4b..1844be9 100644 --- a/tests/test_os_gap_calc.py +++ b/tests/test_os_gap_calc.py @@ -8,3 +8,11 @@ def test_gap_integrand_function(): actual, 0.04471214382962651, decimal=7, err_msg='gap integrand function is off', verbose=True ) + + +def test_gap_integral(): + actual = pysuperconductor.os_gap_calc.gap_integral(1, 5, 2, 10) + numpy.testing.assert_almost_equal( + actual, 1.390972295468881, + decimal=7, err_msg='gap integral is off', verbose=True + )