-
Notifications
You must be signed in to change notification settings - Fork 33
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
Bug Fix: Wiggler diffusion matrix #759
Conversation
…s to initialize z position for every particle
Dear @swhite2401, I am currently cleaning up the code in Could I get some advice with this? Regards, Joan |
Hello @joanarenillas, Sorry for my late intervention, but I was away until now and just had a look to your proposal. There is already a git branch dedicated to the computation of diffusion matrices, called In short, the idea is to have the computation of diffusion matrices as modular as the tracking itself, so that introducing a new kind of element, including its contribution to equilibrium emittances, can be made by simply dropping a new C file in the Since the computation of diffusion matrices involves the tracking of the closed orbit through the element, a simple way is to add the diffusion as an optional computation in the integrator C file itself. For backward compatibility, we cannot change the signature of the integrator, so to indicate the need for the computation of the diffusion matrix, we added a new variable in the Existing integrators ignore this new variable, so are automatically considered as not contributing to diffusion. In the I think you should go directly to this new scheme by basing your working branch on For an example, look at From what I can see, your new
and to add a loop on particles for the "normal" tracking (of course, the computation of diffusion matrices is requested only with a single particle: the closed orbit). |
Hi @joanarenillas, @lfarv and @swhite2401, Besides Joan contributing to the diffusion_matrices branch, which I think it is a good idea, the present MR solves the #749 bug which I think is already a good reason to merge it, after your supervision of course. Best, |
Wigidx=find(Wig(:)==1); | ||
|
||
radindex(Wigidx) = false; % Erase wigglers from the radiative element list. |
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.
radindex = radindex & ~Wig
is more efficient and easier to understand
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.
Thanks for the comment, I'll change this.
atmat/atphysics/Radiation/FDW.c
Outdated
mex-function to calculate integrated radiation diffusion matrix B defined in [2] | ||
for wiggler elements in MATLAB Accelerator Toolbox | ||
O.Jimenez 3/08/18 |
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.
Has it really been initiated in 2018 ? You could mention your contribution…
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.
I will modify it and add my contribution to all files in the next commit.
Ok, no objection! I have a few comments:
Otherwise, for me we could merge this branch. Also, one should think soon of converting this to the new architecture for computation of diffusion matrices: #742. This branch was designed to integrate easily wigglers but also any future kind of element. Though apparently it did raise much interest since it was opened… |
atmat/atphysics/Radiation/FDW.c
Outdated
if(PR2) | ||
ATmultmv(orbit_in,PR2); |
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.
You should propagate the diffusion matrix through the rotation matrix. You are right that at input, propagating a zero matrix is useless, but I think here it should be done.
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, I see there is a diff_yrot.c
function in your branch that does the job. I will update that when adapting it to #742.
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.
Be careful, Yrot is a rotation around the Y axis. Here we are talking of a rotation around the Z axis. I think that the propagation consists just in applying the "ATsandwich" to the rotation matrix (R2).
Note that this is also missing in the present findmpoleraddifmatrix
. I found that while working on the new branch.
Dear @lfarv, Regarding your comments:
After this branch is merged, we are planning on adapting the computation of wiggler diffusion matrices of this branch to #742, so that wigglers are easily integrated. Regards, Joan |
atmat/atphysics/Radiation/FDW.c
Outdated
if(T2) { | ||
ATaddvv(orbit_in,T2); | ||
ATsandwichmmt(T2,BDIFF); | ||
} |
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.
T2 is not a 6x6 transfer matrix, it's a vector ! You cannot send it to ATsandwichmmt
. Did you try and check the result ? It should crash…
A translation has no effect on beam matrices. There is nothing to do to BDIFF.
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 is right. It is now corrected.
I have no more comment. I am not able to appreciate the correctness of the result, I'll trust you . If @ZeusMarti and you are confident that everything is now correct, I can approve and merge, but if you have further validation to do, let me know. |
Dear @lfarv, We are currently working on a benchmark to test our results. We hope to complete it soon. Once we have it, we will let you know the results so you can approve and merge. Regards. |
Dear @lfarv, We are having difficulties in completing the benchmark for the new set of integrators, since the particle dynamics are more complex than we anticipated. We have tried solving the Lorentz equation including energy loss (gamma factor is not constant) and taking into account the Abraham-Lorentz force. Nevertheless, the results we obtain are not 100% consistent. Regarding the references on the Hessian matrices, we have not managed to get any from @mashl, who initially did the computation. I have however reviewed and summarised his calculation in a report which I am happy to share with you if its is of your interest. I have also included some documentation on the wiggler passmethods as you suggested. Although the benchmark is not yet finished, I think it is still worth merging this branch, since it fixes many reported bugs with these passmethods, and includes the diffusion matrix computation for the wiggler. Moreover, the tracking in the new passmethods do not introduce significant deviations from the current version (they are smaller than 10^(-8) m). My internship period at ALBA will finish soon and @ZeusMarti will take over from now. Kind regards, Joan |
I agree with the merge, this is a major improvement. However, before that it would be nice to add simple unit tests. |
Hello @swhite2401, The report will be available online in the following weeks after it is reviewed by the ALBA accelerator's team. |
Hi @swhite2401, by "unit tests" you mean adding an additional test definition in at/pyat/test? What kind of check do you have in mind? a tracking result through the element with and without radiation could be enough? |
Sorry for the delay, Joan left in July and then I went on vacations. We spend the last days trying to bench mark the integrators with a Runge Kutta tracking. This was promising at first but finally we were not able to make it precise enough to be sure that the modification in the radiation kicks formula was better so I just removed the modification in the previous commit. Joan wrote a note that is still being corrected (sorry, we are quite busy with the upgrade simulations). Unfortunately ALBA has now no way to publish open access documentation, is there any interest for us to publish it in arxiv (or similar) once we go though it in detail? Without this modification this branch represents just a couple of bug corrections so I think it is totally save and necessary to merge. @swhite2401 @lfarv , any comment before I merge it? |
@ZeusMarti , this is fine for me, I trust you with the calculations. It is also interesting to merge it now, in this way @lfarv can potentially integrate it in #742 |
Yes, I guess this has implications for #742, the wiggler has its own diffusion matrix calculation included in this PR in function FDW.c. |
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 I approve, I trust you on this one
Dear all,
This is an ongoing Work In Progress, which aims to correct some bugs found in
GWigSymplecticPass.c
andGWigSymplecticRadPass.c
, as well as updatinggwigR.c
andohmienvelope
to include the computation of wiggler diffusion matrices. To do so, a new function (FDW.c
) is currently being developed, following the work of @mashl.More on current and past issues on wiggler passmethods can be found in #715 and #749.
No need to review yet.