!Elegant file for finding quad strengths for cells surounding BMIT wiggler &run_setup lattice = "cls.lte", rootname= "cls", use_beamline = cellbmit, p_central_mev = 2900, default_order = 1, random_number_seed = 123456789 &end &run_control &end &twiss_output concat_order = 1, &end &optimization_setup mode = "minimize", method = "simplex", tolerance = 1e-12, verbose = 0, log_file = /dev/tty, n_evaluations = 500, n_passes=10, n_restarts = 2, &end !Use the following variables: !QA and QB quands on either end are linked (2 knobs, symmetric) !outer QC (QC41 and QC52) are fixed !inner QA, QB, QC are independent (6 knobs, non-symmetric) !This gives us 8 knobs in total and allows for three parameters to compensate for !the insertiond device not being in the center of the straight section. &optimization_variable name = QA41, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QB41, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QC42, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QB42, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QA42, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QA51, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QB51, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_variable name = QC51, item=K1, lower_limit=0.0, upper_limit=2.5, step_size = 0.01 &end &optimization_covariable name = QB52, item=K1, equation = "QB41.K1" &end &optimization_covariable name = QA52, item=K1, equation = "QA41.K1" &end !Set batax, betay, dispersion to their matched values !Set correct tune advance for nux = 10.22/6 and nuy = 4.32/6 !Zero alphax, alphay and the derivative of dispersion !This gives us eight parameters in total and three that require !non-symmetric quadrupol (alphax, alphay, etaxp) !Perform least squares fit &optimization_term term = "betax 9.156 - sqr", weight=1.0 &end &optimization_term term = "betay 2.564 - sqr", weight=1.0 &end &optimization_term term = "alphax 0 - sqr", weight=1.0 &end &optimization_term term = "alphay 0 - sqr", weight=1.0 &end &optimization_term term = "nux 1.703333 - sqr", weight=1.0 &end &optimization_term term = "nuy 0.72 - sqr", weight=1.0 &end &optimization_term term = "etax 0.15 - sqr", weight=1.0 &end &optimization_term term = "etaxp 0.0 - sqr", weight=1.0 &end &bunched_beam &end &optimize summarize_setup=1 &end !Save the lattice so we can output its twiss parameters &save_lattice filename = "%s.new", output_seq = 1, &end !Divide the bend magnet and drifts for better viewing of twiss params. ÷_elements name="DIPOLE", divisions=10 &end ÷_elements name="D1", maximum_length = 0.25 &end !load the new lattice and output its twiss parameters &run_setup lattice = "cls.new", rootname= "cls", magnets = "%s.mag", use_beamline = cellbmit, p_central_mev = 2900, default_order = 2, random_number_seed = 123456789 &end &twiss_output filename = "%s.twi", &end !EOF