Skip to content
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

Use the ct coordinate in the variable multipole pass method #532

Merged
merged 2 commits into from
Dec 5, 2022

Conversation

carmignani
Copy link
Member

The ct coordinate is now used to compute the variable multipole field when we use the SINE option.
Some check_error() were missing in the trackFunction and in the mexFunction.
A bug has been corrected in the mexFunction.

…SINE option. Bug corrected in the mex function.
@swhite2401
Copy link
Contributor

Looks ok to me, did you check that the sign was right?

Comment on lines 118 to 123
if(mode==0){
for(i=0;i<maxorder+1;i++){
pola[i]=get_pol(ElemA, ramps, mode, t+r6[5]/C0, turn, seed, i, periodic);
polb[i]=get_pol(ElemB, ramps, mode, t+r6[5]/C0, turn, seed, i, periodic);
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move the time computation out of the order loop:

            if(mode==0){
                 double tpart = t+r6[5]/C0;
                 for(i=0;i<maxorder+1;i++){
                     pola[i]=get_pol(ElemA, ramps, mode, tpart, turn, seed, i, periodic);
                     polb[i]=get_pol(ElemB, ramps, mode, tpart, turn, seed, i, periodic);
                 };
             };

And I think the sign is right.

Copy link
Contributor

@lfarv lfarv Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be rigorous and anticipate non-relativistic tracking, one would need at entry to the function:

    double beta0;
    if (Param->rest_energy == 0.0) {
        beta0 = 1.0;
    }
    else {
        double gamma0 = Param->energy/Param->rest_energy;
        double betagamma0 = sqrt(gamma0*gamma0 - 1.0);
        beta0 = betagamma0/gamma0;
    }

Param->T0 already takes β0 into account, so one just needs in the particle loop:

   double tpart = t+r6[5]/beta0/C0;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we include the fifth coordinate of each particle for the computation of beta?

Copy link
Contributor

@lfarv lfarv Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carmignani : you are right. In the non-relativistic_tracking branch, there is an modified RFCavityPass, which uses

    double betgami = betagamma0*(1.0 + r6[4]);
    double betai = betgami/sqrt(1.0 + betgami*betgami);
    double tau_rel = (r6[5]-el->TimeLag)/betai/C0;

This is almost correct. Correct for a cavity a position 0. But there is still a pending problem: cavities along the ring are synchronised with the reference particle (β0). So for a cavity at position s, one must subtract s/β0/C0 from the "absolute" time. For a particle with βi, in addition to the delay resulting from its path lengthening, one should add the time difference from coming for the origin to the cavity. I have not verified this and stopped working on non-relativistic tracking for some time.

So for now, I would say:

  1. Non-relativistic tracking is not yet working,
  2. I think we are dealing with low frequencies, and very small phase errors should not mater too much,
  3. For this element, there is not the same phasing condition related to the s position as for accelerating cavities.

So go on as it is (even possibly skipping the beta0 correction), we'll see later.

@carmignani
Copy link
Member Author

Looks ok to me, did you check that the sign was right?

I used the same sign used in RFCavityPass, so I think it is correct.

I would move the time computation out of the order loop

You are right. Are you doing it or I do it?

I missed the introduction of Param->rest_energy!

@lfarv lfarv added Matlab For Matlab/Octave AT code Python For python AT code labels Dec 1, 2022
@lfarv
Copy link
Contributor

lfarv commented Dec 1, 2022

@carmignani : Go on, Nicola.

For info: the whole infrastructure for non-relativistic tracking is there, but I have problems with RFCavityPass, so non-relativistic tracking does not work yet… However better keeping this in mind.

@lfarv lfarv merged commit 2b75a47 into master Dec 5, 2022
@lfarv lfarv deleted the VariableMultipole branch December 5, 2022 20:48
lfarv added a commit that referenced this pull request Dec 5, 2022
lfarv added a commit that referenced this pull request Dec 5, 2022
lfarv added a commit that referenced this pull request Dec 5, 2022
* thread rng in BndMPoleSymplectic4QuantPass and
StrMPoleSymplectic4QuantPass

* clang-format

* updated QuantDiffPass

* small fixes

* cleanup of rng functions

* updated from #532
@lfarv lfarv mentioned this pull request Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Matlab For Matlab/Octave AT code Python For python AT code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants