How to randomly select one injection beam file from 1001 injection beam files

Moderators: cyao, michael_borland

Post Reply
Zhenbiao
Posts: 11
Joined: 06 Apr 2017, 07:41

How to randomly select one injection beam file from 1001 injection beam files

Post by Zhenbiao » 12 Nov 2024, 03:38

Hello,

I am using Elegant for longitudinal jitter simulations. The &error_element command is used to add RF phase and cavity voltage errors. I have 1001 injection beam files (inj_0001.sdds to inj_1001.sdds) from the injector's simulation results. I want to simulate injection beam errors by randomly selecting an injection beam file in each step of the calculation. Assume n_steps=101 in run_control, how to randomly select one injection beam file from 1001 injection beam files at each step of the computation? Can input_list &sdds_beam in work? If it works, how to proceed?

Many thanks for any suggestion,
Zhenbiao

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

Re: How to randomly select one injection beam file from 1001 injection beam files

Post by michael_borland » 12 Nov 2024, 17:30

Zhenbiao,

I would combine the input beam files and randomize their order, as follows

Code: Select all

sddscombine inj_????.sdds -pipe=out \
| sddsprocess -pipe -define=parameter,sortOrder,rnd \
| sddssort -pipe=in randomizedBeams.sdds -parameter=sortOrder
This assigns a random number to each page of the combined file, then sorts by that random number.

In elegant, you then use

Code: Select all

&sdds_beam
	input = randomizedBeams.sdds,
	track_pages_separately = 1
&end
--Michael

Zhenbiao
Posts: 11
Joined: 06 Apr 2017, 07:41

Re: How to randomly select one injection beam file from 1001 injection beam files

Post by Zhenbiao » 12 Nov 2024, 21:00

Dear Michael,

Many thanks for your quick reply. It works well.

Best regards,
Zhenbiao

Post Reply