Re: Pelegant different method
Posted: 26 May 2020, 22:08
by marlibgin
I have another question on this topics, which is a bit urgent in a way
I am optimizing a lattice using the swarm optimizer in parallel mode
In the case under study I do change gradients K1 and bending angles
In the optimisation I can check mpipelegant.o<run_number> and see changes of ANGLEs happen
...
Initial value for QF4.ANGLE is -2.109200e-03
Initial value for DL1A_5.ANGLE is 1.633299e-02
Initial value for DL2A_5.ANGLE is 1.550124e-02
Starting particle swarm optimization.
...
Optimum values of variables and changes from initial values:
QF4.ANGLE: -2.361620555403833e-03 -2.524205554038329e-04
DL1A_5.ANGLE: 1.632666715671888e-02 -6.318659781123781e-06
DL2A_5.ANGLE: 1.550745852681502e-02 6.221960115022906e-06
So the optimiser seems to do the job,
But at the end of it all, when I issue
&save_lattice
&end
and I'd expect to have the new values saved in the *.new lattice, I get
QF4: CSBEND,L=0.15,ANGLE=-0.0021092,K1=4.366428205906299
so the ANGLE value for element QF4 has not been saved
this is my ele file:
÷_elements
name = *,
type = edrift,
exclude = NULL,
divisions = 0,
maximum_length = 0.05,
clear = 0,
&end
&run_setup
lattice = M-H6BA-20-11-1_M36_QF4_QF6_QF8_AB_match7.lte,
use_beamline = RINGRF,
default_order = 3,
concat_order = 1,
random_number_seed = 1,
wrap_around = 1,
p_central_mev = 3500,
parameters = %s.paramOpt,
magnets = %s.mag,
losses = %s.lost
semaphore_file = %s.done
final = %s.finOpt
&end
&run_control
n_steps = 1,
n_indices = 0,
n_passes = 1
reset_rf_for_each_step = 1
first_is_fiducial = 0
restrict_fiducialization = 0
&end
&twiss_output
filename = %s.twi,
radiation_integrals = 1,
matched = 1,
output_at_each_step = 1,
concat_order = 1
higher_order_chromaticity = 0
higher_order_chromaticity_range = 0.0002
chromatic_tune_spread_half_range = 0
compute_driving_terms = 1
leading_order_driving_terms_only = 1
beta_x = 1
beta_y = 1
alpha_x = 0
alpha_y = 0
eta_x = 0
etap_x = 0
&end
¶llel_optimization_setup
method = "swarm",
hybrid_simplex_tolerance = 1e-14,
n_passes = 3,
verbose = 0,
target = 1e-12,
mode = "minimize",
n_evaluations = 1500,
n_restarts = 15,
random_factor = 1,
n_iterations = 1500,
population_size = 240,
population_log = %s.pop,
&end
&optimization_term term = "ex0 1.55e-10 1e-12 segt 1e4 *" &end
&optimization_term term = "nux 58.2 0.2 sene 1e4 *" &end
&optimization_term term = "nuy 18.4 0.2 sene 1e4 *" &end
&optimization_term term = "FPLS#1.alphax 0 0.001 sene 2000 *" &end
&optimization_term term = "FPLS#1.alphay 0 0.001 sene 2000 *" &end
&optimization_term term = "FPSS#1.alphax 0 0.001 sene 2000 *" &end
&optimization_term term = "FPSS#1.alphay 0 0.001 sene 2000 *" &end
&optimization_term term = "FPMS#1.alphax 0 0.001 sene 2000 *" &end
&optimization_term term = "FPMS#1.alphay 0 0.001 sene 2000 *" &end
&optimization_term term = "FPMS#1.etax 0.025 0.001 segt 20000 *" &end
&optimization_term term = "FPMS#1.etax 0.005 0.001 selt 20000 *" &end
&optimization_term term = "FPBUMP#1.etax 0.0725 0.0005 selt 20000 *" &end
&optimization_term term = "FPBUMP#2.etax 0.0725 0.0005 selt 20000 *" &end
&optimization_term term = "FPLS#1.etax 0 0.00025 sene 20000 *" &end
&optimization_term term = "FPSS#1.etax 0 0.00025 sene 20000 *" &end
&optimization_term term = "FPLS#1.etaxp 0 0.00002 sene 2000 *" &end
&optimization_term term = "FPSS#1.etaxp 0 0.00002 sene 2000 *" &end
&optimization_term term = "FPMS#1.etaxp 0 0.00002 sene 2000 *" &end
&optimization_term term = "max.betax 30 0.0001 segt 2000 *" &end
&optimization_term term = "max.betay 30 0.0001 segt 2000 *" &end
&optimization_term term = "FPLS#1.betax 20 0.0001 segt 2000 *" &end
&optimization_term term = "FPLS#1.betax 4 0.0001 selt 2000 *" &end
&optimization_term term = "FPLS#1.betay 10 0.0001 segt 2000 *" &end
&optimization_term term = "FPLS#1.betay 0 0.0001 selt 2000 *" &end
&optimization_term term = "FPSS#1.betax 9 0.0001 segt 2000 *" &end
&optimization_term term = "FPSS#1.betax 1.5 0.0001 selt 2000 *" &end
&optimization_term term = "FPSS#1.betay 4 0.0001 segt 2000 *" &end
&optimization_term term = "FPSS#1.betay 0.5 0.0001 selt 2000 *" &end
&optimization_term term = "FPMS#1.betax 9 0.0001 segt 2000 *" &end
&optimization_term term = "FPMS#1.betax 1 0.0001 selt 2000 *" &end
&optimization_term term = "FPMS#1.betay 4 0.0001 segt 2000 *" &end
&optimization_term term = "FPMS#1.betay 1.5 0.0001 selt 2000 *" &end
&optimization_variable name=QF4, item=ANGLE, lower_limit=-0.0041092, upper_limit=-0.0001092, step_size=1 &end
&optimization_covariable name=QF4L, item=ANGLE, equation=QF4.ANGLE &end
&optimization_covariable name=QF4_C1, item=ANGLE, equation=QF4.ANGLE &end
&optimization_variable name=DL1A_5, item=ANGLE, lower_limit=0.014333, upper_limit=0.018333, step_size=1 &end
&optimization_covariable name=DL1A_4, item=ANGLE, equation=" DL1A_4.ANGLE0 DL1A_5.ANGLE + DL1A_5.ANGLE0 -" &end
&optimization_covariable name=DL1A_3, item=ANGLE, equation=" DL1A_3.ANGLE0 DL1A_5.ANGLE + DL1A_5.ANGLE0 -" &end
&optimization_covariable name=DL1A_2, item=ANGLE, equation=" DL1A_2.ANGLE0 DL1A_5.ANGLE + DL1A_5.ANGLE0 -" &end
&optimization_covariable name=DL1A_1, item=ANGLE, equation=" DL1A_1.ANGLE0 DL1A_5.ANGLE + DL1A_5.ANGLE0 -" &end
&optimization_variable name=DL2A_5, item=ANGLE, lower_limit=0.013501, upper_limit=0.017501, step_size=1 &end
&optimization_covariable name=DL2A_4, item=ANGLE, equation=" DL2A_4.ANGLE0 DL2A_5.ANGLE + DL2A_5.ANGLE0 -" &end
&optimization_covariable name=DL2A_3, item=ANGLE, equation=" DL2A_3.ANGLE0 DL2A_5.ANGLE + DL2A_5.ANGLE0 -" &end
&optimization_covariable name=DL2A_2, item=ANGLE, equation=" DL2A_2.ANGLE0 DL2A_5.ANGLE + DL2A_5.ANGLE0 -" &end
&optimization_covariable name=DL2A_1, item=ANGLE, equation=" DL2A_1.ANGLE0 DL2A_5.ANGLE + DL2A_5.ANGLE0 -" &end
&optimization_covariable name=DQ1, item=ANGLE, equation=" DQ1.ANGLE0 QF4.ANGLE 2 * - DL1A_5.ANGLE DL1A_5.ANGLE0 - 5 * - DL2A_5.ANGLE DL2A_5.ANGLE0 - 5 * - " &end
&bunched_beam
n_particles_per_bunch = 1
emit_x = 8e-11
emit_y = 8e-12
beta_x = 1e-08
beta_y = 5e-09
alpha_x = 0
alpha_y = 0
eta_x = 0.05
eta_y = 0
etap_x = 0
etap_y = 0
Po = 6849.3419
sigma_dp = 0.000961
sigma_s = 0.003
distribution_cutoff[0] = 5,5,5,
centroid[0] = 0,0,0,0,0,0,
&end
&optimize &end
&run_setup
lattice = M-H6BA-20-11-1_M36_QF4_QF6_QF8_AB_match7.lte,
use_beamline = RINGRF,
default_order = 3,
concat_order = 1,
random_number_seed = 1,
wrap_around = 1,
p_central_mev = 3500,
parameters = %s.paramOpt,
magnets = %s.mag,
losses = %s.lost
semaphore_file = %s.done
final = %s.finOpt
&end
&run_control
n_steps = 1,
n_indices = 0,
n_passes = 1
reset_rf_for_each_step = 1
first_is_fiducial = 0
restrict_fiducialization = 0
&end
&twiss_output
filename = %s.twi,
radiation_integrals = 1,
matched = 1,
output_at_each_step = 1,
concat_order = 3
higher_order_chromaticity = 1
higher_order_chromaticity_range = 0.0002
chromatic_tune_spread_half_range = 0
compute_driving_terms = 1
leading_order_driving_terms_only = 1
beta_x = 1
beta_y = 1
alpha_x = 0
alpha_y = 0
eta_x = 0
etap_x = 0
&end
&floor_coordinates
filename = temporaneo.flr
X0 = 0,
Y0 = 0,
theta0 = 0,
&end
&bunched_beam
n_particles_per_bunch = 1
emit_x = 1.57e-10
emit_y = 8e-12
beta_x = 1e-08
beta_y = 5e-09
alpha_x = 0
alpha_y = 0
eta_x = 0.05
eta_y = 0
etap_x = 0
etap_y = 0
Po = 6849.3419
sigma_dp = 0.000961
sigma_s = 0.003
distribution_cutoff[0] = 5,5,5,
centroid[0] = 0,0,0,0,0,0,
&end
&track
center_on_orbit=0,
center_momentum_also=1,
offset_by_orbit=0,
offset_momentum_also=1
&end
&save_lattice
filename=%s.new,
&end
and this is the M-H6BA-20-11-1_M36_QF4_QF6_QF8_AB_match7.lte file:
"DR_01": EDRIFT,L=2.52135
"DR_02": EDRIFT,L=0.075
"DR_03": EDRIFT,L=0.075
"DR_04": EDRIFT,L=0.15
"DR_05": EDRIFT,L=0.075
"DR_06": EDRIFT,L=0.075
"DR_07": EDRIFT,L=0.075
"DR_08": EDRIFT,L=0.075
"DR_09": EDRIFT,L=0.3305
"DR_091": EDRIFT,L=0.075
"DR_092": EDRIFT,L=0.1655
"DR_10": EDRIFT,L=0.075
"DR_11": EDRIFT,L=0.075
"DR_12": EDRIFT,L=0.075
"DR_13": EDRIFT,L=0.1655
"DR_14": EDRIFT,L=0.075
"DR_15": EDRIFT,L=0.075
"DR_16": EDRIFT,L=0.075
"DR_17": EDRIFT,L=0.1
"DR_18": EDRIFT,L=0.08
"DR_19": EDRIFT,L=0.197
"DR_20": EDRIFT,L=0.09
"DR_21": EDRIFT,L=0.09
"DR_22": EDRIFT,L=0.075
"DR_23": EDRIFT,L=0.075
"DR_24": EDRIFT,L=1.3842
"DL_27": EDRIFT,L=3.69635
"DL_26": EDRIFT,L=0.075
"DL_25": EDRIFT,L=0.035
"DL_24": EDRIFT,L=0.035
"DL_23": EDRIFT,L=0.075
"DL_22": EDRIFT,L=0.075
"DL_21": EDRIFT,L=0.075
"DL_20": EDRIFT,L=0.075
"DL_19": EDRIFT,L=0.075
"DL_18": EDRIFT,L=0.075
"DL_17": EDRIFT,L=0.075
"DL_16": EDRIFT,L=0.3305
"DL_161": EDRIFT,L=0.075
"DL_162": EDRIFT,L=0.1655
"DL_15": EDRIFT,L=0.075
"DL_14": EDRIFT,L=0.075
"DL_13": EDRIFT,L=0.075
"DL_12": EDRIFT,L=0.1655
"DL_11": EDRIFT,L=0.075
"DL_10": EDRIFT,L=0.075
"DL_09": EDRIFT,L=0.075
"DL_08": EDRIFT,L=0.1
"DL_07": EDRIFT,L=0.08
"DL_06": EDRIFT,L=0.197
"DL_05": EDRIFT,L=0.09
"DL_04": EDRIFT,L=0.09
"DL_03": EDRIFT,L=0.075
"DL_02": EDRIFT,L=0.075
"DL_01": EDRIFT,L=1.3842
QF1: KQUAD,L=0.15,K1=8.789830489601442,N_KICKS=20
QD2: KQUAD,L=0.15,K1=-7.07693344683834,N_KICKS=20
QD3: KQUAD,L=0.15,K1=-1.919229305042759,N_KICKS=20
QD5: KQUAD,L=0.105,K1=-1.617877657166434,N_KICKS=20
"QD3_C1": KQUAD,L=0.15,K1=-1.875256068698396,N_KICKS=20
"QD2_C1": KQUAD,L=0.105,K1=-3.040643168317334,N_KICKS=20
"QF1_C1": KQUAD,L=0.185,K1=-3.535681926118325,N_KICKS=20
"QUAD_ADD": KQUAD,L=0.185,K1=6.312252329994454,N_KICKS=20
FPLS: MARK,FITPOINT=1
FPSS: MARK,FITPOINT=1
FPMS: MARK,FITPOINT=1
FPBUMP: MARK,FITPOINT=1
"DL1A_5": CSBEND,L=0.2,ANGLE=0.0163329858165,K1=-0.1192115053314074,&
E1=0.02173267,E2=-0.00661351,N_KICKS=20
"DL1A_4": CSBEND,L=0.2,ANGLE=0.008952197403140001,K1=-0.1228981806214646,&
E1=0.00661351,E2=0.0028699,N_KICKS=20
"DL1A_3": CSBEND,L=0.2,ANGLE=0.00704768515122,K1=-0.1038018234246326,&
E1=-0.0028699,E2=0.0103172,N_KICKS=20
"DL1A_2": CSBEND,L=0.2,ANGLE=0.00587235024906,K1=-0.1101688465780408,&
E1=-0.0103172,E2=0.01650797,N_KICKS=20
"DL1A_1": CSBEND,L=0.2,ANGLE=0.00496870301556,K1=-0.117007456724636,&
E1=-0.01650797,E2=0.02173267,N_KICKS=20
"DL2A_5": CSBEND,L=0.16667,ANGLE=0.0155012365667,K1=-0.5753176374001284,&
E1=0.02081345,E2=-0.00668822,N_KICKS=20
"DL2A_4": CSBEND,L=0.16667,ANGLE=0.00863418971688,K1=-0.5786848703509255,&
E1=0.00668822,E2=0.00235048,N_KICKS=20
"DL2A_3": CSBEND,L=0.33334,ANGLE=0.00691526995228,K1=-0.5933353328983929,&
E1=-0.00235048,E2=0.009551499999999999,N_KICKS=20
"DL2A_2": CSBEND,L=0.16667,ANGLE=0.00585447420188,K1=-0.452,&
E1=-0.009551499999999999,E2=0.01561844,N_KICKS=20
"DL2A_1": CSBEND,L=0.16667,ANGLE=0.00503888644772,K1=-0.695,E1=-0.01561844,&
E2=0.02081345,N_KICKS=20
SD1: KSEXT,L=0.14,K2=-468.551787,N_KICKS=20
SD2: KSEXT,L=0.14,K2=-252.427466,N_KICKS=20
SF1: KSEXT,L=0.14,K2=381.897200381,N_KICKS=20
SH1: KSEXT,L=0.1,K2=-50.761506,N_KICKS=20
SH2: KSEXT,L=0.1,K2=-34.306023,N_KICKS=20
S: KSEXT,L=0.1,K2=-114.85553,N_KICKS=20
QF4: CSBEND,L=0.15,ANGLE=-0.0021092,K1=4.366428205906299,E1=-0.0012728,&
E2=-0.0012728,N_KICKS=20
QF4L: CSBEND,L=0.15,ANGLE=-0.0021092,K1=4.563247427153821,E1=-0.0012728,&
E2=-0.00127282,N_KICKS=20
"QF4_C1": CSBEND,L=0.15,ANGLE=-0.0021092,K1=4.149937308864343,E1=-0.0012728,&
E2=-0.0012728,N_KICKS=20
QF6: CSBEND,L=0.36,ANGLE=0.000689929,K1=6.479321495182063,E1=0.000340601,&
E2=0.00340601,N_KICKS=20
QF8: CSBEND,L=0.25,ANGLE=-0.00071017,K1=6.960798560584746,E1=-0.00035509,&
E2=-0.0035509,N_KICKS=20
DQ1: CSBEND,L=0.87,ANGLE=0.05002024100000001,K1=-2.664170971945386,&
E1=0.0255936,E2=0.0255936,N_KICKS=20
OF1: KOCT,L=0.09,K3=-1496,N_KICKS=20
"BPM_01": MONI,GROUP="girder"
"BPM_02": MONI,GROUP="girder"
"BPM_03": MONI,GROUP="girder"
"BPM_04": MONI,GROUP="girder"
"BPM_05": MONI,GROUP="girder"
"BPM_06": MONI,GROUP="girder"
"BPM_07": MONI,GROUP="girder"
"BPM_08": MONI,GROUP="girder"
"BPM_09": MONI,GROUP="girder"
"BPM_10": MONI,GROUP="girder"
"BPM_11": MONI,GROUP="girder"
"COR_01": KICKER
"COR_02": KICKER
"COR_03": KICKER
"COR_04": KICKER
"COR_05": KICKER
"COR_06": KICKER
"COR_07": KICKER
"COR_08": KICKER
"COR_09": KICKER
"COR_10": KICKER
"COR_11": KICKER,L=0.08
RFC: RFCA,VOLT=1488533,PHASE=147.65771247,FREQ=499501358.3498094,CHANGE_T=1
MAL: MALIGN,ON_PASS=0
W1: WATCH,FILENAME="%s.w1",MODE="centroid"
W2: WATCH,FILENAME="%s.w2",MODE="parameter"
W3: WATCH,FILENAME="%s.w3",MODE="coordinate"
RAD: SREFFECTS
DL1A: LINE=(DL1A_5,DL1A_4,DL1A_3,DL1A_2,DL1A_1)
DL2A: LINE=(DL2A_5,DL2A_4,DL2A_3,DL2A_2,DL2A_1)
"ARCA_C2R": LINE=(DR_24,BPM_05,DR_23,COR_05,SH2,DR_22,QF8,DR_21,DQ1,DR_20,QF6,&
DR_19,BPM_04,DR_18,S,COR_04,DR_17,DL2A,DR_16,QD5,DR_15,SD2,COR_03,DR_14,&
BPM_03,DR_13,OF1,DR_12,QF4,DR_11,SF1,FPBUMP,DR_10,QF4,DR_091,OF1,DR_092,&
BPM_02,DR_08,COR_02,SD1,DR_07,QD3,DR_06,-DL1A,DR_05,QD2,DR_04,COR_01,SH1,&
DR_03,QF1,DR_02,BPM_01,DR_01)
"ARCA_C1R": LINE=(DL_01,BPM_06,DL_02,COR_06,SH2,DL_03,QF8,DL_04,DQ1,DL_05,QF6,&
DL_06,BPM_07,DL_07,S,COR_07,DL_08,DL2A,DL_09,QD5,DL_10,SD2,COR_08,DL_11,&
BPM_08,DL_12,OF1,DL_13,QF4L,DL_14,FPBUMP,SF1,DL_15,QF4_C1,DL_161,OF1,DL_162,&
BPM_09,DL_17,COR_09,SD1,DL_18,QD3_C1,DL_19,-DL1A,DL_20,QD2_C1,DL_21,BPM_10,&
DL_22,COR_10,SH1,DL_23,QF1_C1,DL_24,COR_11,DL_25,QUAD_ADD,DL_26,BPM_11,DL_27)
"ARCA_C2": LINE=(ARCA_C2R,-ARCA_C2R)
"ARCA_C21": LINE=(ARCA_C2R,-ARCA_C2R)
"ARCA_C21M": LINE=(-ARCA_C2R,ARCA_C2R)
"ARCA_C1": LINE=(ARCA_C2R,-ARCA_C1R)
"ARCA_C11": LINE=(-ARCA_C1R,ARCA_C1R)
SP: LINE=(FPLS,-ARCA_C1R,FPMS,ARCA_C2R,FPSS,-ARCA_C2R,ARCA_C2R,-ARCA_C2R,&
ARCA_C2R,-ARCA_C2R,ARCA_C1R)
RING: LINE=(6*SP)
RINGRF: LINE=(W3,MAL,RAD,RFC,6*SP,W1,W2)
C2: LINE=(RAD,RFC,-ARCA_C2R,ARCA_C2R)
C2C2: LINE=(RAD,RFC,ARCA_C21M,ARCA_C21M)
USE,"RINGRF"
RETURN
The final file, temporaneo.new, should have the ANGLEs changed, but they are not.
So Only gradients are modified and indeed if I restart an already optimized case, the penaly function is not zero at the beginning.
This is because the ANGLEs have been modified during the optimisation, but are not saved in the final file.
How do I save bending ANGLEs in the *.new output of save_lattice?
Thanks
Marco