How to use wake method in fMBT

Best Python code snippet using fMBT_python

sections.py

Source:sections.py Github

copy

Full Screen

1from ocelot import *2import accelerator.lattice.muy_5pi_mode_A.i1_full as i13import accelerator.lattice.muy_5pi_mode_A.l1_full as l14import accelerator.lattice.muy_5pi_mode_A.l2_full as l25import accelerator.lattice.muy_5pi_mode_A.l3_full as l36import accelerator.lattice.muy_5pi_mode_A.cl_full as cl7import accelerator.lattice.muy_5pi_mode_A.tl34 as tl348import accelerator.lattice.muy_5pi_mode_A.sase1 as sase19import accelerator.lattice.muy_5pi_mode_A.t4 as t410import accelerator.lattice.muy_5pi_mode_A.sase3 as sase311import accelerator.lattice.muy_5pi_mode_A.t4d as t4d12import numpy as np13from accelerator.s2e_sections.section_track import *14from ocelot.cpbd.physics_proc import *15class A1(SectionTrack):16 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):17 18 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)19 # setting parameters20 self.lattice_name = 'A1'21 self.unit_step = 0.0222 #self.input_beam_file = self.particle_dir + 'Exfel.0320_200k.ast'23 self.input_beam_file = self.particle_dir + 'Exfel.0320_250pC.ast'24 #self.input_beam_file = self.particle_dir + 'XFEL_500pC_setup_D_03p2_1M.ast'25 self.output_beam_file = self.particle_dir + 'section_A1.npz'26 self.tws_file = self.tws_dir + "tws_section_A1.npz"27 # init tracking lattice28 start_sim = i1.id_22433449_29 acc1_stop = i1.id_68749308_30 self.lattice = MagneticLattice(i1.cell, start=start_sim, stop=acc1_stop, method=self.method)31 # init physics processes32 sc = SpaceCharge()33 sc.step = 134 sc.nmesh_xyz = [63, 63, 63]35 sc2 = SpaceCharge()36 sc2.step = 537 sc2.nmesh_xyz = [63, 63, 63]38 wake = WakeKick()39 wake.wake_table = WakeTable('accelerator/wakes/mod_TESLA_MODULE_WAKE_TAYLOR.dat')40 wake.factor = 141 smooth = SmoothBeam()42 smooth.mslice = 1000043 # adding physics processes44 acc1_1_stop = i1.id_75115473_45 acc1_wake_kick = acc1_stop46 self.add_physics_process(smooth, start=start_sim, stop=start_sim)47 self.add_physics_process(sc, start=start_sim, stop=acc1_1_stop)48 self.add_physics_process(sc2, start=acc1_1_stop, stop=acc1_wake_kick)49 self.add_physics_process(wake, start=acc1_wake_kick, stop=acc1_wake_kick)50class AH1(SectionTrack):51 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):52 53 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)54 # setting parameters55 self.lattice_name = 'AH1'56 self.unit_step = 0.0257 self.input_beam_file = self.particle_dir + 'section_A1.npz'58 self.output_beam_file = self.particle_dir + 'section_AH1.npz'59 self.tws_file = self.tws_dir + "tws_section_AH1.npz"60 # init tracking lattice61 acc1_stop = i1.id_68749308_62 acc39_stop = i1.stlat_47_i163 self.lattice = MagneticLattice(i1.cell, start=acc1_stop, stop=acc39_stop, method=self.method)64 # init physics processes65 sc = SpaceCharge()66 sc.step = 567 sc.nmesh_xyz = [63, 63, 63]68 wake = WakeKick()69 wake.wake_table = WakeTable('accelerator/wakes/mod_THIRD_HARMONIC_SECTION_WAKE_TAYLOR.dat')70 wake.factor = 271 # adding physics processes72 match_acc39 = acc1_stop73 acc39_wake_kick = i1.stlat_47_i174 smooth = SmoothBeam()75 smooth.mslice = 1000076 #self.add_physics_process(smooth, start=acc39_wake_kick, stop=acc39_wake_kick)77 self.add_physics_process(sc, start=match_acc39, stop=acc39_wake_kick)78 self.add_physics_process(wake, start=acc39_wake_kick, stop=acc39_wake_kick)79class LH(SectionTrack):80 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):81 82 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)83 # setting parameters84 self.lattice_name = 'LH'85 self.unit_step = 0.0286 self.input_beam_file = self.particle_dir + 'section_AH1.npz'87 self.output_beam_file = self.particle_dir + 'section_LH.npz'88 self.tws_file = self.tws_dir + "tws_section_LH.npz"89 # init tracking lattice90 acc39_stop = i1.stlat_47_i191 lhm_stop = l1.id_90904668_92 self.lattice = MagneticLattice(i1.cell + l1.cell, start=acc39_stop, stop=lhm_stop, method=self.method)93 # init physics processes94 sigma=0.00185250907180748195 csr = CSR()96 csr.sigma_min = sigma * 0.197 csr.traj_step = 0.000598 csr.apply_step = 0.00599 sc = SpaceCharge()100 sc.step = 50101 sc.nmesh_xyz = [63, 63, 63]102 tws = Twiss()103 tws.beta_x = 2.36238404123104 tws.beta_y = 2.90712039319105 tws.alpha_x = 1.23079453323106 tws.alpha_y = -1.45354874634107 tws.E = 0.13108 bt = BeamTransform(tws=tws)109 self.add_physics_process(bt, start=i1.match_55_i1, stop=i1.match_55_i1)110 self.add_physics_process(sc, start=acc39_stop, stop=lhm_stop)111 self.add_physics_process(csr, start=acc39_stop, stop=lhm_stop)112class DL(SectionTrack):113 114 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):115 116 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)117 118 # setting parameters119 self.lattice_name = 'DL'120 self.unit_step = 0.02121 self.input_beam_file = self.particle_dir + 'section_LH.npz'122 self.output_beam_file = self.particle_dir + 'section_DL.npz'123 self.tws_file = self.tws_dir + "tws_section_DL.npz"124 # init tracking lattice125 st2_stop = l1.id_90904668_126 dogleg_stop = l1.stlat_96_i1127 self.lattice = MagneticLattice(l1.cell, start=st2_stop, stop=dogleg_stop, method=self.method)128 # init physics processes129 sigma=0.001852509071807481130 csr = CSR()131 #csr.step=10132 #csr.n_bin = 100133 csr.sigma_min = sigma*0.1134 csr.traj_step = 0.0005135 csr.apply_step = 0.005136 sc = SpaceCharge()137 sc.step = 25138 sc.nmesh_xyz = [31, 31, 31]139 self.add_physics_process(csr, start=st2_stop, stop=dogleg_stop)140 self.add_physics_process(sc, start=st2_stop, stop=dogleg_stop)141class BC0(SectionTrack):142 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):143 144 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)145 # setting parameters146 self.lattice_name = 'BC0'147 self.unit_step = 0.1148 self.input_beam_file = self.particle_dir + 'section_DL.npz'149 self.output_beam_file = self.particle_dir + 'section_BC0.npz'150 self.tws_file = self.tws_dir + "tws_section_BC0.npz"151 # init tracking lattice152 st4_stop = l1.stlat_96_i1153 bc0_stop = l1.enlat_101_i1154 self.lattice = MagneticLattice(l1.cell, start=st4_stop, stop=bc0_stop, method=self.method)155 # init physics processes156 sigma=0.0015288820707131323157 csr = CSR()158 #csr.step=10159 #csr.n_bin = 100160 csr.sigma_min = sigma*0.1161 csr.traj_step = 0.0005162 csr.apply_step = 0.005163 smooth = SmoothBeam()164 smooth.mslice = 10000165 #sc = SpaceCharge()166 #sc.step = 10167 #sc.nmesh_xyz = [63, 63, 63]168 #sc.low_order_kick = False169 match_bc0 = st4_stop170 self.add_physics_process(smooth, start=bc0_stop, stop=bc0_stop)171 self.add_physics_process(csr, start=match_bc0, stop=bc0_stop)172 self.dipoles = [l1.bb_96_i1, l1.bb_98_i1, l1.bb_100_i1, l1.bb_101_i1]173class L1(SectionTrack):174 175 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):176 177 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)178 # setting parameters179 self.lattice_name = 'L1'180 self.unit_step = 0.02181 self.input_beam_file = self.particle_dir + 'section_BC0.npz'182 self.output_beam_file = self.particle_dir + 'section_L1.npz'183 self.tws_file = self.tws_dir + "tws_section_L1.npz"184 bc0_stop = l1.enlat_101_i1185 acc2_stop = l1.stlat_182_b1186 # init tracking lattice187 self.lattice = MagneticLattice(l1.cell, start=bc0_stop, stop=acc2_stop, method=self.method)188 # init physics processes189 sc = SpaceCharge()190 sc.step = 50191 sc.nmesh_xyz = [31, 31, 31]192 wake = WakeKick()193 wake.wake_table = WakeTable('accelerator/wakes/mod_TESLA_MODULE_WAKE_TAYLOR.dat')194 wake.factor = 4195 match_acc2 = bc0_stop196 L1_wake_kick = acc2_stop197 self.add_physics_process(sc, start=match_acc2, stop=L1_wake_kick)198 self.add_physics_process(wake, start=L1_wake_kick, stop=L1_wake_kick)199class BC1(SectionTrack):200 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):201 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)202 # setting parameters203 self.lattice_name = 'BC1'204 self.unit_step = 0.05205 self.input_beam_file = self.particle_dir + 'section_L1.npz'206 self.output_beam_file = self.particle_dir + 'section_BC1.npz'207 self.tws_file = self.tws_dir + "tws_section_BC1.npz"208 acc2_stop = l1.stlat_182_b1209 bc1_stop = l1.tora_203_b1210 # init tracking lattice211 self.lattice = MagneticLattice(l1.cell, start=acc2_stop, stop=bc1_stop, method=self.method)212 # init physics processes213 smooth = SmoothBeam()214 smooth.mslice = 10000215 sigma = 0.0005748235512972583216 csr = CSR()217 #csr.step = 10218 #csr.n_bin = 100219 csr.sigma_min = sigma*0.1220 csr.traj_step = 0.0005221 csr.apply_step = 0.005222 sc = SpaceCharge()223 sc.step = 20224 sc.nmesh_xyz = [31, 31, 31]225 match_bc1 = acc2_stop226 self.add_physics_process(smooth, start=bc1_stop, stop=bc1_stop)227 self.add_physics_process(csr, start=match_bc1, stop=bc1_stop)228 self.add_physics_process(sc, start=match_bc1, stop=bc1_stop)229 self.dipoles = [l1.bb_182_b1, l1.bb_191_b1, l1.bb_193_b1, l1.bb_202_b1]230class L2(SectionTrack):231 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):232 233 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)234 # setting parameters235 self.lattice_name = 'L2'236 self.unit_step = 0.02237 self.input_beam_file = self.particle_dir + 'section_BC1.npz'238 self.output_beam_file = self.particle_dir + 'section_L2.npz'239 self.tws_file = self.tws_dir + "tws_section_L2.npz"240 bc1_stop = l1.tora_203_b1241 acc3t5_stop = l2.stlat_393_b2242 # init tracking lattice243 self.lattice = MagneticLattice(l1.cell + l2.cell, start=bc1_stop, stop=acc3t5_stop, method=self.method)244 # init physics processes245 sc = SpaceCharge()246 sc.step = 100247 sc.nmesh_xyz = [31, 31, 31]248 wake = WakeKick()249 wake.wake_table = WakeTable('accelerator/wakes/mod_TESLA_MODULE_WAKE_TAYLOR.dat')250 wake.factor = 4 * 3251 self.add_physics_process(sc, start=bc1_stop, stop=acc3t5_stop)252 self.add_physics_process(wake, start=acc3t5_stop, stop=acc3t5_stop)253class BC2(SectionTrack):254 255 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):256 257 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)258 # setting parameters259 self.lattice_name = 'BC2'260 self.dipoles = [l2.bb_393_b2, l2.bb_402_b2, l2.bb_404_b2, l2.bb_413_b2]261 self.unit_step = 0.02262 self.input_beam_file = self.particle_dir + 'section_L2.npz'263 self.output_beam_file = self.particle_dir + 'section_BC2.npz'264 self.tws_file = self.tws_dir + "tws_section_BC2.npz"265 acc3t5_stop = l2.stlat_393_b2266 bc2_stop = l2.tora_415_b2267 # init tracking lattice268 self.lattice = MagneticLattice(l2.cell, start=acc3t5_stop, stop=bc2_stop, method=self.method)269 # init physics processes270 csr = CSR()271 csr.step=2272 csr.n_bin = 100273 csr.sigma_min = 7.e-6274 csr.traj_step = 0.0005275 csr.apply_step = 0.005276 smooth = SmoothBeam()277 smooth.mslice = 10000278 sc = SpaceCharge()279 sc.step = 50280 sc.nmesh_xyz = [31, 31, 31]281 self.add_physics_process(smooth, start=bc2_stop, stop=bc2_stop)282 self.add_physics_process(csr, start=acc3t5_stop, stop=bc2_stop)283 self.add_physics_process(sc, start=acc3t5_stop, stop=bc2_stop)284class L3(SectionTrack):285 286 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):287 288 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)289 # setting parameters290 self.lattice_name = 'L3'291 self.unit_step = 5.0292 self.input_beam_file = self.particle_dir + 'section_BC2.npz'293 self.output_beam_file = self.particle_dir + 'section_L3.npz'294 self.tws_file = self.tws_dir + "tws_section_L3.npz"295 bc2_stop = l2.tora_415_b2296 acc6t26_stop = cl.match_1673_cl297 # init tracking lattice298 self.lattice = MagneticLattice(l2.cell + l3.cell + cl.cell, start=bc2_stop, stop=acc6t26_stop, method=self.method)299 #self.cav_list = [".A23.", ".A22.", ".A21.", ".A20.", ".A19.", ".A18.", ".A17.", ".A16."]300 #for elem in self.lattice.sequence:301 # if elem.__class__ == Cavity:302 # for cav_num in self.cav_list:303 # if cav_num in elem.id:304 # print(elem.id)305 # elem.v = 0.306 #self.lattice.update_transfer_maps()307 # init physics processes308 sc = SpaceCharge()309 sc.step = 1310 sc.nmesh_xyz = [31, 31, 31]311 wake = WakeKick()312 wake.wake_table = WakeTable('accelerator/wakes/mod_TESLA_MODULE_WAKE_TAYLOR.dat')313 wake.factor = 4 * 21314 self.add_physics_process(wake, start=acc6t26_stop, stop=acc6t26_stop)315 self.add_physics_process(sc, start=bc2_stop, stop=acc6t26_stop)316class CL1(SectionTrack):317 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):318 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)319 # setting parameters320 self.lattice_name = 'CL1'321 self.unit_step = 0.2322 self.input_beam_file = self.particle_dir + 'section_L3.npz'323 self.output_beam_file = self.particle_dir + 'section_CL1.npz'324 self.tws_file = self.tws_dir + "tws_section_CL1.npz"325 acc6t26_stop = cl.match_1673_cl326 collimator1_stop = cl.bpma_1746_cl327 # init tracking lattice328 self.lattice = MagneticLattice(cl.cell, start=acc6t26_stop, stop=collimator1_stop, method=self.method)329 # init physics processes330 sc = SpaceCharge()331 sc.step = 10332 sc.nmesh_xyz = [31, 31, 31]333 sc.low_order_kick = False334 csr = CSR()335 csr.traj_step = 0.0005336 csr.apply_step = 0.005337 csr.n_bin = 300338 csr.sigma_min = 0.2e-6339 self.add_physics_process(csr, start=acc6t26_stop, stop=collimator1_stop)340 self.add_physics_process(sc, start=acc6t26_stop, stop=collimator1_stop)341class CL2(SectionTrack):342 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):343 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)344 # setting parameters345 self.lattice_name = 'CL2'346 self.unit_step = 1347 self.input_beam_file = self.particle_dir + 'section_CL1.npz'348 self.output_beam_file = self.particle_dir + 'section_CL2.npz'349 self.tws_file = self.tws_dir + "tws_section_CL2.npz"350 collimator1_stop = cl.bpma_1746_cl351 collimator2_stop = cl.bpma_1783_cl352 # init tracking lattice353 self.lattice = MagneticLattice(cl.cell, start=collimator1_stop, stop=collimator2_stop, method=self.method)354 # init physics processes355 sc = SpaceCharge()356 sc.step = 1357 sc.nmesh_xyz = [31, 31, 31]358 sc.low_order_kick = False359 self.add_physics_process(sc, start=collimator1_stop, stop=collimator2_stop)360class CL3(SectionTrack):361 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):362 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)363 # setting parameters364 self.lattice_name = 'CL3'365 self.unit_step = 0.2366 self.input_beam_file = self.particle_dir + 'section_CL2.npz'367 self.output_beam_file = self.particle_dir + 'section_CL3.npz'368 self.tws_file = self.tws_dir + "tws_section_CL3.npz"369 collimator2_stop = cl.bpma_1783_cl370 collimator3_stop = cl.ensec_1854_cl371 # init tracking lattice372 self.lattice = MagneticLattice(cl.cell, start=collimator2_stop, stop=collimator3_stop, method=self.method)373 # init physics processes374 sc = SpaceCharge()375 sc.step = 10376 sc.nmesh_xyz = [31, 31, 31]377 sc.low_order_kick = False378 csr = CSR()379 csr.traj_step = 0.0005380 csr.apply_step = 0.005381 csr.n_bin = 300382 csr.sigma_min = 0.2e-6383 self.add_physics_process(csr, start=collimator2_stop, stop=collimator3_stop)384 self.add_physics_process(sc, start=collimator2_stop, stop=collimator3_stop)385class STN10(SectionTrack):386 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):387 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)388 # setting parameters389 self.lattice_name = 'ST10'390 self.unit_step = 10391 self.input_beam_file = self.particle_dir + 'section_CL3.npz'392 self.output_beam_file = self.particle_dir + 'section_STN10.npz'393 self.tws_file = self.tws_dir + "tws_section_STN10.npz"394 collimator3_stop = cl.ensec_1854_cl395 stN10_stop = sase1.ensec_2235_t2396 # init tracking lattice397 self.lattice = MagneticLattice(cl.cell + tl34.cell + sase1.cell, start=collimator3_stop, stop=stN10_stop, method=self.method)398 # init physics processes399 sc = SpaceCharge()400 sc.step = 1401 sc.nmesh_xyz = [31, 31, 31]402 sc.low_order_kick = False403 self.add_physics_process(sc, start=collimator3_stop, stop=stN10_stop)404class SASE1(SectionTrack):405 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):406 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)407 # setting parameters408 self.lattice_name = 'SASE1'409 self.unit_step = 5410 self.input_beam_file = self.particle_dir + 'section_STN10.npz'411 self.output_beam_file = self.particle_dir + 'section_SASE1.npz'412 self.tws_file = self.tws_dir + "tws_section_SASE1.npz"413 # last element sase1 - stsec_2461_t4414 stN10_stop = sase1.ensec_2235_t2415 sase1_stop = sase1.stsec_2461_t4416 # init tracking lattice417 self.lattice = MagneticLattice(sase1.cell, start=stN10_stop, stop=sase1_stop, method=self.method)418 # init physics processes419 wake = Wake()420 wake.wake_table = WakeTable('accelerator/wakes/wake_undulator_OCELOT.txt')421 wake.step = 15422 wake.w_sampling = 500423 sc = SpaceCharge()424 sc.step = 1425 sc.nmesh_xyz = [31, 31, 31]426 sc.low_order_kick = False427 self.add_physics_process(wake, start=sase1.match_2247_sa1, stop=sase1_stop)428 self.add_physics_process(sc, start=stN10_stop, stop=sase1_stop)429class T4(SectionTrack):430 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):431 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)432 # setting parameters433 self.lattice_name = 'T4'434 self.unit_step = 0.2435 self.input_beam_file = self.particle_dir + 'section_SASE1.npz'436 self.output_beam_file = self.particle_dir + 'section_T4.npz'437 self.tws_file = self.tws_dir + "tws_section_T4.npz"438 # last element sase1 - stsec_2461_t4439 sase1_stop = sase1.stsec_2461_t4440 t4_stop = t4.ensub_2800_t4441 csr_start = t4.t4_start_csr442 csr_stop = t4.bpma_2606_t4443 # init tracking lattice444 self.lattice = MagneticLattice(sase1.cell + t4.cell, start=sase1_stop, stop=t4_stop, method=self.method)445 # init physics processes446 sc = SpaceCharge()447 sc.step = 25448 sc.nmesh_xyz = [31, 31, 31]449 csr = CSR()450 csr.traj_step = 0.0005451 csr.apply_step = 0.005452 csr.n_bin = 300453 csr.sigma_min = 0.2e-6454 sc2 = SpaceCharge()455 sc2.step = 25456 sc2.nmesh_xyz = [31, 31, 31]457 # creation of wake object with parameters458 wake = Wake()459 wake.wake_table = WakeTable('accelerator/wakes/wake_hor_1m_500mkm.txt')460 #wake.wake_table = WakeTable('accelerator/wakes/wake_hor_1m.txt')461 # w_sampling - defines the number of the equidistant sampling points for the one-dimensional462 # wake coefficients in the Taylor expansion of the 3D wake function.463 wake.w_sampling = 500464 wake.factor = 1465 wake.step = 1 # step in Navigator.unit_step, dz = Navigator.unit_step * wake.step [m]466 # creation of wake object with parameters467 wake_vert = Wake()468 wake_vert.factor = 1469 wake_vert.wake_table = WakeTable('accelerator/wakes/wake_vert_1m_500mkm.txt')470 #wake_vert.wake_table = WakeTable('accelerator/wakes/wake_vert_1m.txt')471 wake_vert.w_sampling = 500472 wake_vert.step = 1 # step in Navigator.unit_step, dz = Navigator.unit_step * wake.step [m]473 self.add_physics_process(wake, start=t4.wake_start, stop=t4.m_tds)474 svb4 = SaveBeam(filename=self.particle_dir + "before_structure.npz")475 self.add_physics_process(svb4, start=t4.wake_start, stop=t4.wake_start)476 self.add_physics_process(wake_vert, start=t4.m_tds, stop=t4.wake_stop)477 svb3 = SaveBeam(filename=self.particle_dir + "after_structure.npz")478 self.add_physics_process(svb3, start=t4.wake_stop, stop=t4.wake_stop)479 svb1 = SaveBeam(filename=self.particle_dir + "screen1.npz")480 self.add_physics_process(svb1, start=t4.m_img1, stop=t4.m_img1)481 svb2 = SaveBeam(filename=self.particle_dir + "screen2.npz")482 self.add_physics_process(svb2, start=t4.m_img2, stop=t4.m_img2)483 #self.add_physics_process(sc, start=sase1_stop, stop=csr_start)484 self.add_physics_process(sc, start=sase1_stop, stop=csr_start)485 self.add_physics_process(csr, start=csr_start, stop=csr_stop)486 self.add_physics_process(sc2, start=csr_stop, stop=t4.ensub_2800_t4)487 sc_in_bend = SpaceCharge()488 sc_in_bend.step = 25489 sc_in_bend.nmesh_xyz = [31, 31, 31]490 #self.add_physics_process(sc_in_bend, start=csr_start, stop=csr_stop)491class SASE3(SectionTrack):492 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):493 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)494 # setting parameters495 self.lattice_name = 'SASE3'496 self.unit_step = 1497 self.input_beam_file = self.particle_dir + 'section_T4.npz'498 self.output_beam_file = self.particle_dir + 'section_SASE3.npz'499 self.tws_file = self.tws_dir + "tws_section_SASE3.npz"500 start = sase3.ensec_2800_t4501 stop = sase3.ensec_2940_sa3502 # init tracking lattice503 self.lattice = MagneticLattice(sase3.cell, start=start, stop=stop, method=self.method)504 # init physics processes505 sc = SpaceCharge()506 sc.step = 10507 sc.nmesh_xyz = [31, 31, 31]508 self.add_physics_process(sc, start=start, stop=stop)509class T4D(SectionTrack):510 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):511 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)512 # setting parameters513 self.lattice_name = 'SASE3'514 self.unit_step = 1515 self.input_beam_file = self.particle_dir + 'section_SASE3.npz'516 self.output_beam_file = self.particle_dir + 'section_T4D.npz'517 self.tws_file = self.tws_dir + "tws_section_tT4D.npz"518 start = t4d.stsec_2940_t4d519 stop = t4d.ensec_3106_t4d520 # init tracking lattice521 self.lattice = MagneticLattice(t4d.cell, start=start, stop=stop, method=self.method)522 # init physics processes523 sc = SpaceCharge()524 sc.step = 10525 sc.nmesh_xyz = [31, 31, 31]526 self.add_physics_process(sc, start=start, stop=stop)527 csr = CSR()528 csr.traj_step = 0.0005529 csr.apply_step = 0.005530 csr.n_bin = 300531 csr.sigma_min = 0.2e-6532 self.add_physics_process(csr, start=t4d.tora_3065_t4d, stop=t4d.qk_3090_t4d)533class T4_short(SectionTrack):534 def __init__(self, sc_flag=True, csr_flag=True, wake_flag=True):535 SectionTrack.__init__(self, sc_flag, csr_flag, wake_flag)536 # setting parameters537 self.lattice_name = 'T4'538 self.unit_step = 1539 self.calc_tws = False540 self.input_beam_file = self.particle_dir + 'before_structure.npz'541 self.output_beam_file = self.particle_dir + 'section_T4.npz'542 self.tws_file = self.tws_dir + "tws_section_T4.npz"543 # last element sase1 - stsec_2461_t4544 sase1_stop = t4.wake_start# sase1.stsec_2461_t4545 t4_stop = t4.m_img1 #t4.ensub_2800_t4546 csr_start = t4.t4_start_csr547 csr_stop = t4.bpma_2606_t4548 # init tracking lattice549 self.lattice = MagneticLattice(sase1.cell + t4.cell, start=sase1_stop, stop=t4_stop, method=self.method)550 # init physics processes551 sc = SpaceCharge()552 sc.step = 25553 sc.nmesh_xyz = [31, 31, 31]554 csr = CSR()555 csr.traj_step = 0.0005556 csr.apply_step = 0.005557 csr.n_bin = 300558 csr.sigma_min = 0.2e-6559 sc2 = SpaceCharge()560 sc2.step = 25561 sc2.nmesh_xyz = [31, 31, 31]562 # creation of wake object with parameters563 wake = Wake()564 wake.wake_table = WakeTable('accelerator/wakes/wake_hor_1m_500mkm.txt')565 # w_sampling - defines the number of the equidistant sampling points for the one-dimensional566 # wake coefficients in the Taylor expansion of the 3D wake function.567 wake.w_sampling = 500568 wake.factor = 1569 wake.step = 1 # step in Navigator.unit_step, dz = Navigator.unit_step * wake.step [m]570 # creation of wake object with parameters571 wake_vert = Wake()572 wake_vert.factor = 1573 wake_vert.wake_table = WakeTable('accelerator/wakes/wake_vert_1m_500mkm.txt')574 wake_vert.w_sampling = 500575 wake_vert.step = 1 # step in Navigator.unit_step, dz = Navigator.unit_step * wake.step [m]576 #svb1 = SaveBeam(filename=self.particle_dir + "screen1.npz")577 #self.add_physics_process(svb1, start=t4.m_img1, stop=t4.m_img1)578 #svb2 = SaveBeam(filename=self.particle_dir + "screen2.npz")579 svb3 = SaveBeam(filename=self.particle_dir + "after_structure.npz")580 #svb4 = SaveBeam(filename=self.particle_dir + "before_structure.npz")581 #self.add_physics_process(svb2, start=t4.m_img2, stop=t4.m_img2)582 self.add_physics_process(wake_vert, start=t4.wake_start, stop=t4.m_tds)583 #self.add_physics_process(wake, start=t4.m_tds, stop=t4.wake_stop)584 #self.add_physics_process(svb3, start=t4.wake_stop, stop=t4.wake_stop)585 #self.add_physics_process(svb4, start=t4.wake_start, stop=t4.wake_start)586 #self.add_physics_process(sc, start=sase1_stop, stop=csr_start)587 #self.add_physics_process(sc, start=sase1_stop, stop=csr_start)588 #self.add_physics_process(csr, start=csr_start, stop=csr_stop)589 #self.add_physics_process(sc2, start=csr_stop, stop=t4.ensub_2800_t4)590 sc_in_bend = SpaceCharge()591 sc_in_bend.step = 25592 sc_in_bend.nmesh_xyz = [31, 31, 31]593 #self.add_physics_process(sc_in_bend, start=csr_start, stop=csr_stop)594sections = [A1, AH1, LH, DL, BC0, L1, BC1, L2, BC2, L3, CL1,...

Full Screen

Full Screen

wake3D.py

Source:wake3D.py Github

copy

Full Screen

...163 wake1 = np.interp(xwi, xw, wake, 0, 0)164 wake1[0] = wake1[0]*0.5165 xW, Wake = self.convolution(xb, bunch, xwi, wake1)166 return xW[0:nb], Wake[0:nb]167 def add_wake(self, I, T):168 """169 [x, W] = AddWake(I, T)170 :param I: wake table in V/C, W in V (R, L, Cinv, nm, W0, N0, W1, N1)171 :param T:172 :return:173 """174 """[x, W] =AddWake (I,T)175 T - wake table in V/C, W in V176 (R,L,Cinv,nm,W0,N0,W1,N1)"""177 R, L, Cinv, nm, W0, N0, W1, N1 = T178 c = speed_of_light179 x = I[:, 0]180 bunch = I[:, 1]181 if L != 0 or N1 > 0:182 d1_bunch=Der(x,bunch)183 nb=x.shape[0]184 W=np.zeros(nb)185 if N0 > 0:186 x, ww = self.wake_convolution(x, bunch, W0[:, 0], W0[:, 1])187 W = W-ww[0:nb]/c188 if N1>0:189 x, ww = self.wake_convolution(x, d1_bunch, W1[:, 0], W1[:, 1])190 #W = W - ww[0:nb]191 W = W + ww[0:nb]192 if R != 0:193 W = W-bunch*R194 if L != 0:195 #W = W - d1_bunch*L*c196 W = W + d1_bunch*L*c197 if Cinv != 0:198 int_bunch = Int1(x, bunch)199 W = W - int_bunch*Cinv/c200 return x, W201 def add_total_wake(self, X, Y, Z, q, TH, Ns, NF):202 #function [Px Py Pz I00]=AddTotalWake (P,q,wakeFile,Ns,NF)203 T, H = TH204 c = speed_of_light205 #Z=-Z206 Np=X.shape[0]207 X2 = X**2208 Y2 = Y**2209 XY = X*Y210 #generalized currents;211 I00 = s2current(Z, q, Ns, NF, c)212 Nw=I00.shape[0]213 if (H[0,2]>0)or(H[2,3]>0)or(H[2,4]>0):214 qn=q*Y215 I01 = s2current(Z,qn,Ns,NF,c)216 if (H[0, 1] > 0)or(H[1, 3] > 0) or (H[1, 4] > 0):217 qn=q*X218 I10 = s2current(Z,qn,Ns,NF,c)219 if H[1,2]>0:220 qn=q*XY221 I11 = s2current(Z,qn,Ns,NF,c)222 if H[1,1]>0:223 qn=q*(X2-Y2)224 I20_02 = s2current(Z, qn, Ns, NF, c)225 #longitudinal wake226 #mn=0227 x, Wz = self.add_wake (I00, T[int(H[0, 0])])228 if H[0, 1] > 0:229 x, w = self.add_wake(I10, T[int(H[0, 1])])230 Wz = Wz+w231 if H[0,2]>0:232 x, w = self.add_wake(I01, T[int(H[0, 2])])233 Wz = Wz+w234 if H[1,1]>0:235 x, w = self.add_wake(I20_02, T[int(H[1, 1])])236 Wz = Wz+w237 if H[1,2]>0:238 x, w = self.add_wake(I11, T[int(H[1, 2])])239 Wz = Wz+2*w240 Pz = np.interp(Z, x, Wz, 0, 0)241 Py = np.zeros(Np)242 Px = np.zeros(Np)243 #mn=01244 Wz[0:Nw] = 0245 Wy = np.zeros(Nw)246 if H[0, 4] > 0:247 x, w = self.add_wake(I00, T[int(H[0, 4])])248 Wz=Wz+w249 Wy=Wy+w250 if H[1,4]>0:251 x, w = self.add_wake(I10, T[int(H[1, 4])])252 Wz = Wz + 2*w253 Wy = Wy + 2*w254 if H[2,4]>0:255 x, w = self.add_wake(I01, T[int(H[2, 4])])256 Wz = Wz + 2*w257 Wy = Wy + 2*w258 Pz = Pz + np.interp(Z, x, Wz, 0, 0)*Y259 h = x[1] - x[0]260 Wy = -Int1h(h, Wy)261 Py = Py + np.interp(Z, x, Wy, 0, 0)262 #mn=10263 Wz[0:Nw] = 0264 Wx = np.zeros(Nw)265 if H[0, 3] > 0:266 x, w = self.add_wake(I00, T[int(H[0, 3])])267 Wz = Wz + w268 Wx = Wx + w269 if H[1,3]>0:270 x, w = self.add_wake(I10, T[int(H[1, 3])])271 Wz = Wz + 2*w272 Wx = Wx + 2*w273 if H[2,3]>0:274 x, w = self.add_wake(I01, T[int(H[2, 3])])275 Wz = Wz + 2*w276 Wx = Wx + 2*w277 Wx=-Int1h(h,Wx)278 Pz = Pz + np.interp(Z, x, Wz, 0, 0)*X279 Px = Px + np.interp(Z, x, Wx, 0, 0)280 #mn=11281 if H[3,4]>0:282 x, w = self.add_wake(I00, T[int(H[3, 4])])283 Wx=-2*Int1h(h,w)284 p=np.interp(Z,x,Wx,0,0)285 Px = Px + p*Y286 Py = Py + p*X287 Pz = Pz + 2*np.interp(Z, x, w, 0, 0)*XY288 #mn=02,20289 if H[3,3]>0:290 x, w = self.add_wake(I00, T[int(H[3, 3])])291 Pz = Pz+np.interp(Z,x,w,0,0)*(X2-Y2)292 Wx = -2*Int1h(h,w)293 p = np.interp(Z,x,Wx,0,0)294 Px = Px + p*X295 Py = Py - p*Y296 I00[:,0]=-I00[:,0]297 #Z=-Z298 return Px, Py, Pz, I00299 def prepare(self, lat):300 if self.wake_table is None:301 _logger.info("Wake.wake_table is None! Please specify the WakeTable()")302 else:303 self.TH = self.wake_table.TH304 def apply(self, p_array, dz):305 _logger.debug(" Wake: apply: dz = " + str(dz))306 ps = p_array.rparticles307 Px, Py, Pz, I00 = self.add_total_wake(ps[0], ps[2], ps[4], p_array.q_array, self.TH, self.w_sampling, self.filter_order)308 L = self.s_stop - self.s_start309 if L == 0:310 dz = 1.0311 else:312 dz = dz/L313 p_array.rparticles[5] = p_array.rparticles[5] + Pz * dz*self.factor / (p_array.E * 1e9)314 p_array.rparticles[3] = p_array.rparticles[3] + Py * dz*self.factor / (p_array.E * 1e9)315 p_array.rparticles[1] = p_array.rparticles[1] + Px * dz*self.factor / (p_array.E * 1e9)316class WakeKick(Wake):317 def __init__(self, factor=1):318 print("WakeKick physics process is obsolete. Use Wake.")319 Wake.__init__(self)320 self.factor = factor321 def apply(self, p_array, dz):322 _logger.debug(" WakeKick: apply")323 ps = p_array.rparticles324 Px, Py, Pz, I00 = self.add_total_wake(ps[0], ps[2], ps[4], p_array.q_array, self.TH, self.w_sampling,325 self.filter_order)326 p_array.rparticles[5] = p_array.rparticles[5] + self.factor * Pz / (p_array.E * 1e9)327 p_array.rparticles[3] = p_array.rparticles[3] + self.factor * Py / (p_array.E * 1e9)...

Full Screen

Full Screen

add_wake.py

Source:add_wake.py Github

copy

Full Screen

...34 wake.append(float(d[1]))35 return wake36def add_wake_to_beam(beam):37 # beam = read_beam_file(beamf)38 # s, bunch, wake = w.xfel_pipe_wake(s=beam.z, current=beam.I[::-1])39 s, bunch, wake = w.xfel_pipe_wake(s=beam.z, current=beam.I)40 print ('read ', len(wake), ' slice values')41 beam1 = deepcopy(beam)42 beam1.eloss = wake[::-1]43 # f=open(new_beamf,'w')44 # f.write(beam_file_str(beam))45 # f.close()46 return beam147if len(sys.argv)>3:48 command = sys.argv[1]49 beamf = sys.argv[2] 50 outf = sys.argv[3]51else:52 command = ''53 #beamf = '/home/iagapov/tmp/run_2/tmp.beam'54 #command = 'current'55 #outf = 'tmp.beam'56 57if command == 'current':58 beam = read_beam_file(beamf)59 beam.columns = ['ZPOS','CURPEAK']60 beam.I = beam.I[::-1]61 f=open(outf,'w')62 f.write(beam_file_str(beam))63 f.close()64 #print beam_file_str(beam)65if command == 'add_from_file':66 if len(sys.argv)>2:67 wakef = sys.argv[3]68 outf = sys.argv[4] 69 else:70 beamf = '/home/iagapov/tmp/run_2/tmp.beam'71 command = 'current'72 73 wake = get_wake_from_file(wakef)74 beam = read_beam_file(beamf)75 #s, bunch, wake = w.xfel_pipe_wake(s=array(beam.z), current=array(beam.I))76 print ('read ', len(wake), ' slice values')77 beam.eloss = wake[::-1]78 79 f=open(outf,'w')80 f.write(beam_file_str(beam))81 f.close()82 beam = read_beam_file(beamf)83if command == "add":84 #if len(sys.argv)>2:85 # #wakef = sys.argv[3]86 # outf = sys.argv[4]87 #else:88 # beamf = '/home/iagapov/tmp/run_2/tmp.beam'89 # command = 'current'90 #wake = get_wake_from_file(wakef)91 beam = read_beam_file(beamf)92 beam1 = add_wake_to_beam(beam)93 write_beam_file(outf, beam1)94"""95if __name__ == "__main__":96 import ocelot.utils.reswake as w97 from numpy import array98 from matplotlib.pyplot import *99 #beamf = "../../desy/xfel/beams/beam_1nC.txt"100 #beamf = "../../desy/xfel/beams/beam_0.02nC.txt"101 #beamf = "../../desy/xfel/beams/beam_0.25nC.txt"102 beamf = "../test/100pC_skew.txt"103 beamf_new = "../test/100pC_skew_wake.txt"104 beam = read_beam_file(beamf)105 print (beam.z, beam.I)106 #I = array(beam.I[::-1])107 #s = -array(beam.z[::-1])108 s, bunch, wake = w.xfel_pipe_wake(s=array(beam.z), current=array(beam.I))109 beam.eloss = wake[::-1]110 fig, ax1 = subplots()111 ax1.plot(beam.z, beam.I, "b")112 ax1.grid(True)113 ax1.set_ylabel('I[A]', color='b')114 ax2 = ax1.twinx()115 ax2.plot(beam.z, beam.eloss/1000 , "r")116 ax2.set_ylabel('wake, [kV/m]', color='r')117 show()118 add_wake_to_beamf(beamf, beamf_new)119 beam = read_beam_file(beamf_new)120 fig, ax1 = subplots()121 ax1.plot(beam.z, beam.I, "b")122 ax1.set_ylabel('I[A]', color='b')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful