bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
13 stars 15 forks source link

Using the optimizer with beamlines with repeated elements #1305

Open donishzkhan opened 4 hours ago

donishzkhan commented 4 hours ago

I have a periodic lattices with recurring drift and quadrupole entries. The optimizer throws errors ('MERIT_TYPE IS SET TO "TARGET" BUT DATUM DOES NOT EVALUATE TO A SINGLE NUMBER!') for me if I try to optimizer any of these elements.

Is there a way to use the optimizer on these elements?

DavidSagan commented 3 hours ago

@donishzkhan If this is a problem with multiple elements having the same name, you can select specific elements of the same name using the ##N selection suffix (see the Bmad manual for details). Or use the unique_name_suffix construct (see the Tao manual for details).

donishzkhan commented 1 hour ago

I would like these elements to have the same optimized value e.g. for a quadrupole named 'Q3' I would like to optimize its K1 value and within the periodic cell there are 4-5 instances of this quadrupole. But, ultimately I would like to have Bmad/Tao find the single, optimized K1 value for this family of quads.

DavidSagan commented 46 minutes ago

Then use an overlay to control the k1 value of all the q3 elements and optimize by varying the overlay.