Implementing chromatic amplitude as an optimization term
Moderators: cyao, michael_borland
Implementing chromatic amplitude as an optimization term
Hi,
So, I'd like to use the chromatic amplitudes Wx and Wy at the end of my beamline for optimization, but I can't get the code to run when I do so, probably because I'm not implementing it correctly. I have checked with some online tool that the equation itself should be correct, so it probably comes down to understanding the input wrong.
As an example, I want to optimize Wx and write it like this:
&optimization_term term = "sqrt dalphax/dp alphax betax / dbetax/dp * - 2 ^ 1 betax / dbetax/dp * 2 ^ + 5 1e-6 segt", weight = 1, &end ! Wx
This results in the code loading everything without errors and then crashing after "starting" the last element of the beamline. I guess the problem lies in the expression within the quotation marks, but I want to match alpha and beta at the same time, so I can't use the equation in "optimization_setup".
Any help would be appreciated
Best regards
Jonas
So, I'd like to use the chromatic amplitudes Wx and Wy at the end of my beamline for optimization, but I can't get the code to run when I do so, probably because I'm not implementing it correctly. I have checked with some online tool that the equation itself should be correct, so it probably comes down to understanding the input wrong.
As an example, I want to optimize Wx and write it like this:
&optimization_term term = "sqrt dalphax/dp alphax betax / dbetax/dp * - 2 ^ 1 betax / dbetax/dp * 2 ^ + 5 1e-6 segt", weight = 1, &end ! Wx
This results in the code loading everything without errors and then crashing after "starting" the last element of the beamline. I guess the problem lies in the expression within the quotation marks, but I want to match alpha and beta at the same time, so I can't use the equation in "optimization_setup".
Any help would be appreciated
Best regards
Jonas
-
- Posts: 1933
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Implementing chromatic amplitude as an optimization term
Jonas,
Your expression seems to be a mixture of RPN and algebraic notation. Try this
The attached file gives an example.
--Michael
Your expression seems to be a mixture of RPN and algebraic notation. Try this
Code: Select all
&optimization_term term ="dbetax/dp betax / sqr alphax betax / dbetax/dp * dalphax/dp - sqr + sqrt 5 1e-6 segt" &end
--Michael
- Attachments
-
- chromaticAmplitudes.zip
- (2.66 KiB) Downloaded 175 times
Re: Implementing chromatic amplitude as an optimization term
Hi Michael,
Your suggestions seems to be running just fine, thanks!
However, I can't open the example file - my browser saves it as a .php file, which can't be unzipped or opened properly. I can only see short fragements of actual text in a big mess of other symbols. Maybe it doesn't matter, since the line you wrote works.
//Jonas
Your suggestions seems to be running just fine, thanks!
However, I can't open the example file - my browser saves it as a .php file, which can't be unzipped or opened properly. I can only see short fragements of actual text in a big mess of other symbols. Maybe it doesn't matter, since the line you wrote works.
//Jonas
-
- Posts: 1933
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Implementing chromatic amplitude as an optimization term
Jonas,
Sorry about the download problem. Maybe if you rename it to a .zip file, it will work?
--Michael
Sorry about the download problem. Maybe if you rename it to a .zip file, it will work?
--Michael
Re: Implementing chromatic amplitude as an optimization term
Hi,
No worries, I expected the problem to be on my end, which it was. I had to manually enter a name and file extension for it to save properly, then it worked.
Thanks
//Jonas
No worries, I expected the problem to be on my end, which it was. I had to manually enter a name and file extension for it to save properly, then it worked.
Thanks
//Jonas
-
- Posts: 1933
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Implementing chromatic amplitude as an optimization term
Jonas,
We are trying to track this down, since others have reported similar problems but we have trouble replicating it. Can you provide the following information? OS and version, browser and version, and IP address.
You can email it to me (borland "at" anl.gov) if you prefer.
Thanks!
--Michael
We are trying to track this down, since others have reported similar problems but we have trouble replicating it. Can you provide the following information? OS and version, browser and version, and IP address.
You can email it to me (borland "at" anl.gov) if you prefer.
Thanks!
--Michael
Re: Implementing chromatic amplitude as an optimization term
Hi Michael,
I emailed you the info.
Going back on-topic: The program did run with your expression, but something is not correct. I tried running the optimization with target values for beta, alpha and W, for x and y, that I got for the same lattice in MAD-X, and I expected the optimizer to finish immediately, since the target values should be met exactly. This did not happen.
Can I somehow exit the program during a run and see the optimization function evaluations? I don't know where to look for the values of these terms at the moment, I'd like to check if that expressions yields a reasonable/expected value. I have close to 0 experience with rpn expressions and the like, so I can't really tell much from the expression in the optimization file.
Best regards
Jonas
I emailed you the info.
Going back on-topic: The program did run with your expression, but something is not correct. I tried running the optimization with target values for beta, alpha and W, for x and y, that I got for the same lattice in MAD-X, and I expected the optimizer to finish immediately, since the target values should be met exactly. This did not happen.
Can I somehow exit the program during a run and see the optimization function evaluations? I don't know where to look for the values of these terms at the moment, I'd like to check if that expressions yields a reasonable/expected value. I have close to 0 experience with rpn expressions and the like, so I can't really tell much from the expression in the optimization file.
Best regards
Jonas
Re: Implementing chromatic amplitude as an optimization term
To comment on my own comment: I discovered that it was only when running parallel optimization that my output file (just the output of the cmd prompt) didn't show the optimization terms, they were indeed there when I ran it in serial mode.
Re: Implementing chromatic amplitude as an optimization term
Hi again,
So, more questions:
I was able to use the chromatic derivative terms to get where I wanted with a part of the lattice that had no accelerating elements, but now I'm trying to do the same thing in a section that has rfcw elements. I'm matching alpha, beta and their respective chromatic derivatives, in both planes. This seems to be behaving a bit oddly - the first few runs, the optimizer stated that the optimization equation terms were all equal to 0, but when looking at the actual values of all input terms, they were far from the specified values.
This seemed to solve itself somehow and it was okay for a little while, but now I'm getting only "-nan(ind)" on the chromatic derivatives, and a few other entries, in the twiss output file (but alpha and beta are correct). I didn't change anything except the tolerances for the optimization equation terms to refine my values.
Any idea what could be wrong here? I could email some of my files if needed.
EDIT 2018-12-18: So, it seems that I can run the optimizer for a while, which varies from run to run, without getting the NaN values. Sometimes, it ends after not so long and with the optimization function at some rather high value, with the chromatic derivative terms all 0 and the regular twiss terms non-zero (and sometimes large). When I look at the output file for these runs, I have the -nan(ind) entries in the twiss file, and I can't re-run the optimization result file, because it just "converges" immediately to the same result.
//Jonas
So, more questions:
I was able to use the chromatic derivative terms to get where I wanted with a part of the lattice that had no accelerating elements, but now I'm trying to do the same thing in a section that has rfcw elements. I'm matching alpha, beta and their respective chromatic derivatives, in both planes. This seems to be behaving a bit oddly - the first few runs, the optimizer stated that the optimization equation terms were all equal to 0, but when looking at the actual values of all input terms, they were far from the specified values.
This seemed to solve itself somehow and it was okay for a little while, but now I'm getting only "-nan(ind)" on the chromatic derivatives, and a few other entries, in the twiss output file (but alpha and beta are correct). I didn't change anything except the tolerances for the optimization equation terms to refine my values.
Any idea what could be wrong here? I could email some of my files if needed.
EDIT 2018-12-18: So, it seems that I can run the optimizer for a while, which varies from run to run, without getting the NaN values. Sometimes, it ends after not so long and with the optimization function at some rather high value, with the chromatic derivative terms all 0 and the regular twiss terms non-zero (and sometimes large). When I look at the output file for these runs, I have the -nan(ind) entries in the twiss file, and I can't re-run the optimization result file, because it just "converges" immediately to the same result.
//Jonas
-
- Posts: 1933
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Implementing chromatic amplitude as an optimization term
Jonas,
I'm not sure I understand the problem, so if you could send me the files, it would help.
--Michael
I'm not sure I understand the problem, so if you could send me the files, it would help.
--Michael