Quickstart
Installation
This package is tested for and supports Python 3.8+
.
You can install it simply from PyPI
in a virtual environment with:
python -m pip install cpymadtools
Tip
Don’t know what a virtual environment is or how to set it up?
Here is a good primer on virtual environments by RealPython
.
To set up a development environment, see the contributing instructions.
5 Minutes to Cpymadtools
One can use the library by simply importing it:
import cpymadtools
This will include sub-packages of cpymadtools
.
The different sub-packages can be imported separately, depending on your needs:
import cpymadtools.constants
import cpymadtools.coupling
import cpymadtools.lhc
import cpymadtools.matching
import cpymadtools.ptc
import cpymadtools.track
import cpymadtools.tune
import cpymadtools.twiss
import cpymadtools.utils
These sub-packages provide an ensemble of functionality to perform operations with and from Madx
objects; and conveniently setup, run and analyze MAD-X
simulations and their results.
All the public apis in cpymadtools
work in the same fashion: call them with as first argument your
Madx
instance, and then any args
and kwargs
relevant to the functionality at hand.
Let’s say one has initiated their MAD-X
simulation through Madx
as follows:
from cpymad.madx import Madx
madx = Madx()
Then using the cpymadtools
apis goes as:
from cpymadtools.some_module import super_cool_function # pretend these exist ;)
super_cool_function(madx, *args, **kwargs)
In the cpymadtools
one will find modules to:
Encompass existing
MAD-X
commands, such as for example matching or tracking;Perform useful routines with a pythonic interface (for instance betatron coupling calculation and handling or table querying);
Run several (HL)LHC specific functionality.
One can find many examples of the cpymadtools
API’ use in the gallery of the pyhdtoolkit
documentation.