Skip to content
Snippets Groups Projects
Commit c4e06696 authored by Gamelin Alexis's avatar Gamelin Alexis
Browse files

Minor changes

Change back invariant name to cs_invariant
Simplify SkewQuadrupole track method
parent 3e817be0
Branches
Tags
No related merge requests found
...@@ -203,8 +203,8 @@ class TransverseMap(Element): ...@@ -203,8 +203,8 @@ class TransverseMap(Element):
class SkewQuadrupole: class SkewQuadrupole:
""" """
Skew quadrupole element used to introduce betatron coupling. The length of Thin skew quadrupole element used to introduce betatron coupling (the
the quadrupole is neglected. length of the quadrupole is neglected).
Parameters Parameters
---------- ----------
...@@ -226,16 +226,7 @@ class SkewQuadrupole: ...@@ -226,16 +226,7 @@ class SkewQuadrupole:
---------- ----------
bunch : Bunch or Beam object bunch : Bunch or Beam object
""" """
matrix = np.zeros((4,4,len(bunch)))
matrix[0,0,:] = 1
matrix[1,1,:] = 1
matrix[2,2,:] = 1
matrix[3,3,:] = 1
matrix[1,2,:] = -1*self.strength
matrix[3,0,:] = -1*self.strength
xp = bunch['xp'] + matrix[1,2,:]*bunch['y'] bunch['xp'] = bunch['xp'] - self.strength * bunch['y']
yp = bunch['yp'] + matrix[3,0,:]*bunch['x'] bunch['yp'] = bunch['yp'] - self.strength * bunch['x']
bunch['xp'] = xp
bunch['yp'] = yp
...@@ -16,7 +16,7 @@ from mbtrack2.tracking.element import Element ...@@ -16,7 +16,7 @@ from mbtrack2.tracking.element import Element
from mbtrack2.tracking.particles import Bunch, Beam from mbtrack2.tracking.particles import Bunch, Beam
from scipy.interpolate import interp1d from scipy.interpolate import interp1d
from abc import ABCMeta from abc import ABCMeta
#from mpi4py import MPI from mpi4py import MPI
class Monitor(Element, metaclass=ABCMeta): class Monitor(Element, metaclass=ABCMeta):
""" """
...@@ -269,10 +269,10 @@ class BunchMonitor(Monitor): ...@@ -269,10 +269,10 @@ class BunchMonitor(Monitor):
group_name = "BunchData_" + str(self.bunch_number) group_name = "BunchData_" + str(self.bunch_number)
dict_buffer = {"mean":(6, buffer_size), "std":(6, buffer_size), dict_buffer = {"mean":(6, buffer_size), "std":(6, buffer_size),
"emit":(3, buffer_size), "current":(buffer_size,), "emit":(3, buffer_size), "current":(buffer_size,),
"action":(2, buffer_size)} "cs_invariant":(2, buffer_size)}
dict_file = {"mean":(6, total_size), "std":(6, total_size), dict_file = {"mean":(6, total_size), "std":(6, total_size),
"emit":(3, total_size), "current":(total_size,), "emit":(3, total_size), "current":(total_size,),
"action":(2, total_size)} "cs_invariant":(2, total_size)}
self.monitor_init(group_name, save_every, buffer_size, total_size, self.monitor_init(group_name, save_every, buffer_size, total_size,
dict_buffer, dict_file, file_name, mpi_mode) dict_buffer, dict_file, file_name, mpi_mode)
......
...@@ -123,7 +123,7 @@ def plot_bunchdata(filename, bunch_number, dataset, dimension="x", x_var="time") ...@@ -123,7 +123,7 @@ def plot_bunchdata(filename, bunch_number, dataset, dimension="x", x_var="time")
bunch_number : int bunch_number : int
Bunch to plot. This has to be identical to 'bunch_number' parameter in Bunch to plot. This has to be identical to 'bunch_number' parameter in
'BunchMonitor' object. 'BunchMonitor' object.
dataset : {"current", "emit", "mean", "std", "action"} dataset : {"current", "emit", "mean", "std", "cs_invariant"}
HDF5 file's dataset to be plotted. HDF5 file's dataset to be plotted.
dimension : str, optional dimension : str, optional
The dimension of the dataset to plot. Use "None" for "current", The dimension of the dataset to plot. Use "None" for "current",
...@@ -175,7 +175,7 @@ def plot_bunchdata(filename, bunch_number, dataset, dimension="x", x_var="time") ...@@ -175,7 +175,7 @@ def plot_bunchdata(filename, bunch_number, dataset, dimension="x", x_var="time")
label = label_list[axis_index] label = label_list[axis_index]
elif dataset == "action": elif dataset == "cs_invariant":
dimension_dict = {"x":0, "y":1} dimension_dict = {"x":0, "y":1}
axis_index = dimension_dict[dimension] axis_index = dimension_dict[dimension]
y_var = file[group][dataset][axis_index] y_var = file[group][dataset][axis_index]
......
...@@ -232,9 +232,9 @@ class Bunch: ...@@ -232,9 +232,9 @@ class Bunch:
return np.array([emitX, emitY, emitS]) return np.array([emitX, emitY, emitS])
@property @property
def action(self): def cs_invariant(self):
""" """
Return the average action (Couran-Snyder invariant) of each plane. Return the average Courant-Snyder invariant of each plane.
""" """
Jx = (self.ring.optics.local_gamma[0] * self['x']**2) + \ Jx = (self.ring.optics.local_gamma[0] * self['x']**2) + \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment