
!***************************************************************
! Set nominal working point and chromaticities for bare lattice 
!***************************************************************


!&rpn_load
	filename=settings.sdds
	load_parameters=1
!&end



!----------------------------------------
! Transmute RFCAs into DRIFTs 
! These are for elettra_* lattices
!----------------------------------------

!&transmute_elements
	name = RFC*,
	type = RFCA,
	new_type = "DRIF",
!&end



&run_setup
	lattice = ./elettra0.new
	rootname = elettra1af
        default_order = 2    !!!"(order_transport)",
        use_beamline = RING
        p_central_mev = 2000 !!!"(p_central_mev)"
	output = %s.out
	sigma = %s.sig
	centroid = %s.cen
	final = %s.fin
	magnets = %s.mag
	parameters = %s.param
	semaphore_file = %s.done
&end

&run_control
        n_steps = 1
	n_passes = 1
&end


&closed_orbit
	output = %s.clo
	closed_orbit_accuracy = 1e-8
        closed_orbit_iterations = 500
	iteration_fraction = 0.1
&end


!-------------------------------------------------------------
! Compute Twiss parameters
!-------------------------------------------------------------

&twiss_output
	filename="%s.twi"
	higher_order_chromaticity = 1
	quick_higher_order_chromaticity = 1
	leading_order_driving_terms_only = 1
        matched = 1,
	radiation_integrals = 1
        output_at_each_step = 1,
	statistics = 1
&end

!&alter_elements name = "Q1H" item = DX value = 10e-6 &end 

&correct
    mode = orbit
    method = global
    trajectory_output = %s.orb
    corrector_output = %s.cor
    statistics = %s.scor
    correction_accuracy[0] = 1e-5
    correction_accuracy[1] = 1e-5
    do_correction[0] = 1
    do_correction[1] = 1
    n_xy_cycles = 50
    n_iterations = 50
    closed_orbit_accuracy = 1e-8
    closed_orbit_iterations = 500
    closed_orbit_iteration_fraction = 0.25
    verbose = 2
&end



&amplification_factors  
    output = %s.af  
    uncorrected_orbit_function = %s.uof  
    corrected_orbit_function = %s.cof  
    kick_function =%s.kaf  
    name = "Q1H"  
    item = "DX"  
    change = 1e-3 
    plane = "h"
    number_to_do = 1
    maximum_z = 2.6 
&end 


&bunched_beam &end

&track &end

&save_lattice filename = %s.new &end

&stop &end

