pyewjn/tests/noise/test_im_ref.py
Deepak Mallubhotla 071cd2503e
All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good
feat!: Renames to pyewjn
2022-03-28 19:08:35 -05:00

40 lines
945 B
Python

import numpy as np
import pytest
import pyewjn.dielectric
import pyewjn.noise.im_ref
from pyewjn.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 = pyewjn.dielectric.get_lindhard_dielectric(params)
return pyewjn.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), 1e4 is too far off still
(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,
)