Page 1 of 2

Optimising Phase Advance - error

Posted: 25 Jun 2018, 05:58
by jgarland
Hi,

I am quite new to Elegant, so I'm still learning. I am trying to optimise a set of quads to realise a given phase advance between two points. I use the following "optimisation_setup":

&optimization_setup
mode = "minimize", method = "simplex",
target = 0,
tolerance = 1e-12, n_passes = 2, n_evaluations = 10, n_restarts = 5, log_file = "/dev/tty",
output_sparsing_factor = 10
log_file = log
&end

A typical "optimization_variable" looks like:

&optimization_variable name = Q1, item=K1, step_size = 0.01, lower_limit = -35, upper_limit = 35, force_inside=1 &end

And a troublesome "optimization_term" looks like:

&optimization_term term = "E2#1.psix E1#1.psix - abs 0.5 - sqr" &end

The problem I have is the following error is given when I run elegant (terminal output):

unknown token: E1#1.psix
unknown token: E2#1.psix
too few items on stack (subtract)
*stop*
too few items on numeric stack (less)
too few items on logical stack (conditional_udf)
*stop*
too few items on stack (subtract)
*stop*
Problem evaluating expression: ENDUBC3#1.psix ENDMBC2#1.psix - abs 0.5 - sqr
RPN expression errors prevent optimization

I have checked and double checked that I haven't made a mistake in the .lte file, the element names are correct. I have a twiss_output definition and I have checked the .twi file when i run without optimisation, the psix variable is contained within it. Can you help?
Cheers,
Jimmy

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 06:35
by Neeraj
Not sure if this helps, but do you have output_at_each step=1 under &twiss_output ?

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 07:08
by jgarland
Hi Neeraj,

Thanks for your reply. Yes I do, it is set to =1.

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 08:19
by michael_borland
Jimmy,

To match phase advance, use <elementName>#<occurence>.nux or .nuy, rather than .psix and .psiy. nux = psi/(2pi).

--Michael

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 08:23
by jgarland
Hi Michael,

Yes I also tried this (as per the other thread in the forum) but it throws the same error.

I am also a little bit confused as to why nux or nuy would be used in the case of a linac (in my case); surely they are relevant only for circular, or simply periodic machines where the tune can be calculated? Shouln't the phase advance be a more relevant parameter to use for a linac?

Cheers!

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 09:19
by michael_borland
Jimmy,

Do your MARK elements have FITPOINT=1 in the definition?

--Michael

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 09:21
by jgarland
Yes they do, they looks something like this:

E2: MARK, FITPOINT=1

Cheers,
Jimmy

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 09:23
by michael_borland
Jimmy,

Can you upload an example? What you are doing should work.

By the way, using psi or nu is equivalent. Even for linacs and transport lines, some people find it easier to think in terms of the phase advance normalized to 2*pi.

--Michael

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 09:36
by jgarland
It is a long, long lattice definition given to me by others, I think it would be hard to wade through it (for sure I'm having trouble!). In order not to waste anymore time (seeing as there isn't a quick/easy answer) I'm going to build a small example from scratch to work out the problem. I will report back the issue. Do you think this is best?

Thanks,
Jimmy

Re: Optimising Phase Advance - error

Posted: 25 Jun 2018, 09:37
by michael_borland
Jimmy,

Absolutely, a compact example that shows the problem is best. Thanks.

--Michael