ocelot-collab / ocelot

OCELOT is a multiphysics simulation toolkit designed for studying FEL and storage ring-based light sources.
GNU General Public License v3.0
84 stars 58 forks source link

making Chicane set up #223

Closed dmargarone closed 5 months ago

dmargarone commented 5 months ago

Dear Developers,

I want to use Chicane for beam compressor. Please, can you help me to know how I can do it in OCELOT. I want to start with a simple example, like I have a chirped electron beam and then compressing it with the use of a Chicane set up.

Thanks a lot in advance. DM

sergey-tomin commented 5 months ago

Hi,

One of the tutorials includes a simple example of beam compression. Although it is mainly about another subject but first part dedicated to chicane and beam compression. https://nbviewer.org/github/ocelot-collab/ocelot/blob/master/demos/ipython_tutorials/9_thz_source.ipynb

cheers, Sergey.

dmargarone commented 5 months ago

Thank you @sergey-tomin

I will follow the example given in the above link. I will try to learn from this example file. If I will have any questions, I will come back to you for some help or clarification.

Thank you so much for such a wonderful code.

Best regards, DM

dmargarone commented 5 months ago

Hi @sergey-tomin ,

I have a question about "Dx" and "x" variable in the plots (following the tutorials).

I made a small run with chicane as defined below.

Could you please help me to understand what is the meaning of Dx ?? I think x / y are the transverse coordinates of the beam ... is it correct ??

Why beta_x and beta_y shape is different in the two plots generated by the code below ? (I have also attached the two figures.)

lattice

ang_value = 0.5

b1 = Bend(l = 0.2, angle = -ang_value, e1 = 0.0, e2 = -ang_value, tilt = 0., eid= "b") b2 = Bend(l = 0.2, angle = ang_value, e1 = ang_value, e2 = 0.0, tilt = 0., eid= "b") b3 = Bend(l = 0.2, angle = ang_value, e1 = 0.0, e2 = ang_value, tilt = 0., eid= "b") b4 = Bend(l = 0.2, angle = -ang_value, e1 = -ang_value, e2 = 0.0, tilt = 0., eid= "b") d1 = Drift(l=0.5) d2 = Drift(l=0.5)

cell = [Marker(eid="m1"), Drift(l=0.1), b1, d1, b2, d2, b3, d1, b4,Drift(l=0.1), Marker(eid="m2")]

method = {'global': SecondTM}

lat = MagneticLattice(cell, method=method)

plot_opt_func(lat, tws_echo, fig_name=0, legend=False)

x = [tw.x for tw in tws_track] sigma_x = np.sqrt([tw.xx for tw in tws_track]) y = [tw.y for tw in tws_track] sigma_y = np.sqrt([tw.yy for tw in tws_track]) s = [tw.s for tw in tws_track]

plot_opt_func(lat, tws_track, top_plot=["x","y"], fig_name=1, legend=False)

Screenshot 2024-04-04 at 10 17 00 PM Screenshot 2024-04-04 at 10 16 41 PM
sergey-tomin commented 5 months ago

HI,

Dx is horizontal dispersion.

I think x / y are the transverse coordinates of the beam ... is it correct ?? it is correct.

Why is betas are different on two plots? maybe it is because 'tws_echo' and 'tws_track' are different. It is impossible to determine conclusively based on the information provided.

dmargarone commented 5 months ago

Hi @sergey-tomin ,

Thank you for the prompt reply. Please, could you help me to understand the three figures generated in this script. I have three basic questions:

(1) why Dx in figure 1 is different that from figure 2. (2) why beta_x and beta_y are different in figure 1 and 2 (or 3). (3) why "y" is not changing but only "x" coordinate change in figure 3.

Thank you.

Best regards, DM

dmargarone commented 5 months ago

Hi @sergey-tomin ,

OK, now I understand answer of my question (3): why only x-coordinate is changing but not y. It is because the dispersion or deflection by magnetic field only affect position along x-direction [v X B force]).

But, please could you help me to understand question (1) and (2)

Thank you. DM