atcollab / at Goto Github PK
View Code? Open in Web Editor NEWAccelerator Toolbox
License: Apache License 2.0
Accelerator Toolbox
License: Apache License 2.0
In the MML setup instructions, @yrtan reports errors when compiling AT 2.0 on Linux with Matlab 2016b and Matlab 2017b. As far as I know, there is no problem with Matlab 2016a, 2017a and 2018a. We do not have 20xxb versions available. Can anybody having such versions report on what's happening ? The problem may come not from Matlab, but from various gcc versions depending on the Linux distribution…
From @willrogers on July 21, 2017 14:22
From @willrogers on September 1, 2016 8:29
The numpy C function import_array()
needs to be called before the numpy array API can be used. Importing it once in the extension is not enough if more files are used by the extension - in this case the integrators.
The docs are here: http://docs.scipy.org/doc/numpy-1.11.0/reference/c-api.array.html#importing-the-api
Copied from original issue: willrogers/at#1
Copied from original issue: atcollab/at2devel#4
I did the following:
atpath
load atdemos/atmatchExamples/ExampleATMATCH/dba.mat
findm44(RING, 1e-5)
I get the following error:
Error using +
Matrix dimensions must agree.
Error in findm44 (line 120)
RIN = R0(:,ones(1,9)) + [D4 -D4 zeros(6,1)];
Is this a bug?
Hi all,
I'm starting to rewrite some of our AT1.3 pass-methods to AT2.0:
(A). A linear version of IdTable, It is defined by 4 parameters, dx'/dx, dx'/dy,dy'/dx and dy'/dy, it is useful to fit Id effects via its RM changes. We also used it to fit transverse impedance effects in the RM.
(B). An Sliced version of BndMPoleSymplectic4Pass. It uses PolynomA and PolynomB defined as matrices (number of coefficients X number of slices). The rad version is also done, but the ringpara and omhienvelope modifications are pending.
(C). A full Hamiltonian version of BndMPoleSymplectic4Pass, StrMPoleSymplectic4Pass and DriftPass. My idea was to be able emulate MAD's "Exact" flag.
Please, tell me if you think it would be useful to have any of them in this repository!
Cheers,
If I follow the instructions in the INSTALL
file, they don't work for me on Linux:
>> atmexall
mex -DGLNXA64 -largeArrayDims -silent -outdir /home/hgs15624/code/at/atmat/attrack -I'/home/hgs15624/code/at/atintegrators' /home/hgs15624/code/at/atmat/attrack/atpass.c -ldl
Warning: You are using gcc version '4.8.5-16)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'.
For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
> In atmexall at 34
Warning: You are using gcc version '4.8.5'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a
list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
> In atmexall at 34
Warning: Disabling the compiler warning
> In atmexall at 37
mex -DGLNXA64 -largeArrayDims -silent -outdir /home/hgs15624/code/at/atmat/atphysics/Radiation -I'/home/hgs15624/code/at/atintegrators' /home/hgs15624/code/at/atmat/atphysics/Radiation/findmpoleraddiffmatrix.c
mex -DGLNXA64 -largeArrayDims -silent -outdir /home/hgs15624/code/at/atmat/atphysics/NonLinearDynamics /home/hgs15624/code/at/atmat/atphysics/NonLinearDynamics/RDTelegantAT.cpp
mex -DGLNXA64 -largeArrayDims -silent -outdir /home/hgs15624/code/at/atmat/atphysics/nafflib /home/hgs15624/code/at/atmat/atphysics/nafflib/nafflib.c /home/hgs15624/code/at/atmat/atphysics/nafflib/modnaff.c /home/hgs15624/code/at/atmat/atphysics/nafflib/complexe.c
Undefined function 'mexpassmethod' for input arguments of type 'char'.
Error in atmexall (line 62)
mexpassmethod('all',PLATFORMOPTION);
The warning about the compiler is fine, but I don't understand about mexpassmethod
missing. Does this work for everyone else?
Hello,
I tried to use the calcnaff function that we have in the nafflib directory and I found some problems.
If I run the function to analyze the same signal two times I get the same frequencies, but the phases are every time different.
A second issue about the function is that it requires a complex signal, so it cannot be used with real bpm measurements. We could give a vector of zeros as imaginary part of the signal, but then I don't know if we can trust the results.
This is a little tricky because it requires re-writing the Git history, so anyone with a clone of at will need to reclone. Instructions are here: https://help.github.com/articles/changing-author-info/
This is what Git currently thinks the commits are:
(venv3) will@wrmpb ~/c/a/pyat> git shortlog -s -n -e
325 Laurent Farvacque <[email protected]>
255 Boaz Nash <[email protected]>
60 Simone Liuzzo <[email protected]>
44 Laurent Nadolski <[email protected]>
35 Nicola Carmignani <[email protected]>
31 Will Rogers <[email protected]>
8 yretan <yretan@atcollab>
4 peacechang <peacechang@atcollab>
4 ncarmignani <[email protected]>
4 xiahuang <xiahuang@atcollab>
2 thperron2001 <thperron2001@atcollab>
1 Nicola Carmignani <[email protected]>
1 bnash <[email protected]>
1 Giovanna Alea <[email protected]>
Hi,
I just noticed TouschekPiwinskiLifeTime.m uses the functions Cfun and IntegrateLikeElegant and maybe others that are not defined. It is a work in progress or those functions are somewhere else?
Thanks,
Zeus
https://atcollab.github.io/at/
See how to make a global Contents with all functions of AT.
Subdirectory issues
Is-it possible to add a search engine for pages?
Hello,
from matlab2018a the function mxGetPr is not recommended and mxGetDoubles should be used instead.
At some point probably mxGetPr won't work anymore, so we should do something before.
mxGetPr is used in atelem.c
Dear All
I am facing something strange.
I set b1 to some value in a quad (or sextupole).
The orbit generated is of opposite sign of what is expected.
In the vertical plane this is fine.
I add the testing code using ESRF lattice.
Please let me know if you confirm the bug or if I am doing something wrong.
%% ESRF Lattice
Ring=esrf;
[LinData,nu, ksi] = atlinopt(Ring,0,1:length(Ring)+1)
beta = cat(1,LinData.beta);
phase= cat(1,LinData.mu);
eta = cat(2,LinData.Dispersion)';
spos = cat(1,LinData.SPos);
Id = 6;
theta = 1e-4;
orb_ana = (sqrt(beta(Id,1)beta(:,1))/2/sin(pinu(1)).cos(abs(phase(Id,1)-phase(:,1))-pinu(1))-eta(Id,1)*eta(:,1)/mcf(Ring)/LinData(end).SPos)*theta;
Ring{Id}.PolynomB(1)=theta/Ring{Id}.Length;
cod = getcod(Ring);
cod = cod';
figure(400)
clf
subplot(2,1,1)
plot(spos, orb_ana); hold all;
plot(spos, cod(:,1),'k*');
legend('Analytical', 'AT')
ylabel('horizontal orbit')
orb_ana2 = (sqrt(beta(Id,2)beta(:,2))/2/sin(pinu(2)).cos(abs(phase(Id,2)-phase(:,2))-pinu(2))-eta(Id,3)*eta(:,3)/mcf(Ring)/LinData(end).SPos)*theta;
Ring=esrf;
Ring{Id}.PolynomA(1)=theta/Ring{Id}.Length;
cod = getcod(Ring);
cod2 = cod';
subplot(2,1,2)
plot(spos, orb_ana2); hold all;
plot(spos, cod2(:,3),'k*');
legend('Analytical', 'AT')
ylabel('vertical orbit')
From @willrogers on July 21, 2017 14:23
From @lfarv on July 21, 2017 11:49
load_mat.load
alters the Class
field of elements before using them, using the title()
method. But class names are case sensitive and sometimes use capital letters in the middle, for instance RingParam
or ThinMultipole
(CamelCase standard). So load_mat.load
fails when loading such elements. Class names are automatically set in element creation routines and I think they should be kept as they are.
Copied from original issue: willrogers/at#47
Copied from original issue: atcollab/at2devel#8
If we compute the linear optics with atlinopt with the RF frequency changed we would expect to get the off-energy optics, but this is not the case now. atlinopt uses always findorbit4 (through findm44) to get the closed orbit.
The only way to get the off-energy optics is to pass the parameter dpp.
What do you think about using findorbit6 to get the closed orbit and then computing the linear optics around this orbit? In this case, we could compute the off-energy optics just by changing the RF frequency.
We could have a flag, something like "UseOrbit6" or "UseRFFrequency". If the flag is present, the second input of atlinopt would be ignored, the closed orbit would be computed with findorbit6 and the orbit would be passed to findm44 to get the optics.
I noticed that the official value of some important physical constants stored in the file PhysConstant.m has been changed in the last years.
For example, the elementary charge is now 1.6021766208(98)e−19 C according to wikipedia and apparently it will become exactly 1.602 176 634e−19 C soon, but in our PhysConstant.m file the elementary charge value is only 1.602 176 487e-19 C!
I thought that we could just download the updated PhysConstant.m file, but then I noticed that the file is produced in Soleil and it does not come from NIST.
Should we modify the file?
the text function of matlab R2014b is not compatible with atplot.
in this version of matlab the signature text(ax, x, y, ....) is not available.
From @bnash on July 21, 2017 10:58
Modeling of ID's is an important area of development for AT.
There are several different ways to model ID's in AT. The first is simply to create an array of bending magnets. This has the benefit that the radiation effect is computed correctly, but the field profile is not totally right. Also, non-linear effects will not be included here.
Secondly, one can use the analytical method of Ying Wu and Forest (others?). This is implemented in the pass method GWigSymplecticPass.c:
https://github.com/atcollab/at2devel/blob/master/atintegrators/user/GWigSymplecticPass.c
The radiation damping effect may be added in an analagous way as in driftkickrad.c in
https://github.com/atcollab/at2devel/blob/master/atintegrators/BndMPoleSymplectic4RadPass.c
For the diffusion, one would need to modify findmpoleraddiffmatrix.c
https://github.com/atcollab/at2devel/blob/master/atmat/atphysics/findmpoleraddiffmatrix.c
Which is used in OhmiEnvelope.
Finally, one may use the kick map method for tracking through IDs. This is implemented in
https://github.com/atcollab/at2devel/blob/master/atintegrators/IdTablePass.c
Here, one also needs to add the radiation effects. For the damping, one could compute a damping matrix to add to the kick map as a matrix element. For the diffusion, one could compute the diffusion matrix in Radia along with the kick map. This matrix would then need to be read in, in a modified
findmpoleraddiffmatrix.c
Copied from original issue: atcollab/at2devel#2
Hi all,
I have been working on updating the wiggler pass methods from #59 to work with pyat. So far I have added a Wiggler
element class to pyat, both GWigSymplecticPass
and GWigSymplecticRadPass
mex and build (setup.py develop
) without errors, and they both work with atpass
in Python and Matlab. I do however have some questions:
wigglerChanges
branch.GWigSymplecticPass
and GWigSymplecticRadPass
rely on gwig.c
and gwig.h
, and gwigR.c
and gwigR.h
respectively. I could not find any other pass method using this structure, no matter how far back I went in at's history; should I change this, is there a convention?Wiggler
element creation from atwiggler.m
and so had the need to raise errors in at.elements
which is imported by lattice.utils
where AtError
is defined.
AtError
and AtWarning
to their own file, exceptions.py
; at the top level of pyat because after I put them in their own file I could not find a reason why they belonged in at.lattice
. They can now be imported either from at import AtWarning
or from at.exceptions import AtError
, is this satisfactory? Where do you think they should be located?Thanks
When atfastring() is used with a lattice containing cavities with non-zero length, then linear optics will change due to the movement of the cavity element to the start of the ring.
To fix this, atfastring() may check whether each cavity element has a length. If they do, then insert drift-spaces with correct length before/after and set cavity length to zero.
Hi,
In matlab 2009 (I checked that Matlab2017 version works fine), I get the following error message:
[LinData,~, ~] = atlinopt(THERING,0,1);
_??? Error using ==> struct
Array dimensions of input 10 must match those of input 2 or be scalar.
Error in ==> atlinopt at 124
ld = struct('ElemIndex',num2cell(find(REFPTS)),...
Error in ==> atlinopt at 119
[LD, tunesP] = atlinopt(RING,DP+0.5*dDP,refs,o1P); %#ok
This line appears in atsummary, so it makes atsummay not to work, however, the command atlinopt(THERING,0,1) works whithout problem. I guess an empty cell array and {} are not the same thing in Matlab2009, but I'm not sure...
Someone has any idea how to make it compatible with both versions?
Cheers,
Zeus
Hello!
I want to create some deviation in the ring' magnetic field as I am going to learn about the beam's closed orbit correction.
However, I founded that the deviation in PolynomA[0] of dipole , PolynomB[0] and PolynomA[0] of quadrupole have not been considered during the physical calculation.
The orbit haven't change though I add some deviation in PolynomA/B.
I wonder if my pass method has a great influence on it.
My dipole's pass method is BndMPoleSymplectic4E2Pass, and quadrupole's is QuadLinearPass
I am grateful and looking forward to the answer as a beginner of AT!
We should create a README file for the AT repo. If we use Markdown or reStructuredText it will display nicely on Github.
From @willrogers on July 21, 2017 14:23
From @willrogers on March 21, 2017 11:21
AT requires input of shape (6, x)
.
pyAT requires input of shape (x, 6)
.
The difference is confusing. I cannot remember if there is a technical reason why this is, or if it could be corrected to be the same.
Perhaps @lfarv can remember.
Copied from original issue: willrogers/at#27
Copied from original issue: atcollab/at2devel#7
Creating an element that is turned off (PolynomB = 0 for quad, sext, etc.), the MaxOrder is automatically set to 0, since max([1 find(abs(elem.PolynomB)>0,1,'last') find(abs(elem.PolynomA)>0,1,'last')])-1 = 0.
If one wants to turn on the element, it is then not enough to make the PolynomB array non-zero; one must also change MaxOrder to the desired value manually, which seems like an unnecessary extra step, which can easily be forgotten.
Instead, one could check the class of the element in atbaselem, and let MaxOrder = 1 for quads and 2 for sextupoles per default. I guess this may increase computation times somewhere (an element with MaxOrder = 1 is included in calculations, even though PolynomB(2) = 0), but if the number of turned-off elements is low, then it does not matter too much(?).
@willrogers and I are experiencing failures of the new Matlab tests from #80. Initially on R2014b using Python 3.4, but they also fail for me on R2016a.
@lfarv what versions of Matlab and Python are you using?
it would be nice if we could type for ex. help DriftPass and have some message describing the PassMethod DriftPass.c .
This can be doen creating appropriate DriftPass.m comment files in atintegrators.
There are still a few passmethods with the passFunction instead of the trackFunction. I created a branch called track functions to correct them.
This isn't particularly an AT problem, but a general mex problem I'm having at the moment.
(cross-posted as a comment on this item at Matlab central:
https://www.mathworks.com/matlabcentral/answers/372419-why-does-matlab-not-recognize-my-xcode-9-installation-when-running-mex-setup)
I'm using Matlab 9.1.0.441655 on High Sierra. I upgraded XCode to 9.2.
When I run mex -setup I get this result
>> mex -setup -v
Verbose mode is on.
... Looking for compiler 'Xcode with Clang' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('4.5.2').
... Executing command '
agreed=4.5.2
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('4.5.2').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk' ...No.
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' ...No.
... Executing command 'find /Applications/Xcode.app/Contents/Developer -name MacOSX10.12.sdk | egrep 'MacOSX10.12.sdk'' ...No.
... Executing command 'find $$ -name MacOSX10.11.sdk | egrep 'MacOSX10.11.sdk'' ...find: 26060: No such file or directory
No.
... Executing command 'find $$ -name MacOSX10.10.sdk | egrep 'MacOSX10.10.sdk'' ...find: 26064: No such file or directory
No.
... Executing command 'find $$ -name MacOSX10.9.sdk | egrep 'MacOSX10.9.sdk'' ...find: 26067: No such file or directory
No.
Did not find installed compiler 'Xcode with Clang'.
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016b/maci64.html.
When using atbeam you can specify orbit offsets. However some additional checks need to be put in place to avoid the following errors.
After retrieving the closed orbit from atlinopt "paramAll = atlinopt(lattice,0,1)" which has an x-offset of 14mm and 0 for xp, y and yp.
particles = atbeam(np, sigmaMatrix, paramAll.ClosedOrbit)
fails as it should. The sigma matrix in this case if 6x6 and the ClosedOrbit is only in 4 dimensions.
Therefore the correct input should be
particles = atbeam(np, sigmaMatrix, [paramAll.ClosedOrbit' 0 0]')
which correctly applies the orbit offset.
However if you put
particles = atbeam(np, sigmaMatrix, paramAll.ClosedOrbit')
then there is no error. The first element in the ClosedOrbit list is applied to every dimension. In this example:
mean(particles(1,:)) = 14e-3
mean(particles(2,:)) = 14e-3
etc
Additional checks need to be put in place to ensure this fails rather than pass successfully.
Hi all,
I just tried a simple code:
import at
from at import load_mat
import numpy
m = load_mat.load('a25.mat')
rin = numpy.array((1e-6, 0, 0, 0, 0, 0))
print(rin)
at.atpass(m, rin, 1)
print(rin)
It runs well if I use the example "dba.mat", but with our lattice "a25.mat" I get the following error:
Simulating 1 particles for 1 turns through 1469 elements.
Segmentation fault (core dumped)
It seems I can't attach matlab files, so if anyone is willing to help I can send the file.
Thanks,
Zeus
Hello,
First I'd like to thanks all the people working on PyAt. It is really great for Matlab-allergic people (like me). I am a PyAt user since a month, and it's working great.
But one thing I couldn't find in PyAt is a way to easily get elements from the lattice by their FamName, using a string supporting wildcards. This is something possible in Matlab-At, and it is really convenient (specially when the lattice you use is only made of Multipole elements).
For instance I would like to get all focusing quadrupole in my ring by just typing ring['QD*']. Maybe there is already a way to do it in PyAt, but I couldn't find it.
I did a quick implementation of this here. It is just 5 lines long, doesn't support Python2 and don't address the __setitem__ method. If there is no other way of doing this and you think it is worth it, I could do a pull request with it, trying to make it cleaner in the meantime.
Thanks,
Benoit
Hello,
I am doing some tracking-related studies, which include painting the x-x' phase-space portrait, and noticed that a ring produced by atfastring leads to a significantly different portrait than the regular ring.
My test code:
ring = esrf;
[ring_fast,ring_fastRad] = atfastring(ring);
x = 0:1e-4:5e-3;
Rin = zeros(6,length(x));
Rin(1,:) = x;
Rout_fullRing = ringpass(ring,Rin,1000);
Rout_fastRing = ringpass(ring_fast,Rin,1000);
figure;
subplot(1,2,1)
plot(Rout_fullRing(1,:),Rout_fullRing(2,:),'b.');
axis([-6e-3 6e-3 -1.5e-4 1.5e-4]);
title('Normal ring portrait')
subplot(1,2,2)
plot(Rout_fastRing(1,:),Rout_fastRing(2,:),'r.');
axis([-6e-3 6e-3 -1.5e-4 1.5e-4]);
title('Fast ring portrait')
Is this a fundamental limitation of the nonlinear optics in atfastring, or is it fixable somehow?
Dear all,
When using "at/atmat/pubtools/LatticeTuningFunctions/errors/atsettiltdipole.m" to set the tilt error for elements, something seems inconsistent. In attiltelem.m, a straight element is tilted clockwise around the direction of beam motion by an angle PSI, while in atsettiltdipole.m, if following the same tilt sign convention for a dipole element, a "standard" bending magnet will be tilted clockwise, and leads to a horizontal kick that increase px, i.e., PolynomB(1) = -BendingAngle / Length * (1 - cos(PSI)) ; meanwhile, this also leads to a vertical kick that bends downward (decrease py), i.e., PolynomB(1) = -BendingAngle / Length * sin(PSI) . So I guess there is a sign error in the PolynomB(1) in atsettiltdipole.m.
Hello,
I pushed a new branch yesterday and then the automatic check to the master and many other branches failed. I haven't modified the master, so I don't understand the problem.
While converting the last integrators to the Python-compatible trackFunction
, I noted some problems with incompatible data ordering in element parameters.
Data ordering for the coordinate arrays (Rin/Rout) has been decided some time ago ( #6): 6xN matrices with Fortran-ordering. This is transparent for the user since lattice_pass
converts if necessary to the correct ordering.
But for element parameters, the access functions (atGetDoubleArray
...) check that the parameters are in C order (I do not remember why). Fortunately, 2-D parameters are quite rare: I found:
IdTablePass
integrator (newly converted)Matrix66Pass
and MatrixTijkPass
integratorsR1
and R2
axes rotation matrices for all elements: here I think the present implementation is buggyAgain we have 2 solutions for clarifying this:
Keep element parameters in C-order: this means that the C code must be different for Matlab and Python when using 2-D parameters (using #ifdef
s). This is what I did for the interpolation table in IdTablePass
.
Decide that internally, all element parameters in AT are Fortran-ordered. C code is then identical for all versions and data conversion to/from Matlab is easier. Again this can be made almost transparent for the user if elements are built by element creation functions (element.py
). This choice concerns only arrays accessible from C-code: particle coordinates and element parameters. For everything else, data ordering is handled transparently by numpy. This is my preferred solution.
As soon as a decision is made, I can take care of atelem.c and the few concerned integrators.
From @willrogers on July 21, 2017 14:23
From @willrogers on October 6, 2016 20:59
Another point is: what’s next ? You brought the engine, but AT is thousands of lines of Matlab code. I was thinking of “atlinopt” and a few convenience routines to extract/modify lattice parameters (atgetcells, atgetfieldvalues, atsetfieldvalues…). Do you already have plans ?
I was going to base the requirements on what I need for a python middle layer type application: twiss parameters, tunes etc.
There is a lot of stuff in AT, but there's no need to make a complete clone, at least to start with, and translating Matlab to Python is relatively straightforward. The code should be more compact in Python as well.
Copied from original issue: willrogers/at#11
Copied from original issue: atcollab/at2devel#5
I experience a problem when using AT_2_OPA. OPA throws an error when loading the file. Example:
spear3;
AT_2_OPA(THERING,'test_AT2OPA');
Then loading test_AT2OPA_lattice.opa in OPA leads to the error:
"LATTICE ERROR > undefined entry RF in segment test_AT2OPA"
Though, there is a fix! If I manually open test_AT2OPA_lattice.opa in e.g. notepad++, copies all the text, and insert it into a new file with name e.g. 'newTest_AT2OPA_lattice.opa' there seem to be no problem loading the file in OPA.
This suggests that saving the file in Matlab makes it unavailable in OPA, but a file created by notepad++ is OK even though that the content of the two files are identical.
Has anyone seen something similar?
Tested with MATLAB R2018a and R2016b.
There seem to be some discrepancies over how the refpts argument is handled.
linopt
with no refpts M44 is the identity matrix and mu is not calculatedtwissring
with no refpts the results reflect one full orbit (M44 is not identity and mu is non-zero)get_twiss
with no refpts mu is zero but M44 is not identitylinopt
with no refpts mu is zero but M44 is not identityWhat is the correct thing to do with no refpts? I am also not sure I can make the values for mu match.
Trying to install AT for M.B. (LAL and INFN-Frascati) on matlab2015b we got this error
>> atmexall
mex -DGLNXA64 -largeArrayDims -silent -outdir /users/dsksi/biagini/matlab/at/atmat/attrack -I'/users/dsksi/biagini/matlab/at/atmat/../atintegrators' /users/dsksi/biagini/matlab/at/atmat/attrack/atpass.c -ldl
mex -DGLNXA64 -largeArrayDims -silent -outdir /users/dsksi/biagini/matlab/at/atmat/atphysics/Radiation -I'/users/dsksi/biagini/matlab/at/atmat/../atintegrators' /users/dsksi/biagini/matlab/at/atmat/atphysics/Radiation/findmpoleraddiffmatrix.c
mex -DGLNXA64 -largeArrayDims -silent -outdir /users/dsksi/biagini/matlab/at/atmat/atphysics/NonLinearDynamics /users/dsksi/biagini/matlab/at/atmat/atphysics/NonLinearDynamics/RDTelegantAT.cpp
Error using mex
cc1plus: error: unrecognized command line option "-std=c++11"
Error in atmexall (line 49)
eval(MEXCOMMAND);
We commented the line to see if it would work for everything else and it did.
then the function text.m gave the following error
Error using text
First two or three arguments must be numeric doubles.
Error in atplot (line 100)
curve.comment=text(ax,-0.14,1.12,{line1;line2},'Units','normalized',...
Exception in thread "AWT-EventQueue-0" javax.media.nativewindow.NativeWindowException: X11Util.Display: Unable to create a display(localhost:13.0) connection. Thread AWT-EventQueue-0
at jogamp.nativewindow.x11.X11Util.openDisplay(X11Util.java:452)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory.createMutableSurfaceImpl(X11GLXDrawableFactory.java:507)
at jogamp.opengl.x11.glx.X11GLXDrawableFactory.createDummySurfaceImpl(X11GLXDrawableFactory.java:523)
at jogamp.opengl.GLDrawableFactoryImpl.createOffscreenDrawable(GLDrawableFactoryImpl.java:324)
at javax.media.opengl.awt.GLJPanel$OffscreenBackend.initialize(GLJPanel.java:1665)
at javax.media.opengl.awt.GLJPanel.initializeBackendImpl(GLJPanel.java:1339)
at javax.media.opengl.awt.GLJPanel.paintComponent(GLJPanel.java:550)
at com.mathworks.hg.peer.JavaSceneServerGLJPanel.paintComponent(JavaSceneServerGLJPanel.java:147)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$1100(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
From @yrtan on July 28, 2017 0:17
The way that the effects of radiation is calculated seems haphazard. Rather than having two different pass methods of a given element, there should only be one and a flag to indicate if radiation should be considered or not.
Copied from original issue: atcollab/at2devel#9
I get --- AT was not installed correctly Installed in Matlab version 2017b.
Any compatibility issue? I used older 1.2 Version AT and also 2.0.
ATRoot='E:\Accelerator\AT1.2'
ATRoot =
'E:\Accelerator\AT1.2'
>> unzip('atzip.zip',ATRoot)
>> cd(ATRoot)
>> atpath
>> atdiag
>> spear3;
>> plotbeta
AT was not installed correctly
Thank you.
-sa
TL; DR:
How refpts
are handled is inconsistent at best and erroneous at worst; furthermore, the docstrings only complicate things by contradicting each other. Please can someone outline the intended use syntax for refpts
?
I have discovered an issue with the consistency of refpts
, although refpoint related this is different to the issue discussed on #75.
The issue is primarily due to there being no max length check in all of our refpts
handling, and the inconsistency/ambiguity of the docstrings of functions that use refpts
.
On the first point:
Since, in uint32_refpts
, we currently raise a ValueError if numerical refpts
contain duplicates or are not in ascending order, therefore it would be intuitive to have a maximum length check.
Summary of behaviour:
============================================================================================
| refpts = | returns / raises |
============================================================================================
| numpy.array([0,...,2*len(ring)], | Error raised later in function due to indexing |
| dtype=uint32) | / calculation issues, or data of length |
| | 2*len(ring) is sucessfully returned. |
--------------------------------------------------------------------------------------------
| numpy.ones(len(ring), dtype=bool) | data at entrance to every element in the ring |
--------------------------------------------------------------------------------------------
| numpy.ones(len(ring)+1, dtype=bool) | above + data at the non-existant len(ring)+1th |
| | element |
--------------------------------------------------------------------------------------------
| numpy.ones(2*len(ring), dtype=bool) | ValueError: refpts must be ascending |
--------------------------------------------------------------------------------------------
| [0, 1, ..., len(ring)-2, len(ring)-1] | data at entrance to every element in the ring |
--------------------------------------------------------------------------------------------
| [0, 1, ..., len(ring)-1, len(ring)] | above + data at the non-existant len(ring)+1th |
| | element |
--------------------------------------------------------------------------------------------
| [0, 1, ..., 2*len(ring)-1, 2*len(ring)] | ValueError: refpts must be ascending |
--------------------------------------------------------------------------------------------
| [2*len(ring)] | data at entrance to ring i.e. eqivelent to |
| | putting refpts=0 |
============================================================================================
The first isssue is that any array with dtype=numpy.uint32
remains unparsed and so either causes issues in calculations or indexing later on in the function, or even worse it returns data at elements beyond the end of the lattice. The behaviour differs by function but is consistent inside each function.
Secondly because of the line refs = numpy.array([i if (i == n_elements) else i % n_elements for i in numpy.ravel(refs)], dtype=numpy.uint32)
in uint32_refpts
, which is used to support negative indexing, any refpoint > n_elements is converted into a smaller refpoint, usually a duplicate.
In relation to the second:
The few functions that have an explanation of the function of refpts
conflict with each other in those explanations.
get_twiss
, linopt
and ohmi_envelope
give the following description of refpts
:
refpts elements at which data is returned. It can be
1) an integer (0 indicating the first element)
2) a list of integers
3) a numpy array of booleans as long as ring where
selected elements are true
Defaults to None
...
All values are given at the entrance of each element specified in refpts
lattice_pass
further confuses the issue with:
Note:
* lattice_pass(lattice, r_in, refpts=len(line)) is the same as
lattice_pass(lattice, r_in) since the reference point len(line) is the
exit of the last element
* lattice_pass(lattice, r_in, refpts=0) is a copy of r_in since the
reference point 0 is the entrance of the first element
Finally bool_refpts
introduces another contradiction:
Return a boolean numpy array of length n_elements + 1 where True elements
are selected. This is used for indexing a lattice using True or False
values.
N.B. find_orbit4
, find_sync_orbit
, find_orbit6
, find_m44
, find_m66
, and patpass
all make use of refpts
without any explanation in their docstrings.
My conclusions:
refpts
should be indexed from 0.refpts=n_elements+1
being, logically speaking, the same as refpts=0
for some of the physics data it is useful to have because it indicates the data at the end of the last element/ring which may well be different to the data at the start of the first element.refpts
should either be in all relevant docstrings or they should reference or inherit one description.uint32_refpts
and put the refpts
checking logic into a separate parsing function, that way it could be used more generally and uint32_refpts
would contain purely the conversion to uint32; or perhaps a general refpts conversion function that takes an output_dtype
argument might be better?Please can someone confirm whether the conclusions that I've outlined are correct; any suggestions or insights about the refpts
handling redesign are also welcome.
I'd also be interested in the equivalent behaviour in Matlab, if anyone knows off-hand, I may look into this fully later on.
Dear @bnash @carmignani @lnadolski @lfarv ,
as noticed by Zeus Marti' (ALBA) and me and Reine Versteegen in the past there is a problem with getcellstruct.m
.
When getcellstruct.m
is called many times, after the Nth call (N big enough), a warning starts to be printed.
The only way to cancel the warning is to restart matlab. However after several calls to getcellstruct.m
the warning will appear again.
A possible, very ugly, fix has been committed in error_corrections branch
Hello,
I installed pyat using a virtual environment on a machine with Debian 8 and python 3.4 with the help of @abdomit.
2 tests out of 150 fail.
================================== 2 failed, 148 passed, 4 warnings in 1.96 seconds ===================================
I tried also on a machine with Debian 9 and python 3.5 and all the tests pass.
============================================= 150 passed in 1.61 seconds ==============================================
In the attached file you can see the output of the tests.
errors.txt
Hi all,
I calculated the mode-emittances of an imperfect ring lattice with atx.m, I tried to rotate the lattice to start with different elements (say, start the lattice at straight section centre, or at one arbitrary place in the arc), but the calculated mode-emittances(in particular the vertical emittance) diff for different starting points, which seems nonphysical. In the following lines I used the esrf lattice as an illustration:
RING=esrf();
ringpara(RING)
indS=find( atgetcells( RING, 'Class', 'Sextupole' ));
s00=findspos(RING, 1:length(RING)+1);
[bd, par]=atx(RING,0,1:length(RING));
emits=par.modemittance;
RING1 = RING;
%%%%% misalign sextupoles to represent machine imperfections
dxs = 100e-6 * randn([length(indS),1]);
dys = 100e-6 * randn([length(indS),1]);
RING1=atsetshift( RING1, indS, dxs, dys);
[bd1, par1]=atx(RING1,0,1:length(RING1));
emits1=par1.modemittance;
fprintf('%.4e ',emits1);fprintf('\n');
nlen=length(RING);
results=zeros([nlen, 7]);
for ind = 1 : 100 : nlen
RING2 = [ RING1(ind:end,1); RING(1:ind-1,1)]; %%%% rotate and start the lattice at ind-th element
[bd2, par2]=atx(RING2,0,1:length(RING2));
emits2=par2.modemittance;
demitsratio=(emits2-emits1)./emits1;
results(ind, :) = [s00(ind), demitsratio, emits2];
fprintf('%.4e ',results(ind, :));fprintf('\n');
end
plot(results(:,1),results(:,2),'b-');
hold on;
plot(results(:,1),results(:,3),'r-');
legend('dex/ex0','dey/ey0');
save('./esrf_emits.txt','results','-ascii');
The Australian Synchrotron lattice is fairly simple with 14 fold symmetry and 3 families of quadrupoles to pin the tunes and dispersion in the straights. I was thinking of extending the atfittune or creating a atfittunedisp function. For us this function is always used.
Would this be worth adding? Suggestions?
I have been working on an interactive Linear Optics and lattice editing GUI for an accelerator physicist here at Diamond.
Side note: a big thank you to @lfarv as the
at.plot
functionality has worked well and been very helpful.
He would like some Global Linear Optics Properties displayed which are not currently calculated in pyat (Linear Dispersion Action, Momentum Spread and the Damping Partition Numbers). As I understand it, these are all calculated from / related to the Radiation Integrals. To save time we are working around the issue and trying to calculate them from the outputs of functions currently in pyat. However, after discussion with him he has said that the accelerator physics group at Diamond are very interested in the Synchrotron Integrals when developing lattices. So, although not that important it would be nice if we could calculate them in pyat.
The new parameters comparison tests have been failing for me. All three failed at the mcf comparison with slightly different values between Matlab and Python:
dp | py_mcf | ml_mcf |
---|---|---|
0.0 | 8.506395615730056e-05 | 8.506669244225616e-05 |
0.01 | 8.820482604883597e-05 | 8.820785279280231e-05 |
-0.01 | 8.231552705045038e-05 | 8.23179738933576e-05 |
Is this just a tolerance issue, to what accuracy would they be expected to agree? For reference, I had failures, all with roughly the same values, on:
Python | Matlab |
---|---|
2.7.3 | R2014b |
3.3.7 | R2016a |
3.4.9 | R2016a |
From @bnash on July 21, 2017 11:9
For multiparticle tracking, including impedance, one may use the impedance pass method:
https://github.com/atcollab/at2devel/blob/master/atintegrators/impedance_tablePass.c
We should have a creation function for this element and some examples.
Copied from original issue: atcollab/at2devel#3
From @willrogers on July 21, 2017 14:23
From @willrogers on October 20, 2016 8:44
I believe we should be able to upload binary 'wheels' to Pypi.
This should allow pip install pyat
.
I think this will require building with setuptools
rather than distutils
(a fairly minor change).
Copied from original issue: willrogers/at#18
Copied from original issue: atcollab/at2devel#6
in
[l,t,c]=atlinopt(ring,0,indexes_in_ring)
the output l.mu is not correctly computed.
To obtain the correct computation it is needed to issue the following comands:
[l,t,c]=atlinopt(ring,0,1:length(ring)+1)
l(indexes_in_ring).mu
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.