Skip to content

Commit

Permalink
Merge pull request #100 from xsuite/release/v0.5.2
Browse files Browse the repository at this point in the history
Release 0.5.2
  • Loading branch information
freddieknets authored Sep 26, 2024
2 parents ebfb1f5 + 752c25e commit a932828
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "xcoll"
version = "0.5.1"
version = "0.5.2"
description = "Xsuite collimation package"
homepage = "https://github.com/xsuite/xcoll"
repository = "https://github.com/xsuite/xcoll"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_install_single_existing_marker(beam, test_context):
assert np.isclose(pos_centre - line[name].length/2, line.get_s_position(name))
assert isinstance(line[name], xc.BlackAbsorber)
tab = line.get_table()
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
assert xt.line._is_aperture(line[idx-1], line)
assert xt.line._is_aperture(line[idx+1], line)

Expand All @@ -47,14 +47,14 @@ def test_install_single_existing_marker(beam, test_context):
tab = line.get_table()
existing_length = 0.12
line[name].length += existing_length
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
while True:
idx -= 1
if tab.element_type[idx].startswith('Drift'):
assert line[idx].length > existing_length/2
line[idx].length -= existing_length/2
break
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
while True:
idx += 1
if tab.element_type[idx].startswith('Drift'):
Expand All @@ -68,7 +68,7 @@ def test_install_single_existing_marker(beam, test_context):
assert np.isclose(pos_centre - line[name].length/2, line.get_s_position(name))
assert isinstance(line[name], xc.EverestCollimator)
tab = line.get_table()
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
assert xt.line._is_aperture(line[idx-1], line)
assert xt.line._is_aperture(line[idx+1], line)

Expand All @@ -84,7 +84,7 @@ def test_install_single_existing_marker(beam, test_context):
assert np.isclose(pos_centre - line[name].length/2, line.get_s_position(name))
assert isinstance(line[name], xc.EverestCrystal)
tab = line.get_table()
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
assert xt.line._is_aperture(line[idx-1], line)
assert xt.line._is_aperture(line[idx+1], line)

Expand Down Expand Up @@ -121,7 +121,7 @@ def test_install_single_no_marker(beam, test_context):
assert np.isclose(line.get_s_position(name), 12.4)
assert isinstance(line[name], xc.BlackAbsorber)
tab = line.get_table()
idx = tab.mask[[name]][0]
idx = tab.rows.indices[[name]][0]
assert xt.line._is_aperture(line[idx-1], line)
assert isinstance(line[idx-1], xt.LimitEllipse)
assert np.isclose(line[idx-1].a_squ, 0.16)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
from xcoll import __version__

def test_version():
assert __version__ == '0.5.1'
assert __version__ == '0.5.2'

2 changes: 1 addition & 1 deletion xcoll/beam_elements/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def assign_optics(self, *, nemitt_x=None, nemitt_y=None, beta_gamma_rel=None, na
raise ValueError("When using `twiss`, need to provide the name as well.")
else:
tw_up = twiss.rows[name]
tw_down = twiss.rows[twiss.mask[[name]]+1]
tw_down = twiss.rows[twiss.rows.indices[[name]]+1]
if not np.isclose(tw_up.s[0] + self.length, tw_down.s[0]):
raise ValueError(f"Downstream twiss not compatible with length {self.length}m.")
self._optics = {
Expand Down
2 changes: 1 addition & 1 deletion xcoll/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# ======================
# Do not change
# ======================
__version__ = '0.5.1'
__version__ = '0.5.2'
# ======================
10 changes: 5 additions & 5 deletions xcoll/initial_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def generate_pencil_on_collimator(line, name, num_particles, *, side='+-', penci
if is_converging:
# pencil at front of jaw
match_at_s = s_front
sigma = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{plane}'][0]
sigma_transv = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{transv_plane}'][0]
sigma = beam_sizes.rows[name:f'{name}>>1'][f'sigma_{plane}'][0]
sigma_transv = beam_sizes.rows[name:f'{name}>>1'][f'sigma_{transv_plane}'][0]
else:
# pencil at back of jaw
match_at_s = s_back
sigma = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{plane}'][1]
sigma_transv = beam_sizes.rows[name:f'{name}%%1'][f'sigma_{transv_plane}'][1]
sigma = beam_sizes.rows[name:f'{name}>>1'][f'sigma_{plane}'][1]
sigma_transv = beam_sizes.rows[name:f'{name}>>1'][f'sigma_{transv_plane}'][1]
dr_sigmas = pencil_spread/sigma

# Generate 4D coordinates
Expand Down Expand Up @@ -157,7 +157,7 @@ def generate_delta_from_dispersion(line, at_element, *, plane, position_mm, nemi
twiss = line.twiss()

beam_sizes = twiss.get_beam_covariance(nemitt_x=nemitt_x, nemitt_y=nemitt_y)
beam_sizes = beam_sizes.rows[at_element:f'{at_element}%%1'][f'sigma_{plane}']
beam_sizes = beam_sizes.rows[at_element:f'{at_element}>>1'][f'sigma_{plane}']
sigma = beam_sizes[0] if match_at_front else beam_sizes[1]
delta = (position_mm - betatron_cut*sigma - twiss.rows[at_element][plane])
delta /= twiss.rows[at_element][f'd{plane}']
Expand Down
6 changes: 3 additions & 3 deletions xcoll/line_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def get_optics_at(names, *, twiss=None, line=None):
twiss = line.twiss()
if not hasattr(names, '__iter__') and not isinstance(names, str):
names = [names]
coll_entry_mask = twiss.mask[names]
tw_entry = twiss.rows[coll_entry_mask]
tw_exit = twiss.rows[coll_entry_mask+1]
coll_entry_indices = twiss.rows.indices[names]
tw_entry = twiss.rows[coll_entry_indices]
tw_exit = twiss.rows[coll_entry_indices+1]
tw_exit.name = tw_entry.name
return tw_entry, tw_exit

Expand Down

0 comments on commit a932828

Please sign in to comment.