Optimizing the quadrupole strengths
Moderators: cyao, michael_borland
Optimizing the quadrupole strengths
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
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 241 times

 template.ele
 optimization
 (1.85 KiB) Downloaded 253 times
Neeraj

 Posts: 1818
 Joined: 19 May 2008, 09:33
 Location: Argonne National Laboratory
 Contact:
Re: Optimizing the quadrupole strengths
Neeraj,
You shouldn't expect the results to depend on p_central
Michael
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.
Michael
 Attachments

 transport.ele
 (2.03 KiB) Downloaded 301 times
Re: Optimizing the quadrupole strengths
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
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
Re: Optimizing the quadrupole strengths
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
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

 Posts: 1818
 Joined: 19 May 2008, 09:33
 Location: Argonne National Laboratory
 Contact:
Re: Optimizing the quadrupole strengths
Neeraj,
If you continue to have problems, please upload the files and I'll take a look.
Michael
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 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?
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.,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! ￼
Code: Select all
...
&optimize &end
&save_lattice filename = lattice.new &end
&run_setup
lattice = lattice.new
...
&end
...
Michael
Re: Optimizing the quadrupole strengths
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.
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 188 times
Neeraj

 Posts: 1818
 Joined: 19 May 2008, 09:33
 Location: Argonne National Laboratory
 Contact:
Re: Optimizing the quadrupole strengths
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. There were also a few other issues with your files.
Michael
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. 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.
Michael
 Attachments

 TripletTest.tar.gz
 (1.58 KiB) Downloaded 252 times
Re: Optimizing the quadrupole strengths
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.
[*]And when everything works, and aperture is set, how can I find the transmission after each element?
Thanks.
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.
[*]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 196 times
Neeraj
Re: Optimizing the quadrupole strengths
Hi Michael,
just dropping a reminder so that you don't fail to notice this post.
regards
just dropping a reminder so that you don't fail to notice this post.
regards
Neeraj

 Posts: 1818
 Joined: 19 May 2008, 09:33
 Location: Argonne National Laboratory
 Contact:
Re: Optimizing the quadrupole strengths
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 firstorder 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
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 firstorder 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

 Bunch50MeV1.tar.gz
 (2.01 MiB) Downloaded 188 times