adds full functionality test for find_n_gap
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good

This commit is contained in:
Deepak Mallubhotla 2020-11-24 13:57:37 -06:00
parent 346caf3ea0
commit 3cda66441e
Signed by: deepak
GPG Key ID: 64BF53A3369104E7
2 changed files with 31 additions and 0 deletions

View File

@ -1,6 +1,9 @@
import numpy # type: ignore
import scipy.integrate as integrate # type: ignore
import scipy.optimize # type: ignore
import logging
from typing import Tuple
def energy(freq: float, delta: float) -> float:
@ -68,3 +71,22 @@ def n_integral(temp: float, delta: float, mu_star: float) -> float:
lower = integrate.quad(integrand, 0, intermediate)[0]
upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
return lower + upper
def find_gap_for_n(
temp: float,
n_bare: float,
debye_frequency: float,
nv: float
) -> 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

View File

@ -67,3 +67,12 @@ def test_n_integral():
verbose=True
)
assert not record
def test_find_n_gap():
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
)