skip to navigation
skip to content

Not Logged In

cern-cpymad 0.9

Cython binding to MAD-X

There are currently no active developers working on this project. At the moment the code is still working fine against the current stable and development version of Mad-X, so it should still be useful. Below you find a list of alternative projects which may have a more complete feature set and documentation.

Known Forks and Similar Projects:

CPyMAD

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.

Important: cern-cpymad links against an unofficial build of MAD-X that is not supported by CERN, i.e. in case of problems you will not get help there.

Dependencies

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.

Installation

Installation instructions are available at http://pymad.github.io/cpymad/installation.

Usage

from cern import cpymad

# Instanciate a model:
m = cpymad.load_model('lhc')

# Calculate TWISS parameters:
twiss, summary = m.twiss()

# Your own analysis below:
from matplotlib import pyplot as plt
plt.plot(twiss['s'], twiss['betx'])
plt.show()

See http://pymad.github.io/cpymad for further documentation.

Development guidelines

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 the testing 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:

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.

License

cern-cpymad must be used in compliance with the licenses as described in the following sections:

License for cern-cpymad source

applies to the python source of the cern-cpymad package:

Copyright (c) 2011, CERN. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use cern-cpymad except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

License for MAD-X

applies to binary distributions that do not require a separate installation of MAD-X, i.e. binaries that are statically linked to MAD-X:

CERN

EUROPEAN ORGANISATION FOR NUCLEAR RESEARCH


Program name:                 MAD --- Methodical Accelerator Design

CERN program library entry:   T5001

Authors or contacts:          mad@cern.ch
                              BE-ABP Group
                              CERN
                              CH-1211 GENEVA 23
                              SWITZERLAND


Copyright CERN, Geneva 1990 - Copyright and any other appropriate legal
protection of this computer program and associated documentation reserved
in all countries of the world. Organisations collaborating with CERN may
receive this program and documentation freely and without charge. CERN
undertakes no obligation for the maintenance of this program, nor
responsibility for its correctness, and accepts no liability whatsoever
resulting from its use. Program and documentation are provided solely for
the use of the organisation to which they are distributed. This program
may not be copied or otherwise distributed without permission. This
message must be retained on this and any other authorised copies. The
material cannot be sold. CERN should be given credit in all references.

Additional SDDS License

applies to binary distributions that include the online model:

Copyright (c) 2002 University of Chicago. All rights reserved.

SDDS ToolKit is distributed subject to the following license conditions:

 SOFTWARE LICENSE AGREEMENT
 Software: SDDS ToolKit

 1. The "Software", below, refers to SDDS ToolKit (in either source code,
    or binary form and accompanying documentation). Each licensee is
    addressed as "you" or "Licensee."

 2. The copyright holders shown above and their third-party licensors
    hereby grant Licensee a royalty-free nonexclusive license, subject to
    the limitations stated herein and U.S. Government license rights.

 3. You may modify and make a copy or copies of the Software for use
    within your organization, if you meet the following conditions:
      a. Copies in source code must include the copyright notice and this
         Software License Agreement.
      b. Copies in binary form must include the copyright notice and this
         Software License Agreement in the documentation and/or other
         materials provided with the copy.

 4. You may modify a copy or copies of the Software or any portion of it,
    thus forming a work based on the Software, and distribute copies of
    such work outside your organization, if you meet all of the following
    conditions:
      a. Copies in source code must include the copyright notice and this
         Software License Agreement;
      b. Copies in binary form must include the copyright notice and this
         Software License Agreement in the documentation and/or other
         materials provided with the copy;
      c. Modified copies and works based on the Software must carry
         prominent notices stating that you changed specified portions of
         the Software.

 5. Portions of the Software resulted from work developed under a U.S.
    Government contract and are subject to the following license: the
    Government is granted for itself and others acting on its behalf a
    paid-up, nonexclusive, irrevocable worldwide license in this computer
    software to reproduce, prepare derivative works, and perform publicly
    and display publicly.

 6. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT
    WARRANTY OF ANY KIND. THE COPYRIGHT HOLDERS, THEIR THIRD PARTY
    LICENSORS, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
    ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED
    WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
    TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
    OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS
    OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE
    WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT
    THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS
    ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED.

 7. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDERS,
    THEIR THIRD PARTY LICENSORS, THE UNITED STATES, THE UNITED
    STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR
    ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE
    DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS
    OF PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
    SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
    (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, EVEN
    IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF
    SUCH LOSS OR DAMAGES.

Changelog

0.9

Date: 17.11.2014

  • don’t link against numpy anymore (this makes distribution of prebuilt binaries on windows actually useful)
  • add MAD-X license notice (required to distribute binaries)
  • setup.py doesn’t require setuptools to be pre-installed anymore (if internet is available)
  • some doc-fixes
  • convert cpymad._couch to a simple module (was a single file package)
  • use logging through-out the project
  • alow logger to be specified as model/madx constructor argument
  • multi-column access, e.g.: table.columns['betx','bety']
  • move tests one folder level up

0.8

Date: 30.06.2014

  • isolate cpymad: remove jpymad backend, remove pymad base
  • bootstrap the dependency on numpy
  • remove custom MAD-X path discovery during setup. You should use –madxdir if the library is not installed in a system location.
  • add function libmadx.is_expanded
  • add function libmadx.chdir
  • handle MAD-X table columns with integer arrays
  • make madx.command more powerful (allows **kwargs and attribute access)
  • use inherited pipes for IPC with remote MAD-X processes (allows to forward stdin/stdout separately)
  • close connection to remote process on finalization of LibMadxClient
  • remove MAD-X command checks, recursive_history and filename completion
  • fix name clash
  • fix some bugs
  • rename convenience constructors to cern.cpymad.load_model and cern.cpymad.start_madx due to name clash with module names

0.7

Date: 16.04.2014

  • close handles in remote process properly on all supported python versions
  • rewrite libmadx.get_table functionality
  • madx functions that return tables now return proxy objects instead. For backward compatibility these can be iterated to allow unpacking into a tuple
  • the returned table columns is now a proxy object as well and not TfsTable
  • remove retdict parameter
  • move some cpymad specific functionality into the cpymad package
  • add libmadx/madx functions to access list of elements in a sequence

0.6

Date: 17.03.2014

  • raise exception and don’t hang up anymore, if libmadx process crashes
  • on python>=3.4, close handles in remote process properly
  • let every ‘Madx’ instance have an independent copy of the madx library. this makes the madx module much more useful. previously, this was only true for instances of ‘cpymad.model’.
  • restrict to only one cython module that links to libmadx. (allows static linking which is advantageous on windows!)
  • use YAML model files instead of JSON
  • make ‘madx’ a submodule of ‘cpymad’
  • fix test exit status

0.5

Date: 21.01.2014

  • migrate to setuptools from distutils
  • python3 support
  • add continuous integration with Travis
  • proper setup.py and MANIFEST.in to be used with PyPI
  • rename package to ‘cern-pymad’
  • allow to build from PyPI without having cython
 
File Type Py Version Uploaded on Size
cern-cpymad-0.9.tar.gz (md5) Source 2014-11-17 1MB
cern_cpymad-0.9-cp27-none-win32.whl (md5) Python Wheel cp27 2014-11-17 4MB
cern_cpymad-0.9-py2.7-win32.egg (md5) Python Egg 2.7 2014-11-17 4MB
  • Downloads (All Versions):
  • 6 downloads in the last day
  • 83 downloads in the last week
  • 315 downloads in the last month