feat!: big breaking change set
All checks were successful
gitea-physics/pynam/pipeline/head This commit looks good
All checks were successful
gitea-physics/pynam/pipeline/head This commit looks good
This commit is contained in:
@@ -9,38 +9,47 @@ def get_common_lindhard_dielectric():
|
||||
return pynam.dielectric.get_lindhard_dielectric(params)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
(10, -1222.185185062794 + 1.2249999998777178e8j),
|
||||
(1000, 16924.14814718176 + 1.2250000020552777e8j),
|
||||
(1e8, 83.687499999706 + 0.00022417398943752126j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
(10, -1222.185185062794 + 1.2249999998777178e8j),
|
||||
(1000, 16924.14814718176 + 1.2250000020552777e8j),
|
||||
(1e8, 83.687499999706 + 0.00022417398943752126j),
|
||||
],
|
||||
)
|
||||
def test_lindhard_dielectric(test_input, expected):
|
||||
|
||||
eps_to_test = get_common_lindhard_dielectric()
|
||||
|
||||
np.testing.assert_almost_equal(
|
||||
eps_to_test(test_input), expected,
|
||||
decimal=6, err_msg='b function is off'
|
||||
eps_to_test(test_input), expected, decimal=6, err_msg="b function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((100, 100), -883.3001542404703 + 1.2566370613549341e8j),
|
||||
((100, 1e5), 5.827225842825694e7 + 3.933446612656656e7j),
|
||||
((100, 1e10), 1.0084823001646925 + 2.0013975538629039e-10j),
|
||||
((100, 1e7), 8483.300121667038 + 0.6340397839154446)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((100, 100), -883.3001542404703 + 1.2566370613549341e8j),
|
||||
((100, 1e5), 5.827225842825694e7 + 3.933446612656656e7j),
|
||||
((100, 1e10), 1.0084823001646925 + 2.0013975538629039e-10j),
|
||||
((100, 1e7), 8483.300121667038 + 0.6340397839154446),
|
||||
],
|
||||
)
|
||||
def test_zeta_pi_lindhard_dielectric(zeta_p_i_epsilon, test_input, expected):
|
||||
u, y = test_input
|
||||
actual = zeta_p_i_epsilon(np.sqrt(u**2 + y**2))
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=10**3.8, err_msg='lindhard dielectric differs from Mathematica'
|
||||
actual,
|
||||
expected,
|
||||
rtol=10**3.8,
|
||||
err_msg="lindhard dielectric differs from Mathematica",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def zeta_p_i_epsilon():
|
||||
params = CalculationParams(omega=1e9, omega_p=3.544907701811032e15, tau=1e-14, v_f=2e6)
|
||||
params = CalculationParams(
|
||||
omega=1e9, omega_p=3.544907701811032e15, tau=1e-14, v_f=2e6
|
||||
)
|
||||
return pynam.dielectric.get_lindhard_dielectric(params)
|
||||
|
||||
@@ -3,101 +3,115 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2), 7 / (2 * np.sqrt(6))),
|
||||
((2, 0.25), -5j / np.sqrt(39))
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[((1, 2), 7 / (2 * np.sqrt(6))), ((2, 0.25), -5j / np.sqrt(39))],
|
||||
)
|
||||
def test_g(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.low_k_nam.g(*test_input), expected,
|
||||
decimal=7, err_msg='g function is off'
|
||||
pynam.dielectric.low_k_nam.g(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="g function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 1, 0), 8 / 5),
|
||||
((1, 1, 1), 3 / 5 + 11j / 15),
|
||||
((1, 0, 1), 16j / 15)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[((1, 1, 0), 8 / 5), ((1, 1, 1), 3 / 5 + 11j / 15), ((1, 0, 1), 16j / 15)],
|
||||
)
|
||||
def test_f(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.low_k_nam.f(*test_input), expected,
|
||||
decimal=7, err_msg='f function is off'
|
||||
pynam.dielectric.low_k_nam.f(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="f function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 3, 1, 0), 1.42546694754),
|
||||
((1, 2, 3, 4), 0.0206212167 + 0.4411134527j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[((2, 3, 1, 0), 1.42546694754), ((1, 2, 3, 4), 0.0206212167 + 0.4411134527j)],
|
||||
)
|
||||
def test_i1(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.low_k_nam.i1(*test_input), expected,
|
||||
decimal=7, err_msg='i1 function is off'
|
||||
pynam.dielectric.low_k_nam.i1(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="i1 function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 3, 1, 0), 1.47903168398),
|
||||
((1, 2, 3, 4), 0.079491440779 + 0.441113452718j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[((2, 3, 1, 0), 1.47903168398), ((1, 2, 3, 4), 0.079491440779 + 0.441113452718j)],
|
||||
)
|
||||
def test_i2(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.low_k_nam.i2(*test_input), expected,
|
||||
decimal=7, err_msg='i1 function is off'
|
||||
pynam.dielectric.low_k_nam.i2(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="i1 function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 3, 4), 0.228292),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 3, 4), 0.228292),
|
||||
],
|
||||
)
|
||||
def test_a(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.low_k_nam.a(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='a function is off'
|
||||
actual, expected, decimal=6, err_msg="a function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 1, 2, 0, 4), 0.479529593125),
|
||||
((100, 1, 2, 3, 4), -2.62529549942e-6 + 2.60588e-12j),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((2, 1, 2, 0, 4), 0.479529593125),
|
||||
((100, 1, 2, 3, 4), -2.62529549942e-6 + 2.60588e-12j),
|
||||
],
|
||||
)
|
||||
def test_b_int(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.low_k_nam.b_int(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='b int function is off'
|
||||
actual, expected, decimal=6, err_msg="b int function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0, 4), 3.514889721181435),
|
||||
((1, 2, 3, 4), -0.0598057 + 0.437146j),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 0, 4), 3.514889721181435),
|
||||
((1, 2, 3, 4), -0.0598057 + 0.437146j),
|
||||
],
|
||||
)
|
||||
def test_b(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.low_k_nam.b(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='b function is off'
|
||||
actual, expected, decimal=6, err_msg="b function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0, 4), 0),
|
||||
((1, 2, 3, 4), 0.98358 + 0.648221j),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 0, 4), 0),
|
||||
((1, 2, 3, 4), 0.98358 + 0.648221j),
|
||||
],
|
||||
)
|
||||
def test_sigma_alk(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.low_k_nam.sigma_nam_alk(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='b function is off'
|
||||
actual, expected, decimal=6, err_msg="b function is off"
|
||||
)
|
||||
|
||||
|
||||
def test_sigma_alk_benchmark(benchmark):
|
||||
result = benchmark(pynam.dielectric.low_k_nam.sigma_nam_alk, 1, 2, 3, 4)
|
||||
np.testing.assert_almost_equal(
|
||||
result, 0.98358 + 0.648221j,
|
||||
decimal=6, err_msg='b function is off'
|
||||
result, 0.98358 + 0.648221j, decimal=6, err_msg="b function is off"
|
||||
)
|
||||
|
||||
@@ -4,102 +4,136 @@ import pynam.dielectric.nam_dielectric_coefficient_approximator
|
||||
from pynam.baskets import CalculationParams
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# (
|
||||
# (omega, sigma_n, tau, v_f, T, T_c, c_light),
|
||||
# (xi, nu, t, A, B)
|
||||
# )
|
||||
(
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# (
|
||||
# (omega, sigma_n, tau, v_f, T, T_c, c_light),
|
||||
# (xi, nu, t, A, B)
|
||||
# )
|
||||
(
|
||||
(1e9, 1e16, 1e-14, 2e6, 0.8e11, 1e11, 3e8),
|
||||
(0.007307411691175783, 730.7411691175784, 0.5845929352940626, 0.00004871607794117188, 10000000)
|
||||
)
|
||||
])
|
||||
(
|
||||
0.007307411691175783,
|
||||
730.7411691175784,
|
||||
0.5845929352940626,
|
||||
0.00004871607794117188,
|
||||
10000000,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
def test_dedimensionalise_parameters(test_input, expected):
|
||||
actual_parameters = pynam.dielectric.nam_dielectric_coefficient_approximator.get_dedimensionalised_parameters(
|
||||
*test_input)
|
||||
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.xi, expected[0],
|
||||
decimal=6, err_msg='xi incorrectly calculated'
|
||||
*test_input
|
||||
)
|
||||
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.nu, expected[1],
|
||||
decimal=6, err_msg='nu incorrectly calculated'
|
||||
actual_parameters.xi,
|
||||
expected[0],
|
||||
decimal=6,
|
||||
err_msg="xi incorrectly calculated",
|
||||
)
|
||||
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.nu,
|
||||
expected[1],
|
||||
decimal=6,
|
||||
err_msg="nu incorrectly calculated",
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.t, expected[2],
|
||||
decimal=6, err_msg='t incorrectly calculated'
|
||||
actual_parameters.t, expected[2], decimal=6, err_msg="t incorrectly calculated"
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.a, expected[3],
|
||||
decimal=6, err_msg='A incorrectly calculated'
|
||||
actual_parameters.a, expected[3], decimal=6, err_msg="A incorrectly calculated"
|
||||
)
|
||||
np.testing.assert_almost_equal(
|
||||
actual_parameters.b, expected[4],
|
||||
decimal=6, err_msg='B incorrectly calculated'
|
||||
actual_parameters.b, expected[4], decimal=6, err_msg="B incorrectly calculated"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# (
|
||||
# (omega, sigma_n, tau, v_f, T, T_c, c_light),
|
||||
# (a, b, c, d, u_l)
|
||||
# )
|
||||
(
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# (
|
||||
# (omega, sigma_n, tau, v_f, T, T_c, c_light),
|
||||
# (a, b, c, d, u_l)
|
||||
# )
|
||||
(
|
||||
(1e9, 1e16, 1e-14, 2e6, 0.8e11, 1e11, 3e8),
|
||||
(3.789672906817707e10, 3.257134605133221e8, 2.655709897616547e18, 2.15e16, 7.007759408279888e7)
|
||||
)
|
||||
])
|
||||
(
|
||||
3.789672906817707e10,
|
||||
3.257134605133221e8,
|
||||
2.655709897616547e18,
|
||||
2.15e16,
|
||||
7.007759408279888e7,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
def test_nam_coefficients(test_input, expected):
|
||||
actual_coefficients = pynam.dielectric.nam_dielectric_coefficient_approximator.get_nam_dielectric_coefficients(
|
||||
*test_input)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.a, expected[0],
|
||||
rtol=1e-6, err_msg='a incorrectly calculated'
|
||||
*test_input
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.b, expected[1],
|
||||
rtol=1e-6, err_msg='b incorrectly calculated'
|
||||
actual_coefficients.a,
|
||||
expected[0],
|
||||
rtol=1e-6,
|
||||
err_msg="a incorrectly calculated",
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.b,
|
||||
expected[1],
|
||||
rtol=1e-6,
|
||||
err_msg="b incorrectly calculated",
|
||||
)
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.c, expected[2],
|
||||
rtol=1e-2, err_msg='c incorrectly calculated'
|
||||
actual_coefficients.c,
|
||||
expected[2],
|
||||
rtol=1e-2,
|
||||
err_msg="c incorrectly calculated",
|
||||
)
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.d, expected[3],
|
||||
rtol=1e-2, err_msg='d incorrectly calculated'
|
||||
actual_coefficients.d,
|
||||
expected[3],
|
||||
rtol=1e-2,
|
||||
err_msg="d incorrectly calculated",
|
||||
)
|
||||
np.testing.assert_allclose(
|
||||
actual_coefficients.u_l, expected[4],
|
||||
rtol=1e-5, err_msg='u_l incorrectly calculated'
|
||||
actual_coefficients.u_l,
|
||||
expected[4],
|
||||
rtol=1e-5,
|
||||
err_msg="u_l incorrectly calculated",
|
||||
)
|
||||
|
||||
|
||||
def test_nam_eps():
|
||||
u_c = 1e15
|
||||
eps_to_test = pynam.dielectric.nam_dielectric_coefficient_approximator.get_nam_dielectric(u_c, CalculationParams(
|
||||
omega=1e9,
|
||||
omega_p=3.54491e15,
|
||||
tau=1e-14,
|
||||
v_f=2e6,
|
||||
t_rel=0.8,
|
||||
t_c=1e11
|
||||
))
|
||||
|
||||
np.testing.assert_allclose(
|
||||
eps_to_test(10), -3.789672906817707e10 + 3.257134605133221e8j,
|
||||
rtol=1e-3, err_msg='below u_l bad'
|
||||
eps_to_test = (
|
||||
pynam.dielectric.nam_dielectric_coefficient_approximator.get_nam_dielectric(
|
||||
u_c,
|
||||
CalculationParams(
|
||||
omega=1e9, omega_p=3.54491e15, tau=1e-14, v_f=2e6, t_rel=0.8, t_c=1e11
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
eps_to_test(1e10), -2.655709887616547e8 + 2.302290450767144e6j,
|
||||
rtol=1e-3, err_msg='linear region bad'
|
||||
eps_to_test(10),
|
||||
-3.789672906817707e10 + 3.257134605133221e8j,
|
||||
rtol=1e-3,
|
||||
err_msg="below u_l bad",
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
eps_to_test(1e17), 1,
|
||||
rtol=1e-6, err_msg='above cutoff bad'
|
||||
eps_to_test(1e10),
|
||||
-2.655709887616547e8 + 2.302290450767144e6j,
|
||||
rtol=1e-3,
|
||||
err_msg="linear region bad",
|
||||
)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
eps_to_test(1e17), 1, rtol=1e-6, err_msg="above cutoff bad"
|
||||
)
|
||||
|
||||
@@ -3,120 +3,163 @@ import numpy as np
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2), 7 / (2 * np.sqrt(6))),
|
||||
((2, 0.25), -5j / np.sqrt(39))
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[((1, 2), 7 / (2 * np.sqrt(6))), ((2, 0.25), -5j / np.sqrt(39))],
|
||||
)
|
||||
def test_g(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.sigma_nam.g(*test_input), expected,
|
||||
decimal=7, err_msg='g function is off'
|
||||
pynam.dielectric.sigma_nam.g(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="g function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0), 2),
|
||||
((1, 2, 3), 2 - 3j),
|
||||
((1, 0, 3), -3j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected", [((1, 2, 0), 2), ((1, 2, 3), 2 - 3j), ((1, 0, 3), -3j)]
|
||||
)
|
||||
def test_s(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.sigma_nam.s(*test_input), expected,
|
||||
decimal=7, err_msg='s function is off'
|
||||
pynam.dielectric.sigma_nam.s(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="s function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0), 4 - 3 * np.log(3)),
|
||||
((1, 1, 0.1), 1.7258022209219421 + 0.4146045220413866j),
|
||||
((1, 2, 1), 0.535971651563 + 0.291580606867j),
|
||||
((1, 0, 1), (np.pi - 2)*1j),
|
||||
((2, 1.09637631718, 0), 0.97892512273 + 1.09875591859j),
|
||||
((2, 1, 0), 0.91197960825 + 1.17809724510j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 0), 4 - 3 * np.log(3)),
|
||||
((1, 1, 0.1), 1.7258022209219421 + 0.4146045220413866j),
|
||||
((1, 2, 1), 0.535971651563 + 0.291580606867j),
|
||||
((1, 0, 1), (np.pi - 2) * 1j),
|
||||
((2, 1.09637631718, 0), 0.97892512273 + 1.09875591859j),
|
||||
((2, 1, 0), 0.91197960825 + 1.17809724510j),
|
||||
],
|
||||
)
|
||||
def test_f(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.sigma_nam.f(*test_input), expected,
|
||||
decimal=7, err_msg='f function is off'
|
||||
pynam.dielectric.sigma_nam.f(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="f function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 3, 1, 0), 1.43292419807),
|
||||
((1, 2, 3, 4), 0.020963572915 + 0.441546735048j),
|
||||
((1, 2, 2, 0), 2.24702466263660598724031013350450660504 + 2.6687342075059525776833106878900822165j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((2, 3, 1, 0), 1.43292419807),
|
||||
((1, 2, 3, 4), 0.020963572915 + 0.441546735048j),
|
||||
(
|
||||
(1, 2, 2, 0),
|
||||
2.24702466263660598724031013350450660504
|
||||
+ 2.6687342075059525776833106878900822165j,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_i1(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.sigma_nam.i1(*test_input), expected,
|
||||
decimal=7, err_msg='i1 function is off'
|
||||
pynam.dielectric.sigma_nam.i1(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="i1 function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 3, 1, 0), 1.48649022993),
|
||||
((1, 2, 3, 4), 0.079899419983 + 0.441546735048j),
|
||||
((1, 2, 2, 0), 2.5083371377336783093007366990156440969 + 2.6687342075059525776833106878900822165j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((2, 3, 1, 0), 1.48649022993),
|
||||
((1, 2, 3, 4), 0.079899419983 + 0.441546735048j),
|
||||
(
|
||||
(1, 2, 2, 0),
|
||||
2.5083371377336783093007366990156440969
|
||||
+ 2.6687342075059525776833106878900822165j,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_i2(test_input, expected):
|
||||
np.testing.assert_almost_equal(
|
||||
pynam.dielectric.sigma_nam.i2(*test_input), expected,
|
||||
decimal=7, err_msg='i1 function is off'
|
||||
pynam.dielectric.sigma_nam.i2(*test_input),
|
||||
expected,
|
||||
decimal=7,
|
||||
err_msg="i1 function is off",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 3, 4), 0.228396),
|
||||
((0.007307411691175783, 1e8, 730.7411691175784, 0.5845929352940626), 1.37272e-7)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 3, 4), 0.228396),
|
||||
(
|
||||
(0.007307411691175783, 1e8, 730.7411691175784, 0.5845929352940626),
|
||||
1.37272e-7,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_a(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.sigma_nam.a(*test_input))
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-5, err_msg='a function is off'
|
||||
)
|
||||
np.testing.assert_allclose(actual, expected, rtol=1e-5, err_msg="a function is off")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((2, 1, 2, 0, 4), 0.19089933550122580816258795500979108668 + 0.30273783507819906415704926284048453889j),
|
||||
((100, 1, 2, 3, 4), -2.62529549976e-6 + 2.60765e-12j),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
(
|
||||
(2, 1, 2, 0, 4),
|
||||
0.19089933550122580816258795500979108668
|
||||
+ 0.30273783507819906415704926284048453889j,
|
||||
),
|
||||
((100, 1, 2, 3, 4), -2.62529549976e-6 + 2.60765e-12j),
|
||||
],
|
||||
)
|
||||
def test_b_int(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.sigma_nam.b_int(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='b int function is off'
|
||||
actual, expected, decimal=6, err_msg="b int function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0, 4), 1.23149 + 2.08627j),
|
||||
((1, 2, 3, 4), -0.0595819 + 0.437385j),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 0, 4), 1.23149 + 2.08627j),
|
||||
((1, 2, 3, 4), -0.0595819 + 0.437385j),
|
||||
],
|
||||
)
|
||||
def test_b(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.sigma_nam.b(*test_input))
|
||||
np.testing.assert_almost_equal(
|
||||
actual, expected,
|
||||
decimal=6, err_msg='b function is off'
|
||||
actual, expected, decimal=6, err_msg="b function is off"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
((1, 2, 0, 4), 0),
|
||||
((1, 2, 3, 4), 0.984117 + 0.647951j),
|
||||
((0.007307411691175783, 1e8, 730.7411691175784, 0.5845929352940626), 0.00008925294700016892 + 0.0102953966846717j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
((1, 2, 0, 4), 0),
|
||||
((1, 2, 3, 4), 0.984117 + 0.647951j),
|
||||
(
|
||||
(0.007307411691175783, 1e8, 730.7411691175784, 0.5845929352940626),
|
||||
0.00008925294700016892 + 0.0102953966846717j,
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_sigma_nam(test_input, expected):
|
||||
actual = np.real_if_close(pynam.dielectric.sigma_nam.sigma_nam(*test_input))
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-3, err_msg='sigma_nam function is off'
|
||||
actual, expected, rtol=1e-3, err_msg="sigma_nam function is off"
|
||||
)
|
||||
|
||||
|
||||
def test_sigma_nam_benchmark(benchmark):
|
||||
result = benchmark(pynam.dielectric.sigma_nam.sigma_nam, 1, 2, 3, 4)
|
||||
np.testing.assert_almost_equal(
|
||||
result, 0.984117 + 0.647951j,
|
||||
decimal=6, err_msg='sigma nam benchmrak function is off'
|
||||
result,
|
||||
0.984117 + 0.647951j,
|
||||
decimal=6,
|
||||
err_msg="sigma nam benchmrak function is off",
|
||||
)
|
||||
|
||||
@@ -8,34 +8,50 @@ from pynam.baskets import CalculationParams
|
||||
|
||||
@pytest.fixture
|
||||
def chi_zz_e_lindhard():
|
||||
params = CalculationParams(omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14)
|
||||
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.chi.get_chi_zz_e(eps_l)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# z chi_zz_e_lindhard(z)
|
||||
(1e-5, 4.0249088868003124e6),
|
||||
(1e-6, 4.400474453780887e9),
|
||||
(1e-7, 7.768467746685921e12),
|
||||
(1e-8, 1.8541895525296864e16),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# z chi_zz_e_lindhard(z)
|
||||
(1e-5, 4.0249088868003124e6),
|
||||
(1e-6, 4.400474453780887e9),
|
||||
(1e-7, 7.768467746685921e12),
|
||||
(1e-8, 1.8541895525296864e16),
|
||||
],
|
||||
)
|
||||
def test_chi_zz_e_lindhard(chi_zz_e_lindhard, test_input, expected):
|
||||
actual = chi_zz_e_lindhard(test_input)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-3, err_msg='chi_zz_e is inaccurate for Lindhard case', verbose=True
|
||||
actual,
|
||||
expected,
|
||||
rtol=1e-3,
|
||||
err_msg="chi_zz_e is inaccurate for Lindhard case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# z chi_zz_e_lindhard(z)
|
||||
(1e-6, 4.400474453780887e9),
|
||||
])
|
||||
def test_chi_zz_e_lindhard_benchmark(benchmark, chi_zz_e_lindhard, test_input, expected):
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# z chi_zz_e_lindhard(z)
|
||||
(1e-6, 4.400474453780887e9),
|
||||
],
|
||||
)
|
||||
def test_chi_zz_e_lindhard_benchmark(
|
||||
benchmark, chi_zz_e_lindhard, test_input, expected
|
||||
):
|
||||
actual = benchmark(chi_zz_e_lindhard, test_input)
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-3, err_msg='chi_zz_e is inaccurate for Lindhard case', verbose=True
|
||||
actual,
|
||||
expected,
|
||||
rtol=1e-3,
|
||||
err_msg="chi_zz_e is inaccurate for Lindhard case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
@@ -8,24 +8,32 @@ 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)
|
||||
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), 1e4 is too far off still
|
||||
(1e5, 1.602855764970752e-8),
|
||||
(1e6, 1.704326041013161e-8),
|
||||
(1e7, 2.674124312031195e-8),
|
||||
(1e8, 7.441319151047531e-8),
|
||||
])
|
||||
@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
|
||||
actual,
|
||||
expected,
|
||||
rtol=1e-4,
|
||||
err_msg="imrp is inaccurate for Lindhard case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
@@ -8,49 +8,65 @@ from pynam.baskets import CalculationParams
|
||||
|
||||
@pytest.fixture
|
||||
def zeta_p_integrand_lindhard():
|
||||
params = CalculationParams(omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14)
|
||||
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.zeta.get_zeta_p_integrand(eps_l)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# y u zeta_p_i(u, y)
|
||||
((100, 100), -6.891930153028566e-13 - 7.957747045025948e-9j),
|
||||
((1e5, 100), -1.0057257267146669e-10 - 4.0591966623027983e-13j),
|
||||
((100, 1e5), 1.1789175285399862e-8 - 7.957833322596519e-9j)
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"test_input,expected",
|
||||
[
|
||||
# y u zeta_p_i(u, y)
|
||||
((100, 100), -6.891930153028566e-13 - 7.957747045025948e-9j),
|
||||
((1e5, 100), -1.0057257267146669e-10 - 4.0591966623027983e-13j),
|
||||
((100, 1e5), 1.1789175285399862e-8 - 7.957833322596519e-9j),
|
||||
],
|
||||
)
|
||||
def test_zeta_p_integrand_lindhard(zeta_p_integrand_lindhard, test_input, expected):
|
||||
actual = zeta_p_integrand_lindhard(*test_input)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-7, err_msg='Zeta_p is inaccurate for Lindhard case', verbose=True
|
||||
actual,
|
||||
expected,
|
||||
rtol=1e-7,
|
||||
err_msg="Zeta_p is inaccurate for Lindhard case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def zeta_p_lindhard():
|
||||
params = CalculationParams(omega=1e9, v_f=2e6, omega_p=3.544907701811032e15, tau=1e-14)
|
||||
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.zeta.get_zeta_p_function(eps_l)
|
||||
|
||||
|
||||
@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)
|
||||
])
|
||||
@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):
|
||||
actual = zeta_p_lindhard(test_input)
|
||||
|
||||
np.testing.assert_allclose(
|
||||
actual, expected,
|
||||
rtol=1e-4, err_msg='Zeta_p is inaccurate for Lindhard case', verbose=True
|
||||
actual,
|
||||
expected,
|
||||
rtol=1e-4,
|
||||
err_msg="Zeta_p is inaccurate for Lindhard case",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
@@ -2,4 +2,4 @@ from pynam import __version__
|
||||
|
||||
|
||||
def test_version():
|
||||
assert __version__ == '0.1.0'
|
||||
assert __version__ == "0.1.0"
|
||||
|
||||
@@ -3,18 +3,28 @@ import pynam.util.complex_integrate
|
||||
|
||||
|
||||
def test_complex_quad():
|
||||
actual = pynam.util.complex_integrate.complex_quad(lambda x: x ** 2 + 1j * x ** 3, 0, 6)[0]
|
||||
actual = pynam.util.complex_integrate.complex_quad(
|
||||
lambda x: x**2 + 1j * x**3, 0, 6
|
||||
)[0]
|
||||
# int_1^6 dx x^2 + i x^3 should equal (1/3)6^3 + (i/4)6^4
|
||||
np.testing.assert_almost_equal(
|
||||
actual, (6**3)/3 + 1j*(6**4)/4,
|
||||
decimal=7, err_msg='complex quadrature is broken', verbose=True
|
||||
actual,
|
||||
(6**3) / 3 + 1j * (6**4) / 4,
|
||||
decimal=7,
|
||||
err_msg="complex quadrature is broken",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
|
||||
def test_complex_quadrature():
|
||||
actual = pynam.util.complex_integrate.complex_quadrature(lambda x: x ** 2 + 1j * x ** 3, 0, 6)[0]
|
||||
actual = pynam.util.complex_integrate.complex_quadrature(
|
||||
lambda x: x**2 + 1j * x**3, 0, 6
|
||||
)[0]
|
||||
# int_1^6 dx x^2 + i x^3 should equal (1/3)6^3 + (i/4)6^4
|
||||
np.testing.assert_almost_equal(
|
||||
actual, (6**3)/3 + 1j*(6**4)/4,
|
||||
decimal=7, err_msg='complex quadrature is broken', verbose=True
|
||||
actual,
|
||||
(6**3) / 3 + 1j * (6**4) / 4,
|
||||
decimal=7,
|
||||
err_msg="complex quadrature is broken",
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user