Skip to content

Commit 72c67fc

Browse files
Merge remote-tracking branch 'fsoubelet/fix_ibs_examples' into release/0.25.13
2 parents 3221b42 + 0451a08 commit 72c67fc

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

examples/005_ibs/003_tracking_with_kicks.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
# This file is part of the Xfields Package. #
33
# Copyright (c) CERN, 2021. #
44
# ########################################### #
5-
import xfields as xf
65
import xobjects as xo
76
import xpart as xp
87
import xtrack as xt
98

9+
import xfields as xf
10+
1011
context = xo.ContextCpu(omp_num_threads="auto")
1112

1213
##########################
@@ -35,7 +36,7 @@
3536
# the kick at the end of the line and configure it. This internally
3637
# provides the necessary information to the element
3738
line.configure_intrabeam_scattering(
38-
element=ibs_kick, name="ibskick", index=-1, update_every=50
39+
element=ibs_kick, name="ibskick", at=line.get_length(), update_every=50
3940
)
4041

4142
############################################

examples/005_ibs/004_tracking_with_kicks_tbt_emittances.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# This file is part of the Xfields Package. #
33
# Copyright (c) CERN, 2021. #
44
# ########################################### #
5-
import xfields as xf
6-
import xobjects as xo
5+
import matplotlib.pyplot as plt
6+
import numpy as np
77
import xpart as xp
88
import xtrack as xt
9-
from xfields.ibs._formulary import _gemitt_x, _gemitt_y, _sigma_delta, _bunch_length
10-
import numpy as np
11-
import matplotlib.pyplot as plt
9+
10+
import xfields as xf
11+
from xfields.ibs._formulary import _bunch_length, _gemitt_x, _gemitt_y, _sigma_delta
1212

1313
##########################
1414
# Load xt.Line from file #
@@ -27,7 +27,7 @@
2727
# ibs_kick = xf.IBSKineticKick(num_slices=50)
2828
ibs_kick = xf.IBSAnalyticalKick(formalism="nagaitsev", num_slices=50)
2929
line.configure_intrabeam_scattering(
30-
element=ibs_kick, name="ibskick", index=-1, update_every=50
30+
element=ibs_kick, name="ibskick", at=line.get_length(), update_every=50
3131
)
3232

3333
################################
@@ -47,7 +47,7 @@
4747
)
4848

4949
for turn in range(nturns):
50-
print(f"Tracking turn {turn+1}/{nturns} ", end="\r", flush=True)
50+
print(f"Tracking turn {turn+1}/{nturns} ", end="\r", flush=True)
5151
line.track(particles, num_turns=1)
5252
epsx.append(_gemitt_x(particles, tw.betx[0], tw.dx[0]))
5353
epsy.append(_gemitt_y(particles, tw.bety[0], tw.dy[0]))

tests/test_ibs_kicks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from cpymad.madx import Madx
55
from ibs_conftest import XTRACK_TEST_DATA, get_ref_particle_from_madx_beam
66
from numpy.testing import assert_allclose
7-
from xobjects.test_helpers import for_all_test_contexts, fix_random_seed
7+
from xobjects.test_helpers import fix_random_seed, for_all_test_contexts
88

99
from xfields.ibs import IBSAnalyticalKick, IBSKineticKick
1010
from xfields.ibs._formulary import _bunch_length, _gemitt_x, _gemitt_y, _sigma_delta
@@ -236,7 +236,7 @@ def test_track_analytical_kick(test_context):
236236
cavities = [element for element in line.elements if isinstance(element, xt.Cavity)]
237237
for cavity in cavities:
238238
cavity.lag = 180
239-
line.configure_intrabeam_scattering(element=ibskick, name="ibskick", at=0, update_every=100)
239+
line.configure_intrabeam_scattering(element=ibskick, name="ibskick", at=line.get_length(), update_every=100)
240240
tw = line.twiss(method="4d")
241241
particles = xp.generate_matched_gaussian_bunch(
242242
num_particles=2000,
@@ -286,7 +286,7 @@ def test_track_kinetic_kick(test_context):
286286
cavities = [element for element in line.elements if isinstance(element, xt.Cavity)]
287287
for cavity in cavities:
288288
cavity.lag = 180
289-
line.configure_intrabeam_scattering(element=ibskick, name="ibskick", at=0, update_every=100)
289+
line.configure_intrabeam_scattering(element=ibskick, name="ibskick", at=line.get_length(), update_every=100)
290290
tw = line.twiss(method="4d")
291291
particles = xp.generate_matched_gaussian_bunch(
292292
num_particles=2000,

xfields/ibs/_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ def configure_intrabeam_scattering(
140140
element : IBSKick, optional
141141
If provided, the element is first inserted in the line,
142142
before proceeding to configuration. In this case the keyword
143-
arguments are passed on to the `line.insert_element` method.
144-
This will also discard and rebuild the line tracker.
143+
arguments are passed on to the `line.insert` method. This will
144+
also discard and rebuild the line tracker.
145145
update_every : int
146146
The frequency at which to recompute the kick coefficients, in
147147
number of turns. They will be computed at the first turn of
148148
tracking, and then every `update_every` turns afterwards.
149149
150150
**kwargs : dict, optional
151151
Required if an element is provided. Keyword arguments are
152-
passed to the `line.insert_element()` method according to
153-
`line.insert_element(element=element, **kwargs)`.
152+
passed to the `line.insert()` method according to
153+
`line.insert(obj=element, what=name, **kwargs)`.
154154
155155
Raises
156156
------

0 commit comments

Comments
 (0)