Page 1 of 1

RPN expression error

Posted: 12 Apr 2024, 02:54
by weijie
Hi Michael:

I am using optmizization to do matching in a transportation line. But at the &optimization_term section, the expression of the given function do not work well, saying:
unknown token: M2.betax
too few items on stack (divide).

I am currently using the release posted at Sep 13 2023 04:37:07. Here are the files.

Best
Weijie Fan

Re: RPN expression error

Posted: 19 Aug 2024, 11:51
by michael_borland
Weijie,

You need to use "M2#1.betax" instead of "M2.betax". The reason is that elegant allows multiple instances of the marker M2 in the beamline, so you have to tell it which one to use (even when there is in fact only one).

Another problem is here:

Code: Select all

&optimization_term
term = "20 betax betay - sqr + ", weight=1.0
term = " M2#1.betax 20 1e-6 selt 2", weight=1.0
&end
where you've given two values for the term parameter. Only the second will be used. In this case, the term given will evaluate to a constant value of "2". If you just want a barrier function that limits betax to 20, remove the "2".

Also, I suggest you add

Code: Select all

&global_settings
        tracking_matrix_points = 5
&end
at the top of the .ele file. This will reduce the number of particles used for tracking-based matrix determination, which will make the run faster. Since you are only optimizing linear properties, this would be good enough.

--Michael