An ESRF undulator simulation with SHADOW

This is an example of generating an undulator source with SHADOW. The undulator parameters are: K=2.08 wavelength=46mm 35 periods, placed in a ESRF low beta straight section and using the third harmonic.
This source is the one used for the Beamline 1 calculations.
We will generate a white source in a small energy interval close to the third harmonic peak. We use few energy points because we only need the energy interval a little wider than the monochromator resolution, so in such range of few eV the undulator spectrum can be considered flat.

expgc.shadow<22>make_id ---------------------------------------------------------------------- Type of Insertion Device. Enter:  for wiggler   (large K)      [ 1 ] for undulator (small K)      [ 2 ]  Then ? 2   ----------------------------------------------------------------------   Define Insertion Device parameters:          wavelength of insertion device (m) : .046        deflection parameter K : 2.08        electron energy (GeV) : 6       Enter the number of points to be used in the  trajectory calculation.        ( max = 1001, suggested 101 ) : 101  End correction field factor (0-1) : 1   ----------------------------------------------------------------------    Two files will be created. One will contain a  record of the parameters used in the calculation, the other       the trajectory itself. The names of the files can be specified by the user, e.g., MYFILE.PAR and MYFILE.TRJ.   Output files specification:          Name for parameter file: und.par        Name for UNDULATOR trajectory file: und.traj        Do you want a plottable file [ Y/N ] ?    ----------------------------------------------------------------------     Calculation Completed. File out results.     ----------------------------------------------------------------------     Files:   und.traj                                                                         und.par                                                                            Written to disk.   All Done. Trajectory computed and stored on Disk. ----------------------------------------------------------------------     *********************** UNDULATOR RADIATION ***********************   Parameters from :  	User interactive process   (0)  	NAMELIST file		   (1)   Choice :  Computation done by :        supplied program        (0)        user's program          (1)  Choice :    ---------------------------------------------------------------------------     Define Radiation Computational parameters:   Polar coordinate is used here.  Number of points in energy (51 max) : 11                       theta (31 max) : 31                         phi (31 max) : 31   ---------------------------------------------------------------------------   ---------------------------------------------------------------------------          Enter name of trajectory file from EPATH  (input ) :und.traj   ---------------------------------------------------------------------------   Undulator case. Trajectory computed by EPATH with following parameters:   Number of points       :  101 Undulator wavelength   :    4.6000000000000D-02  meters Deflection parameter   :    2.0800000000000 Peak magnetic field    :   0.48431195430933  tesla Electron energy	       :    6.0000000000000  GeV Gamma		       :    11740.316448203 ****** Fundamental energy     :    2349.2306933582  eV Fundamental wavelength :    5.2783098635786  Angstrom ******   ---------------------------------------------------------------------------  Parameters for Radiation Computation. Please note value of first harmonic from above table.      Enter number of periods: 35 /* The third harmonic peak will be at 7047.69eV. I recommed to use
a small energy interval close near the peak at the left side, where
the undulator spectrum is almost flat. Let's say we use the interval
from 7040 to 7046eV because the bandwith of the beamline monochromator
will select few eV. The interval is not very critical, because after
the source generation you can change the energy interval without
generating again the source by using the utility RECOLOR. That asumes
the geometric characteristics of thes source will not be changed, that
is true if we do not go very far away from the starting undulator peak.  */
         spectrum starting energy [ eV ] : 7040                   final           [ eV ] : 7046          electron current         [ A  ] : .1 /* At this point you have to look for your pocket calculator. Tha next
value will be tha angular range used for the source generation. A very
big range will include all the radiation with all the undulator rings
at the selected energy, but usually in the beamline there is a slit
which selects something less that the central cone. That is our case,
so we only are interested in the central cone. If we use a wider interval
we will lose statistics (number of good rays through our system).
The angular width ogf the central cone is  [see for instance the Yellow Book]
width = gamma**(-1) sqrt[(1+(K**2/2))/(2 n N)]
where gamma = E[Gev]*1957 n is the n-th harmonic used and N is the
number of periods. 
In our case we have a central cone width at the 3rd harmonic about 
0.011 mrad so a limit value of 0.015 will be OK                    */

 Maximum angle between radiation and undulator axis [ mrad ]: 0.015 All undulator parameters defined.  How many times of optimization ? 
      /* Put always 0 */
How often do you want a report on calculations ?  E.G., 20, 50,... ? 1000   ---------------------------------------------------------------------------   Begin calculations.    Phi / Horz:  Theta / Vert : Energy:        CPU Time:      % Completed:    0.367        0.500E-06      0.704E+04       5.82              9.46   0.785        0.100E-05      0.704E+04       11.4             18.92    1.20        0.150E-05      0.704E+04       16.8             28.38      0.        0.250E-05      0.704E+04       22.2             37.84   0.419        0.300E-05      0.704E+04       28.0             47.30   0.838        0.350E-05      0.704E+04       33.7             56.76    1.26        0.400E-05      0.704E+04       39.3             66.22   0.524E-01    0.500E-05      0.704E+04       44.6             75.68   0.471        0.550E-05      0.705E+04       50.0             85.14   0.890        0.600E-05      0.705E+04       55.4             94.60   ---------------------------------------------------------------------------   Spectra Computations completed.     ---------------------------------------------------------------------------   Calculation completed. ---------------------------------------------------------------------------   ---------------------------------------------------------------------------   Begin computation of total power. Total Power emitted in the specified angles is:      2.5007562757905D-02 Watts.   Preliminary calculations completed.     Number of optimizations finished :   0    Do you want to write out spectra ?   Do you want to create a SHADOW file ? 1  Name of (binary) file for SHADOW: und.shz^?   a  File name for parameter info : und.info ---------------------------------------------------------------------------   Files: und.info                                                                                                                                                          und.sha                                                                          written to disk. ---------------------------------------------------------------------------   
/* Now, let's see the information files und.par and und.info          */

expgc.shadow<23> cat und.par Parameters used for run creating UNDULATOR case. Trajectory stored in: und.traj                                                                         The UNDULATOR case uses 1 period only. ------   INPUT    --------- Insertion device  Wavel.  [ m ] =     4.6000000000000D-02 Beam Energy             [ GeV ] =     6.0000000000000 K                               =     2.0800000000000 Field correction factor         =     1.0000000000000 ------   OUTPUT    --------- Gamma                           =     11740.316448203 Peak Magnetic field   [ Tesla ] =    0.48431195430933 Fundamental              [ Ev ] =     2349.2306933582 Fundamental       [ Angstroms ] =     5.2783098635786 Equivalent SR C.W.     [ Angs ] =     1.0668055208414               C.E.       [ eV ] =     11622.099584019 expgc.shadow<24> cat und.info  ---------------------------------------------  Trajectory computed by EPATH with following        	    parameters: Number of points :   101 Wavelen. (und)   :     4.6000000000000D-02 meters Fundamental wvl  :     5.2783098635786 angstroms Fund.    energy  :     2349.2306933582 eV K is             :     2.0800000000000 Gamma            :     11740.316448203 Beta0            :    0.99999999637248 C units Field B0         :    0.48431195430933 tesla Electron energy  :     6.0000000000000GeV  ---------------------------------------------  Read   101 trajectory records from und.traj Number periods used in ERAD:   35 Total power radiated in the limits [ W ]:     2.5007562757905D-02  ---------------------------------------------  Working with constant dE (units eV) . Energy interval =   0. Limits:     7040.0000000000    7046.0000000000 Number of points:   11  ---------------------------------------------  POLAR ANGLES CHOSEN     Azimutal angle (units rad) . Limits:   0.    1.5707963267949 Number of points:   31  ---------------------------------------------  Polar angle (units mrad) . Limits:   0.    1.5000000000000D-02 Number of points:   31 Spectra written into (binary) file:                                                                                   in units: PHOTONS/SEC/eV/RAD**2   ---------------------------------------------   ---------------------------------------------  
/* Ans last, let's generate the source                         */

expgc.shadow<25> go source  SOURCE selected. Begin procedure.  This procedure generates a SOURCE for SHADOW. Mode selected [ ?  for HELP ] ? proi mpt Call to INPUT ---------------------------------- S H A D O W  ------------------------------
 Jan 1992                     F.Cerrina                         ECE - UW           Defining source :  When prompted for a yes/no answer, you may enter: for   YES  answer      Y, 1 for   NO   answer      anything else   Do you want a verbose [ 1 ] or terse [ 0 ] output ?1 ------------- SOURCE SPECS ------------------ Options available: Random in  BOTH REAL and MOMENTUM space	      0 Grid       BOTH				      1 Grid       REAL, random  MOMENTUM	              2 Random     REAL,  grid   MOMENTUM		      3 Ellipses in PHASE space, random around each ellipse 4 Ellipses in PHASE space,   grid around each ellipse 5  Source modelling type [ 0-5 ] ? 0  How many rays [ 1 - 5 000 ] ? 5000  Seed [ odd, 1000 - 1 000 000 ] ? 23277  Do you want to optimize the source ?  Source type : [ 0 ] regular source               [ 1 ] normal wiggler               [ 2 ] undulator               [ 3 ] elliptical wiggler  Then ? 2  File containing the CDF's ? und.sha  Sigma along X ? .005617
                 /* Unit chosen: cm  */
             Z ? .003787 Electron beam emittance.  Units are : rads*[ units of length used so far ]  Beam emittances in X [ at waist ] ? 5.49e-7  Distance of insertion device's center from X waist [ signed ] ? 0  Beam emittances in Z [ at waist ] ? 6.78e-8  Distance of insertion device's center from Z waist [ signed ] ? 0   Polarization component of interest. Enter   parallel polarization    1  perpendicular            2  total                    3                     then ?  Polarization Selected [ 1-3 ] ? 3  Do you want to store the optical paths (OPD) [Y/N] ? 1  Do you want to generate the A vectors (electric field)          [Y/N] ?1 Exit from INPUT_SOURCE Calling gen_source with /civa/users/b/shadow/shadow92/bin/gen_source start.00 Generated   250 rays out of   5000             500             750             1000             1250             1500             1750             2000             2250             2500             2750             3000             3250             3500             3750             4000             4250             4500             4750             5000 Exit from SOURCE SOURCE => Source has been succesfully generated.  SOURCE procedure completed.  Shadow:: exit 
/* Everything done. Let's have a llog of the results        */

expgc.shadow<27> idl IDL. Version 2.2.2 (sunos sparc). Copyright 1989-1992, Research Systems, Inc. All rights reserved.  Unauthorized reproduction prohibited. Site: 1796. Licensed for use by: ESRF  15 April 1991. If you are running SunOS 4.1.1, there is a bug in the 	operating system kernel you should know about. Read the file 	sunos_4_1_1_a.doc in the notes directory of the IDL distribution 	for details.  1 January 1992. If you are running IDL Widgets with OpenWindows 3.0 you         may see error messages such as the following:            OPEN LOOK Toolkit Warning in application "idl": _OlGetImage: Could            not open file "/usr/openwin/lib/bitmaps/h12pinin"         Read the file openwin_bitmaps.doc in the notes directory of the IDL         distribution for details.  If you are tired of seeing this message, edit or delete the file motd_sunos, in the main IDL directory. 
/* Image in real space          */

IDL> plotxy,'begin.dat',1,3,a,/cart
% Compiled module: PLOTXY. % Compiled module: READSH. % Compiled module: GETRAYS.           18cols        5000points       0=error flag % Compiled module: ROUND. % Compiled module: CART_AXES. % Compiled module: HISTOGRAMW. 
/* Image in divergence space      */

IDL> plotxy,a,4,6,/cart
 
/* General information    */

IDL> infosh,a
 % Compiled module: INFOSH. ***********************************************************************             Information about SHADOW file stored in IDL    Number of rays is =         5000  Number of columns =           18  Number of good rays =    5000  Number of lost rays =           0                     #############                                     # ALL RAYS  #                                     #############                      Total intensity is              =        5000.0000  Normalized intensity is         =        1.0000000  Photon energy (eV)       7040.0020       7045.9984   % Compiled module: STDEV. col       minimum         maximum         mean           St. Dev     1     -0.019708675     0.026153547   1.8884069e-05    0.0056547764  2        0.0000000       0.0000000       0.0000000       0.0000000  3     -0.013101239     0.014272746   5.0878695e-05    0.0037050890  4   -0.00033486974   0.00033889030  -1.5956150e-06   9.7810494e-05  5       0.99999994       1.0000000       1.0000000   6.8739613e-09  6   -7.2492852e-05   6.7387404e-05  -5.5341961e-09   1.8941592e-05   *********************************************************************** IDL> exit
 expgc.shadow<28> exit expgc.shadow<29> 

[Back| Software for Science| ESRF]
Last modified: 23 Jun 1997
M. Sanchez del Rio (srio@esrf.fr)