Home > Scripts > Models > Factory > rietveld.m



model=rietveld(parameters, ...., instrument, ....) Rietveld refinement of powder


function y = rietveld(varargin)


 model=rietveld(parameters, ...., instrument, ....) Rietveld refinement of powder

 This function build a fit model from:
   * a sample structure
   * a McStas instrument model (usually a diffractometer)
 The model can then be used for refinement as a usual fit model:
   fits(model, data_set, parameters, options, constraints)

 Any powder structure can be entered, and there is no limitation on the number
   of parameters/atoms n the cell. The powder model takes into account 
   Biso, charge, occupancy, spin
   Equally, the instrument model can be of any complexity, including sample
   environments, other sample phases (incl. amorphous), multi-dimensional PSD 
   detectors, ... It is possible to specify which monitor file to use from 
   the McStas instrument. The instrument resolution function is not computed
   using the legacy Caglioti formalism, but is fully convoluted with the
   sample component from the McStas instrument description.
   The default, and recommended, instrument is templateDIFF, but others are possible
   including TOF-diffractometers, PSD-diffractometers, and even Laue.

 Once set, the fit parameters may be constraint with either the usual 'constraints'
   argument to 'fits', or by setting the model constraints such as:
     model.Sample_a     = 'fix';     % fix 'a' lattice parameter
     model.Sample_alpha = [80 110];  % restrict alpha lattice angle in degrees
 Parameters of the model can be entered as:
 * a structure with one field 'structure.<atom>' per atom in the cell, named from the atom, e.g.
     p.structure.Al1=[x y z {Biso occ spin charge}] where {Biso occ spin charge} are optional
     p.Al1          =[...] can also be used for a compact specification (see exemple below).
   plus additional fields
     p.cell=[a b c alpha beta gamma] lattice cell parameters (Angs and deg)
     p.Spgr='space group' as Number, Hall or Hermman-Mauguin

 * a structure to configure the McStas simulation parameters, with fields from
       ncount: number of neutron events per iteration, e.g. 1e5 (double)
       dir:    directory where to store results (string)
       mpi:    number of processors/cores to use with MPI on localhost (integer) 
       seed:   random number seed to use for each iteration (double)
       gravitation: 0 or 1 to set gravitation handling in neutron propagation (boolean)
       compile: 0 or 1 to force re-compilation of the instrument (boolean)
         this is recommended if you ran in serial, and want to use MPI afterwards.
       monitors:  cell string of monitor names (cellstr)
     Only the last monitor in the selection is used to compute the refinement criteria.
     Type 'help mcstas' for more information about these items.

   In addition, the 'CFML_write' field allows to set the name of the intermediate
     reflection file written by the CrysFML routines, and usable by the PowderN
     and Isotropic_Sqw McStas components. The default intermediate file is

 * a vector array where Z is the atomic number
     p=[ a b c alpha beta gamma (Z x y z Biso occ spin charge) (...) ... ]

 * a CIF/CFL/PCR/shellX file name from which structure is extracted.

 * a McStas instrument description file name (.instr extension) to specify
     the instrument model to use. The default instrument is 'templateDIFF.instr'

 * a char with label/value pairs separated by ';' to build a structure.

 * All additional structure fields are sent to the McStas instrument model.

 Example: refine a NaCaAlF powder structure with the templateDIFF McStas instrument
    Sample.title = 'Na2Ca3Al2F14';
    Sample.cell  = [10.242696  10.242696  10.242696  90.000  90.000  90.000];
    Sample.Spgr  = 'I 21 3';
    Sample.Ca1   = [0.46737  0.00000  0.25000  0.60046  0.50000   0.0   2.0];
    Sample.Al1   = [0.24994  0.24994  0.24994  0.18277  0.33333   0.0   3.0];
    Sample.Na1   = [0.08468  0.08468  0.08468  2.25442  0.33330   0.0   1.0];
    Sample.F1    = [0.13782  0.30639  0.12023  0.56669  1.00000   0.0  -1.0];
    Sample.F2    = [0.36209  0.36363  0.18726  1.42140  1.00000   0.0  -1.0];
    Sample.F3    = [0.46123  0.46123  0.46123  0.88899  0.33333   0.0  -1.0];
 The resulting hklF2 file 'reflections.laz' will be used by the instrument Powder 
 parameter and the model is computed at constant wavelength lambda=2.36 (given as char)
    f = rietveld(Sample, 'templateDIFF.instr',' Powder=reflections.laz; lambda="2.36"');
 you may plot the model (using McStas) in the [10 170] angular range:
    plot(f, f.Guess, linspace(-.2,.2,50),linspace(10,170,300));
 Then 'f' is an iFunc Rietveld model. Then perform the Rietveld refinement:
    p = fits(measurement, f); % where measurement holds a measured powder diffractogram

 See also: mcstas, iFunc, iData, iFunc/fits
 (c) E.Farhi, ILL. License: EUPL.


This function calls: This function is called by:
Generated on Wed 22-Mar-2017 09:13:30 by m2html © 2005. iFit (c) E.Farhi/ILL EUPL 1.1