Skip to content
Snippets Groups Projects
Commit b54a0bae authored by Keon Hee KIM's avatar Keon Hee KIM Committed by GUBAIDULIN
Browse files

Optimize boolean indexing in CircularResistiveWall

parent 9543045d
No related branches found
No related tags found
2 merge requests!280.8.0,!15Optimize boolean indexing in CircularResistiveWall
......@@ -163,18 +163,17 @@ class CircularResistiveWall(WakeField):
in high-energy particle accelerators. World Scientific.
"""
wl = np.zeros_like(time)
idx1 = time < 0
if exact == True:
idx1 = time > 0
idx2 = time == 0
idx3 = np.logical_not(np.logical_or(idx1, idx2))
factor = (self.Z0 * c / (3 * np.pi * self.radius**2) * self.length)
if np.any(idx2):
wl[idx1] = self.__LongWakeExact(time[idx1], factor)
# fundamental theorem of beam loading
wl[idx2] = 3 * factor / 2
wl[idx3] = self.__LongWakeExact(time[idx3], factor)
else:
idx2 = np.logical_not(idx1)
wl[idx2] = self.__LongWakeApprox(time[idx2])
idx = time >= 0
wl[idx] = self.__LongWakeApprox(time[idx])
return wl
def TransverseWakeFunction(self, time, exact=True):
......@@ -220,16 +219,14 @@ class CircularResistiveWall(WakeField):
Detectors and Associated Equipment 806 (2016): 221-230.
"""
wt = np.zeros_like(time)
idx1 = time < 0
if exact == True:
idx2 = time == 0
idx3 = np.logical_not(np.logical_or(idx1, idx2))
idx = time > 0
factor = ((self.Z0 * c**2 * self.t0) /
(3 * np.pi * self.radius**4) * self.length)
wt[idx3] = self.__TransWakeExact(time[idx3], factor)
wt[idx] = self.__TransWakeExact(time[idx], factor)
else:
idx2 = np.logical_not(idx1)
wt[idx2] = self.__TransWakeApprox(time[idx2])
idx = time >= 0
wt[idx] = self.__TransWakeApprox(time[idx])
return wt
def __LongWakeExact(self, t, factor):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment