CPyMad is a Cython binding to MAD-X.
MAD-X is a software package to simulate particle accelerators and is used at CERN and all around the world. It has its own proprietary scripting language and is usually launched from the command line.
There is also a binding via JMad called JPyMAD. This has less features but does not require a C compiler for installing.
To build MAD-X and CPyMAD from source you will need
- CMake
- python>=2.6
- C / Fortran compilers.
Furthermore, CPyMAD depends on the following python packages:
The python packages can be installed using pip.
Further instructions are available at http://pymad.github.io/cpymad.
from cern import cpymad
# Instanciate a model:
m = cpymad.load_model('lhc')
# Calculate TWISS parameters:
twiss, summary = pm.twiss()
# Your own analysis below:
from matplotlib import pyplot as plt
plt.plot(twiss['s'], twiss['betx'])
See http://cern.ch/pymad/ for further documentation.
Coding:
Try to be consistent with the PEP8 guidelines as far as you are familiar with it. Add unit tests for all non-trivial functionality. Dependency injection is a great pattern to keep modules testable.
Version control:
Commits should be reversible, independent units if possible. Use descriptive titles and also add an explaining commit message unless the modification is trivial. See also: A Note About Git Commit Messages.
Tests:
Currently, two major test services are used:
- The tests on CDash are run on a daily basis on the
master
branch and on update of thetesting
branch. It ensures that the integration tests for the LHC models are working correctly on all tested platforms. The tests are run only on specific python versions. - The Travis CI service is mainly used to check that the unit tests for pymad itself execute on several python versions. Python{2.6,2.7,3.3} are supported. The tests are executed on any update of an upstream branch.
Contribution work flow:
This motivates the following work flow when performing any changes:
All changes are reviewed via pull-requests. Before merging to master the
pull-request must reside aliased by the testing
branch long enough to
be confirmed as stable. Any issues are discussed in the associated issue
thread. Concrete suggestions for changes are best posed as pull-requests
onto the feature branch.