Skip to content

Commit ac995bd

Browse files
committed
Adapt example
1 parent 1d09916 commit ac995bd

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

examples/multiline_matching/001_match_lumi_with_target.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
'on_sep8h': collider.vars['on_sep8h']._value,
6161
'on_sep8v': collider.vars['on_sep8v']._value,
6262
}
63-
64-
res = collider.match(
63+
tw0 = collider.twiss(lines=['lhcb1', 'lhcb2'])
64+
opt = collider.match(
6565
solver_options={'n_bisections': 3, 'min_step': 1e-5, 'n_steps_max': 200},
6666
ele_start=['e.ds.l8.b1', 's.ds.r8.b2'],
6767
ele_stop=['s.ds.r8.b1', 'e.ds.l8.b2'],
68-
twiss_init='preserve',
68+
twiss_init=tw0, ele_init=xt.START,
6969
lines=['lhcb1', 'lhcb2'],
7070
vary=[
7171
# Knobs to control the separation
@@ -95,12 +95,13 @@
9595
collider.vars['on_sep8v'] = knob_values_before_ideal_matching['on_sep8v']
9696

9797
# Leveling with crossing angle and bump rematching
98+
tw0 = collider.twiss(lines=['lhcb1', 'lhcb2'])
9899
collider.match(
99100
solver_options={'n_bisections': 3, 'min_step': 0, 'n_steps_max': 200},
100101
lines=['lhcb1', 'lhcb2'],
101102
ele_start=['e.ds.l8.b1', 's.ds.r8.b2'],
102103
ele_stop=['s.ds.r8.b1', 'e.ds.l8.b2'],
103-
twiss_init='preserve',
104+
twiss_init=tw0, ele_init=xt.START,
104105
targets=[
105106
# Luminosity
106107
xt.TargetLuminosity(
@@ -111,13 +112,13 @@
111112
# Separation plane inclination
112113
xt.TargetSeparationOrthogonalToCrossing(ip_name='ip8'),
113114
# Preserve crossing angle
114-
xt.TargetList(['px', 'py'], at='ip8', line='lhcb1', value='preserve', tol=1e-7, scale=1e3),
115-
xt.TargetList(['px', 'py'], at='ip8', line='lhcb2', value='preserve', tol=1e-7, scale=1e3),
115+
xt.TargetList(['px', 'py'], at='ip8', line='lhcb1', value=tw0, tol=1e-7, scale=1e3),
116+
xt.TargetList(['px', 'py'], at='ip8', line='lhcb2', value=tw0, tol=1e-7, scale=1e3),
116117
# Close the bumps
117-
xt.TargetList(['x', 'y'], at='s.ds.r8.b1', line='lhcb1', value='preserve', tol=1e-5, scale=1),
118-
xt.TargetList(['px', 'py'], at='s.ds.r8.b1', line='lhcb1', value='preserve', tol=1e-5, scale=1e3),
119-
xt.TargetList(['x', 'y'], at='e.ds.l8.b2', line='lhcb2', value='preserve', tol=1e-5, scale=1),
120-
xt.TargetList(['px', 'py'], at='e.ds.l8.b2', line='lhcb2', value='preserve', tol=1e-5, scale=1e3),
118+
xt.TargetList(['x', 'y'], at='s.ds.r8.b1', line='lhcb1', value=tw0, tol=1e-5, scale=1),
119+
xt.TargetList(['px', 'py'], at='s.ds.r8.b1', line='lhcb1', value=tw0, tol=1e-5, scale=1e3),
120+
xt.TargetList(['x', 'y'], at='e.ds.l8.b2', line='lhcb2', value=tw0, tol=1e-5, scale=1),
121+
xt.TargetList(['px', 'py'], at='e.ds.l8.b2', line='lhcb2', value=tw0, tol=1e-5, scale=1e3),
121122
],
122123
vary=[
123124
xt.VaryList(['on_sep8h', 'on_sep8v'], step=1e-4), # to control separation
@@ -213,22 +214,23 @@
213214

214215
# Match separation to 2 sigmas in IP2
215216
print(f'Knobs before matching: on_sep2 = {collider.vars["on_sep2"]._value}')
217+
tw0 = collider.twiss(lines=['lhcb1', 'lhcb2'])
216218
collider.match(
217219
lines=['lhcb1', 'lhcb2'],
218220
ele_start=['e.ds.l2.b1', 's.ds.r2.b2'],
219221
ele_stop=['s.ds.r2.b1', 'e.ds.l2.b2'],
220-
twiss_init='preserve',
222+
twiss_init=tw0, ele_init=xt.START,
221223
targets=[
222224
xt.TargetSeparation(ip_name='ip2', separation_norm=3, plane='x', tol=1e-4,
223225
nemitt_x=nemitt_x, nemitt_y=nemitt_y),
224226
# Preserve crossing angle
225-
xt.TargetList(['px', 'py'], at='ip2', line='lhcb1', value='preserve', tol=1e-7, scale=1e3),
226-
xt.TargetList(['px', 'py'], at='ip2', line='lhcb2', value='preserve', tol=1e-7, scale=1e3),
227+
xt.TargetList(['px', 'py'], at='ip2', line='lhcb1', value=tw0, tol=1e-7, scale=1e3),
228+
xt.TargetList(['px', 'py'], at='ip2', line='lhcb2', value=tw0, tol=1e-7, scale=1e3),
227229
# Close the bumps
228-
xt.TargetList(['x', 'y'], at='s.ds.r2.b1', line='lhcb1', value='preserve', tol=1e-5, scale=1),
229-
xt.TargetList(['px', 'py'], at='s.ds.r2.b1', line='lhcb1', value='preserve', tol=1e-5, scale=1e3),
230-
xt.TargetList(['x', 'y'], at='e.ds.l2.b2', line='lhcb2', value='preserve', tol=1e-5, scale=1),
231-
xt.TargetList(['px', 'py'], at='e.ds.l2.b2', line='lhcb2', value='preserve', tol=1e-5, scale=1e3),
230+
xt.TargetList(['x', 'y'], at='s.ds.r2.b1', line='lhcb1', value=tw0, tol=1e-5, scale=1),
231+
xt.TargetList(['px', 'py'], at='s.ds.r2.b1', line='lhcb1', value=tw0, tol=1e-5, scale=1e3),
232+
xt.TargetList(['x', 'y'], at='e.ds.l2.b2', line='lhcb2', value=tw0, tol=1e-5, scale=1),
233+
xt.TargetList(['px', 'py'], at='e.ds.l2.b2', line='lhcb2', value=tw0, tol=1e-5, scale=1e3),
232234
],
233235
vary=
234236
[xt.Vary('on_sep2', step=1e-4),

0 commit comments

Comments
 (0)