refactor Log-Gaussian susceptibility

This commit is contained in:
Dominik Demuth 2023-04-17 17:43:18 +02:00
parent 56b588293d
commit 4a9d50e8a4

View File

@ -48,18 +48,17 @@ class LogGaussian(Distribution):
_omega = np.atleast_1d(omega)
_tau = np.atleast_1d(tau0)
pool = Pool(processes=min(cpu_count(), 4))
integration_ranges = [(omega_i, tau_j, sigma) for (omega_i, tau_j) in product(_omega, _tau)]
if HAS_C_FUNCS:
res_real = _integration_parallel(_omega, _tau, sigma, _integrate_process_imag)
res_imag = _integration_parallel(_omega, _tau, sigma, _integrate_process_real)
else:
res_real = None
res_imag = None
with np.errstate(divide='ignore'):
res_real = np.array(pool.map(_integrate_process_imag, integration_ranges))
res_imag = np.array(pool.map(_integrate_process_real, integration_ranges))
ret_val = (res_real+1j*res_imag).reshape((_omega.shape[0], _tau.shape[0]))
return ret_val.squeeze()
return (res_real + 1j * res_imag).squeeze()
@staticmethod
def specdens(omega: ArrayLike, tau: ArrayLike, sigma: float):
def specdens(omega: ArrayLike, tau: ArrayLike, sigma: float) -> np.ndarray:
_omega = np.atleast_1d(omega)
_tau = np.atleast_1d(tau)
@ -106,8 +105,7 @@ def _integrate_specdens_c(omega: np.ndarray, tau: np.ndarray, sigma: float) -> n
return res
def _integrate_process_imag(args):
omega_i, tau_j, sigma = args
def _integrate_process_imag(omega_i, tau_j, sigma):
area = quad(_integrand_freq_imag_high, 0, 50, args=(omega_i, tau_j, sigma))[0]
area += quad(_integrand_freq_imag_low, -50, 0, args=(omega_i, tau_j, sigma))[0]