Optimizing statistical Twiss parameters using quads

Moderators: cyao, michael_borland

Post Reply
Björklund
Posts: 84
Joined: 19 May 2016, 07:14

Optimizing statistical Twiss parameters using quads

Post by Björklund » 26 Jul 2017, 11:46

Hi,

I'm wondering if there is a way to optimize the statistical (i.e. calculated from the beam particle distribution) Twiss functions using, say, quadrupoles. I didn't find anything in the Final output file and I tried just using the variable name from the Sigma output file (betaxBeam, etc.), but just got the error "RPN expression errors prevent optimization", so I guess that it doens't work.

The reason I'm wondering is because I have a beam where these statistical Twiss functions don't match the "nominal" ones given by starting parameters and the lattice. The discrepancy seems to come from emittance growth in bunch compressors and energy spread and such, but I would like to match the average Twiss parameters of the actual beam to certain values at a specified location using a quad matching section.

Is there a way to do this?

Best regards
Jonas

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Optimizing statistical Twiss parameters using quads

Post by michael_borland » 13 Sep 2017, 10:38

Jonas,

Sorry for the late reply; I just saw this one.

The best way to do this is to determine the betax, alphax, etc for the beam and use those as the initial values in the &twiss_output command. You can then optimize the quadrupoles to match to the desired twiss parameters at the end of the beamline. sddsanalyzebeam can give you the lattice functions for the beam (use the -correctedOnly option).

If you really need to use tracking, then the final beam beta functions can be expressed in terms of the beam moments.

--Michael

Björklund
Posts: 84
Joined: 19 May 2016, 07:14

Re: Optimizing statistical Twiss parameters using quads

Post by Björklund » 21 Jan 2018, 05:49

Hi Michael,

Now it is my turn for a late reply :)

So, after some time trying other things, I found myself returning to this idea. I tried canceling chromatic derivatives and such to make the lattice first-order apochromatic (as defined in C. A. Lindstrøm and E. Adli, Phys. Rev. Accel. Beams 19, 071002), but since I have some sections with RF elements in them, where the energy spread changes over distance, that did not turn out to give the expected results for all sections. My situation is that I have a beam which receives a rather large energy spread during transport, which makes the twiss functions vary over the bunch length. This makes matching quite difficult.

Could you give me an example of how to implement the alpha and beta functions for use in an optimization_term, using the beam moments? I found the slice_analysis function, which I'm using (with one slice to get the beam average) to enable the normalized emittances for optimization. Would it be possible for you to add the Twiss functions to the final (.fin) output file, which I assume is the one to use for this purpose?

Also, I'm using a bunched_beam with 1000 particles now, but that gives quite poor statistics, so I'd like to use more particles. However, using something like 5000, or more, particles causes the optimizer to crash with the message "Terminated by SIGSEGVProgram trace-back:".

I am now using a generated input beam for my proper tracking as well, which has uniform slice Twiss parameters, but I would like to use a proper Astra simulation, which will then have some pre-existing slice variation, and I would like to cancel this to as large an extent as possible at the end of my first section. I tried tracking with an sdds_beam, but that wasn't possible - the program started running but just crashed without an error message. Is this a feature, or am I doing something wrong?

A lot of stuff at once, I know, but I'd really appreciate some input.

Best regards
Jonas

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Optimizing statistical Twiss parameters using quads

Post by michael_borland » 22 Jan 2018, 09:24

Jonas,

This can be done using the beam moments at the end of the beamline, which are computed irrespective of slice analysis. See the attached files.

--Michael
Attachments
trackingBasedMatching.zip
(1.32 KiB) Downloaded 251 times

Björklund
Posts: 84
Joined: 19 May 2016, 07:14

Re: Optimizing statistical Twiss parameters using quads

Post by Björklund » 22 Jan 2018, 14:28

Hi Michael,

So I implemented the optimization and generation of bunched_beam they way you did it in the file (plus Po, sigma_dp and sigma_s), and it seems to be working a bit better better. Have tried with 5000 particles now and it ran for a long while, but it eventually crashed in the same way as before. I'm running v 34 on Windows, could this be some weakness in the Windows distribution compared to the Linux version? Since it crashes, the partial optimization progress is unfortunately also lost, soft_failure = 1 appears to not catch this one.

About the tracking with sdds_beam instead, is that at all possible? It would be very nice if I could somehow use a simulated Astra file as input for the optimizer, once I get the bunched_beam optimization going properly.

Best regards,
Jonas

michael_borland
Posts: 1933
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Optimizing statistical Twiss parameters using quads

Post by michael_borland » 22 Jan 2018, 14:31

Jonas,

It shouldn't matter if you use bunched_beam or sdds_beam. Can you upload (or email borland "at" aps.anl.gov) an example so I can try to replicate the crash?

Also, to run faster, use Pelegant.

--Michael

Björklund
Posts: 84
Joined: 19 May 2016, 07:14

Re: Optimizing statistical Twiss parameters using quads

Post by Björklund » 23 Jan 2018, 05:30

Hi Michael,

I just e-mailed my files to you, hopefully they don't end up in your spam folder :)

Best regards
Jonas

Post Reply