From 11f332886c08b2420643c07d9777afbaedc04e8e Mon Sep 17 00:00:00 2001 From: nmounet Date: Mon, 18 Nov 2024 16:16:30 +0100 Subject: [PATCH] Some optimisation in transverse wake function of resonator, in component.py --- xwakes/wit/component.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xwakes/wit/component.py b/xwakes/wit/component.py index 3d6384fc..0c1eea80 100644 --- a/xwakes/wit/component.py +++ b/xwakes/wit/component.py @@ -581,20 +581,19 @@ def wake(self, t): plane = self.plane omega_r = 2 * np.pi * f_r root_term = np.sqrt(1 - 1 / (4 * q ** 2) + 0J) + omega_bar = omega_r * root_term + alpha = omega_r / (2 * q) if plane == 'z': - omega_bar = omega_r * root_term - alpha = omega_r / (2 * q) out = np.zeros_like(t) mask = t >= 0 out[mask] = factor * (omega_r * r * np.exp(-alpha * t[mask]) * ( np.cos(omega_bar * t[mask]) - alpha * np.sin(omega_bar * t[mask]) / omega_bar) / q).real else: - omega_bar = omega_r * root_term out = np.zeros_like(t) mask = t >= 0 - out[mask] = factor * (omega_r * r * np.exp(-omega_r * t[mask] / (2 * q)) * - np.sin(omega_r * root_term * t[mask]) / + out[mask] = factor * (omega_r * r * np.exp(-alpha * t[mask]) * + np.sin(omega_bar * t[mask]) / (q * root_term)).real return out