******************************************************************************
   The thickness and the gamma ratio for multilayers can be varied across the 
surface as deposition conditions changed.  In SHADOW, it can be defined as a
regular multilayer (see MLAYER.DEMO), plus a factor F(x,y) for the thickness
and a factor G(x,y) for the gamma, MULTIPLYING the nominal thickness and 
gamma.  
 
   The procedure is to run PRE_MLAYER as usual to define the nominal 
multilayer.  Then run GRADE_MLAYER to generate two 2D cubic splines to fit
F(x,y) and G(x,y).
******************************************************************************
$ PRE_MLAYER
Name of output file :  WC.DAT
Photon energy (eV) from :  100
                     to :  300
********************************************************
Specify the substrate material :
Density [ g/cm3 ] ?  2.32
How many atomic species (up to 5) ?  1
H2O would be: HH,2 and OO,1. Then ? 
Enter 2-letters (capitalized) atomic symbol and formula index for :            1
SI
1
Formula:  
SI( 1) 

Molecular weight is :    28.10000     Number of molecules/cm3:   4.9719812E+22
Atoms/Cm3 of each species:
    SI
 0.49720E+23
 Density    2.320000     g/cm3
********************************************************
Right above the substrate is the even layer material.
Specify the even layer material :
Density [ g/cm3 ] ?  2.2
How many atomic species (up to 5) ?  1
H2O would be: HH,2 and OO,1. Then ? 
Enter 2-letters (capitalized) atomic symbol and formula index for :            1
CC
1
Formula:  
CC( 1) 

Molecular weight is :    12.00000     Number of molecules/cm3:   1.1040512E+23
Atoms/Cm3 of each species:
    CC
 0.11041E+24
 Density    2.200000     g/cm3
********************************************************
Odd layer material is on top of the even layer.
Specify the odd layer material :
Density [ g/cm3 ] ?  19.3
How many atomic species (up to 5) ?  1
H2O would be: HH,2 and OO,1. Then ? 
Enter 2-letters (capitalized) atomic symbol and formula index for :            1
WW
1
Formula:  
WW( 1) 

Molecular weight is :    184.0000     Number of molecules/cm3:   6.3166570E+22
Atoms/Cm3 of each species:
    WW
 0.63167E+23
 Density    19.30000     g/cm3
********************************************************
No. of layer pairs :  40
For EACH layer pairs, specify the thickness t : 
     t = t(odd)+t(even),     in Angstroms
and the gamma ratio :
     t(even)/(t(odd)+t(even))
starting from the substrate surface.  
 
Type two -1 whenever you want the remaining layers to assume the thickness and 
gamma of the previous one.
t and gamma of layer            1
35, 0.428					! Nominal t and gamma
t and gamma of layer            2
-1, -1						! All 40 layers are the same.
********************************************************
Is t and/or gamma graded over the surface ?  1	   ! Yes. t or gamma may vary.
Then you should run GRADE_MLAYER to generate the spline coefficients for the t
and gamma factors.  Now type in the filenamyou WILL be using to store the 
spline  coefficients :  
WC.GRADE					! File to store the splines 
					! computed by GRADE_MLAYER
					! later on.
$ DIR

Directory D2:[SHADOW.DEVEL.SHADOW.TEST]

F_GAMMA.DAT;2             1  29-MAR-1990 10:35:04.95  (RE,RWED,RE,)
F_THICK.DAT;2             1  29-MAR-1990 10:34:16.35  (RE,RWED,RE,)
WC.DAT;1                 13  29-MAR-1990 10:39:47.98  (RE,RWED,RE,)

Total of 3 files, 15 blocks.
! This is F(x,y), where t(x,y) = F(x,y)*t.  It is a 4x5 array, both (x,y) 
! extend from -2 to +2. The format is :
!       nx        ny
!   ----------------- Y --------------------
!   |    \
!   |         \
!   X               F(x,y)
!   |                          \
!   |                                  \
$ TY F_THICK.DAT
         4      5
        -2     -1      0       1       2
 -2     0.99   0.995   1.0     1.005   1.01
 -1     0.99   0.995   1.0     1.005   1.01
  0     0.99   0.995   1.0     1.005   1.01
  2     0.99   0.995   1.0     1.005   1.01
$
! 
! This is G(x,y), where g(x,y) = G(x,y)*g.  Same format as F(x,y).  
! In this example, only the thickness varies across the surface, the gamma 
! does not.
!
$ TY F_GAMMA.DAT
          4      5
         -2     -1      0       1       2
 -2     1.0    1.0     1.0     1.0     1.0
 -1     1.0    1.0     1.0     1.0     1.0
  0     1.0    1.0     1.0     1.0     1.0
  2     1.0    1.0     1.0     1.0     1.0
$
$ GRADE_MLAYER
For a graded multilayer, you will specify the factor MULTIPLYING the thickness
t and the gamma ratio, across the optical surface.
In PRE_MLAYER, you have already defined the nominal t and gamma AT THE ORIGIN.  
Here you will specify their multiplicafactor F(x,y).  For non-graded multilayer,
 F(x,y) = 1.0.
*******************************************************
Enter file-name for output:  WC.GRADE		! Same as specified at the last
					! part of PRE_MLAYER.
 
File containing the t factor mesh :  F_THICK.DAT
Setting up            4 by            5 array.
Array read correctly. Compute spline.
Spline succesfully completed.
 
File containing the gamma factor mesh :  F_GAMMA.DAT
Setting up            4 by            5 array.
Array read correctly. Compute spline.
Spline succesfully completed.
Task completed. Spline stored in 
WC.GRADE                                
                                       
$ DIR

Directory D2:[SHADOW.DEVEL.SHADOW.TEST]

F_GAMMA.DAT;2             1  29-MAR-1990 10:35:04.95  (RE,RWED,RE,)
F_THICK.DAT;2             1  29-MAR-1990 10:34:16.35  (RE,RWED,RE,)
WC.DAT;1                 13  29-MAR-1990 10:39:47.98  (RE,RWED,RE,)
WC.GRADE;1                9  29-MAR-1990 10:59:38.20  (RE,RWED,RE,)

Total of 4 files, 24 blocks.
!
! To check, generate a point source at 200eV to radiate the graded multilayer.
!
$ GO SOURCE

Hit <RETURN> when ready: 


SOURCE selected. Begin procedure.


This procedure generates a SOURCE for SHADOW.
Mode selected [ ? <ret> for HELP ] ? : PROMPT
Call to INPUT


---------------------------------- S H A D O W  ------------------------------- 
Jun 1988                                         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 ] ?  500
Seed [ odd, 1000 - 1 000 000 ] ?  2357
Do you want to optimize the source ?  0

Source type : [ 0 ] regular source
              [ 1 ] wiggler
              [ 2 ] undulator
Then ?  0

 The source is specified in the laboratory reference frame. The program will then rotate the set of 
rays in the mirror frame.

Type of source,now.

         use  ( 0 ) for point source  
              ( 1 ) for rectangular s.
              ( 2 ) for elliptical  s.
              ( 3 ) for gaussian    s.

X-Z plane source type [ 0-3 ] ?  0

Source depth. The actual source will be centered on the no-depth position. Use 
         (1) for no depth,
         (2) for flat depth distribution,
         (3) for gaussian depth distribution,
                (4) for a synchrotron source depth distr.

                   Then ? 
Source Depth [ 1-4 ] ?  1


O.K., got it so far.
         Source distribution now. We may use 
             ( 1 ) for a flat source
             ( 2 )       uniform   s.
             ( 3 )       gaussian  s.
             ( 4 )       synchrotron 
             ( 5 )       conical 
             ( 6 )       exact synchrotron 

Source Angle Distribution [ 1-6 ] ?  2
Horizontal half-divergence [ (+)x, rads ] ?  0
                           [ (-)x, rads ] ?  0
Vertical                   [ (+)z, rads ] ?  0.05
                           [ (-)z, rads ] ?  0.05
Do you want a Photon energy [ Y/N ] ?  1
We have these choices :
Single line ......................... 1
Several lines ....................... 2
Uniform source....................... 3
Energy distribution [ 1-3 ] ?  1
Photon Energy [ 0 ] or Angstroms [ 1 ] ?  0
Energy [ eV ] ?  200

Do you want to store the optical paths (OPD) [Y/N] ?  0
Do you want to generate the A vectors (electric field) [Y/N] ? 0
Exit from INPUT_SOURCE


Generated          250 rays out of          500
                   500
Exit from SOURCE
SOURCE => Source has been succesfully generated.

SOURCE procedure completed.

Shadow:: TRACE


Ray Tracing Selected. Begin procedure.


Mode selected [ ? <ret> for HELP ] ? : PROMPT
PROMPT selected.
Call to RESET
Exit from RESET


Mode selected is: 
PROMPT                                                                          
Options: to start anew                 [ 0 ] 
            to restart from a given OE [ 1 ] 
Then ?  0
Call to INPUT_OE



---------------------------------- S H A D O W  ------------------------------- 
Jun 1988                                         F.Cerrina        ECE - UW      
 
When prompted for a yes/no answer, you may enter:
for   YES  answer      Y, 1
for   NO   answer      anything else
 

Defining Optical Element:  1
Continue ? [ ^Z or %EXIT to terminate OS ]  1


Do you want a verbose [ 1 ] or terse [ 0 ] output ? 1
You may save disk space by not writing out the  intermediate STAR or MIRR data f
iles. In general you will not need them unless you have specific needs (footprin
ts, etc.) 
 
Files to write out. Options: 
All............................ [ 0 ] 
Mirror only.....................[ 1 ] 
Image at CP only................[ 2 ] 
None............................[ 3 ] 
 Then ?  0

Let's define the optical or central axis of the system
for this particular optical element.
By this I mean a "virtual" line that runs throughout
the optical system. Along this line are located the 
"continuation" planes, where the OS is subdivided in the
individual OE. This line does not have to coincide with the
true optical axis, as it is used mainly for bookeeping the
data, but it helps greatly in the data analysis if this
identity is preserved as everything in the program is referredto it.
Once established, you still have complete freedom of
"moving" around the mirrors. 
In the case of a grating, you will have several choices. The 
program may override your specifications for the central axis 
and locate the source and image at the "best" position. 
You will be prompted later for this option.
It is recommended to use CM as units. This is not critical for
 most cases, but it is in the case of diffraction elements.
Optical Element definition:
Incidence Angle ?  26
Source Distance ?  30
Reflection Angle?  26
Image Distance  ?  30
Reflector [ 0 ] or refractor [ 1 ] ?  0

Lets define the mirror. I may compute its parameters, like the
radius or the axes. This will not affect the rest of the calcu
lations; all the geometrical parameters may be modified later.
Or, you may wish to specify the mirror parameters yourself.


What kind of surface are we dealing with ?
spherical    = 1
elliptical   = 2
toroidal     = 3
paraboloid   = 4
plane        = 5
Codling slit = 6
hyperbolical = 7
cone      = 8
polynomial   = 9

Mirror surface [ 1-9] ?  5
Is the mirror Cylindrical ? 0
Is this optical element a Fresnel Zone Plate ?  0
Are we dealing with a Grating ?  0

Are we dealing with a crystal [ Y/N ] ?  0
Is the mirror convex [ Y/N ] ?  0
Reflectivity of Surface. SHADOW may solve the Fresnel equations locally.
Available options:'No reflectivity              .......... 0 
Full polarization dependence .......... 1 
No        "           "      .......... 2 
Reflectivity mode [ 0,1,2 ] ?  2

Optical constants from file  ( for multi-line source ) ..... 0
Optical constants from keyboard  (single-line source ) ..... 1
Define multilayer from file                            ..... 2
Optical Constant Source: [file=0,tt:=1], multilayer [2] ? 2
File with thicknesses and refractive indices of multilayer ? WC.DAT
Do the thicknesses vary as the cosine of the angle from the pole ?  0


Mirror orientation angle. Angles are measured CCW, in deg,
referring to the mirror normal. Alpha=0 is the mirror
sitting at the origin, facing up. Alpha = 90 is the 
mirror standing at your right and facing left when you 
look along the beam STANDING ON THE PREVIOUS MIRROR and so on.
Orientation Angle [ Alpha ] ?  0

Mirror Dimensions finite [ Y/N ] ? 0

 The Optical Element and the the relative mirror are now fully 
defined. The mirror pole is now located at the "center" of the 
optical element. It is possible to override this situation and 
"move" the mirror without affecting the rest of the system.
 It is also possible to move the "source" without affecting the
rest of the system.
 The movements are expressed in the DEFAULT Mirror Ref. Frame.
 so that if you move BOTH source and mirror the relative
movement is the vector sum of the individual ones.
A word of caution: SOURCE movements and MIRROR movements are
NOT equivalent from the point of view of the whole system.
Do you want to move the Source [ Y/N ] ?  0
   
--- Mirror rotations and position. ---
We define three angles, as rotations around the three axis.
These rotation are  defined in the program as corrections to
the mirror nominal position; that is, they modify the mirror
position relative to the Default Mirror Reference Frame, where
all the calculations are performed. Remember that rotations
do NOT commute. I apply them in the same order of entry.
CW ROTATIONS are (+) angles. A translation can be also applied to the mirror.
Do you want to move the mirror itself [ Y/N ] ?  0
Distorted surface [ Y/N ] ?  0

Any screens in this OE [ Y/N ] ?  0

Slit at continuation plane [ Y/N ] ?  0
Extra Image plates [ Y/N ] ?  0
File containing the source array ?  BEGIN.DAT
Exit from INPUT
Tracing optical element #            1
Call to SETSOUR
Exit from SETSOUR
Call to IMREF
Exit from IMREF
Call to OPTAXIS
Exit from OPTAXIS
Call to MSETUP
Exit from MSETUP
Call to RESTART
Exit from RESTART
Call to MIRROR
      :
      :
      :
$ PREPLOT
PREPLOT> Input file ?  MIRR.01
Read                  500 rays.
Each ray has           12 entries.
PREPLOT> How many columns to write out ?  2
Row [1-12]  : the individual column
Row   [20]  : R = SQRT(X**2 + Y**2 + Z**2)
Row   [21]  : angle from the Y-axis
Row   [22]  : the magnitude of A vector
Row   [23]  : A**2
PREPLOT> Row # 1 :  2				! Along Y-axis on the mirror
PREPLOT>       2 :  23				! Intensity
Options --- Enter
0 for excluding the losses
1 for including losses at a particular O.E.
2 for plotting all the rays .
3 for plotting ONLY the losses (all of them)
4 for plotting ONLY the losses at a given O.E.
PREPLOT> Then ?  0
***********
Found          500 good points out of         500
Output options :
  [ 0 ] store rays in a file
  [ 1 ] plot directly on screen
  [ 2 ] both
Then ?  2
PREPLOT> Output file ? MIRR.PLT
PREPLOT> Terminal type: [ 0 ] VT240, [ 1 ] TEK 40xx, [ 2 ] HIREZ, [ 3 ] TEK 4107
!
! Use UGTEK to look at GRADE_MLAYER.SAVE, which shows the graded multilayer 
! enhanced the reflectivity over a non-graded one.
!
