Skip to content

Commit

Permalink
use accmodels for free tracking example
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoubelet committed Jul 16, 2023
1 parent a93f832 commit faa2856
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions examples/demo_track_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
In this example we will use the LHC lattice to illustrate the tracking workflow when using
`~.cpymadtools`.
.. important::
This example requires the `acc-models-lhc` repository to be cloned locally. One
can get it by running the following command:
.. code-block:: bash
git clone -b 2022 https://gitlab.cern.ch/acc-models/acc-models-lhc.git --depth 1
Here I set the 2022 branch for stability and reproducibility of the documentation
builds, but you can use any branch you want.
"""
# sphinx_gallery_thumbnail_number = -1
import matplotlib.pyplot as plt
Expand All @@ -26,22 +37,13 @@
plt.rcParams.update(_SPHINX_GALLERY_PARAMS) # for readability of this tutorial

###############################################################################
# Let's start by setting up the LHC in ``MAD-X``, in this case at top energy:

madx = Madx(stdout=False)
madx.call("lhc/lhc_as-built.seq")
madx.call("lhc/opticsfile.22") # collision optics

lhc.make_lhc_beams(madx)
lhc.re_cycle_sequence(madx, sequence="lhcb1", start="MSIA.EXIT.B1") # as done in OMC

madx.command.use(sequence="lhcb1")

###############################################################################
# Slicing is necessary in ``MAD-X`` in order to perform tracking, so let's do so.
# Let's start by setting up the LHC in ``MAD-X``, in this case at collision
# optics and energy and with a sliced lattice. To understand the function below
# have a look at the :ref:`lhc setup example <demo-lhc-setup>`.

lhc.make_lhc_thin(madx, sequence="lhcb1", slicefactor=4)
madx.use(sequence="lhcb1")
madx = lhc.prepare_lhc_run3(
opticsfile="R2022a_A30cmC30cmA10mL200cm.madx", slicefactor=4, stdout=False
)

###############################################################################
# Now we can track a particle. By default, the "start of machine" as ``MAD-X`` sees it
Expand Down Expand Up @@ -105,7 +107,7 @@

###############################################################################
# .. tip::
# To get the tunes of the particle, one can find the peak of the spectra.
# To get the fractional tunes of the particle, one can find the peak of the spectra.
#
# .. code-block:: python
#
Expand All @@ -123,7 +125,7 @@
ylabel="Spectrum [a.u]",
figsize=(18, 10),
)

plt.show()

###############################################################################
# In case the user provided ``ONETABLE=True`` to the tracking function, then all
Expand Down

0 comments on commit faa2856

Please sign in to comment.