adding tighter error tolerances and adding checks for imrpl

This commit is contained in:
2020-07-14 10:59:33 -05:00
parent 622af16142
commit a7c33fb5df
4 changed files with 56 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
import numpy as np
import pytest
import pynam.dielectric
import pynam.noise.im_ref
from pynam.baskets import CalculationParams
@pytest.fixture
def im_ref_p_lindhard():
params = CalculationParams(omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14)
eps_l = pynam.dielectric.get_lindhard_dielectric(params)
return pynam.noise.im_ref.get_im_ref_p(eps_l)
@pytest.mark.parametrize("test_input,expected", [
# u im_ref_p_l(u)
# needs to be close in range around 1/z, so from 1e4 to 1e8
(1e4, 1.821722334939806e-8),
(1e5, 1.602855764970752e-8),
(1e6, 1.704326041013161e-8),
(1e7, 2.674124312031195e-8),
(1e8, 7.441319151047531e-8),
])
def test_im_ref_p_lindhard(im_ref_p_lindhard, test_input, expected):
actual = im_ref_p_lindhard(test_input)
np.testing.assert_allclose(
actual, expected,
rtol=1e-4, err_msg='imrp is inaccurate for Lindhard case', verbose=True
)

View File

@@ -38,7 +38,13 @@ def zeta_p_lindhard():
@pytest.mark.parametrize("test_input,expected", [
# u zeta_p(u)
(1, 0.000199609 - 0.000199608j),
# (10, 0.00019960929309663014 - 0.00019927000998506335j),
# (100, 0.0001996175250684056 - 0.0001654898843938523j),
# (1e3, 0.0002003339895748246 + 0.003212370020888438j),
# (1e4, 0.00028616168676982363 + 0.34096962141224463j),
(1e5, 0.0025183067257958545 + 34.11087430547122j),
(1e6, 0.026829658454640887 + 3411.0870128247902j),
(1e7, 0.4292211181081069 + 341088.797211291j),
(1e8, 14.348462224076096 + 3.391157983312813e7j)
])
def test_zeta_p(zeta_p_lindhard, test_input, expected):