Skip to content
Snippets Groups Projects
Commit 7df41cfe authored by Keon Hee KIM's avatar Keon Hee KIM
Browse files

Import _wofz from particles_electromagnetic_fields

parent 2bf4ef51
No related branches found
No related tags found
1 merge request!14Faster CircularResistiveWall
...@@ -5,9 +5,9 @@ Define resistive wall elements based on the WakeField class. ...@@ -5,9 +5,9 @@ Define resistive wall elements based on the WakeField class.
import numpy as np import numpy as np
from scipy.constants import c, epsilon_0, mu_0 from scipy.constants import c, epsilon_0, mu_0
from scipy.special import wofz as _scipy_wofz
from mbtrack2.impedance.wakefield import Impedance, WakeField, WakeFunction from mbtrack2.impedance.wakefield import Impedance, WakeField, WakeFunction
from mbtrack2.tracking.particles_electromagnetic_fields import _wofz
def skin_depth(frequency, rho, mu_r=1, epsilon_r=1): def skin_depth(frequency, rho, mu_r=1, epsilon_r=1):
...@@ -239,21 +239,11 @@ class CircularResistiveWall(WakeField): ...@@ -239,21 +239,11 @@ class CircularResistiveWall(WakeField):
wt[idx2] = self.__TransWakeApprox(time[idx2]) wt[idx2] = self.__TransWakeApprox(time[idx2])
return wt return wt
def __wofz(self, z):
"""
Compute the Faddeeva function w(z) = exp(-z**2) * erfc(-i*z).
Returns
-------
tuple
Real and imaginary parts of the Faddeeva function.
"""
res = _scipy_wofz(z)
return res.real, res.imag
def __LongWakeExact(self, t, factor): def __LongWakeExact(self, t, factor):
w1re, _ = self.__wofz( 1j * np.sqrt(2 * t / self.t0) ) w1re, _ = _wofz( 0, np.sqrt(2 * t / self.t0) )
w2re, _ = self.__wofz( np.exp(1j * np.pi / 6) * w2re, _ = _wofz( np.cos(np.pi/6) *
np.sqrt(2 * t / self.t0),
np.sin(np.pi/6) *
np.sqrt(2 * t / self.t0) ) np.sqrt(2 * t / self.t0) )
wl = factor * ( 4 * np.exp(-1 * t / self.t0) * wl = factor * ( 4 * np.exp(-1 * t / self.t0) *
...@@ -262,8 +252,10 @@ class CircularResistiveWall(WakeField): ...@@ -262,8 +252,10 @@ class CircularResistiveWall(WakeField):
return wl return wl
def __TransWakeExact(self, t, factor): def __TransWakeExact(self, t, factor):
w1re, _ = self.__wofz( 1j * np.sqrt(2 * t / self.t0) ) w1re, _ = _wofz( 0, np.sqrt(2 * t / self.t0) )
w2re, w2im = self.__wofz( np.exp(1j * np.pi / 6) * w2re, w2im = _wofz( np.cos(np.pi/6) *
np.sqrt(2 * t / self.t0),
np.sin(np.pi/6) *
np.sqrt(2 * t / self.t0) ) np.sqrt(2 * t / self.t0) )
wt = factor * ( 2 * np.exp(-1 * t / self.t0) * wt = factor * ( 2 * np.exp(-1 * t / self.t0) *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment