1
0
forked from IPKM/nmreval

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) _omega = np.atleast_1d(omega)
_tau = np.atleast_1d(tau0) _tau = np.atleast_1d(tau0)
pool = Pool(processes=min(cpu_count(), 4)) if HAS_C_FUNCS:
integration_ranges = [(omega_i, tau_j, sigma) for (omega_i, tau_j) in product(_omega, _tau)] 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'): return (res_real + 1j * res_imag).squeeze()
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()
@staticmethod @staticmethod
def specdens(omega: ArrayLike, tau: ArrayLike, sigma: float): def specdens(omega: ArrayLike, tau: ArrayLike, sigma: float) -> np.ndarray:
_omega = np.atleast_1d(omega) _omega = np.atleast_1d(omega)
_tau = np.atleast_1d(tau) _tau = np.atleast_1d(tau)
@ -106,8 +105,7 @@ def _integrate_specdens_c(omega: np.ndarray, tau: np.ndarray, sigma: float) -> n
return res return res
def _integrate_process_imag(args): def _integrate_process_imag(omega_i, tau_j, sigma):
omega_i, tau_j, sigma = args
area = quad(_integrand_freq_imag_high, 0, 50, args=(omega_i, tau_j, sigma))[0] 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] area += quad(_integrand_freq_imag_low, -50, 0, args=(omega_i, tau_j, sigma))[0]