Removes warnings from overflow and from scipy bug
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
All checks were successful
gitea-physics/pysuperconductor/pipeline/head This commit looks good
This commit is contained in:
parent
3cda66441e
commit
54917655cd
@ -2,6 +2,7 @@ import numpy # type: ignore
|
|||||||
import scipy.integrate as integrate # type: ignore
|
import scipy.integrate as integrate # type: ignore
|
||||||
import scipy.optimize # type: ignore
|
import scipy.optimize # type: ignore
|
||||||
import logging
|
import logging
|
||||||
|
import warnings
|
||||||
|
|
||||||
from typing import Tuple
|
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)
|
return n_integrand_function(xi, temp, delta, mu_star)
|
||||||
intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2)
|
intermediate = 20 * numpy.sqrt(delta ** 2 + mu_star ** 2)
|
||||||
lower = integrate.quad(integrand, 0, intermediate)[0]
|
lower = integrate.quad(integrand, 0, intermediate)[0]
|
||||||
upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
|
# upper = integrate.quad(integrand, intermediate, numpy.inf)[0]
|
||||||
return lower + upper
|
# 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(
|
def find_gap_for_n(
|
||||||
@ -81,6 +84,11 @@ def find_gap_for_n(
|
|||||||
) -> Tuple[float, float]:
|
) -> Tuple[float, float]:
|
||||||
n = n_bare * find_gap(0, 0, debye_frequency, nv)
|
n = n_bare * find_gap(0, 0, debye_frequency, nv)
|
||||||
nv_inv = 1 / nv
|
nv_inv = 1 / nv
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings(
|
||||||
|
"ignore",
|
||||||
|
message="Creating an ndarray from ragged nested"
|
||||||
|
)
|
||||||
sol = scipy.optimize.root(
|
sol = scipy.optimize.root(
|
||||||
lambda x: [
|
lambda x: [
|
||||||
gap_integral(temp, x[0], x[1], debye_frequency) - nv_inv,
|
gap_integral(temp, x[0], x[1], debye_frequency) - nv_inv,
|
||||||
|
@ -70,9 +70,12 @@ def test_n_integral():
|
|||||||
|
|
||||||
|
|
||||||
def test_find_n_gap():
|
def test_find_n_gap():
|
||||||
|
actual = None
|
||||||
|
with pytest.warns(None) as record:
|
||||||
actual = pysuperconductor.os_gap_calc.find_gap_for_n(.3, .1, 100, .2)
|
actual = pysuperconductor.os_gap_calc.find_gap_for_n(.3, .1, 100, .2)
|
||||||
numpy.testing.assert_almost_equal(
|
numpy.testing.assert_almost_equal(
|
||||||
actual[0], 1.0296692197710933,
|
actual[0], 1.0296692197710933,
|
||||||
decimal=7, err_msg="did not find correct delta",
|
decimal=7, err_msg="did not find correct delta",
|
||||||
verbose=True
|
verbose=True
|
||||||
)
|
)
|
||||||
|
assert not record
|
||||||
|
Loading…
x
Reference in New Issue
Block a user