Skip to content
Snippets Groups Projects
Commit aeebff52 authored by GUBAIDULIN's avatar GUBAIDULIN
Browse files

Merge branch 'optimize_indices_CircularResistiveWall' into 'develop'

Optimize boolean indexing in CircularResistiveWall

See merge request !15
parents 65908062 b54a0bae
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): ...@@ -163,18 +163,17 @@ class CircularResistiveWall(WakeField):
in high-energy particle accelerators. World Scientific. in high-energy particle accelerators. World Scientific.
""" """
wl = np.zeros_like(time) wl = np.zeros_like(time)
idx1 = time < 0
if exact == True: if exact == True:
idx1 = time > 0
idx2 = 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) 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 # fundamental theorem of beam loading
wl[idx3] = self.__LongWakeExact(time[idx3], factor) wl[idx2] = 3 * factor / 2
else: else:
idx2 = np.logical_not(idx1) idx = time >= 0
wl[idx2] = self.__LongWakeApprox(time[idx2]) wl[idx] = self.__LongWakeApprox(time[idx])
return wl return wl
def TransverseWakeFunction(self, time, exact=True): def TransverseWakeFunction(self, time, exact=True):
...@@ -220,16 +219,14 @@ class CircularResistiveWall(WakeField): ...@@ -220,16 +219,14 @@ class CircularResistiveWall(WakeField):
Detectors and Associated Equipment 806 (2016): 221-230. Detectors and Associated Equipment 806 (2016): 221-230.
""" """
wt = np.zeros_like(time) wt = np.zeros_like(time)
idx1 = time < 0
if exact == True: if exact == True:
idx2 = time == 0 idx = time > 0
idx3 = np.logical_not(np.logical_or(idx1, idx2))
factor = ((self.Z0 * c**2 * self.t0) / factor = ((self.Z0 * c**2 * self.t0) /
(3 * np.pi * self.radius**4) * self.length) (3 * np.pi * self.radius**4) * self.length)
wt[idx3] = self.__TransWakeExact(time[idx3], factor) wt[idx] = self.__TransWakeExact(time[idx], factor)
else: else:
idx2 = np.logical_not(idx1) idx = time >= 0
wt[idx2] = self.__TransWakeApprox(time[idx2]) wt[idx] = self.__TransWakeApprox(time[idx])
return wt return wt
def __LongWakeExact(self, t, factor): def __LongWakeExact(self, t, factor):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment