Computing for Science

The Computing for Science (CS) group supports ILL scientists, students and visitors in a number of activities including data analysis, instrument simulation and sample simulation.

Back to ILL Homepage

All Software

These help pages were designed at the

Clarendon Laboratory, Department of Physics, Oxford University, U.K.

by A. Tennant and D. McMorrow.

Monte Carlo simulations of scans for neutron triple-axis spectrometers.

One of the options on the menu bar of the "Rescal: Parameters" window is labelled "simulation". Clicking on it causes an extra window to a appear entitled "Rescal: Simulation". In order to make a simulation, a dispersion and line-shape need to be defined. At the moment the program is set up for sinusoidal dispersions with an energy gap at the zone centre. The current line-shape is Lorentzian and a detailed balance and 1/energy structure factor for antiferromagnetic line-shapes has been included. Details of how to modify the program are given in the final section of this web page. The simulation takes full account of the changes in the resolution at each point in the scan and also corrects for changes in resolution volume, counts by monitor etc. 

Entering parameters for the simulation

Parameters defining the scan, dispersion, and linewidth are given in the "Rescal: Simulation" window generated on clicking on the "simulation" button on the menu bar of the "Rescal: Parameters" window. The "Rescal: Simulation" window (a screen-shot will be added later) consists of a title bar ("Rescal: Simulation"), menu bar with options 


  • Exit: exits out of the simulation level of RESCAL for MATLAB and closes the "Rescal: Simulation" window and plot.
  • Parameters: a pull-down menu giving the choice of "Get Parameters" or "Save Parameters" which allows the user to read/save simulation parameters from/to a file.
  • Run: which runs the specified simulation. The 4D Monte Carlo convolution is calculated and displayed on a new figure (screen-shot to be added) along with plot of unconvoluted line-shape.


  • the final component of the "Rescal: Simulation" window is the set of parameter boxes. This consists of nine parameters describing the scan 


  • Hstart, Kstart, Lstart & Estart: starting point values of H,K,L & E, in r.l.u. and meV respectively, for the scan.
  • Hend, Kend, Lend & Estart: final values of H,K,L & E, in r.l.u. and meV respectively, for the scan.
  • NSC: number of points in the scan including the starting and finishing points.


  • a parameter for the number of Monte Carlo points in the integration 


  • NMC: number of Monte Carlo points in the integration (typically of order 3000).


  • ten parameters describing the dispersion of the excitations 


  • Hzb, Kzb, Lzb & Egap: these are the (H,0,0), (K,0,0), (L,0,0) zone-boundary energies and energy gap at the zone-centre respectively (all in meV).
  • Hzero, Kzero & Lzero: the three r.l.u. coordinates of the zone-centre point.
  • Hphase, Kphase & Lphase: these are the parameters defining the repetition rate of the sinusoidal dispersion in the principle directions (H,K,L). The values are 2 for an antiferromagnetic repitition and 1 for a ferromagnetic repetition.


  • and the final two parametrs are 


  • Gamma: the full-width-half-maximum (FWHM) of the Lorentzian line-shape.
  • T(K): temperature in degrees Kelvin.
  • Modifying the dispersion and line-shape

    As remarked earlier, the program has been set up to calculate scattering for a sinusoidal dispersion and Lorentzian line-shape. Both of these can be tailored for specific purposes. The dispersion and lineshape are defined in the macro mc_sqw.m. This consists of a definition of wq - the dispersion as a function of Q(r.l.u.) - and s - the scattering from the line-shape. The definitions of wq and s are self evident form mc_sqw.m, however there is a fundamental difference in the definition of the functions from that using Fortran. Matlab uses matrices as it's basic unit rather than scalars. Because of this wq and s should be viewed as array equalities and functions. One ramification of this is that the normal arithmetic operators (+,-,*,/,^) are matrix operations and other operators between scalars and matrices or element-by-element operations must be prfixed by a dot i.e. .*,./ or .^.


(c) A. Tennant D. McMorrow November 29 1995