-
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
Allow setting "dp" in 6D linear optics #364
Conversation
Since you are modifying this @simoneliuzzo pointed out an issue with We may want to integrate |
@swhite2401: You are right for the output of |
Well I ran into this problem earlier comparing |
|
The
|
@simoneliuzzo and @carmignani: this improvement is now ready and answers some of you questions. Do you have any comment? |
Dear Laurent, |
Dear Laurent, I prepared this small script to see if the usual commands I am used to use would work within this branch.
|
@simoneliuzzo: Thanks for the test Simone, I'll take your remarks one by one, but at some point, I'll need your lattices. For now:
From this, I see:
What is
If Thanks for your tests, they are really very useful! |
Dear Laurent, I copyed different parts of scripts. r = ring. best regards |
Dear Laurent, |
No ! |
Isn't this atlinopt4? |
You are right, but |
Hello @lfarv, |
Hello @carmignani : I was too fast in trying to correct the bug reported by @simoneliuzzo… Pull the last revision and it should be OK. Sorry… |
There is another way to derive I propose to leave this branch as it is (no |
I'm slowly checking the different modifications of the pull request. |
I agree this warning is very annoying and has to be removed, this is detrimental to user's experience: warnings should be avoided in general they are counter-productive |
We can remove it. The idea comes from time measurements I did: to get a ring parameter, for a test lattice (hmba I think), it takes 80 ms without RingParam, and 0.2 ms with. Huge gain. Another example: when requiring ring properties in each test, the standard test sequence of GitHub (matlab_tests) takes on my Mac 15s with RingParam, and 45s without (it was a modified test sequence tailored for that measurement, however "hmba" has the RingParam, so the whole difference come from the "dba" tests). There is nothing new there, it has always been like that, I just noticed it. Even when working on single cells, and may be even more, it's useful to create the RIngParam element (which by the way provides the So I agree, I'll remove the warning, but if you have ideas to recall users that it's beneficial, that would be nice. Forgot to say: the advantage of the warning is that it tells exactly what to do ! |
Can't we built an ring=atloadlattice(filename, matkey) function, similar to the one we have in python that would create this element? We may use it in instead of the native load() function |
That's the best solution. And then, try to convince users to use it instead of the usual |
Ok for the load functions. One line instead of 3-4 is better, and it is a single change, likely not perturbing the following code. I imagine that the loaded lattices would be defaulted to 4D? This could give troubles when loading optics tuned for off energy operation. May be RingParam could remember this feature. |
Concerning atlinopt dp input, I have no objection in having a warning that something is wrong, (it could even be further detailed with: please use atlinopt6). I do not understand why the wrong atlinopt+6D+dp output changed compared to previous versions of AT. The correct 6D optics are given by atlinopt6, why changing also atlinopt? |
Sorry, I did not read well the outputs of my test functions (thanks @carmignani ). The functions that give the warning and the wrong results are only atfittune atplot and atfitchrom. atlinopt is ok. |
This morning I did a git pull in this branch and I had a lot of conflicts in several files. I tried to solve the problems for about half hour, then I recloned the repository from zero. I thought it was only a problem of my local repository, but I see that Simone had a very similar problem just now, so maybe there is something wrong in the last commits. By the way, the new clone works well, so I don't understand what was the problem. |
Where do you get a warning ? |
Did you modify any file in your working directory? I don't understand what happened. But I also do not understand the 17 commits from me reported above. They look like old things, I did not work so much yesterday ! I hope everything is back to normal. |
Do I understand that rather than adding right now a "check_radiation" in That looks like a good way to diagnose and correct this problem step by step. In addition, the warning could be silenced, like what is done for "dp in 6D". |
@lfarv, |
@carmignani: don't worry, I could not interpret the messages, I'm not a git expert. I probably did something wrong, I don' know what, but a far as I could see, the repository is correct… |
Up to now, in linear optics computations based on
atlinopt6
,"dp"
could be set only for 4D lattices (so-called "radiation OFF"), since in 6D the off-momentum is fixed by the RF frequency.With this PR, setting
"dp"
inatlinopt6
is also allowed in 6D, by first making a copy of the lattice with a modified the RF frequency.This applies in turn to some other functions already based on
atlinopt6
:atplot
tunechrom
atfittune
atfitchrom
and will apply in future conversions to
atlinopt6
.This feature makes the behaviour for 6D lattices ("radiation ON") fully identical to to 4D.
Warning 1
This offers some new convenience, may cost extra computations: for a single call to
atlinopt6
(for instance), the time spent by:is identical to the one spent by:
But if several functions are called in a row with an identical
"dp"
value, the frequency change will be executed several times, leading to additional useless computations. Better setting explicitly the desired frequency once at the beginning.Warning 2
"dp"
is a keyword parameter (atlinopt6
for instance), the new feature is only applied if"dp"
is explicitly provided. Otherwise the lattice is left unchanged, as it is the case now."dp"
is a positional parameter, whenever possible it becomes optional and the same rule applies. This is the case foratplot
,tunechrom
,atfittune
,atfitchrom
. But it may happen when converting other functions toatlinopt6
that this is not possible, if the"dp"
argument cannot be distinguished from the next one. In that case, specifying'dp',[]
or'dp',NaN
will achieve the same result:"dp"
will be set to 0 in 4D or left unchanged in 6D. These special values are accepted is all functions.Warning 3
This behaviour is backward compatible with the previous one, with a minor difference:
in 6D, calling
atplot(ring, 0.0,srange)
used to ignore the 0.0 value. Now, it will effectively recompute the RF frequency to achieve 0.0, even it is was the case before. You must skip the"dp"
argument and callatplot(ring,srange)
to leavering
unchanged (see above). It's similar for the other functions.in 6D, you must skip the
"dp"
argument or set it to[]
orNaN
to leave the lattice unchanged. Otherwise, the specified value will be honoured, with additional computation, which anyway correct!Control
This feature is provided by a wrapper function
wrapper6D
which is called in all the previously mentioned functions. This allows to control the new behaviour with a global option, to disable it, enable it or enable it with a warning. This option and its default value is still to be defined.