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

Fix problems with transfer line mode #342

Merged
merged 3 commits into from
Jan 6, 2022
Merged

Fix problems with transfer line mode #342

merged 3 commits into from
Jan 6, 2022

Conversation

lfarv
Copy link
Contributor

@lfarv lfarv commented Dec 28, 2021

The transfer-line mode of linopt* has some problems:

  • in Matlab, the initial orbit is not correctly taken into account (pointed out by @simoneliuzzo)
  • in 6D, the initial dispersion is not correctly reproduces (both Matlab and python)

Both are fixed in this pull request.

@simoneliuzzo
Copy link
Contributor

Dear @lfarv and @swhite2401,

thank you for this fix!

It works when using atlinopt6.

if I keep my script unmodified and use atlinopt, it gives this error.

Screenshot 2022-01-04 at 08 12 54

when I block the script at that line here is the size of the orbitin variable:

Screenshot 2022-01-04 at 08 08 58

in case this is an intended feature, then I would suggest modifying the help of atlinopt as well, for example triggering an error when computing transfer line optics, saying, please use atlinopt6, and giving ad example of "conversion"
use:
[a,twi] = atlinopt6(THERING,ind);
instead of:
THERING =atradoff(THERING);
twi = atlinopt(THERING,0,ind);

I also noted a 10* in the code for the vertical emittance (line 260 of linear.py). This is may be dangerous? I think about my lattices with errors, would I get all time 10 times larger vertical emittance?

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

@simoneliuzzo : You are still running atlinopt with radiation on ! Its output is 4D, and you enter it a 6D processing, so the dimensions are wrong. The test preventing the use of atlinopt with radiation ON is ready since long, just waiting for you ! The foreseen error message will mention atlinopt6 as a possible workaround.

@simoneliuzzo
Copy link
Contributor

Hi Laurent,

I tried to add an atradoff line, but the message is still the same, dimensions not ok.

atplot transferline mode is working only with 6D-radiation-on-atlinopt6 optics? What about transferlines?

where can I try the test that you mention? There is a branch for it probably.

Indeed this radiation-atlinopt-atlinopt6 combos are rather hard to get to my simple user mind, I never get the correct combination!
If I get it correctly, the message is: never use atlinopt again, use atlinopt6. May be we could add a deprecation message to annoy lazy/messy users as me?

thank you!

best regards
Simone

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

@simoneliuzzo: Concerning your last sentence, you are basically right: it's usually better now to use atlinopt6. atlinopt may still be used if you are interested in the Sagan/Rubin formalism for H/V coupling. In this respect it is not "deprecated", but I can add a sentence in the help recommending atlinopt6 for general purpose.

But keep in mind that dispersion and β-functions are 2D notions. Even if atlinopt6 can deal with radiation ON by kind of "annihilating" the longitudinal motion to extract them, you get the same results (except closed orbit effects) faster by switching radiation OFF. atlinopt6 with rad. OFF is slightly faster than atlinopt, but with rad. ON it is significantly slower.

Concerning transfer lines:

  • The twiss_in data has to be generated with the right "dimension": 4x4 without radiation, 6x6 with radiation. So you must use the same mode to produce the data and to enter it at the entrance of the transfer line (even with atlinopt6).
  • There may still be problems using atlinopt data in atlinopt6 input or vice-versa, because of the different formalism. The point you mention comes from different dimensions of the closed orbit (4x1 or 6x1). I'll solve this one, and try to get simple cases (no H/V coupling) work. But it will never be perfect.

@simoneliuzzo
Copy link
Contributor

Dear Laurent,
since this pull request acts on atplot, (somehow) I am facing an other small problem. The field ElemIndex in the lindata structure is missing.
Calls such as atplot(ring,@plotWdispP) and atplot(ring,@plB0curlyh) are failing with this error: Unrecognized field name "ElemIndex".
thank you for your help!
ciao
Simone

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

I also noted a 10* in the code for the vertical emittance (line 260 of linear.py). This is may be dangerous? I think about my lattices with errors, would I get all time 10 times larger vertical emittance?

No problem, these numbers are arbitrary. The sum of R-matrices is necessary to extract the Eigen vectors. The arbitrary "emittance" get out as Eigen values, which are ignored.

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

Calls such as atplot(ring,@plotWdispP) and atplot(ring,@plB0curlyh) are failing with this error: Unrecognized field name "ElemIndex".

I do not get this error. Am I missing something?

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

Now, with radiation OFF, the test_da_elettra test runs with either atlinopt or atlinopt6.

@simoneliuzzo
Copy link
Contributor

Calls such as atplot(ring,@plotWdispP) and atplot(ring,@plB0curlyh) are failing with this error: Unrecognized field name "ElemIndex".

I do not get this error. Am I missing something?

I do not know.
here a picture
Screenshot 2022-01-04 at 18 11 12

@lfarv
Copy link
Contributor Author

lfarv commented Jan 4, 2022

You must be in a wrong branch: neither master nor fix_twiss_in have this line !

@simoneliuzzo
Copy link
Contributor

You must be in a wrong branch: neither master nor fix_twiss_in have this line !

You are right Laurent! the branch is correct, actually the whole path is different. This is an ESRF based issue (computing cluster home not equal to the standard site user home). sorry for spamming.

This branch works also for me, both with atlinopt and atlinopt6.

@simoneliuzzo
Copy link
Contributor

I have not looked at the python version

@lfarv lfarv merged commit 06d0cc7 into master Jan 6, 2022
@lfarv lfarv deleted the fix_twiss_in branch January 6, 2022 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants