lnls-fac / pyaccel

Python module for beam dynamics tracking and optics calculations
MIT License
7 stars 5 forks source link

Add Rhombus (delta22) and Ellipse (BC) shaped vchamber #108

Closed xresende closed 2 years ago

xresende commented 2 years ago

New vacuum chamber shapes were implemented in trackcpp, namely, rhombus and ellipse shapes (See PR https://github.com/lnls-fac/trackcpp/pull/50). Delta vacuum chambers are special cases of rhombus shapes and BC vacuum chamber, circular shape, is a special case of ellipse. Any positive integer number for vchamber can be used. This number correponds a the p-norm that define the shape of the chamber(1 - rhombus, 2 - ellipse, ... 0 - rectangle). This PR adapts pyaccel for these new shapes and for particle tracking losses simultaneously in the xy planes.

Example:


#!/usr/bin/env python-sirius

from pyaccel.elements import VChamberShape
from pymodels import si
from pyaccel import tracking

thering = si.create_accelerator()
thering.vchamber_on = True

# --- vchamber h and v limits
thering[0].hmax = +0.010
thering[0].hmin = -0.010
thering[0].vmax = +0.010
thering[0].vmin = -0.010

# --- tracking parameters

deltar = 0.001  # only rectangle passes
# deltar = 0.002  # rectangle, 4-norm pass
# deltar = 0.003  # rectangle, p-norm (p>1) and ellipse pass
# deltar = 0.009  # all pass

rx0, ry0 = +0.010 - deltar, +0.010 - deltar
px0, py0 = 0, 0
elems = [0,1,2]  # only first ring elements

print('rectangle shaped vchamber - elem & traj')
thering[0].vchamber = VChamberShape.rectangle
print(thering[0])
traj, *_ = tracking.line_pass(thering, [rx0,px0,ry0,py0,0,0], elems)
print(traj)
print()

print('4-norm shaped vchamber - elem & traj')
thering[0].vchamber = 4
print(thering[0])
traj, *_ = tracking.line_pass(thering, [rx0,px0,ry0,py0,0,0], elems)
print(traj)
print()

print('4-norm shaped shaped vchamber - elem & traj')
thering[0].vchamber = VChamberShape.ellipse
print(thering[0])
traj, *_ = tracking.line_pass(thering, [rx0,px0,ry0,py0,0,0], elems)
print(traj)
print()

print('rhombus (delta) shaped vchamber - elem & traj')
thering[0].vchamber = VChamberShape.rhombus
print(thering[0])
traj, *_ = tracking.line_pass(thering, [rx0,px0,ry0,py0,0,0], elems)
print(traj)
print()