Optimizing the quadrupole strengths

Moderators: cyao, michael_borland

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Optimizing the quadrupole strengths

Post by Neeraj » 06 Jun 2018, 11:26

Dear All,

I am very new to elegant, and basically have zero experience with optimization procedures. I fear this question is going to be very basic.

I am trying to find the optimum K1 values for a simple doublet transport for MeV range protons. I am trying to minimize Sx and Sy by optimizing K1 for both the quad. And all the lengths involved are fixed. However, I think there is something fundamentally wrong in what I am doing here, because when I change the p_central_mev value, the optimum K1 values do not vary. In the end, I want to find the K1 combination that produces the smallest spot at 40cm from the second quad. Can any of you tell me what am I doing wrong?

Thanks
Neeraj
Attachments
transport.lte
quadrupole doublet
(391 Bytes) Downloaded 444 times
template.ele
optimization
(1.85 KiB) Downloaded 473 times
-Neeraj

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

Re: Optimizing the quadrupole strengths

Post by michael_borland » 06 Jun 2018, 19:49

Neeraj,

You shouldn't expect the results to depend on p_central
  • K1 doesn't depend on momentum, since it is a geometric quantity.
  • You've specified the initial *geometric* emittance. If you specified initial normalized emittance, you'd see a difference as p_central is changed.
I modified your .ele file to work better. Look for "!!!" to see the places I've changed.

--Michael
Attachments
transport.ele
(2.03 KiB) Downloaded 545 times

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Re: Optimizing the quadrupole strengths

Post by Neeraj » 08 Jun 2018, 03:59

Hi Michael,

Thanks a lot for the quick response. At some point I started to consider K1 to be the gradient. Also thank you very much for the corrections and comments. Helped me a lot to understand the procedure.

-Neeraj
-Neeraj

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Re: Optimizing the quadrupole strengths

Post by Neeraj » 11 Jun 2018, 10:14

Michael,

I see that using 'simplex' method, the optimized values differ as I vary the initial values of K1s. Is there a way to overcome this and get better values for K1s for the smallest beam size, regardless of their initial values?

I am using the lattice obtained from optimization to track a beam through the quads. However, after focusing I get a larger beam spot than I started with! :?

thanks
-Neeraj
-Neeraj

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

Re: Optimizing the quadrupole strengths

Post by michael_borland » 12 Jun 2018, 08:06

Neeraj,
I see that using 'simplex' method, the optimized values differ as I vary the initial values of K1s. Is there a way to overcome this and get better values for K1s for the smallest beam size, regardless of their initial values?
There can be several reasons for this. For example, the solution may not be unique, or it may not have fully converged. Try reducing the tolerance value in the &optimization_setup command.
I am using the lattice obtained from optimization to track a beam through the quads. However, after focusing I get a larger beam spot than I started with! 
That suggests that you aren't loading the lattice from optimization. You should use &save_lattice to save the lattice, then use the saved lattice in your new &run_setup command. E.g.,

Code: Select all

...
&optimize &end

&save_lattice filename = lattice.new &end

&run_setup
lattice = lattice.new
...
&end

...
If you continue to have problems, please upload the files and I'll take a look.

--Michael

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Re: Optimizing the quadrupole strengths

Post by Neeraj » 12 Jun 2018, 09:46

Michael,
Thanks for the reply.
I am using the optimized lattice generated using save_lattice. When I look at the beam sizes on watchpoints at the start and end of the beamline, I see that the final spot is significantly bigger. Please find the files attached and help me figure out the mistake.
Attachments
DoubletTest.tar.gz
(1.72 KiB) Downloaded 385 times
-Neeraj

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

Re: Optimizing the quadrupole strengths

Post by michael_borland » 12 Jun 2018, 13:08

Neeraj,

I think the problem is that you only have two quadrupoles. Since the x and y beam parameters are pretty similar at the beginning of the beamline, it is not possible to focus them both to a small value at the end. For this, you need a triplet. I tried it and it worked quite well.
triplet.png
There were also a few other issues with your files.
  • Didn't set N_KICKS value on the KQUAD elements. The default is often too small, so I set this to 20.
  • WATCH elements in the beamline slow down optimization, so I disable them.
  • Didn't set one_random_bunch=1 on the &optimization_setup command, which can confuse the optimizer.
See attached (look for "!!!" in the files to see my changes).

--Michael
Attachments
TripletTest.tar.gz
(1.58 KiB) Downloaded 448 times

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Re: Optimizing the quadrupole strengths

Post by Neeraj » 19 Jun 2018, 07:08

Michael,

Sorry to bother you again with a similar issue, but I am really lost here.

Although it functions fine with the &buched_beam namelist, I am having troubles trying to get the optimization and tracking done for an &sdds_beam.
I have produced the sdds bunch file from a csv file (the truncated version of which is in the attachment) with all the right columns and units as mentioned by you in another post.
  • I have an initial bunch of ~ mm.mrad spread in my file. When I look at this bunch with a WATCH element at the start of my beamline, I get much bigger values for the spot, of the order of centimeters! I guess it probably has to do something with my unit conversions, but I am unable to figure out what I have done wrong.
  • Secondly, trying to optimize K1's of a triplet for this beam results in pretty low values, and no focusing.
  • Setting initial values of K1's to 50, for eg., I do get some practical values out from the optimization, but still no smaller spot than the initial (wrongly scaled) spot.
Please find attached all the files I am using including the csvtosdds conversion script. Kindly help me resolve this problem.

[*]And when everything works, and aperture is set, how can I find the transmission after each element?

Thanks.
Attachments
Bunch50MeV.tar.gz
(2.02 MiB) Downloaded 390 times
-Neeraj

Neeraj
Posts: 23
Joined: 24 May 2018, 10:42

Re: Optimizing the quadrupole strengths

Post by Neeraj » 24 Jun 2018, 08:00

Hi Michael,

just dropping a reminder so that you don't fail to notice this post. :)

regards
-Neeraj

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

Re: Optimizing the quadrupole strengths

Post by michael_borland » 25 Jun 2018, 09:18

Neeraj,

Sorry for not responding sooner. The email notifications from the forum are not all that reliable.

The issue with this optimization appears to be that the beam has large energy spread and large divergence. As a result of the large divergence, the triplet must be very strong to turn the diverging beam into a converging one. However, the variation in the focusing strength that results from the large energy spread prevents doing this uniformly across the beam. This is made much worse by the fact that the focusing strengths must be very large to deal with the large beam divergence.

You can demonstrate this by changing the KQUAD elements to QUAD elements with ORDER=1. This turns off the variation of focusing with energy offset by using a simple first-order model for the quadrupoles. In this case, the beam can be focused to back to a small spot. However, that isn't what will happen in the real world.

Another problem is that there are outlier particles that make the rms beam sizes an unreliable measure of the effective beam sizes. You can filter these out when converting the data to SDDS. See attached.

--Michael
Attachments
Bunch50MeV-1.tar.gz
(2.01 MiB) Downloaded 390 times

Post Reply