adds n integral and tests for warnings for overflows
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good

This commit is contained in:
Deepak Mallubhotla 2020-11-23 15:41:24 -06:00
parent abe17baaf1
commit 85968f881f
Signed by: deepak
GPG Key ID: 64BF53A3369104E7
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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