feat: adds unapproximated nam calc
This commit is contained in:
parent
4d59f9c09c
commit
20db727015
@ -4,7 +4,12 @@ import pyewjn.dielectric.low_k_nam
|
|||||||
|
|
||||||
from pyewjn.baskets import CalculationParams, CalculationConstants
|
from pyewjn.baskets import CalculationParams, CalculationConstants
|
||||||
|
|
||||||
from typing import Tuple
|
from typing import Tuple, Callable
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
FIXED_LARGE_MOMENTUM = 1e8
|
FIXED_LARGE_MOMENTUM = 1e8
|
||||||
|
|
||||||
@ -141,10 +146,10 @@ def get_unapproximated_nam_dielectric(
|
|||||||
u_c: float,
|
u_c: float,
|
||||||
params: CalculationParams,
|
params: CalculationParams,
|
||||||
constants: CalculationConstants = CalculationConstants(),
|
constants: CalculationConstants = CalculationConstants(),
|
||||||
):
|
) -> Callable[[float], float]:
|
||||||
|
|
||||||
sigma_n = params.omega_p**2 * params.tau / (4 * np.pi)
|
sigma_n = params.omega_p**2 * params.tau / (4 * np.pi)
|
||||||
coeffs = get_nam_dielectric_coefficients(
|
dedim = get_dedimensionalised_parameters(
|
||||||
params.omega,
|
params.omega,
|
||||||
sigma_n,
|
sigma_n,
|
||||||
params.tau,
|
params.tau,
|
||||||
@ -153,4 +158,19 @@ def get_unapproximated_nam_dielectric(
|
|||||||
params.t_c,
|
params.t_c,
|
||||||
constants.c_light,
|
constants.c_light,
|
||||||
)
|
)
|
||||||
return coeffs.eps(u_c)
|
prefactor = 4j * np.pi * dedim.b
|
||||||
|
|
||||||
|
def eps_ret(u: float) -> float:
|
||||||
|
if u * dedim.a * 100 < abs(dedim.xi + 1j * dedim.nu):
|
||||||
|
_logger.info("Falling to low k version")
|
||||||
|
return prefactor * pyewjn.dielectric.low_k_nam.sigma_nam_alk(
|
||||||
|
dedim.xi, u * dedim.a, dedim.nu, dedim.t
|
||||||
|
)
|
||||||
|
elif u < u_c:
|
||||||
|
return prefactor * pyewjn.dielectric.sigma_nam.sigma_nam(
|
||||||
|
dedim.xi, u * dedim.a, dedim.nu, dedim.t
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return eps_ret
|
||||||
|
@ -137,3 +137,31 @@ def test_nam_eps():
|
|||||||
np.testing.assert_allclose(
|
np.testing.assert_allclose(
|
||||||
eps_to_test(1e17), 1, rtol=1e-6, err_msg="above cutoff bad"
|
eps_to_test(1e17), 1, rtol=1e-6, err_msg="above cutoff bad"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_unapproximated_nam_eps():
|
||||||
|
u_c = 1e15
|
||||||
|
eps_to_test = pyewjn.dielectric.nam_dielectric_coefficient_approximator.get_unapproximated_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",
|
||||||
|
)
|
||||||
|
|
||||||
|
np.testing.assert_allclose(
|
||||||
|
eps_to_test(1e10),
|
||||||
|
-2.645743e8 + 2.293455422222e6j,
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user