MMEMB - Fitting models of mixed bilayers of surfactants or lipids to neutron reflectivity data

Adrian R. Rennie, Uppsala University, Sweden

December 2016, Last modified 17 June 2018.


1. Introduction
   1.1 General
   1.2 Legal Notice
2. Use of the Program
   2.1 Data Files
   2.2 Definitions of Parameters
   2.3 Suggestions for Start Values
   2.4 Customising the Program
3. Simultaneous Fits with Multiple Data Sets
   3.1 General
   3.2 Uses
4. Suggestions and Hints
   4.1 Hints
   4.2 Frequently Asked Questions
Acknowledgements and References

1. Introduction

1.1 Introduction and General Remarks

Fitting models to reflectivity or scattering data is usually best performed by including the constraints of prior knowledge about the to the models. A further objective in fitting algorithms is to choose the parameters for minimisation that are not correlated. For this reason fitting programs have been developped that are designed for particular classes of scientific problems. In the case of structures formed by surfactants, the individual molecules are often identified by known hydrophilic and hydrophobic regions with known volumes and scattering contrast. For simple systems the programs BIKE and MBIKE are used to model bilayers of surfactants and lipids that occur at solid/solution interfaces.

The program MMEMB extends the model used in BIKE to include mixtures of two amphiphiles and the possibility that these are segregated non-uniformly. The structure is shown schematically in the figure below:


Associated with each volume for the surfactant there will be a scattering length. Solvent molecules are also defined by a volume and a scattering length. These are discussed in more detail in sections 2.2 and 2.3 below.

The program mmemb is an extension of bike which allows unconstrained models of multiple uniform layers for a single data set. The program mbike is equivalent to the program wetdoc for multiple data sets. These two programs provides a means of making interactive, graphical fits to neutron reflection data using multilayer models calculated using optical matrix methods. The parameters may be changed manually to explore the effect of different structural models or varied using a least squares algorithm.

The program iss constrained to model 5 layers with 4 of the layers defined by molecular properties of adsorbed species (volume, extent of the tail region etc.). The programs are intended for operation with Windows and can optionally be run with the clickfit_m GUI. The current version is prepared using the MinGW Fortran compiler. The current version of mmemb is 1.4.

The programs are written entirely in FORTRAN and use the FITFUN fitting package and PGPLOT (T. J. Pearson, Caltech) graphics as modified by R. E. Ghosh from the ILL, Grenoble, France.

Installation The program can be downloaded with other software as a zip file It is recommended to run the program using clickfit and the utility 'Prop' available from the ILL. Instruction for download and use of Prop are available from the ILL WWW site. Prop is installed but clickfit and the fitting programs only need to be copied to suitable directories.

Information about other fitting programs that will treat smooth profiles, multiple bilayers and other specific problems is available on the web at:

1.2 Legal Notice

These programs are made available for non-commercial use without charge. They should be acknowledged in any publication by reference to the Author and this web page. No guarantee is provided that the results of the programs are correct. It is the reponsibility of the user to check all results.

2. Use of Program

Instructions on the use of FITFUNS can be found in the documentation at the ILL, Grenoble.

The main options for the program are chosen from a 'Prelude' dialogue box that allows selection of the data format, use of resolution function etc.

The default choices in the prelude can be changed by editing the appropriate .fcl file. Once the choices are made, the main program is controlled from another interactive window:

The individual variables can be selected with a mouse and a new dialogue box appears that allows new values for parameter and the step size to be given. Other functions can be selected from the buttons or pull down menus. When display of data or a fit is calculated, it is shown in a separate graphics window:

2.1 Data Files

Ten different ASCII data formats can be read in the current version. These are:

The data format is selected in either the opening dialogue or the Clickfit 'Prelude'. A fuller description of the data formats is available at The four column data set input has been added in August 2007. The 4th column provides information about Q resolution of the data. At present this resolution is not automatically incorporated in the calculation but information must be provided separately. The input routine is purely to provide convenience and avoid reformatting data. It is hoped to incorporate automatic use of resolution from data sets when some agreement is reached about how resolution is defined.

2.2 Definitions

The program assumes that data for scattering length density is provided in units of 1 x 10-6 A-2. If the momentum transfer, Q, in the input data files is in Å-1 then the thickness of layers must be given in Å. These could be scaled with other parameters if input data is in nm-1.

The following summary of the definitions may be useful:

  1. Top - the scattering length density of the bulk medium through which the neutron beam approaches the interface (10-6 Å-2.
  2. Scale - Multiplicative factor to put input data on an absolute scale of reflectivity.
  3. F Sol - Fraction of solvent in the 'Oxide' layer (should be between 0 and 1).
  4. Rough - Gaussian interfacial roughness between the substrate and the 'oxide' layer.
  5. Bgd - a flat background that is added to the model calculation.
  6. Thick Ox - Thickness of the 'oxide' layer between the first material and the layer of surfactant head groups. (units are Å)
  7. Rho Ox - Scattering length density of the 'oxide' layer between the first material and the layer of surfactant head groups. (units are 10-6 Å-2)
  8. Rough Ox - Roughness between the 'oxide' layer and the adjacent layer of surfactant head groups.
  9. Thick Hn - Thickness of the surfactant head group region next to the 'oxide' layer (inner layer)(thn). (units are Å)
  10. Thick Ti - Thickness of the surfactant tail group region for the inner layer (Ti). (units are Å)
  11. Th To/Ti - Ratio of the thickness of the surfactant tail group region in the outer layer to that in the inner layer (To / Ti). (dimensionless)
  12. Th Ho/Hi - Ratio of the thickness of the surfactant tail group region in the outer layer to that in the inner layer (Ho / Hi). (dimensionless)
  13. b solv - Scattering length of a single solvent molecule. (Units are fm or 10-15 m)
  14. V solv - Volume of a single solvent molecule. (Units are Å3)
  15. b head A - Scattering length of molecule A head group. (Units are fm or 10-15 m)
  16. V head A - Volume of molecule A head group. (Units are Å3)
  17. b tail A - Scattering length of molecule A tail. (Units are fm or 10-15 m)
  18. V tail A - Volume of molecule A tail. (Units are Å3)
  19. b head B - Scattering length of molecule B head group. (Units are fm or 10-15 m)
  20. V head B - Volume of molecule B head group. (Units are Å3)
  21. b tail B - Scattering length of molecule B tail. (Units are fm or 10-15 m)
  22. V tail B - Volume of molecule B tail. (Units are Å3)
  23. AHG i - Area per surfactant A molecule in the in the inner layer of the bilayer structure (Units are Å2)
  24. AHG o/i - Ratio of the area per surfactant A molecule in the inner layer of the bilayer structure to that in the outer layer (Dimensionless)
  25. NB i - Number of B molecules per A molecule in the inner layer (Dimensionless)
  26. NBo/NBi - Ratio Number of B molecules per A molecule in the outer layer to that in the inner layer (Dimensionless)
  27. F Bh ih Fraction of B heads in inner head region
  28. F Bt ih Fraction of B tails in inner head region
  29. RF Bh oh Ratio of fraction of B heads in outer head region/inner region
  30. RF Bt oh Ratio of fraction of B tails in outer head region/inner region
  31. Rough f - the roughness as a fraction of the layer thickness for each of the surfactant region layers (should be less than about 0.3)

The following diagram indicates this arrangement schematically:


The space in the layers of heads and tails that is not filled by surfactant molecules is assumed to be filled by solvent molecules. An important physical constraint is that the space in these layers is at least sufficient for the surfactant molecules, both A and B. This implies, for example, that:

(thn + tti + tto + tho) x Ahd   >   2 x (Vhead tot + Vtail tot)

For mmemb, The scattering length of each component can be set to a different value for each data set. The thickness, volume and roughness are kept the same for modelling each data set.

The roughness for the top material and oxide layers is given in Ångstrom but the roughness at the following interface for the other layers is defined as a fraction of the thickness (Rough f).

2.3 Some Suggestions for Start Values of Parameters

It is for the user to determine how to model data and to choose parameters and values consistently. Some examples and suggestions as to how to estimate parameters are provided here. Data for scattering lengths and a simple means of determining scattering length densities is provided at the NCNR, NIST web site. The following table provides some approximate values for scattering length densities in the units used in the programs. In order to obtain a scattering length the atomic formula for a molecule is needed. The scattering length density calculation needs also information about the mass density of the material (which is combined with the formula mass) to determine a formula volume.

Material Chemical Formula Scattering Length Density / 10-6 Å-2
Silicon Si 2.07
Silica SiO2 amorphous 3.41
Sapphire Al2O3 5.8
Water H2O -0.56
Heavy Water D2O 6.35

In these programs the parameters for the solvent and the surfactant moieties are given in terms of the molecular volume and the scattering length. Some examples of approximate values for these quantites are given in the next table.

Material Chemical Formula Formula Volume / Å3 Scattering Length / 10-15m (fm)
Water H2O 30 -1.68
Heavy Water D2O 30 19.15
Dodecyl Chain C12H25 370 -13.8
Dodecyl Chain deuterated C12D25 370 246.5
Hexaoxyethylene C12H25O6 440 21.1

The users input of molecular volume will be important in determining the amount of solvent that is surrounding the surfactant in the interfacial layers. It is important to consider when calculating volumes whether it is appropriate to consider a liquid or a crystalline density. The values for layer thickness for the surfactants will clearly depend greatly on the molecular structure but are ofte in the region of 10 to 30 Å. The areas per molecule in the layer are similarly varied but often in the range of 40 to 200 Å2.

It is very important to check that the values for the roughness are physically reasonable. The approximation used by the program due to Nevot and Croce is only valid for values of the roughness that are small compared with the layer thickness. If large values of the roughness or continuously varying profiles are needed for a model it will be necessary to choose a different program that can model such profiles. Please consult the catalogue of other programs to make a suitable choice such as lprof or cprof.

2.4 Customising the Operation

The last parameters, the ranges for fitting and the limits for graphs are saved in a parameter file if the 'Save' option is used. These are the defaults when the program is restarted.

Further customisation of the defaults is possible by editing the clickfit configuration file that is used to start the program. An example (mmemb.fcl) is shown below:

prld|title|MMEMB - A.R. Rennie  version 1.4   4 March 2018 
prld|Data type .dat 0; RAL 1; Afit 2; NIST 3; .TXT (ANSTO) 4; .OUT (ILL) 5; New .his 6; .mft 7; 3-col no header 8; mantid .mft 9 |float|7| 0 | 9 |
prld|Give data weighting 0-none;1-statistical|float|0| 0 | 1 |
prld|Fit data as R*Q**4 0-no, 1 yes |float|0| 0 | 1 |
prld|Include resolution 0-none; 1 const dQ/Q; 2 const dQ; 3 (dQ/Q + dQ); 4 taken from input data |float|4| 0 |4|
prld|Resolution: for dQ/Q constant give % resolution |float|5.0|.1|30|
prld|Resolution: for Delta-Q constant give value (A-1)|float|0.01| 1e-5 | 0.1 |
rcmd|wntle|Reading new data
rcmd|title|Reading reflectivity data
rcmd|Data filename.dat |filer|a28708.mft|
main|wntle|mmemb - fitting a mixed bilayer model to multiple reflection data
hcmd|title|MMEMB - mmemb+gui
hcmd|View file/View helpfile |filed|mmemb.hhh
jcmd|wntle|model output
jcmd|title|Write out model for later comparison with data
jcmd|Write out reflectivity file (1) or Interface as BSD file (2) |float|1|1|2|
jcmd|using parameter set number|float|1|1|10|
jcmd|Reflectivity file: Minimum Q value A-1 |float|0|0|4
jcmd|Reflectivity file: Maximum Q value A-1 |float|0.3|0.05|4
jcmd|Reflectivity file: Number of points in output |float|200|50|512
jcmd|Filename for output: |filew|mmembout
jcmd|Title for reflectivity results|text|Output from mmemb
rstx|attempt restart function (dummy at present - rsta control name)

The default data types, resolution and even input data file name can be altered by editing the fcl file. It is possible to keep multiple copies of fcl files with different names in order to start the program with different defaults.

3. Simultaneous fits to multiple Contrasts or other Multiple Data Sets

3.1 General

A separate program MBIKE is used to read and make simultaneous fits to multiple data sets for the same sample or structure. The use is very similar to BIKE but it should be used with the clickfit_m graphical user interface (GUI) as this permits setting some different values for parameters for different data sets.

There is one additional parameter in MBIKE (21): Mult Ahg. This is a multiplicative factor for the area per molecule for each data set. If set to 1 the area is just Area/hd. It can be either smaller or larger than 1.

The following parameters can be allowed to vary between different data sets (the others are constrained to be identical):

It is expected that for a given experiment only some of the different variables will be needed but the range of parameters that can be constrained or varied allows some flexibility in use of the program. Different ranges of momentum transfer for fitting can be selected for different data sets using the options under 'Fitting' in the GUI or the 'O' command if the program is run from a command line.

3.2 Uses with multiple data sets

There are a number of reasons to fit a model to multiple data sets. These include:

  1. Using different isotopic contrasts to effectively determine lost phase information. In these cases specific values of b will be chosen for the different data sets. It may also be necessary to allow for different background values.
  2. Checking the combination of different instrument configurations to verify that they match correctly or to determine optimum scale factors. In this case all parameters apart from teh scale factor are likely to be held constant. It will be convenient to choose different Q ranges for the fits for each data set.
  3. Compare samples that are expected to have identical structures but just different coverage. In this case the area per Mult Ahg will be varied and other parameters fixed.

4. Suggestions and Hints

4.1 Hints

In studies of complicated systems make sure that the model for the bare substrate fits the data measured for that system before proceeding to more complex systems. It is useful to build up from simple models (few layers) to more complex models (many layers) when trying to fit data. Check that the model is compatible with all contrasts before proceeding.

It is usually convenient to refine a model with only a few parameters initially. Manual changes of parameters to find good starting values are often the most efficient way to search for reasonable models.

Resolution can be included in different ways: the normal function would be to assume a constant dQ/Q. A further option is either constant dQ or a combination of terms that have fixed values of dQ/Q and dQ. This resembles a function that approximates to fixed slits at various angles is available for scans made in this way (using the old version of D17 at the ILL.) Data from D17 is no longer normally collected in this way. Old versions of the program allowed definition of resolution in terms of the slit sizes etc but this. is no longer included in current versions.

At present the resolution from individual data sets is not used in calculating smearing even when information is provided in the fourth column (as no standard definition is available).

The default options in this program is for equal weighting of all data points in the fits. This is often found to be more satisfactory than weighting by the errors which are frequently not appropriately chosen. Systematic errors and variation in the resolution may be large compared with the random errors particularly at large reflectivity (small Q).

4.2 Frequently Asked Questions and Answers

  1. How do I constrain a bilayer to be symmetric? It is possible to keep the thickness of the two head group regions identical even when fitting this parameter by setting the ratio of the thicknesses and the composition parameters to 1 (and keeping them fixed). Generally setting a negative step size equal to a parameter number will provide a constraint that the parameters are identical. This can be used to keep some ratio parameters the same.
  2. Is there a simple way to check that the parameters are physically reasonable? The 'post-fit options' or 'Extra' buttons in the GUI (J on command line) can provide some simple physical parameters of the model. Make sure that the number of solvent molecules is positive.
  3. What is the surface excess? There are two molecules at the interface in the area Area/hd (A). This can be converted to an excess, Γ, in mass per unit area. If the molecular mass of the surfactant is M and Avogadro's constant is NA then:

    Γ = 2 M / (NA A)

    If necessary make allowance for the value of Mult Ahg. You will also need to convert to whatever units (e.g. cm2 or m2) are required. A is in Å2.
  4. Can I fit a series of runs (e.g. adsorption kinetics)? Yes. It is possible to automate a sequence of fits with bike so that the program automatically reads a sequence of data files and uses either the saved fit parameters or the revised parameters after the previous fit. The fitted parameters are provided in a csv file for users to analyse further. Use the 'Make Sequence File' button in the clickfit GUI. Normally it is better to try and fit only a single or few parameters in this way.
  5. What are the errors in the fit parameters? The programs report the statistical uncertainty in the minimisation (using the user selected weighting) as a percentage of the fitted parameter. The errors are valid if the program reports that it has found a minimum. They do not allow for any systematic errors in the measurements, data reduction or scaling that are often larger than the errors in the minimisation! There is some discussion of uncertainty and errors in a paper by H. M. Kwaambwa, M. Hellsing and A. R. Rennie in Langmuir 26, 3902-310 (2010) particularly in regards of systematic uncertainty in the determination of the background.
  6. How do I fit multiple bilayers? Many systems will adsorb as multilayers or are deposited as multilayers by Langmuir-Blodgett deposition. These experiments need other fitting programs such as tram, trikk or stige. Please consult the catalogue of other programs to make a choice.
  7. How do I fit models that include large patches on a surface? The program spots can fit defined layers and calculate averages for density profiles that could be different on different areas of a surface. This would be appropriate for patches that are large or are separated by more than the coherence length of the scattering experiment. The program is not specifically designed for bilayer structures. Please consult the documentation for spots for more details.


I am very grateful to Dr Ron Ghosh who has provided the FITFUN and clickfit software and co-operated in the development of these programs.


A description of the methods used in these calculations is given in the Rutherford Appleton Laboratory Report: 'Adaptation of Methods in Multilayer Optics for the Calculation of Specular Neutron Reflection' by J. Penfold, No. RAL-88-088.

Other details on the calculation of reflectivity profiles can be found in the books by O. S. Heavens, 'Optical Properties of Thin Solid Films', 2nd Ed. (1991) Dover and J. Lekner, 'Theory of Reflection', M. Nijhof, Amsterdam (1987). The matrix calculations were originaly described by F. Abeles Ann. de Physique, 5, 611 (1950) and the method to include small amounts of roughness by L. Nevot and P. Croce J. Phys. Appl. 15, T61 (1980).

Please report mistakes or make suggestions for improvements to:

Professor Adrian R. Rennie
Uppsala University, Uppsala, Sweden


Program and documentation: © Copyright A. R. Rennie Last updated 17 June 2018.