Skip to content

HOWTO: McXtrace reflectivity files

Erik B Knudsen edited this page Dec 2, 2021 · 6 revisions

This page is intended to document how reflectivity datafiles for use with McXtrace may be generated.

McXtrace includes a few data-files (in the data folder of your installation), that may be used as examples, but other than that these are simply ascii-files that contain either material parameters from which one may compute reflectivity number or reflectivity itself. McXtrace accepts a few different parametrizations of reflectivity, e.g. as function of q, or as a function of Energy and glancing angle θ.

Reflectivity as a function of q

The top of the file should look like this:

 #param=q
 #q_min=0.1
 #q_max=0.2
 #q_step=0.01
 0.1 1.0
 0.101 0.99
 ...

The order of the header lines is not significant. The q_min,q_max,q_step lines are not strictly necessary but it is advisable. Any other lines (before the data block) beginning with # are ignored, so it is possible (and desirable) to include additional comments about what the contents of the file, e.g. recipe for multilayer.

Reflectivity as a function of Energy and glancing angle θ

The top of the file should the look like:

#param=eth
#E_min=0.1
#E_max=120
#E_step=0.001
#theta_min=0.001
#theta_max=2
#theta_step=0.0002
1.0   0.99 0.989 0.987 0.8 ...
0.99  0.98 0.979 0.976 0.77 ...
...

In this case the energy and theta values are implicit. The columns correspond to theta in degrees, and rows to energy in keV.

Generating files with IMD and IDL.

Using a version of the script/program found in support/scripts - layer_SiO2.pro we may generate a mirror reflectivity file by means of the following recipe (on Linux), assuming you have access to IDL and IMD. Please note that it is not enough to have the demo version of IDL-present since it disables file-IO which is needed for reading optical constants.

  1. Start IDL: idl
  2. From within the IDL command prompt, run imd by .r imd. This opens two windows: the main IMD window and an IMD-launcher window. Close those two and you should see a message: 'Type "imd" to start IMD again'. IMDs computational routines are now available from the console.
  3. Load the set of scripts supplied with McXtrace .r mlayer_reflectivity. This library contains two main routines: qcompute and ethcompute that can be called from outside. It also has a small set of examples: SiC_Ir_SiO2, SiC_Ir_SiO2_console, and `SiC_Ir_SiO2_et, which you may be helpful when you develop your own scripts.
  4. Generate a set of layer depths: Example: zdepths=[100,200,300]
  5. Specify a set of materials: Example: mats=['Cr','Zr','Ir']
  6. Set q limits and number of sampled points in the format [q_min,Nq,q_max] : Example: qq=[0.001,200,1.001]
  7. Run the scripting layer:
    Example: qcompute, OUTFILE='output_data', mats, zdepths, qq,comment='I am a comment to appear in the header' This will generate an output file called output_data that you may use directly in McXtrace.

If an energy,theta parameterization is what you want, replace step 6 with something akin to:
ethcompute, OUTFILE='output_data', mats, zdepths, Energy, g_angle, comment='I am a comment to appear in the header',
where Energy and g_angle are triplets similar to qq above.

You may call qcompute and ethcompute without setting OUTFILE and copy-the console output to a file manually, but be aware that you may introduce additional linebreaks in the Energy,theta case if you have a large number of sample steps in theta.

Clone this wiki locally