-
Notifications
You must be signed in to change notification settings - Fork 34
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
Atavedata #678
Conversation
…polynom(2) and displacement errors in sextupoles, rotated quadrupoles). Also dipole edge focusing effects have been included.
Hello @ZeusMarti , this looks nice should we add this to the python too? |
Hi @swhite2401, sure, I can take care of it but I'm not python fluent and we are quite busy with alba-II, it can take some time. Don't take me wrong, I would be happy, for me it would be good a way to force myself to get more familiar with pyat. If you don't feel like waiting for me to go through the exercise please feel free to add the changes yourself. |
No rush! If you want to train yourself it is very good! Let me know in case you would need any help! |
Results look nice. Concerning the code, please look at the review above ! |
Sorry Laurent, I do not see the review! |
Dear @lfarv , neither I see your reviews or requests. |
atmat/atphysics/atavedata.m
Outdated
function avebeta=betadrift(beta0,alpha0,L) | ||
gamma0=(alpha0.*alpha0+1)./beta0; | ||
avebeta=0.5*(beta0+beta1)-gamma0.*L.*L/6; | ||
avebeta=beta0-alpha0.*L+gamma0.*L.*L/3; | ||
end | ||
|
||
function avebeta=betafoc(beta1,alpha0,alpha1,K,L) | ||
gamma1=(alpha1.*alpha1+1)./beta1; | ||
avebeta=0.5*((gamma1+K.*beta1).*L+alpha1-alpha0)./K./L; | ||
function avebeta=betafoc(beta0,alpha0,K,L) | ||
gamma0=(alpha0.*alpha0+1)./beta0; | ||
avebeta=((beta0+gamma0./K).*L+(beta0-gamma0./K).*sin(2.0*sqrt(K).*L)./sqrt(K)/2.0+(cos(2.0*sqrt(K).*L)-1.0).*alpha0./K)./L/2.0; | ||
end |
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.
Why did you change the average beta functions: using final values gives simpler (and faster) expressions. These are analytically correct.
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 issue 399, using final values diverges for small K values.
Hi @ZeusMarti and @oscarxblanco. Is it better now? I was confused because for me it appears in the conversation… Sorry. |
Dear @lfarv , yes. Now the review is visible to me. |
pyat/at/physics/linear.py
Outdated
L = numpy.array([el.Length for el in ring_selected]) | ||
K = numpy.array([get_strength(el) for el in ring_selected]) | ||
sext_strength = numpy.array([get_sext_strength(el) for el in ring_selected]) | ||
roll = numpy.array([get_roll(el) for el in ring_selected]) | ||
ba = numpy.array([get_bendingangle(el) for el in ring_selected]) | ||
e1 = numpy.array([get_e1(el) for el in ring_selected]) | ||
Fint = numpy.array([get_fint(el) for el in ring_selected]) | ||
gap = numpy.array([get_gap(el) for el in ring_selected]) | ||
dx = numpy.array([get_dx(el) for el in ring_selected]) |
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.
sext_strength
, roll
and dx
are not used anywhere, apparently
pyat/at/physics/linear.py
Outdated
ClosedOrbit=lindata.closed_orbit.copy() | ||
|
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.
ClosedOrbit
is not used
@ZeusMarti : I get more that 100 warnings about code not respecting PEP8. Most of them are:
You should use an IDE which warns about that (ex. PyCharm or VSCode) |
@lfarv , I implemented your last comments. I realized that I have not properly tested it adding magnet movements, rolls and closed orbit errors, I'll do it after holidays. Also, the code logic is a bit cumbersome, there are different behaviors for thin or long, focusing or not, drifts. Any suggestions on how to make it more clear? Maybe it just needs more comments? |
Agreed, but since you are at the moment the most familiar with this code, go on… My only concern is about the "epsilon" trick for the focusing strength. Is not it possible to correctly treat the 0-strength quadrupoles?
Excellent ! |
Hi @lfarv, I'm sorry I have not been able to advance much, however I noticed a peculiar behaviour of the function, both in Matlab and python in the master branch and this branch. Since the input parameter refpts is used only to create a bolean array, if refpts is not sorted that information is lost in the calculation and the results are given always assuming a sorted order. It was the cause of some trouble for me so I'm wondering if this behavior should be kept. We could simply unsort the arrays at the end or alternatively generate a warning in case of non sorted refpts and output the sorted refpts. Which is your opinion on this? |
Hi @ZeusMarti : the
The problem is that it would be difficult (and time consuming) to check the validity of Now, for this PR, it's up to you ! |
Ah, sorry! My bad. Then I see no point in implementing a different behavior for atavedata.m. hopefully I can address the final details of this PR shortly. |
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.
That looks very good! Any comment, @swhite2401?
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.
All good for me
Everyone looked happy with this, so I merge |
The file has been changed to:
This tries to solve issue #399