Skip to content
Snippets Groups Projects
Commit d3409915 authored by Alexis GAMELIN's avatar Alexis GAMELIN
Browse files

Apply formatters and fix docstrings

parent 584b3d9c
No related branches found
No related tags found
1 merge request!14Faster CircularResistiveWall
......@@ -63,6 +63,7 @@ class CircularResistiveWall(WakeField):
exact : bool, optional
If False, approxmiated formulas are used for the wake function
computations.
The default is True.
References
----------
......@@ -81,13 +82,7 @@ class CircularResistiveWall(WakeField):
"""
def __init__(self,
time,
frequency,
length,
rho,
radius,
exact=True):
def __init__(self, time, frequency, length, rho, radius, exact=True):
super().__init__()
self.length = length
......@@ -147,7 +142,7 @@ class CircularResistiveWall(WakeField):
time : array of float
Time points where the wake function is evaluated in [s].
exact : bool, optional
If True, the exact expression is used. The default is False.
If True, the exact expression is used. The default is True.
Returns
-------
......@@ -172,8 +167,7 @@ class CircularResistiveWall(WakeField):
if exact == True:
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):
# fundamental theorem of beam loading
wl[idx2] = 3 * factor / 2
......@@ -207,7 +201,7 @@ class CircularResistiveWall(WakeField):
time : array of float
Time points where the wake function is evaluated in [s].
exact : bool, optional
If True, the exact expression is used. The default is False.
If True, the exact expression is used. The default is True.
Returns
-------
......@@ -231,8 +225,7 @@ class CircularResistiveWall(WakeField):
idx2 = time == 0
idx3 = np.logical_not(np.logical_or(idx1, idx2))
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)
else:
idx2 = np.logical_not(idx1)
......@@ -241,40 +234,35 @@ class CircularResistiveWall(WakeField):
def __LongWakeExact(self, t, factor):
w1re, _ = _wofz(0, np.sqrt(2 * t / self.t0))
w2re, _ = _wofz( np.cos(np.pi/6) *
np.sqrt(2 * t / self.t0),
np.sin(np.pi/6) *
np.sqrt(2 * t / self.t0) )
w2re, _ = _wofz(
np.cos(np.pi / 6) * np.sqrt(2 * t / self.t0),
np.sin(np.pi / 6) * np.sqrt(2 * t / self.t0))
wl = factor * (4 * np.exp(-1 * t / self.t0) *
np.cos(np.sqrt(3) * t / self.t0)
+ w1re - 2 * w2re )
np.cos(np.sqrt(3) * t / self.t0) + w1re - 2*w2re)
return wl
def __TransWakeExact(self, t, factor):
w1re, _ = _wofz(0, np.sqrt(2 * t / self.t0))
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) )
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))
wt = factor * (2 * np.exp(-1 * t / self.t0) *
( np.sqrt(3) * np.sin(np.sqrt(3) * t / self.t0)
- np.cos(np.sqrt(3) * t / self.t0) )
+ w1re + 2 * ( np.cos(-np.pi/3) * w2re
- np.sin(-np.pi/3) * w2im ) )
(np.sqrt(3) * np.sin(np.sqrt(3) * t / self.t0) -
np.cos(np.sqrt(3) * t / self.t0)) + w1re + 2 *
(np.cos(-np.pi / 3) * w2re - np.sin(-np.pi / 3) * w2im))
return wt
def __LongWakeApprox(self, t):
wl = -1 * (1 / (4 * np.pi * self.radius) *
np.sqrt(self.Z0 * self.rho / (c * np.pi * t**3))
* self.length)
np.sqrt(self.Z0 * self.rho /
(c * np.pi * t**3)) * self.length)
return wl
def __TransWakeApprox(self, t):
wt = (1 / (np.pi * self.radius**3) *
np.sqrt(self.Z0 * c * self.rho / (np.pi * t)) *
self.length)
np.sqrt(self.Z0 * c * self.rho / (np.pi * t)) * self.length)
return wt
......
......@@ -709,9 +709,8 @@ class LongRangeResistiveWall(Element):
Wake function in [V/C].
"""
wl = (1 / (4 * pi * self.radius) * np.sqrt(self.Z0 * self.rho /
(c*pi*t**3))
* self.length) * -1
wl = (1 / (4 * pi * self.radius) *
np.sqrt(self.Z0 * self.rho / (c * pi * t**3)) * self.length) * -1
return wl
def Wdip(self, t, plane):
......@@ -739,8 +738,8 @@ class LongRangeResistiveWall(Element):
else:
raise ValueError()
wdip = (1 / (pi * r3**3) * np.sqrt(self.Z0 * c * self.rho / (pi * t))
* self.length)
wdip = (1 / (pi * r3**3) * np.sqrt(self.Z0 * c * self.rho / (pi*t)) *
self.length)
return wdip
def update_tables(self, beam):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment