! Scan the quadrupole strength and find acceptance

&run_setup
        lattice = lattice.lte
        default_order = 2,
        use_beamline = cell
        p_central_mev = 0.004,  !! Really? 
        parameters = %s.param
        final = %s.fin
&end

&run_control
&end

&optimization_setup
	method = simplex
	mode = minimize
	target = 1e-12
	tolerance = 1e-14
	n_evaluations = 500
	n_passes = 3
	log_file = /dev/tty
	verbose = 0
&end

&optimization_term term = "R16 abs" &end
&optimization_term term = "R26 abs" &end

&optimization_variable name=Q1, item=K1, lower_limit=-1e3, upper_limit=1e3, step_size=1e-3 &end
&optimization_variable name=Q2, item=K1, lower_limit=-1e3, upper_limit=1e3, step_size=1e-3 &end

&twiss_output
    matched = 0,
    local_dispersion = 1,
    statistics = 1,
    beta_y = 1, alpha_y =  0,
    beta_x = 1, alpha_x = 0,
    concat_order             = 1,
    statistics               =  1
&end

&bunched_beam
&end

&optimize &end

&save_lattice filename = %s.new &end
