All checks were successful
gitea-physics/pyewjn/pipeline/head This commit looks good
59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
import numpy as np
|
|
import pytest
|
|
|
|
import pyewjn.dielectric
|
|
import pyewjn.noise.chi
|
|
from pyewjn.baskets import CalculationParams
|
|
|
|
|
|
cutoff_to_use = 5.4596e9
|
|
|
|
|
|
@pytest.fixture
|
|
def chi_zz_e_nam():
|
|
params = CalculationParams(
|
|
omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14, t_rel=0.99999
|
|
)
|
|
eps_l = pyewjn.dielectric.get_nam_dielectric(cutoff_to_use, params)
|
|
return pyewjn.noise.chi.get_chi_zz_e(eps_l)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"test_input,expected",
|
|
[
|
|
# z chi_zz_e_nam(z)
|
|
(1e-5, 4.07695673649665e6),
|
|
(1e-6, 4.095895777068543e9),
|
|
# (1e-7, 5.012885033150058e12), commenting this one out because it seems numerically too unstable
|
|
# (1e-8, 1.441261982619894e16), commenting this one out because it seems numerically too unstable
|
|
],
|
|
)
|
|
def test_chi_zz_e_nam(chi_zz_e_nam, test_input, expected):
|
|
actual = chi_zz_e_nam(test_input)
|
|
|
|
np.testing.assert_allclose(
|
|
actual,
|
|
expected,
|
|
rtol=0.05,
|
|
err_msg="chi_zz_e is inaccurate for nam case",
|
|
verbose=True,
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"test_input,expected",
|
|
[
|
|
# z chi_zz_e_nam(z)
|
|
(1e-6, 4.095895777068543e9),
|
|
],
|
|
)
|
|
def test_chi_zz_e_nam_benchmark(benchmark, chi_zz_e_nam, test_input, expected):
|
|
actual = benchmark(chi_zz_e_nam, test_input)
|
|
np.testing.assert_allclose(
|
|
actual,
|
|
expected,
|
|
rtol=0.05,
|
|
err_msg="chi_zz_e is inaccurate for nam case",
|
|
verbose=True,
|
|
)
|