pymad / cpymad

cPyMAD is a python interface to Mad-X using cython and libmadx

Home Page:http://cern.ch/pymad

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use Usage?

Landau1908 opened this issue · comments

Hey, Thomas

I don't know how to use Usage to verify correct installation.

Usage content:

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'])

I copy the code recommended by the Usage and save as 2.py. According to some advices online, I run 2.py in command line, but an error occurs as follows:

E:\pymad\test>python 2.py

  ++++++++++++++++++++++++++++++++++++++++++++
  +     MAD-X 5.02.02  (32 bit, Windows)     +
  + Support: mad@cern.ch, http://cern.ch/mad +
  + Release   date: 2014.07.04               +
  + Execution date: 2014.08.10 10:17:38      +
  ++++++++++++++++++++++++++++++++++++++++++++
Traceback (most recent call last):
  File "2.py", line 11, in <module>
    twiss, summary = pm.twiss()
NameError: name 'pm' is not defined

  Number of warnings: 0

  ++++++++++++++++++++++++++++++++++++++++++++
  + MAD-X 5.02.02 (32 bit) finished normally +
  ++++++++++++++++++++++++++++++++++++++++++++

E:\pymad\test>

There is a rather obvious typo in the usage example: it should be m.twiss() instead of pm.twiss(), as is also indicated by the error.

Do you have programming background? If not, I am not sure, whether this module is a good place to start for you. Did you use plain MAD-X and found it insufficient for your needs?