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

Removed atol

parent b83abb5f
No related branches found
No related tags found
1 merge request!14Faster CircularResistiveWall
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
...@@ -62,10 +62,6 @@ class CircularResistiveWall(WakeField): ...@@ -62,10 +62,6 @@ class CircularResistiveWall(WakeField):
exact : bool, optional exact : bool, optional
If False, approxmiated formulas are used for the wake function If False, approxmiated formulas are used for the wake function
computations. computations.
atol : float, optional
Absolute tolerance used to enforce fundamental theorem of beam loading
for the exact expression of the longitudinal wake function.
Default is 1e-20.
References References
---------- ----------
...@@ -88,8 +84,7 @@ class CircularResistiveWall(WakeField): ...@@ -88,8 +84,7 @@ class CircularResistiveWall(WakeField):
length, length,
rho, rho,
radius, radius,
exact=False, exact=False):
atol=1e-20):
super().__init__() super().__init__()
self.length = length self.length = length
...@@ -104,7 +99,7 @@ class CircularResistiveWall(WakeField): ...@@ -104,7 +99,7 @@ class CircularResistiveWall(WakeField):
Z2 = c / omega * length * (1 + np.sign(frequency) * 1j) * rho / ( Z2 = c / omega * length * (1 + np.sign(frequency) * 1j) * rho / (
np.pi * radius**3 * skin_depth(frequency, rho)) np.pi * radius**3 * skin_depth(frequency, rho))
Wl = self.LongitudinalWakeFunction(time, exact, atol) Wl = self.LongitudinalWakeFunction(time, exact)
Wt = self.TransverseWakeFunction(time, exact) Wt = self.TransverseWakeFunction(time, exact)
Zlong = Impedance(variable=frequency, Zlong = Impedance(variable=frequency,
...@@ -127,7 +122,7 @@ class CircularResistiveWall(WakeField): ...@@ -127,7 +122,7 @@ class CircularResistiveWall(WakeField):
super().append_to_model(Wxdip) super().append_to_model(Wxdip)
super().append_to_model(Wydip) super().append_to_model(Wydip)
def LongitudinalWakeFunction(self, time, exact=False, atol=1e-20): def LongitudinalWakeFunction(self, time, exact=False):
""" """
Compute the longitudinal wake function of a circular resistive wall Compute the longitudinal wake function of a circular resistive wall
using Eq. (11), of [1], or approxmiated expression Eq. (24), of [2]. using Eq. (11), of [1], or approxmiated expression Eq. (24), of [2].
...@@ -136,8 +131,8 @@ class CircularResistiveWall(WakeField): ...@@ -136,8 +131,8 @@ class CircularResistiveWall(WakeField):
Eq. (11) in [1] is completely equivalent to Eq. (22) in [2]. Eq. (11) in [1] is completely equivalent to Eq. (22) in [2].
If some time value is smaller than atol, then the fundamental theorem The fundamental theorem of beam loading is applied for the exact
of beam loading is applied: Wl(0) = Wl(0+)/2. expression of the longitudinal wake function: Wl(0) = Wl(0+)/2.
Parameters Parameters
---------- ----------
...@@ -145,10 +140,6 @@ class CircularResistiveWall(WakeField): ...@@ -145,10 +140,6 @@ class CircularResistiveWall(WakeField):
Time points where the wake function is evaluated in [s]. Time points where the wake function is evaluated in [s].
exact : bool, optional exact : bool, optional
If True, the exact expression is used. The default is False. If True, the exact expression is used. The default is False.
atol : float, optional
Absolute tolerance used to enforce fundamental theorem of beam loading
for the exact expression of the longitudinal wake function.
Default is 1e-20.
Returns Returns
------- -------
...@@ -171,17 +162,11 @@ class CircularResistiveWall(WakeField): ...@@ -171,17 +162,11 @@ class CircularResistiveWall(WakeField):
if exact == True: if exact == True:
idx2 = time == 0 idx2 = time == 0
idx3 = np.logical_not(np.logical_or(idx1, idx2)) idx3 = np.logical_not(np.logical_or(idx1, idx2))
# idx4 = np.isclose(time, 0, atol=atol) & (time >= 0)
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): if np.any(idx2):
# fundamental theorem of beam loading # fundamental theorem of beam loading
wl[idx2] = 3 * factor / 2 wl[idx2] = 3 * factor / 2
wl[idx3] = self.__LongWakeExact(time[idx3], factor) wl[idx3] = self.__LongWakeExact(time[idx3], factor)
# if np.any(idx4):
# closest_to_zero_idx = np.argmin(time[idx4])
# # Get the actual index in the original array
# closest_to_zero_idx = np.where(idx4)[0][closest_to_zero_idx]
# wl[closest_to_zero_idx] *= 0.5
else: else:
idx2 = np.logical_not(idx1) idx2 = np.logical_not(idx1)
wl[idx2] = self.__LongWakeApprox(time[idx2]) wl[idx2] = self.__LongWakeApprox(time[idx2])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment