Moving complex quad file to comlpex integrate
This commit is contained in:
@@ -22,3 +22,25 @@ def test_lindhard_dielectric(test_input, expected):
|
||||
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)
|
||||
])
|
||||
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'
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def zeta_p_i_epsilon():
|
||||
params = CalculationParams(omega=1e9, omega_p=3.544907701811032e15, tau=1e-14, v_f=2e6)
|
||||
return pynam.dielectric.get_lindhard_dielectric(params)
|
||||
|
||||
0
tests/noise/__init__.py
Normal file
0
tests/noise/__init__.py
Normal file
28
tests/noise/test_zeta.py
Normal file
28
tests/noise/test_zeta.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
import pynam.dielectric
|
||||
import pynam.noise.zeta
|
||||
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)
|
||||
eps_l = pynam.dielectric.get_lindhard_dielectric(params)
|
||||
return pynam.noise.zeta.get_zeta_p_integrand(eps_l)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_input,expected", [
|
||||
# u y zeta_p_i(u, y)
|
||||
((100, 100), -6.891930153028566e-13 - 7.957747045025948e-9j),
|
||||
((100, 1e5), -1.0057257267146669e-10 - 4.0591966623027983e-13j),
|
||||
((1e5, 100), 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
|
||||
)
|
||||
@@ -1,9 +1,9 @@
|
||||
import numpy as np
|
||||
import pynam.util.complex_quad
|
||||
import pynam.util.complex_integrate
|
||||
|
||||
|
||||
def test_complex_quad():
|
||||
actual = pynam.util.complex_quad.complex_quadrature(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,
|
||||
Reference in New Issue
Block a user