Skip to content

Commit b4b6d2a

Browse files
authored
Merge pull request #62 from lhcopt/feature/remove_python_particle
Adaptation to xsuite v0.2.0
2 parents 99cb2b0 + 79362c0 commit b4b6d2a

18 files changed

+357
-704
lines changed

pymask/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
from .lumi import *
88
from .coupling import *
99
from .tunechroma import *
10+
11+
from pathlib import Path
12+
_pkg_root = Path(__file__).parent.absolute()
13+
del(Path)

pymask/beambeam.py

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -614,57 +614,67 @@ def find_bb_separations(points_weak, points_strong, names=None):
614614

615615
return sep_x, sep_y
616616

617-
618-
619-
620-
621-
622-
623-
624-
625617
def setup_beam_beam_in_line(
626618
line,
627619
bb_df,
628620
bb_coupling=False,
629621
):
630-
import xline
622+
import xfields as xf
631623
assert bb_coupling is False # Not implemented
632624

633-
for ee, eename in zip(line.elements, line.element_names):
634-
if isinstance(ee, xline.elements.BeamBeam4D):
635-
ee.charge = (bb_df.loc[eename, 'other_num_particles']
636-
* bb_df.loc[eename, 'other_particle_charge']) # TODO update xline interface to separate charge and b. population
625+
for ii, (ee, eename) in enumerate(zip(line.elements, line.element_names)):
626+
if isinstance(ee, xf.BeamBeamBiGaussian2D):
627+
ee.n_particles=bb_df.loc[eename, 'other_num_particles']
628+
ee.q0 = bb_df.loc[eename, 'other_particle_charge']
637629
ee.sigma_x = np.sqrt(bb_df.loc[eename, 'other_Sigma_11'])
638630
ee.sigma_y = np.sqrt(bb_df.loc[eename, 'other_Sigma_33'])
639-
ee.beta_r = bb_df.loc[eename, 'other_relativistic_beta']
640-
ee.x_bb = bb_df.loc[eename, 'separation_x']
641-
ee.y_bb = bb_df.loc[eename, 'separation_y']
642-
643-
if isinstance(ee, xline.elements.BeamBeam6D):
644-
645-
ee.phi = bb_df.loc[eename, 'phi']
646-
ee.alpha = bb_df.loc[eename, 'alpha']
647-
ee.x_bb_co = bb_df.loc[eename, 'separation_x']
648-
ee.y_bb_co = bb_df.loc[eename, 'separation_y']
649-
ee.charge_slices = [(bb_df.loc[eename, 'other_num_particles']
650-
* bb_df.loc[eename, 'other_particle_charge'])] # TODO update xline interface to separate charge and b. population
651-
ee.zeta_slices = [0.0]
652-
ee.sigma_11 = bb_df.loc[eename, 'other_Sigma_11']
653-
ee.sigma_12 = bb_df.loc[eename, 'other_Sigma_12']
654-
ee.sigma_13 = bb_df.loc[eename, 'other_Sigma_13']
655-
ee.sigma_14 = bb_df.loc[eename, 'other_Sigma_14']
656-
ee.sigma_22 = bb_df.loc[eename, 'other_Sigma_22']
657-
ee.sigma_23 = bb_df.loc[eename, 'other_Sigma_23']
658-
ee.sigma_24 = bb_df.loc[eename, 'other_Sigma_24']
659-
ee.sigma_33 = bb_df.loc[eename, 'other_Sigma_33']
660-
ee.sigma_34 = bb_df.loc[eename, 'other_Sigma_34']
661-
ee.sigma_44 = bb_df.loc[eename, 'other_Sigma_44']
631+
ee.beta0 = bb_df.loc[eename, 'other_relativistic_beta']
632+
ee.mean_x = bb_df.loc[eename, 'separation_x']
633+
ee.mean_y = bb_df.loc[eename, 'separation_y']
634+
if isinstance(ee, xf.BeamBeamBiGaussian3D):
635+
params = {}
636+
params['phi'] = bb_df.loc[eename, 'phi']
637+
params['alpha'] = bb_df.loc[eename, 'alpha']
638+
params['x_bb_co'] = bb_df.loc[eename, 'separation_x']
639+
params['y_bb_co'] = bb_df.loc[eename, 'separation_y']
640+
# TODO update xtrack interface to separate charge and b. population
641+
params['charge_slices'] = [(bb_df.loc[eename, 'other_num_particles']
642+
* bb_df.loc[eename, 'other_particle_charge'])]
643+
params['zeta_slices'] = [0.0]
644+
params['sigma_11'] = bb_df.loc[eename, 'other_Sigma_11']
645+
params['sigma_12'] = bb_df.loc[eename, 'other_Sigma_12']
646+
params['sigma_13'] = bb_df.loc[eename, 'other_Sigma_13']
647+
params['sigma_14'] = bb_df.loc[eename, 'other_Sigma_14']
648+
params['sigma_22'] = bb_df.loc[eename, 'other_Sigma_22']
649+
params['sigma_23'] = bb_df.loc[eename, 'other_Sigma_23']
650+
params['sigma_24'] = bb_df.loc[eename, 'other_Sigma_24']
651+
params['sigma_33'] = bb_df.loc[eename, 'other_Sigma_33']
652+
params['sigma_34'] = bb_df.loc[eename, 'other_Sigma_34']
653+
params['sigma_44'] = bb_df.loc[eename, 'other_Sigma_44']
662654

663655
if not (bb_coupling):
664-
ee.sigma_13 = 0.0
665-
ee.sigma_14 = 0.0
666-
ee.sigma_23 = 0.0
667-
ee.sigma_24 = 0.0
656+
params['sigma_13'] = 0.0
657+
params['sigma_14'] = 0.0
658+
params['sigma_23'] = 0.0
659+
params['sigma_24'] = 0.0
660+
661+
params["x_co"] = 0
662+
params["px_co"] = 0
663+
params["y_co"] = 0
664+
params["py_co"] = 0
665+
params["zeta_co"] = 0
666+
params["delta_co"] = 0
667+
params["d_x"] = 0
668+
params["d_px"] = 0
669+
params["d_y"] = 0
670+
params["d_py"] = 0
671+
params["d_zeta"] = 0
672+
params["d_delta"] = 0
673+
674+
newee = xf.BeamBeamBiGaussian3D(old_interface=params)
675+
line.elements[ii] = newee
676+
677+
668678

669679

670680
def crabbing_strong_beam(mad, bb_dfs, z_crab_twiss,
@@ -871,16 +881,15 @@ def find_bb_xma_yma(points_weak, points_strong, names=None):
871881

872882
# Find as the position of the strong in the lab frame (points_strong[i_bb].p)
873883
# the reference frame of the weak in the lab frame (points_weak[i_bb].sp)
874-
vbb_ws = points_strong[i_bb].p - points_weak[i_bb].sp
875-
884+
vbb_ws = points_strong[i_bb].p - points_weak[i_bb].sp
876885
# Find separations
877886
xma.append(np.dot(vbb_ws, pbw.ex))
878887
yma.append(np.dot(vbb_ws, pbw.ey))
879888

880889
return xma, yma
881890

882891
def compute_xma_yma(bb_df):
883-
892+
884893
xma, yma = find_bb_xma_yma(
885894
points_weak=bb_df['self_lab_position'].values,
886895
points_strong=bb_df['other_lab_position'].values,

pymask/linear_normal_form.py

Lines changed: 0 additions & 223 deletions
This file was deleted.

0 commit comments

Comments
 (0)