This program is used to make least sqares fits of small-angle neutron (or X-ray) scattering data with models of non-interacting particles or simple peak shapes. Polydispersity and instrument resolution can be included in the calculations.
The information provided below and the program is given with no warranty. The program is made available for non-profit, academic research by contact with the author. It must not be further distributed without explicit permission. The author would be grateful for information about any errors in the documentation or bugs in the program. Suggestions for improvements would also be very much appreciated.
Copyright: Adrian R. Rennie (1999, 2005) E-mail: Adrian.Rennie@fysik.uu.se
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
Return to: Adrian R. Rennie Homepage
This program calculates small-angle scattering (SANS or SAXS) for non-interacting particles. It covers a wide range of simple models and allows different scales and weighting of the fit to be included in the minimisation. The program also permits polydispersity and instrument resolution to be included in the calculation.
Apart from the models for isolated particles, the program can be used to fit a variety of other simple functions. In particular models with peaks in scattering either at momentum transfer (Q) equal to zero or at some finite Q can be fitted. Examples of these in practice would include a Lorentzian at Q=0 to model critical scattering, Gaussian peaks at finite Q to interpret Bragg diffraction at low Q and models of fractal behaviour such as ln(Intensity) varying linearly with ln(Q).
In some cases it may be important to include resolution in the model while for other data the effect may be insignificant. The use of the program interactively allows these effects to be rapidly visualised.
New Features. Some new features in the present version (Version 2.3 - May 1999) include (i) the ability to plot size distributions and obtain this data as an ASCII file and (ii) the calculation of g(r) as a real space distribution of density for the model. This last option is useful for comparison with other means of analysis such as indirect Fourier transforms.
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
2.1 Basic Models, 2.2 Resolution, 2.3 Polydispersity, 2.4 Background, 2.5 Scales.
The models are defined by a basic function that can then be modified by instrument resolution and polydispersity with separate resolution integrals. A background can also be included. These terms are described in turn below.>
The following models are presently available in the program:
The following units are used for the various parameters used in the models:
A summary of this information can be obtained with the command I from the subsidiary command menu. See Section 3.3.
The resolution is calculated assuming that there are components of instrument broadening arising from both the wavelength spread and the finite angular resolution. The scattering is calculated by averaging the calculated I(Q) over a range of Q values appropriate to the width of the resolution function. The resolution is assumed to be a Gaussian function with a width that varies with Q. One component arises from the spread in wavelength and will be effectively constant with Q but the effect of angular divergence will vary with Q.
The resolution is defined by the following parameters:
Although much of this information can be found in some data files, it is common that the correct values have not been stored and it is useful to verify that the data is sensible. If studies are made of well defined spherical particles, the resolution may be very important in modifying the sharp fringes that might otherwise be observed.
Strictly the calculation of resolution broadening in this way is only appropriate to 'pin-hole' scattering cameras with a monochromatic beam. On other instruments such as time-of-flight SANS, the resolution will not take the same form. Indeed as the scattering at given Q arises from many wavelengths, it is not possible to calculate the 'resolution function' without the knowledge of the scattering distribution. In practice a reasonable approximation to the resolution may be obtained by suitable adjustment of the parameters. Data from Bonse-Hart double crystal cameras or slit geometries (e.g. Kratky cameras) will usually require separate desmearing routines.
The polydispersity can be either a log-normal distribution or a Gaussian distribution of size. The default is a log-normal distribution but this can be changed using the J and D options.
Polydispersity can be applied to all models but it may not be sensible to include this in some models (e.g. Gaussian function). For the rod, the polydispersity can be put on either the radius or the length.
The size distribution used in the fits can be seen in graphical form by using the option G from the subsidiary command menu. The data is shown as a probability distribution of radii. Scattering weights the fits according to the size of the particles, e.g. as R6 for spheres. The large end of the distribution is correspondingly more important in the fit and a larger range of R is used above the modal radius than below.
If it is the intention to fit a particle size distribution, care must be taken that the effects are not confused with instrument resolution or by models that intrinsically include a range of distances within particles. It may be difficult to distinguish polydisperse spheres and ellipsoids unless data is provided on an absolute scale of intensity or other information is available.
There are three options for the background:
The background spectrum can be scaled by a constant (that is a fittable parameter). It may be necessary to use such a factor if the transmission of the sample is such that only a fraction of the background should be fitted to the sample data. This facility can also be used to accomodate changing amounts of incoherent scattering.
If the model is required beyond the range of the background spectrum a simple linear extrapolation is made to either smaller or larger Q values.
The following options are available for the the scales:
Y Axis (Intensity)
X Axis
These can be combined in any combination. This will allow the representation of the data while fitting in standard forms such as a Guinier or Zimm plot.
The choice of scales can also be used to influence the weighting of data points in the minimisation. See section 3.5 for more details.
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
3.1 Data, 3.2 Main Command Menu, 3.3 Subsidiary Command Menu, 3.4 Errors, 3.5 Hints, 3.6 Example
The program uses the FITFUN (http://www.ill.fr/Computing/fitfun.htm) library developed at the ILL by Ron Ghosh. In turn this uses PGPLOT graphics as used at the ILL.
The data to be analysed is assumed to be in a the standard
format for ILL averaged data. This is described in documentation
at the ILL -
ILL SANS Treated Data Formats http://www.ill.fr/data_treat/sanstreateddata.html.
Some information on how to convert data from other facilities can
found in the following references:
http://www.ill.fr/data_treat/sanstreat.html#foreign
http://www.ch.kcl.ac.uk/kclchem/staff/arr/convert.htm
Although the implicit assumption is made that the data comes from
SANS experiments, the experienced user will find that the program
can also be applied to X-ray and light scattering results if suitable
allowance is made in the parameters.
The data is usually provided as a sequence of Q, I(Q) and an estimate of the error ErrI(Q). The errors are normally used to weight the the residues in the fit. In particular amy points with zero error are automatically excluded from the fit unless this facility is deliberately disabled. It may be necessary to use this option for data from some instruments or facilities that do not provide an estimate of the error in intensity.
Note
The option of giving extra information after the R command is not a standard feature of FITFUN and is particular to this program and is not found generally in other programs. It is therefore not described in the standard documentation.
The following options are available from a subsidiary menu access by J from the main FITFUN command prompt:
D This allows a choice between Gaussian and log-normal distributions of particle size. The Gaussian is a symmetric while the log-normal distribution has a 'tail' of large particles. The default distribution type is a log-normal and this can only be changed by this command.
F This provides a simple Fourier integral of the model data to calculate r2g(r). It uses an integral of the model scattering function calculated without any instrument broadening or background. The model is extended to 8 times the maximum Q in the data in order to reduce errors of termination in the integral of {sin(Qr)/Qr}I(Q) Q2 that runs from zero to Qmax which is taken as proportional to g(r).
Some questions with this routine allow the g(r) data to be further smoothed, replotted on different scales or output as a simple ASCII file. This option is useful if further plots or hard copy output is required. The format of this file is as described under option L.
G This provides a plot on the screen of the size distribution used in the polydispersity calculation. It indicates the range used in the calculation but the scales are rounded to some convenient numbers. At present there is no provision for hard copy output of this plot. If this is required it will be necessary to use a screen dump or to use the data obtained from option L.
L
This allows the data shown in option G to be output as an ASCII
file for further analysis or plotting. The format of the file
is as follows:
NDATA
Run No., Ext., Title information
4 lines of parameters used in calculations
NDATA lines of R and P(R)
P & R These change the number of fitable parameters but the the current version of the FITFUN library does not allow the titles of the parameters to be updated. They will remain as on entry to the program. It may be useful to remember that the variable 20 is the polydispersity and variable 19 is the wavelength spread (% FWHM).
X & Y If the variables for the scales are changed it is essential that the data is reread using the R command from the main command menu. It is easy to reread the same data set as this will be the default data set. It will probably also be necessary to change the corresponding plot limits with the X and Y commands in the main menu.
There are three main options that are available for weighting the function to be minimised by the program. These may be selected according to the problem and the data available.
Chi Squared The square of the difference between the model and the data divided by the experimental error in the data is minimised for the range of points included in the fit.
Each Data Point Equally The square of the difference between the model and the data is minimised for each point included in the fit.
Scaled as Y-Axis The square of the difference between the model and the data converted to the current Y-axis scale is minimised for each point included in the fit.
If no data is available for the experimental errors, it is clearly not possible to use the first option. Although it might be thought that this is always the preferred way to produce an optimum fit to experimental data there are several reasons why this is not always the case. For example, the nature of the scattering may be such that some parts of the data are measured with far better statistical accuracy than other parts that contain important information about the sample. Under these circumstances it may be necessary to emphasize the lower intensity parts of the data in the fit.
The dependence of some models on the fit parameters may mean that the minimisation is most stable if fits are optimised using the scaled variables that effectively provide almost uniform sensitivity to each parameter that is to be fitted.
Under all circumstances it is necessary to exclude data that is known to be systematically in error from the minimisation in a fit. This will include regions that have been masked to exclude regions shadowed by a beam stop or where the detector is defective. This can be done using the Only command to select regions of interest. To aid the exclusion of masked regions in the data, it is normal for the program to exclude automatically any data point for which the experimental error is zero. This option can be switched off, either on entry to the program or in the subsidiary command menu with the option W which can be used to change other weighting options.
As with most general purpose programs it is difficult to account for correlated errors. An example of this difficulty would arise if a backround spectrum includes errors from the same detector normalisation as the sample spectrum to be fitted. The program will combine the statistical errors in these data sets as though they are independent. In practice, standard data reduction procedures will also have this problem. It is common for the errors associated with a data set to be somewhat over estimated. There seems to be no simple way around this problem unless a full history of the data reduction is available. In consequence the weighting of fits may never be truly correct in a conventional, statistical sense.
The errors in the fitted parameters that are displayed with the V command are only correct if the minimisation has terminated. If the previous message was 'Limit of Iterations reached' or 'No Minimum Found' the errors for the individual parameters can not be considered as valid!
When starting to fit data it is often advantageous to use a simple model and to fit the simplest (clearest) data. Choose a contrast that has a well defined structure or a system with known parameters. It is sometimes expedient to vary the parameters manually at first to get some idea of their relative significance and appropriate orders of magnitude.
The program will run much faster if there is no resolution or polydispersity included in the model. On slow computers this may significantly alter the performance as extra loops of model calculation have to be made for each of these terms.
Save the parameters at regular intervals with the S command. Although there is some attempt to protect the program, some combinations of values can cause the calculation to crash. If the values are saved, it will avoid having to enter them all again.
Within the main loop of the program, the command Help will provide instructions on operation of the FITFUN routines. More information can be found on the command structure and the fitting algorithms in R E Ghosh ‘Fitfun 96’ ILL Technical Report ILL89GH08 and some notes at the following WWW location: (http://www.ill.fr/Computing/fitfun.htm).
Some models may include parameters that are highly correlated. For example some polydispersity and resolution parameters may introduce very similiar effects to a model curve. Any attempt to fit such parameters together in a least-squares minimisation may give problems. It will normally be evident that a good minimum is not found and this can be verified by inspecting the correlation matrix. Use L in the main command menu. It will usually be desirable to find some means of fixing one of the parameters.
The following text shows an example of the program dialogue when run on a Silicon Graphics computer:
duck 18% rfit
Program RFIT
Version 2.4 A. R. Rennie May 1999
rfit> Choose from the following models :-
1 - Debye function
2 - Spherical particle
3 - Lorentzian
4 - Gaussian
5 - Cylinder
6 - Ellipsoid
7 - Product of 2 Debye functions
8 - Product of Debye and Sphere
9 - Fractal Log I = a Log Q + const.
10 - Two Gaussians
11 - Some hints on units
rfit> Give a number 1 -11 [1] :
2
rfit> Do you want to include polydispersity in the model (Y/N) [N] ? n
rfit> Do you want to include resolution broadening in model (Y/N) [N] ?
rfit> Do you want Flat background or background spectrum (F/S) [F] ?
rfit> Do you sloping background (Y/N) [N] ?
rfit> Do you want to fit points with zero error (Y/N) [N] ?
rfit> Choose from following variables for Y-axis :-
1 - Intensity (linear)
2 - Log(I)
3 - Sqrt(I)
4 - I * Q**2
5 - 1 / I(Q)
rfit> Present variable is 1. New value ?
rfit> Choose from following variables for X-axis :-
rfit> Choose from following variables for X-axis :-
1 - Intensity (linear)
2 - Q**2
3 - Log(Q)
rfit> Present variable is 1. New value ?
rfit version 2.4
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>r 19320 3
Run 19320 Ext. 3
55 Values of I(Q) have been read in.
THERE ARE 20 DATA POINTS IN CURRENT FITTING RANGE
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>v
FITFUN 5.4 TITLE: 19320 3 le: E3 3.1m/ le: E3 3.1m/
FITTING Y : Intensity VERSUS X : Q
NUMBER PARAMETER VALUE ( OLD VALUE ) STEP % DEVIATION
1 Rhard 13.87 ( 13.87 ) 0.2000 0.00
2 I(q=0) 0.4254 ( 0.4254 ) 0.2000 0.00
3 Flat bak 0.6321E-01( 0.6321E-01) 0.2000 0.00
4 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
5 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
6 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
7 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
8 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
9 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
10 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
11 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
12 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
13 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
14 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
15 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
16 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
17 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
18 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
19 Unused 5.000 ( 5.000 ) 0.0000E+00 0.00
20 Unused 4.249 ( 4.249 ) 0.2000 0.00
100 MAXIMUM STEP 100.0 300 SUBSTEP 0.05000
200 ACCURACY 0.1000E-01
THERE ARE 20 POINTS IN THE CURRENT RANGE SET BY "ONLY" COMMAND.
CURRENT LIMITS (IF RANGE IS NON-ZERO) ARE :
0.400E-01 TO 0.100 0.000E+00 TO 0.000E+00 0.000E+00 TO 0.000E+00
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>v 1 17 .4
rfit>f 50
FITTING.....
.....ENDED
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>f
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>v
FITFUN 5.4 TITLE: 19320 3 le: E3 3.1m/ le: E3 3.1m/
FITTING Y : Intensity VERSUS X : Q
NUMBER PARAMETER VALUE ( OLD VALUE ) STEP % DEVIATION
1 Rhard 19.56 ( 17.00 ) 0.4000 6.30
2 I(q=0) 0.4041 ( 0.4254 ) 0.2000 6.47
3 Flat bak 0.8351E-01( 0.6321E-01) 0.2000 48.56
4 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
5 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
6 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
7 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
8 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
9 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
10 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
11 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
12 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
13 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
14 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
15 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
16 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
17 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
18 Unused 0.0000E+00( 0.0000E+00) 0.0000E+00 0.00
19 Unused 5.000 ( 5.000 ) 0.0000E+00 0.00
20 Unused 4.249 ( 4.249 ) 0.2000 0.00
100 MAXIMUM STEP 100.0 300 SUBSTEP 0.05000
200 ACCURACY 0.1000E-01
THERE ARE 20 POINTS IN THE CURRENT RANGE SET BY "ONLY" COMMAND.
CURRENT LIMITS (IF RANGE IS NON-ZERO) ARE :
0.400E-01 TO 0.100 0.000E+00 TO 0.000E+00 0.000E+00 TO 0.000E+00
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>s
TYPE HELP OR OPTION: H,R,D,X,Y,V,F,O,P,L,W,C,E,J,S,T,Z
rfit>exit
duck 19%
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
This program is currently available for Silicon Graphics Unix and for PC's that run DOS (or DOS prompts from Windows 3.1, Windows 9x, Windows NT etc.). The programs are functionally similar but under DOS the program will only work with full screen mode. Currently version 2.4 of rfit is available for both PC and Unix.
The program will require that certain environment variables are set.
In particular the
PGPLOT graphics library as used at the
ILL will require devices for
screen and hard copy output to be defined. Some advice on the use
of the program on a PC can be found with the description of the
standard ILL SANS treatment programs that are available for PC's. This
information is in the following ILL Technical Report:
R. E. Ghosh, S. U. Egelhaaf, A. R. Rennie A Computing Guide for
Small-Angle Scattering Experiments Institut Laue-Langevin, Grenoble,
France ILL98GH14T (1998)
and is summarised as documentation on the WWW at
http://www.ill.fr/data_treat/pcsans.html. The original
documentation about the PGPLOT library can be found at the following
location:
http://astro.caltech.edu/~tjp/pgplot/.
The file GRFONT.DAT is required for the plotting routines and must be copied to PGPLOT_DIR if not already on the system. On a PC the file DOSXMSF.EXE is required in the current path to run the program.
It will be necessary to use SET (on a PC) or setenv on UNIX systems to define certain quantities. Further documentation is provided at the ILL but a few examples are given below.
DOS
SET PGPLOT_ILL_DEV_1=/MS
SET PGPLOT_ILL_DEV_2=/HJ
SET PGPLOT_ILL_PPAGE=2
SET PGPLOT_DIR=C:\PROG\
UNIX
setenv PGPLOT_ILL_DEV_1 /XSERV
setenv PGPLOT_ILL_DEV_2 /VPS
setenv PGPLOT_ILL_PPAGE 2
setenv PGPLOT_DIR /usr/prog/mydir/
It is convenient to include these commands in a .BAT file (DOS) or in a login procedure on UNIX systems.
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
I am extremely grateful to Dr Ron Ghosh of the ILL, Grenoble for provision of the libraries and much help.
Go to: Introduction, Models, Use of Program, Systems & Versions, Acknowledgments, Contact.
Department of Physics, Uppsala University Sweden
E-mail: Adrian.Rennie@fysik.uu.se
Last Modified 26 October 2005