expgc.shadow<81> bragg
/* Let us calculate a single flat crystal in laue geometry,
diamond 111 with thickness=50microns at 8035eV              */

All crystal structures are refered to a cubic unit cell.
Bravais lattice type : 
0	for 	ZincBlende
1	for 	Rocksalt
2	for	simple FCC
3       for     CsCl structure
hexagonal Bravais lattice type: 
4       for     Hexagonal Close-Packed structure
5       for     Hexagonal Graphite structure
 Then ? 2
 Lattice constant (Angs) ? 3.56
Index of crystal plane of reflection H,K,L : 
1
1
1
***********************************************************
Simple FCC structure
***********************************************************
 Enter atomic symbol (capitalized) for the basis atom : CC
***********************************************************
Atomic scattering factor is defined by fo + f' + if", where
    fo = fo(SIN(theta)/Lambda) is the non-dispersive part
    f', f" (Lambda) are the dispersive part.
***********************************************************
We need fo at 3 different values of SIN(theta)/Lambda, which
should cover the range of interest and center around :
SIN(theta)/Lambda =    0.24326556286080 ratio.
***********************************************************
Please enter 1) SIN(theta)/Lambda, 2) fo ,
For basis atom, first set : 
.2,3.58
              , second set : 
.25,2.976
              , third set : 
.3,2.502
***********************************************************
f', f" is furnished from optical constant library within ...
 minimum photon energy (eV) : 8000
 maximum photon energy (eV) : 8100
 energy step (eV) : 5
 Do you want to include crystal absorption [1/0] ? 1
 Temperature (Debye-Waller) factor : 1
 Output file name (for SHADOW) : c8.111
 Do you want to generate a rocking curve [1/0] ? 1
What do you want to calculate ?: 
[1] Diffracted beam in Transmission (Laue) geometry 
[2] Diffracted beam in Reflection (Bragg) geometry  
[3] like [2] using thick crystal approximation
  <?> 1
 ... at what energy (eV) ? 8035
 
So far, we are working with:
Lambda 		 =     1.5430640945862 Angstroms
Theta (graz) 	 =     22.047452177753 degrees
Bragg angle      =     22.048390592442 degrees
Structure factor  =   (    12.274226145606,    3.8548008268108D-02)
Refraction index = 1 - delta - i*beta :
           delta =     5.6982057590194D-06
            beta =     9.1237126865854D-09
Absorption coeff =     7.4301485855848 cm-1
 
 Do you want to calculate a mosaic crystal ?0
 thickness of the crystal [cm] ? .005
Asymmetric cut angle (deg) between face and bragg planes (CW)= 
50
The width of the Rock Curve in function of incident angle is
1/2 width for s-pol  =  :     11.895268508103 microradians
1/2 width for p-pol  =  :     8.5430413173636 microradians
The width of the Rock Curve in function of reflected angle is
1/2 width for s-pol  =  :     5.8611572544359 microradians
1/2 width for p-pol  =  :     4.2094138991567 microradians
Asymmetric factor b=  :    0.49273013471223
    
 +/- how many microradians : 100
 How many points : 200
 Do you want to use sec [1/0] ? 0
 Do you want the R.C. centered [1/0] ? 0
 Do you want to try another energy [1/0] ? 0
expgc.shadow<82> 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


IDL> set_plot,'ps'

IDL> device,filename='rock_curve.ps'
IDL> plotfile,'rock_curve_inc.s',xra=[-1e-4,1e-4],yra=[0,.8],$
IDL> title='Diamond 111 50um 8035eV Laue',xti='rad'

     200 lines in the file
IDL> exit





/* now you can print the file rock_curve.ps with the two rock curves
(s and p-polarization), in function of the incident angle           */

/* We are going to generate a punctual source divergent in the 
vertical plane'                                                     */

expgc.shadow<85> go source
SOURCE selected. Begin procedure.

This procedure generates a SOURCE for SHADOW.
Mode selected [ ? <ret> for HELP ] ? 
Enter:
MENU:		for screen-driven menus
PROMPT:		prompted session
BATCH:		file-oriented session

This procedure generates a SOURCE for SHADOW.
Mode selected [ ? <ret> for HELP ] ? prompt
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

 Do you want a verbose [ 1 ] or terse [ 0 ] output ?
------------- SOURCE SPECS ------------------
 Source modelling type [ 0-5 ] ? 
 How many rays [ 1 - 5 000 ] ? 2000
 Seed [ odd, 1000 - 1 000 000 ] ? 12853
 Do you want to optimize the source ? 
 Source type : [ 0 ] regular source
              [ 1 ] normal wiggler
              [ 2 ] undulator
              [ 3 ] elliptical wiggler
 Then ? 
 X-Z plane source type [ 0-3 ] ? 
 Source Depth [ 1-4 ] ? 
 Source Angle Distribution [ 1-6 ] ? 
 Horizontal half-divergence [ (+)x, rads ] ? 0
                            [ (-)x, rads ] ? 0
 Vertical                   [ (+)z, rads ] ? .0001
                            [ (-)z, rads ] ? .0001
 Do you want a Photon energy [ Y/N ] ? 1
 Energy distribution [ 1-3 ] ? 1
 Photon Energy [ 0 ] or Angstroms [ 1 ] ? 0
 Energy [ eV ] ? 8035
 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
 Phase difference ?0
 Degree of polarization ?1
 Incoherent [0] or coherent [1] ?
Exit from INPUT_SOURCE
Calling gen_source with /civa/users/b/shadow/shadow92/bin/gen_source start.00
Generated   250 rays out of   2000
            500
            750
            1000
            1250
            1500
            1750
            2000
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
Call to RESET
Exit from RESET
[H[2JMode selected is: 
PROMPT                                                                          
Options: to start anew                 [ 0 ] 
            to restart from a given OE [ 1 ] 
 Then ? 
Call to INPUT_OE
---------------------------------- S H A D O W  ------------------------------- 
 Jan 1992                     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 ? [ EXIT to terminate OS ] 


 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 files. In general you will not     need them unless you have specific needs (footprints, etc.) 
 
Files to write out. Options: 
All............................ [ 0 ] 
Mirror only.....................[ 1 ] 
Image at CP only................[ 2 ] 
None............................[ 3 ] 
  Then ? 
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 ? 
 Source Distance ? 10
 Reflection Angle? 
 Image Distance  ? 0
 Reflector [ 0 ] or refractor [ 1 ] ? 1
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 ? 
 Is this optical element a Fresnel Zone Plate ? 
 Are we dealing with a Grating ? 
 Are we dealing with a crystal [ Y/N ] ? 1
File containing crystal parameters ?
c8.111
 Is it a mosaic crystal [ Y/N ] ? 0
 What is the crystal thickness [cm] ? .005
 Is the crystal asymmetric [ Y/N ] ? 1
Enter the angle formed by the crystal planes with the crystal 
surface. Use a positive value if the plane normal lies along 
the +Y direction (focusing), negative otherwise.
 Planes angle [ deg ] ? 50

For the Laue case: is the beam arriving onto the bragg planes [0] , or under the bragg planes [1] ?
  <?> 1
 Are we working in Johansson geometry [Y/N] ? 0
 Automatic Tuning of Crystal [ Y/N ] ?1
You must then supply the wavelength (or photon energy) at 
which you want the crystal tuned.
 Energy, in eV, [ 0 ] or wavelength, in Angs., [ 1 ] ? 0
 Photon Energy ? 8035
 Is the mirror convex [ Y/N ] ? 

 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 ] ? 
 Mirror Dimensions finite [ Y/N ] ?
 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 ] ? 
   
--- 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 ] ? 
 Distorted surface [ Y/N ] ? 
 Do you want to include surface roughness [Y/N] ? 
 Any screens in this OE [ Y/N ] ? 
 Slit at continuation plane [ Y/N ] ? 
 Extra Image plates [ Y/N ] ? 
 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
Exit from MIRROR
Call to IMAGE
Exit from IMAGE
Call to RESET
Exit from RESET
Do you want to change input mode ? 
Call to INPUT_OE
---------------------------------- S H A D O W  ------------------------------- 
 Jan 1992                     F.Cerrina                         ECE - UW         

 Defining Optical Element:  2
 Continue ? [ EXIT to terminate OS ] exit
End of session

Procedure completed.

Shadow:: exit



/* Now, lets plot the output intensity (column 23 of star.01 file) in 
function of the incoming divergence (column 6 of begin.dat file). 
We use IDL for such graphic                                           */


expgc.shadow<86> 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
IDL> a=readsh('begin.dat')

          18cols        2000points       0=error flag
IDL> b=readsh('star.01')

          18cols        2000points       0=error flag
IDL> c=b                     /* copy output file to structure "c" */
IDL> c.ray(5,*)=a.ray(5,*)   /* use the divergence column of the source */
IDL> set_plot,'ps'

IDL> device,filename='plotxy.ps'
IDL> plotxy,c,6,23,hist=-1,xra=[-1e-4,1e-4],yra=[0,.8]
IDL> exit



/* That's the end. The four possible cases in laue asymmetric geometry
are reduced to only two:

case A)
alpha > 0  and rays below bragg planes (as the example showed, ORDER=-1)

    *   \
      *  \
        * \
__________*_____________   crystal surface
          * \
         *   \-> Bragg Planes
        *     \
       * -> Exit beam


case B)
alpha > 0 and rays onto the bragg planes

                 \      *
                  \    *
                   \  *
                    \*
              ----------------------------  -> crystal surface
                      \*
                       \ *
                        \  *
        Bragg Planes ->  \   *-> Exit beam


Case C)
alpha < 0 and rays below the Bragg planes => equivelent to case A)

                             /
                            /   * -> incoming ray
                           /  *
                          / *
                         /*
---------------------------------------------
                       /*
                      / *
                     /  *
                    /   *
                   /    *-> outcoming ray
                  /

Case D) 
alpha < 0 and beam onto ythe bragg planes ==> equivalent to case B


*/
civa.shadow<94> exit


