Dear Sara,
I'm glad my example was useful!
To understand the beam current calculation you can unfold this sequence of commands and do it step-by-step:
Code: Select all
exec \
sddshist $w -pipe=out \
-dataColumn=dt -sizeOfBins=[expr {$bin_size_ds/3.0e8}] -statistics \
-lowerLimit=[expr {$s_min/3.0e8}] -upperLimit=[expr {$s_max/3.0e8}] | \
sddsprocess -pipe \
"-define=column,I,Charge Particles / frequency * sddshistBinSize / ,units=A" \
"-define=column,s,dt c_mks * -1 *,units=m" | \
sddsprocess -pipe=in $I \
"-process=I,maximum,I_max"
sddshist w1.sdds w1_hist.sdds -dataColumn=dt -statistics
-- this command will produce the histogram of particles with respect to dt column of w1.sdds watchpoint output. You can plot it typing
sddsplot w1_hist.sdds -col=dt,frequency -split=page -sep=page

- hist.png (5.77 KiB) Viewed 10044 times
(press N or P to move between different turns saved in a separate pages of sdds file).
This is a longitudinal distribution of your beam with automatic binning. If you want to use a custom binning it can be specified in the -sizeOfBins, -lowerLimit and -upperLimit arguments of sddshist. But first it might be a good idea to use automatic binning.
To get the longitudinal position along the bunch instead of the time delay dt you need to multiply the dt by the speed of particles (i.e. 3e8 m/s). This can be done by typing
sddsprocess w1_hist.sdds "-define=column,s,dt -3e8 *,units=m" (please note that sddsprocess uses
rpn notation).
"-" sign is needed because the particles with dt>0 are the particles from the beam tail and with dt<0 -- from the beam head.
In order to calculate the beam current you need to divide the beam charge in a bin by the size of the bin in seconds:
sddsprocess w1_hist.sdds "-define=column,I,Charge Particles / frequency * sddshistBinSize /,units=A"
The human-readable formula would be
I = Charge*(frequency/Particles)/sddshistBinSize
Parameters
Charge (bunch charge),
Particles (number of macro-particles) are already in the w1.sdds file and
sddshistBinSize parameter is written by the sddshist command. (
frequency is the number of particles per bin).
Now
sddsplot w1_hist.sdds -col=s,I -split=page -sep=page can plot the bunch current profile:

- I.png (5.19 KiB) Viewed 10044 times
Best regards,
/Alexey