Note
Go to the end to download the full example code.
LHC Crossing Schemes
This example shows how to use the plot_two_lhc_ips_crossings
function to visualise the crossing schemes setup at the LHC IRs.
Note
This is very LHC-specific and will not work with other machines.
import matplotlib.pyplot as plt
from cpymad.madx import Madx
from pyhdtoolkit.cpymadtools import lhc
from pyhdtoolkit.plotting.crossing import plot_two_lhc_ips_crossings
from pyhdtoolkit.plotting.styles import _SPHINX_GALLERY_PARAMS
from pyhdtoolkit.utils import logging
logging.config_logger(level="error")
plt.rcParams.update(_SPHINX_GALLERY_PARAMS) # for readability of this tutorial
Setup a simple LHC simulation in MAD-X
, with collision optics (at 6.8 TeV):
madx = Madx(stdout=False)
madx.option(echo=False, warn=False)
madx.call("lhc/lhc_as-built.seq")
madx.call("lhc/opticsfile.22") # collisions optics
Let’s explicitely re-cycle both sequences to avoid having IR1 split at beginning and end of lattice. Note that it is important to re-cycle both sequences from the same points for the plots later on. Created beams use a normalized emittance of 3.75E-6 m rad as corresponds to the Run 2 config of this opticsfile.
lhc.re_cycle_sequence(madx, sequence="lhcb1", start="IP3")
lhc.re_cycle_sequence(madx, sequence="lhcb2", start="IP3")
lhc.make_lhc_beams(
madx, nemitt_x=3.75e-6, nemitt_y=3.75e-6, energy=6800
) # necessary after re-cycling
madx.command.use(sequence="lhcb1")
Now we plot the crossing schemes, here for IP1 and IP5.
fig1 = plt.figure(figsize=(18, 11))
plot_two_lhc_ips_crossings(madx, first_ip=1, second_ip=5)
fig1.align_ylabels([fig1.axes[0], fig1.axes[1]])
plt.show()
We can have a look at, say, IP2 and IP8 by simply changing the parameters, and for instance also remove the highlighting of MQX and MBX elements:
fig2 = plt.figure(figsize=(18, 11))
plot_two_lhc_ips_crossings(madx, first_ip=2, second_ip=8, highlight_mqx_and_mbx=False)
fig2.align_ylabels([fig2.axes[0], fig2.axes[1]])
plt.show()
Let’s not forget to close the rpc connection to MAD-X
:
References
The use of the following functions, methods, classes and modules is shown in this example:
lhc
:make_lhc_beams
,re_cycle_sequence
crossing
:plot_two_lhc_ips_crossings
Total running time of the script: (0 minutes 8.820 seconds)