-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
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
Matlab ring properties #443
Conversation
Dear @lfarv, I will test this pull request at the end of this week or (more likely) in August. best regards |
Hi @lfarv Can you guide me to use pyat within matlab? How to import the pyat module? Best regards, Laurent. |
Finally I got it I am not sure this is documented somewhere. |
in file githubsetup, I got an error. Error using pyenv |
Dear @lfarv I got many errors using githubrun on MATLAB 2021b I am very sorry for the bad formatting
|
Dear @lfarv radiation property is missing with respect to python version. |
Dear @lfarv atmaincavities is missing the search for the minimum frequency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments in Conversation
Hello @lnadolski I appreciate to see your involvement in the evolution of AT ! Thanks for testing and proposing !
That's too tricky and dangerous ! All you have to do is to set in
As the name suggests, >> ok=assertSuccess(run(testsuite('atmat/attests'))) But anyway, you apparently succeeded in running them ! I'm discovering the Matlab test framework. It looks powerful, but is not obvious to use. The tests are still preliminary, they may be more systematic.
Yes, 2022a is much better in converting Matlab and python datatypes, so I focused on this version. Github is able to run this one, and for each previous version, the code needs becomes more and more cluttered with explicit conversions. Do you think going backwards is worth the effort?
Ok. But since in Matlab a lattice is not a well controlled class object, for checking radiation on/off, the
Yes, how could we call it? Unfortunately, the |
Looking at you result:
There is something strange with this test. It looks like something is not reproducible. I'm looking at that |
OK. but matlab is not running in the virtual environment. Should I do it as well ?
Ok, thanks
This is indeed a concern. On my side, in our development environment and in the control room we have not switched yey to the latest version of matlab. This can take really a few years to do it since I need to convince my control people and get an Linux flavor compatible with the latest version of MATLAB without breaking TANGO. This is really a huge piece of work. I think we will be several facilities in the same case.
I let you choose ;-) Laurent |
Matlab is not concerned. Virtual environments are a way to have on the same machine different python "installations", each with its own set of installed software. You can select the wone you want in to ways:
|
I see the point. But we are talking here of a single test procedure recently introduced. AT itself is (should be…) compatible with Matlab R2016b, almost 6 years old ! Testing by comparing with python is only possible with the few most recent versions. I'll add a check in the test class to throw an error if using a too old version, with an explicit message. We can go back one or two versions at the cost of less "clean" code, but not more. Which version would you set as the minimum one? |
I do agree with you. If this affects only the testing procedure, this is fine with me. Concerning the scripts using py.at within matlab like atwritepy, we should maybe have a HOWTO to get py.at properly configured as discussed earlier. Otherwise the advice to the user would be to load the m/mat lattice directly from python and do the conversion within python. To my knowledge only 3 scripts are concerned: |
|
for @lnadolski: two new properties are available: 'radiation': longitudinal motion (cavities, radiating elements, ...) |
@simoneliuzzo: can you have a look at this pull request? |
Dear @lfarv, I am testing this branch. I find confusing that output change according to input. props = atGetRingProperties(betamodel) [en, hh] = atGetRingProperties(betamodel,'Energy','HarmNumber') If it is done for speed reasons, I would prefer to have something like: props = atGetRingProperties(betamodel,'Energy','HarmNumber') props = struct with fields:
This is just my personal opinion, not a showstopper. I continue testing best regards |
Dear @lfarv, I tried to set Periodicity to 20 and -100. There is nothing preventing these (wrong) actions. The HarmonicNumber changes proportionally to cell_harmnumber May be there could be some limitations in this input? as for InputParser in matlab some validation function could check that periodicity is allowed (0 < total angle < 2pi for the ring for example). |
Dear @lfarv , I think that the default properties could be all properties. The simplest call is longer but verbose and answers completely to the question asked by the user when calling the function atGetRingProperties "What are (all) the ring properties?". |
I have done a few more simple tests. I have errors when I expect errors and changes of parameters as expected. |
Dear @lfarv I have tested changing the RF frequency using atSetRingProperty and using atsummary (modified in this branch) to compute the horizontal emittance. I get the figure below. Is this expected? I find it personally misleading. Having compared with real SR data the output of ATX, I consider it to be correct. best regards |
@simoneliuzzo : let me show the motivation behind these changes: Concerning the output, the choice between a single structure or multiple output parameters is based on convenience: with multiple parameters, you can choose the variable name you want, you don't need to to remember the field names, and for performance, you avoid the access to a field of a structure: the properties are ready to use ! To summarise, I would say that the old syntax is kept for existing code, but for new code I think that in 99% of cases, the new multiple output syntax is more convenient, and rather intuitive if you look at it: one output per input… |
Good point. I'll look at that ! |
Do you mean the original syntax
If you think that the functionality "What are (all) the ring properties?" is useful, a solution might be something like: props=atGetRingProperties(ring, 'all') which does not affect existing code. Is it worth ? |
Very interesting. As you know, But I fully agree that your test is legitimate and very instructive. So:
And thanks for testing and reporting ! |
Dear @lfarv , I understand. I think it is an historical naming problem. If I imagine to be a new AT user, I would use May be atGetRingProperty could replace and deprecated ringpara, atsummary and atx? |
If the help is explaining this dynamic output I have no practical problems. May be @swhite2401 , @lnadolski and @carmignani have an opinion on this point? |
I have the same understanding as @simoneliuzzo : for all parameters I call either Concerning the output format, the solution adopted is fine with me. |
Dear @lfarv,
|
@simoneliuzzo, @lnadolski : I think you both summarised the purpose of I keep from you comments:
@lnadolski : you are right, |
atmat/lattice/atparamscan.m
Outdated
case 'brho' | ||
clight=PhysConstant.speed_of_light_in_vacuum.value; | ||
energy=getenergy(ring); | ||
rest_energy=getparticle(ring).rest_energy; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lfarv
Indexing into Function Call Results is only working for R2022a++
this nice feature makes an error for earlier version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same on lines #217 and 228
A quick fix could be
tmp = getparticle(ring);
rest_energy=tmp.rest_energy;
|
@simoneliuzzo, @lnadolski : I think all your remarks have been implemented. Anything else before merging? |
This is a major update of the handling of ring properties in Matlab.
Ring properties are simulating the properties of a "Lattice" object, though a lattice in Matlab is not a class object, for performance reasons. Instead, the ring properties are accessed through the
atSetRingProperties
andatGetRingProperties
functions, and are stored, for some of them, in aRingParam
element.The update of these two functions includes:
atGetRingProperties
function,New interface for
atGetRingProperties
The present interface stays unchanged:
The new interface is more flexible, allowing to select the desired properties and giving access to the new ones:
[v1, v2, ...] = atGetRingProperties(ring, 'prop1, 'prop2', ...]
Example:
The efficiency has been improved, specially if the
RingParam
element is missing, by caching and reusing previous results. For the best efficiency, it's better to ask for all the desired properties in one call: since some properties depend on others, it avoids repeating the computations.New properties
Most of the properties available in python are now available. The present list is:
It also appeared that there might be some confusion between values concerning the single cell and values concerning the full ring ('periodicity' x cells). Historical values still concern the full ring, but the values for one cell are now explicitly identified by a
cell_
prefix.Compatibility with python properties
Aliases are set so that the python property names are correctly interpreted:
Both property names may now be used.