-
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
Cleanup Lattice and cavity access #316
Conversation
Other additions:
|
This looks good, I have question though: why are you storing the particle mass in Also variable names like |
in the help of atsetcavity I read:
is this intended? may be just a copy-paste. |
Laziness ! Still a few modules to update… I'll move them. Already 26 files changed, it makes reviewing tedious, but maybe a few more does not matter.
I prefer naming constants with short and commonly-used names. Using |
Well I often write |
I think this is right: if you describe one cell of a ring, it has to be self-consistent, so that you can track it independently. What AT sees, tracks and analyses is the "cell". The "ring" values are for convenience, because they are the ones commonly used (think of tunes, circumference, and indeed harmonic number). So you have: circumference_cell = circumference_ring/n_cells All relationships between these variables must apply on both cell and ring. To answer one of @swhite2401's question on the usefulness of the harmonic number, it's for instance useful to compute the nominal RF frequency. I admit that it could be an attribute of the lattice rather than RF cavity, |
Honestly, I find this Reading the new help of I understand |
if periodicity (or ncells) is 1, it sets the Harmonic number to HarmNumber. Is not it what you want ? I think you are misunderstanding the meaning of
It's not a question of speed. It just makes the description of periodic machines easier by describing only one cell and say "repeat it n times". Of course it may happen that periodicity is not properly taken into account in the code. The solution is to repair it, not to remove it. |
Dear @lfarv and @swhite2401 , I also find periodicity rather misleading. It is question 0 of everyone starting to use pyAT. What is periodicity? how to set it? answer is often: please set to 1 and forget about it. I personally fought with this feature also with AT1.* . I was allowed to work with a single cell, but I add to set unreal parameters for the harmonic number to get the correct parameters. Quite confusing, personally. I think that it is more user friendly, to let the user multiply is lattice by the relevant amount of cells to get a full ring. To allow to have computed parameters for a full ring starting from a single standard cell, I think that the suggestion of @swhite2401 to input periodicity in Those functions could have periodicity =1 and if need be, "autocompute" the number of cells from the angle, or use the user input. |
@swhite2401 and @simoneliuzzo : I'm really puzzled by your confusion ! Is there any ambiguity on the number of times you have to repeat your cell to get a full ring ? I don't see why! That's Is there any ambiguity on the harmonic number ? It's the ratio between the RF frequency and the revolution frequency of the ring. That's what you have to set as harmonic_number. Again, of you find how it can be better expressed, tell me. So where is the difficulty ? Anyway, if you don't like it, you both propose a way of working which is perfect legal : set periodicity to 1 and do all the scalings yourself. Why not, some of the rules are given above. Another way which is to describe a ring as the concatenation of n identical cells is also possible, by I find it too bad to multiply all the computation times (orbit, matrices, optics) by n, and loose on numerical errors. A factor 32, to take a well known example. That's not marginal ! But you can do it ! But you should not prevent users who want it to use it : you can easily choose the way you want to work. |
I do agree with @lfarv |
2 questions about
|
What you have at the moment is fine, still I think your implementation is not safe and cannot guaranty that clight (or other constants) are not overwritten. Providing we cannot declare constants in python I would strongly advocate for a naming convention that prevents interference with users scripts. |
Concerning That being said I will not insist on removing (or changing) it if you like it but please in the help/documentation write I may propose a simpler alternative for pyAT. |
You are right, but I think it's not worse than: from math import pi
pi=3.14 for those who consider 3 digits is enough, or from scipy.constants import c
c=2.998e8 which I think is even worse. |
Sure none of these are good but we may try to make it a bit safer by naming our constants I also found this (I haven't tried myself), but this could be a solution:
|
I have to admit I don't quite understand the problem with Even when you're doing something you probably should avoid, such as If I'm wrong on that, the suggestion of including only the
The variables should be kept as clear and simple as possible. |
@MJGaughran : if you really do So:
|
Done, unless I missed one… |
Ok fine by me, I have no royalist pretentions! And thanks for updating the help |
@lfarv I hope you don't mind, but your comment did intrigue me. I just tried the following snippet, and it does not change the value of
Changing the variable directly in I think keeping constants outside of the |
@MJGaughran, @swhite2401: I did another test, showing clearly what's happening:
I don't fully understand what's happening, it looks like importing makes a local copy of the module value. Reassigning the local variable breaks the link. Anyway, this shows that we are completely safe, that's nice. To be complete, typing: |
Perfect! |
This is done. I think we are now ready to merge. Any other comment ? |
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.
Ok for me
The Lattice object has new methods an properties:
and corresponding read-only properties:
The cavity access module is improved, particularly on frequency: it is possible to set the frequency to the "nominal" value, optionally specifying an off-momentum.
All this is now explained in a new page of the Web site. To allow previewing this page, the site is temporarily directed to this development branch. Please look at it, in particular to the frequency control, and give your comments, either on the code or on the documentation.
NB: I had to change the name of frequency controls, to clearly distinguish
revolution_frequency
andrf_frequency
. If this is not acceptable, I can revert to initial (frequency
in short).