Skip to content

Commit

Permalink
Delete artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
fuodorov committed Aug 7, 2024
1 parent b9ada36 commit 1e2e77a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 81 deletions.
80 changes: 2 additions & 78 deletions redpic/accelerator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def __init__(
xp: float = 0.0,
y: float = 0.0,
yp: float = 0.0,
frequency: float = 0.0,
phase: float = 0.0,
):
"""
Initialization of an accelerator element.
Expand All @@ -44,10 +42,6 @@ def __init__(
Offset of the element along the y-axis, [m]
yp: float, optional
Element rotation in the z-y plane, [rad]
w: float, optional
Cirular frequency of the element, [rad/s]
phi: float, optional
Phase of the element, [rad]
"""
self.z0 = z0
self.max_field = max_field
Expand All @@ -57,8 +51,6 @@ def __init__(
self.xp = xp
self.y = y
self.yp = yp
self.frequency = frequency
self.phase = phase

self.z_start = 0.0e0
self.z_stop = 0.0e0
Expand Down Expand Up @@ -220,51 +212,6 @@ def read_offsets(beamline: dict, z: np.arange) -> interpolate.interp1d:
return (offset_correct_x, offset_correct_xp, offset_correct_y, offset_correct_yp)


def read_frequency_and_phase(beamline: dict, z: np.arange) -> (interpolate.interp1d, interpolate.interp1d):
field_files = {}
F = 0
frequency, phase = 0, 0

if not beamline:
z_data = [i / len(z) for i in range(len(z))]
F_data = [0 for i in range(len(z))]
f = interpolate.interp1d(z_data, F_data, fill_value=(0, 0), bounds_error=False)
F = F + f(z)
frequency, phase = F, F
else:
for element in beamline.values():
if not (element.file_name in field_files): # pylint: disable=superfluous-parens
field_files[element.file_name] = np.loadtxt(element.file_name)
M = field_files[element.file_name]
z_data = M[:, 0] + element.z0
F_data = M[:, 1]

if not element.length == 0:
z_data = np.linspace(element.z_start, element.z_stop, len(z_data))
f_frequency = interpolate.interp1d(
z_data,
[element.frequency for i in range(len(z_data))],
fill_value=(0, 0),
bounds_error=False,
)
f_phase = interpolate.interp1d(
z_data,
[element.phase for i in range(len(z_data))],
fill_value=(0, 0),
bounds_error=False,
)
else:
f = interpolate.interp1d(z_data, 0 * F_data, kind="cubic", fill_value=(0, 0), bounds_error=False)
f_frequency, f_phase = f, f

frequency = frequency + f_frequency(z)
phase = phase + f_phase(z)

frequency = interpolate.interp1d(z, frequency, kind="linear", fill_value=(0, 0), bounds_error=False)
phase = interpolate.interp1d(z, phase, kind="linear", fill_value=(0, 0), bounds_error=False)
return (frequency, phase)


class Accelerator:
"""
Top-level accelerator class that contains all the accelerator data.
Expand Down Expand Up @@ -312,8 +259,6 @@ def __init__(self, z_start: float, z_stop: float, dz: float):
self.Gzdz = interpolate.interp1d
self.Dx, self.Dxp = interpolate.interp1d, interpolate.interp1d
self.Dy, self.Dyp = interpolate.interp1d, interpolate.interp1d
self.B_freq, self.B_phase = interpolate.interp1d, interpolate.interp1d
self.E_freq, self.E_phase = interpolate.interp1d, interpolate.interp1d

def add_solenoid(
self,
Expand All @@ -326,8 +271,6 @@ def add_solenoid(
xp: float = 0.0,
y: float = 0.0,
yp: float = 0.0,
frequency: float = 0.0,
phase: float = 0.0,
) -> None:
"""
Creates a solenoid lenses in the accelerator.
Expand All @@ -351,15 +294,8 @@ def add_solenoid(
Offset of the element along the y-axis
yp: float, optional
Element rotation in the z-y plane
frequency: float, optional
Frequency of the element, [Hz]
phase: float, optional
Phase of the element, [rad]
"""
self.Bz_beamline[name] = Element(
center, max_field, file_name, name, x=x, xp=xp, y=y, yp=yp, frequency=frequency, phase=phase
)
self.Bz_beamline[name] = Element(center, max_field, file_name, name, x=x, xp=xp, y=y, yp=yp)

def add_accel(
self,
Expand All @@ -372,8 +308,6 @@ def add_accel(
xp: float = 0.0,
y: float = 0.0,
yp: float = 0.0,
frequency: float = 0.0,
phase: float = 0.0,
) -> None:
"""
Creates an accelerating module in the accelerator.
Expand All @@ -397,15 +331,8 @@ def add_accel(
Offset of the element along the y-axis
yp: float, optional
Element rotation in the z-y plane
frequency: float, optional
Frequency of the element, [Hz]
phase: float, optional
Phase of the element, [rad]
"""
self.Ez_beamline[name] = Element(
center, max_field, file_name, name, x=x, xp=xp, y=y, yp=yp, frequency=frequency, phase=phase
)
self.Ez_beamline[name] = Element(center, max_field, file_name, name, x=x, xp=xp, y=y, yp=yp)

def add_quadrupole(self, name: str, center: float, max_field: float, file_name: str) -> None:
"""
Expand Down Expand Up @@ -586,9 +513,6 @@ def compile(self) -> None:
self.z, Dyp_Bz(self.z) + Dyp_Ez(self.z), kind="linear", fill_value=(0, 0), bounds_error=False
)

self.B_freq, self.B_phase = read_frequency_and_phase(self.Bz_beamline, self.parameter)
self.E_freq, self.E_phase = read_frequency_and_phase(self.Ez_beamline, self.parameter)

def __str__(self):
string = "Accelerator structure.\n"
string += "\tSolenoids:\n"
Expand Down
2 changes: 1 addition & 1 deletion redpic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

NAME = "redpic"

VERSION = "0.11.0"
VERSION = "0.11.1"

AUTHOR = "Vyacheslav Fedorov"

Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
packages=find_packages(),
install_requires=required,
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down

0 comments on commit 1e2e77a

Please sign in to comment.