Tracking for DA study

Moderators: cyao, michael_borland

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Tracking for DA study

Post by ccwang » 09 Jan 2009, 20:53

Dear Michael and Cyao,

I am a new user for elegant. When doing DA study, I would like to have turn-by-turn information about particle at each point in x-y plane. Is there any example code available? Thanks a lot in advance.

ccwang

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Re: Tracking for DA study

Post by ccwang » 09 Jan 2009, 22:45

BTW, here is my elegant input script for DA study. I wish this one is correct.


!----------------------------------------------------------------------------------------
&run_setup
lattice = "ALBA.lte",
magnets = "%s.mag",
use_beamline = "RING",
p_central = 5870.854,
default_order = 2,
concat_order =0,
random_number_seed = 10
&end


&run_control
n_steps = 1,
n_passes = 1000
&end
&twiss_output filename = "%s.twi", statistics=1, radiation_integrals=1,
!matched = 1,
output_at_each_step=1 &end

&error_control clear_error_settings = 1, &end



&bunched_beam n_particles_per_bunch = 1 &end


&find_aperture
output = "%s.aper", boundary = "%s.abnd",
xmin = -0.05, xmax = 0.05, ymax = 0.05,
nx = 501, ny = 251, verbosity = 2
&end

&stop &end

michael_borland
Posts: 1735
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking for DA study

Post by michael_borland » 12 Jan 2009, 14:10

You can obtain turn-by-turn data by inserting a WATCH element into the lattice, as in

w1: watch,filename="%s.w1",mode="coord"
ring1: line=(w1,ring)

However, be advised that this will slow down the simulation considerably. Also, I think you'll find this is a confusing way to look at phase space motion, because not all the particles in the grid are tracked, resulting in an incomplete picture.

A better way is illustrated in the attached files.

--Michael
Attachments
parTrack.lte
(1.78 KiB) Downloaded 1001 times
parTrack.ele
(1.06 KiB) Downloaded 1032 times

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Re: Tracking for DA study

Post by ccwang » 13 Jan 2009, 20:10

Dear Michael,

Thanks a lot. I have one follow up question. In "parTrack.ele", the way to vary parameters is
---------------------------------------------------------------------
&vary_element
name=mal, item=dx, initial=1e-2, final=6e-2,
index_number=0, index_limit=6
&end
---------------------------------------------------------------------

It seems we only vary "dx" and fix the dy to be zero. Is it possible to do vary "dx" with dy to be some non-zero value. Besides, is it possible to vary "dx" and "dy" both to do a 2-d scan. If so, how can we know which index is correspond to which (dx,dy)? Thanks a lot.

Best wishes,
Chinchi

michael_borland
Posts: 1735
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking for DA study

Post by michael_borland » 14 Jan 2009, 10:02

Chinchi,

The easiest way to set DY to a non-zero value is using the alter_elements command, as in
&alter_elements name=MAL, item=DY, value=1e-4 &end
which sets DY to 0.1 mm. This should go before the run_control command.

You can also vary DX and DY in a 2D grid. This is shown in the attached file. In this input file, the "final" output file under run_setup is requested, which contains the values of DX and DY. We can then use the SDDS cross-referencing program sddsxref to associate these values with the phase space data. Try the following:
% elegant parTrack2d.ele
% sddsxref parTrack2d.w1 parTrack2d.fin -pipe=out -leave=* -transfer=parameter,MAL.* | sddsprocess -pipe=in parTrack2d.w1a -print=parameter,Label1,"DX=%g DY=%g",MAL.DX,MAL.DY
% sddsplot -groupby=page,names -split=page -separate=names -layout=2,2 -title=@Label1 -graph=dot -column=Cx,Cxp -column=Cy,Cyp -column=Cx,Cy -column=Cxp,Cyp parTrack2d.w1a

You'll get a set of plots showing (x, x'), (y,y'), (x,y), and (x',y') for each initial pair of DX and DY values. Once the plot window appears, use the 'n' and 'p' keys to view the Next or Previous plot.

--Michael
Attachments
parTrack2d.ele
(744 Bytes) Downloaded 1067 times

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Re: Tracking for DA study

Post by ccwang » 16 Jan 2009, 06:09

Dear Michael,

In your example, there are two lines in run_set:
----------------------------------------------------
default_order = 1,
concat_order =1
----------------------------------------------------

What does this "order" mean for? As I know, the default order is 2, why we should set 1 for the tracking?

Thanks a lot.

Chinchi

michael_borland
Posts: 1735
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking for DA study

Post by michael_borland » 16 Jan 2009, 09:28

Chinchi,

Setting the default matrix order to 1 is necessary for tracking in rings because otherwise it is non-symplectic (you'll get fictitious growth or decay of particle motion).

When tracking in rings, you should always use KSEXT and KQUAD elements instead of SEXT and QUAD. These give you higher order effects in a symplectic way.

Also, using CSBEND is recommended for "small" rings, whereas SBEND is ok (with default_order=1) for large rings.

--Michael

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Re: Tracking for DA study

Post by ccwang » 16 Jan 2009, 19:35

Dear Michael,

Thanks a lot for!

I have one more question. For the dynamic aperature, shall we set the order to be two? If yes, it looks to me that the model elegant used for tracking and dynamical aperature calcualtion is different, is it true?

Best wishes,
Chinchi

michael_borland
Posts: 1735
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: Tracking for DA study

Post by michael_borland » 16 Jan 2009, 21:15

Chinchi,

It is safest to use default_order=1 for dynamic aperture (find_aperture command) and momentum aperture (momentum_aperture command), because you want the tracking to be symplectic.

I say "safest", because there are cases where you can set default_order=2 and still get valid results. Examples would be when you use only kick elements (e.g., KQUAD, KSEXT, and CSBEND), or when you explicitly set the order of certain elements to 1 in the element definition.

For example, for APS dynamic/momentum aperture, we use KQUAD, KSEXT, and SBEN elements. On the SBENs, we explicitly set ORDER=1 and EDGE_ORDER=1, to ensure it is symplectic. The advantage is that we can leave default_order=2 and elegant will still do chromaticity calculations. We can get away with this for APS because the bending radius is quite large (38m).

If you want to track a smaller ring, you should use KQUAD, KSEXT, and CSBEND elements only. In that case, setting default_order=1 only affects the order of the edge matrices for the dipoles, but it is still important. Once again, you can also set EDGE_ORDER=1 on the CSBEND element definitions, leave default_order=2, and elegant will compute chromaticities etc using second order terms (except for the dipole edge effects).

--Michael

ccwang
Posts: 12
Joined: 09 Jan 2009, 05:10

Re: Tracking for DA study

Post by ccwang » 16 Jan 2009, 21:50

Dear Michael,

May I ask what is the difference between "CSBEND" and "SBEND"?

Chinchi

Post Reply