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 & Update: Wiggler diffusion matrix #759
base: master
Are you sure you want to change the base?
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 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.