We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, Thomas
How to do a match with small step, i.e.1e-6, in cpymad? When I run a small example in cpymad, an error occurs.
python script: filename:HITFIL.py
# -*- coding: utf-8 -*- """ Created on Tue Jun 23 07:42:22 2015 @author: Administrator """ from cpymad.madx import Madx import numpy as np import matplotlib.pylab as plt import scipy.interpolate as itp m = Madx(command_log='MATCH1.log') print (m.version) m.call('../MATCH1.madx') m.survey(sequence='FODO') m.match( constraints=[ dict(range='#e', MUX='0.16', MUY='0.25') ], vary=['QF->K1', 'QD->k1'] ) twiss = m.twiss(sequence='FODO', columns=['name','s','betx','bety']) twiss['s'][15] = 12.5 x = np.arange(0,twiss['s'][-1],0.1) #from scipy import interpolate #tck = interpolate.splrep(bx, by, s=0) #y = interpolate.splev(x, tck, der=0) #y1 = interpolate.interp1d(bx, by, kind='cubic') y = itp.spline(twiss['s'],twiss['betx'],x) plt.plot(twiss['s'],twiss['betx'],'ro', label='betx') plt.plot(x,y,'-k') plt.plot(twiss['s'],twiss['bety'], label='bety') plt.legend() plt.show()
madx script: filename:MATCH1.madx
// //MADX Example: simple MATCH //Author: Y. CH. Feng, IMP //Date: 04122015 TITLE,'Example 3: MATCH1.MADX'; BEAM, PARTICLE = ELECTRON, PC = 3.0; D: DRIFT, L = 1.0; QF: QUADRUPOLE, L = 0.5, K1 := 0.2; QD: QUADRUPOLE, L = 0.5, K1 := -0.2; FODO: LINE = (QF, 5*(D), QD, QD, 5*(D), QF); USE, PERIOD = FODO; //....match phase advance at the end of cell to 60 and 90 deg respectively //MATCH, SEQUENCE = FODO; //CONSTRAINT, SEQUENCE = FODO, RANGE = #E, MUX = 0.16666666, MUY = 0.25; //VARY, NAME = QF->K1, STEP = 1E-6; //VARY, NAME = QD->K1, STEP = 1E-6; //LMDIF, CALLS = 500, TOLERANCE = 1E-20; //ENDMATCH; //SELECT, FLAG = SECTORMAP, clear; //SELECT, FLAG = TWISS, coloumn = name, s, betx, alfx, bety, alfy; //TWISS, file = MATCH1.dat, sectormap; //PLOT, HAXIS = S, VAXIS = BETX, BETY, COLOUR = 100; //VALUE, TABLE(SUMM, Q1); //verify result //VALUE, TABLE(SUMM, Q2);
error information from cpymad:
runfile('E:/cython_madx/test/cpymad/HITFIL.py', wdir='E:/cython_madx/test/cpymad') MAD-X 5.02.05 (2015.04.06) Traceback (most recent call last): File "<ipython-input-12-bd24745bd20b>", line 1, in <module> runfile('E:/cython_madx/test/cpymad/HITFIL.py', wdir='E:/cython_madx/test/cpymad') File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 601, in runfile execfile(filename, namespace) File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 66, in execfile exec(compile(scripttext, filename, 'exec'), glob, loc) File "E:/cython_madx/test/cpymad/HITFIL.py", line 23, in <module> vary=['QF->K1', 'QD->k1'] File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\madx.py", line 424, in match sequence = self._use(sequence) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\madx.py", line 388, in _use or not self._libmadx.is_sequence_expanded(sequence)): File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\_rpc.py", line 93, in DeferredMethod funcname, args, kwargs) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\client.py", line 80, in _request self._conn.send((kind, args)) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\connection.py", line 53, in send return pickle.dump(data, self._send, -1) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\_rpc.py", line 93, in DeferredMethod funcname, args, kwargs) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\client.py", line 91, in _request return self._dispatch(response) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\client.py", line 97, in _dispatch return handler(*args) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\client.py", line 101, in _dispatch_exception raise exc_info AttributeError: Traceback (most recent call last): File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\rpc_util\service.py", line 85, in _dispatch response = handler(*args) File "C:\Python27\lib\site-packages\cpymad-0.10.6-py2.7-win32.egg\cpymad\_rpc.py", line 110, in _dispatch_function_call AttributeError: 'module' object has no attribute '__getnewargs__'
The text was updated successfully, but these errors were encountered:
Please post minimal example.
Sorry, something went wrong.
Sorry, this example is just the simplest one.
The error comes from match line, especially at vary=['QF->K1', 'QD->k1']
No branches or pull requests
Hi, Thomas
How to do a match with small step, i.e.1e-6, in cpymad? When I run a small example in cpymad, an error occurs.
python script:
filename:HITFIL.py
madx script:
filename:MATCH1.madx
error information from cpymad:
The text was updated successfully, but these errors were encountered: