Simulation of a multislit in elegant

Moderators: cyao, michael_borland

Post Reply
Philippe Piot
Posts: 83
Joined: 20 Aug 2008, 13:18
Location: Northern Illinois University & Argonne National Laboratory
Contact:

Simulation of a multislit in elegant

Post by Philippe Piot » 04 Nov 2009, 09:22

Hi,
Is there a simple way to simulate a multislit system in elegant (e.g. a series of vertical slits with same opening and center-to-center separation as one would use to measure the transverse emittance). Right now I am doing this the "brute force way" using a tcl script with the SCRIPT command but it makes things very slow for large number of macroparticle. I was thinking to stack a series of RCOL with very thin length but cannot figure out how to do this and whether this would work. Thank you! -- Philippe.

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

Re: Simulation of a multislit in elegant

Post by michael_borland » 06 Nov 2009, 10:53

Philippe,

I can't think of a way to do this other than using the SCRIPT element. It would be a good thing to have so I'll add it to the list of needed features.

--Michael

Philippe Piot
Posts: 83
Joined: 20 Aug 2008, 13:18
Location: Northern Illinois University & Argonne National Laboratory
Contact:

Re: Simulation of a multislit in elegant

Post by Philippe Piot » 06 Nov 2009, 13:53

Thanks Michael. Since then I improved my tcl script to use the sddsprocess command. It is now much faster; I post below for the benefit of anybody interested -- Philippe.

#!/bin/sh
# \
exec tclsh "$0" "$@"
if [llength $argv]!=2 {
return -code error
}

set input [lindex $argv 0]
set output [lindex $argv 1]

puts "input \t $input"
puts "output \t $output"

set D 0.001
set W 0.00005

set W1L $W
set W1U [expr $D-$W]
set W2L [expr $D+$W]
set W2U [expr 2*$D-$W]
set W3L [expr 2*$D+$W]
set W3U [expr 3*$D-$W]
set W4L [expr 3*$D+$W]
set W4U [expr 4*$D-$W]
set W5L [expr 4*$D+$W]
set W5U [expr 5*$D-$W]
set W6L [expr 5*$D+$W]
set W6U [expr 6*$D-$W]
set W7L [expr 6*$D+$W]
set W7U [expr 7*$D-$W]
set W8L [expr 7*$D+$W]
set W8U [expr 8*$D-$W]
set W9L [expr 8*$D+$W]
set W9U [expr 9*$D-$W]
set W10L [expr 9*$D+$W]
set W10U [expr 10*$D-$W]
set W11L [expr 10*$D+$W]
set W11U [expr 11*$D-$W]
set W12L [expr 11*$D+$W]
set W12U [expr 12*$D-$W]
set W13L [expr 12*$D+$W]
set W13U [expr 13*$D-$W]

set c 299798452.00

exec sddsprocess $input -pipe=out -filter=column,x,$W1L,$W1U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W2L,$W2U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W3L,$W3U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W4L,$W4U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W5L,$W5U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W6L,$W6U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W7L,$W7U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W8L,$W8U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W9L,$W9U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W10L,$W10U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W11L,$W11U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W12L,$W12U,! | \
sddsprocess -pipe=in,out -filter=column,x,$W13L,$W13U,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W13U,-$W13L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W12U,-$W12L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W11U,-$W11L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W10U,-$W10L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W9U,-$W9L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W8U,-$W8L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W7U,-$W7L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W6U,-$W6L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W5U,-$W5L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W4U,-$W4L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W3U,-$W3L,! | \
sddsprocess -pipe=in,out -filter=column,x,-$W2U,-$W2L,! | \
sddsprocess -pipe=in $output -filter=column,x,-$W1U,-$W1L,!

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

Re: Simulation of a multislit in elegant

Post by michael_borland » 06 Nov 2009, 17:17

Phillipe,

Thanks for posting this. You can make it even faster by using only one sddsprocess invocation, as follows:

exec sddsprocess $input $output -filter=column,x,$W1L,$W1U,! \
-filter=column,x,$W2L,$W2U,! \
-filter=column,x,$W3L,$W3U,! \
...

--Michael

Post Reply