BYBAN - Fitting multilayer neutron reflectivity data


  1. Introduction
  2. Model of Interface and Parameters
  3. Use of Program
  4. Examples
  5. Legal Notice
  6. Acknowledgement

1. Introduction

November 2010, Documentation last modified 29 May 2018

The programs fit data that arises from a repeated multilayer structure such as that arising from a concentrated surfactant phase at an interface. The program BYBAN can be used to create a model stack of multiple surfactant bilayers (such as a lamellar phase) that includes a thermal fluctuation amplitude. The program byban is an extension the program tram that has an identical model except for the inclusion of fluctuations. These programs for multiple bilayers of amphiphiles are related to the simpler programs drydoc and bike that allow similar models for either a simple sequence of unrelated layers or a molecular bilayer. Another program VELO uses a model with a sinusoidal variation in the scattering length density at the interface.

These programs are designed to make 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 programs are written 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. The programs are intended for operation with a GUI. The current versions are prepared using the MinGW Fortran compiler. The current version of byban is 1.0.

Installation It is recommended to run the program using clickfit and the utility 'Prop' available from the ILL. Instructions for the download and use of Prop are available from the ILL WWW site.

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

2. Model and Description of Parameters

2.1 Model used in 'byban'

The model in byban is a modification of that used in the related program tram for a repeatng structure of a surfactant bilayer at the interface of two bulk phases. The special feature of this program is that it treats the case of reflectivity profiles that are dominated by Bragg peaks from the repeating structure and includes an extra term to allow for thermal fluctuations of the bilayers. The intensity of Bragg peaks depends on a number of parameter but it is well known that thermal motion will reduce the intensity of diffraction from a crystal by a factor that depends exponentially on the mean square amplitude of the fluctuations, ξ. This is usually written as a Debye-Waller factor, FDW given by:

FDW = exp(-2W)

where 2W = Q2ξ2 / 3. Q is the momentum transfer that is given by:

Q = (4π/λ)sin θ

where λ is the wavelength and θ is the grazing angle of incidence. This treatment is widely used in studies of scattering from crystals (see e.g. G. L. Squires, Theory of Thermal Neutron Scattering, Dover, New York.) but the application to reflectivity data needs some special consideration. This is based on the idea that the reflectivity for an interfacial structure, R(Q)as a function of momentum transfer Q can be considered approximately as the product of two terms that are RF(Q) and Φ2. RF(Q) is the reflectivity that would occur for a sharp interface of the two bulk phases and Φ is the Fourier transform of the scattering length density distribution in the direction normal to the interface. The term RF is known as the Fresnel reflectivity and includes total reflection below the critical value of Q. The second term concerns interfacial layers and can account for the perturbation in the reflectivity without needing to use dynamic scattering theory that is beyond the first Born approximation. The approach has been used by Tidswell et al (Phys. Rev. B, 1990, 41, 1111-1128.) for liquid films and by Penfold et al for multilayers of surfactant/polymer complexes (Langmuir, 2007, 23, 3690-3698.).

By analogy with the calculation of scattering from crystals at elevated temperatures, the term Φ2 can be multiplied by FDW if the interface gives rise to a reflectivity that is dominated by Bragg peaks. The approximation that the reflectivity is separable in to these distinct functions allows a further simplification: the FDW can be used to multiply the reflectivity calculated by an optical matrix method in place of RF(Q) Φ2. This is the approach used in the program 'byban'.

It should be emphasised that this approach is quite different to simply increasing the roughness of each bilayer. The thermal fluctuations of the bilayer can reduce the correlation between the lamellae at an interface while preserving well the self-assembled bilayer structure. This reduction in correlation reduces the intensity of the Bragg peaks with increasin Q. The fluctuations can be of the same order or even larger than the lamellar thickness. Roughness must always be constrained to values that are small compared to a layer thickness. The calculation is only approximate as other structure at the interface would not be fluctuating and the Fresnel reflectivity should not be altered. As total reflection occurs at low Q, the influence of FDW is usually small at the critical Q for total reflection.

The possibility to include roughness and near surface layers has been left in the program so as to provide a simple direct comparison with the program 'tram'. The assumptions for validity of this calculation are that the reflectivity is dominated by the Bragg peaks and that the correlations between the near surface layers and the 'crystal' structure are small so that cross-terms in the expansion of a full scattering function can be ignored. These conditions are fulfilled in a number of practical examples such as those used to illustrate the use of the program in the description below.

2.2 Parameterisation of the Model

The bulk phases are described as 'top' (through which the incident beam reaches the sample) and 'sub' that will be the subphase beneath the interface and an interfacial structure of bilayers and solvent. The structure is shown schematically in Figure 1. Between the 'top' phase and the bilayer structure, four arbitrarily chosen layers of defined thickness and scattering length density are defined. These can be used to model a non repeating surface structure such as oxide on a solid surface, grafted interfaces or other special layers. They are defined in terms of thickness, t, scattering length density, ρ and roughness, ξ. These layers are numbered from 1 to 4 (increasing away from 'top' towards 'sub'). This notation corresponds to that used in drydoc.

Layer sequence used in model

Figure 1. Layer structure modeled in byban with 4 near surface layers and then repeating bilayers separated by solvent.

The individual bilayers that form the multilayer structure are parameterised in terms of molecular properties in a manner similar to that used in bike. Some details of this structure are shown in Figure 2. The bilayer consists of two regions of heads with solvent separated by a region of tails plus solvent. In each bilayer the two 'head' regions are assumed to be identical (i.e. the bilayer is symmetric). Each bilayer is further separated by a layer of pure solvent. The composition of the bilayer regions (and hence the scattering length density of each layer) is calculated from the area per molecule, A, in each half of the bilayer. For these calculations it is necessary to define the scattering length, b, and volume, V, of the head and tail moieties of the molecule in the bilayer. Some tools for understanding and checking the physical model are described in section 3.2 below. The model constrains the bilayers to contain equal numbers of 'heads' and 'tails' but the user must check that the solvation of the molecules is realistic. It is also important to keep the roughness small for the approximations in the calculation to remain valid.

Diagram of heads and tails of surfactant molecules

Figure 2a. Head and tail regions of surfactants modeled in byban that then form repeating bilayers separated by solvent.

Diagram of one bilayer of surfactant

Figure 2b. Bilayer of surfactants modeled in byban that are separated by solvent.

The fraction of the head region that is occupied by solvent, xhs, is given by:

xhs = 1 - (Vh / A th )

The fraction of the tail region that is occupied by solvent, xts, is given by:

xts = 1 - (2Vt / A tt )

The scattering length density of each of these layers is then given by:

?h = (1 - xhs) (bh / Vh) + xhs ?sol

?t = (1 - xts) (bt / Vt) + xts ?sol

where ?sol is taken to be identical to the scattering length density of the bulk medium furthest from the incident beam, ?s. An extension of this simple model allows a gradient in the composition of the bilayers to be introduced. The area per molecule can be different near the top surface (Ai) and close to the bulk solvent (Ao). The value of A for each bilayer is assumed to vary linearly between Ai and Ao. This corresponds to a volume fraction of molecules that varies as 1/z (z is the disatance away from the interface). For convenience if Ao is set to zero, it is automatically taken to be identical to Ai and this corresponds to no composition gradient. Thus the general expression for Aj, the area for each molecule in the bilayer number j is:

Aj = Ai + (j/N) (Ao - Ai).

The program is dimensioned so that it could calculate 120 repeats of the bilayer structure although this is rarely necessary as the changes in the reflectivity that arise from the repeating structure are normally rather small on increasing N above about 30. It is not recommended to use N as a variable parameter in least squares fitting as the derivatives of residuals with respect to this integer quantity are necessarily discontinuous. The user should rather experiment with different values of N by manually changing the value and if necessary fitting other parameters. When N is small (say 3 or 5) the value of N will significantly alter both the width and intensity of the Bragg peaks that arise from the repeating structure.

The parameters that are used in the program byban are listed in Table 1.

Table 1. Parameter used in program byban

No. Parameter Name in program Symbol Unit
1 Scattering length density of medium with incident beam Rho (top) ρT 10-6 -2
2 Scattering length density of substrate Rho (sub) ρS 10-6 Å-2
3 Experimental Scale Factor Scale FS None
4 Top surface roughness (between 1st layer and incident beam medium) Rough ξa Å
5 Background Bgd B None
6 Thickness of layer 1 Thick 1 t1 Å
7 Scattering length density of layer 1 rho 1 ρ1 10-6 Å-2
8 Roughness between layer 1 and layer 2 Rough 1 ξ1 Å
9 Thickness of layer 2 Thick 2 t2 Å
10 Scattering length density of layer 2 rho 2 ρ2 10-6 Å-2
11 Roughness between layer 2 and layer 3 Rough 2 ξ2 Å
12 Thickness of layer 3 Thick 3 t3 Å
13 Scattering length density of layer 3 rho 3 ρ3 10-6 Å-2
14 Roughness between layer 3 and layer 4 Rough 3 ξ3 Å
15 Thickness of layer 4 Thick 4 t4 Å
16 Scattering length density of layer 4 rho 3 ρ4 10-6 Å-2
17 Roughness between layer 4 and repeating structure Rough 4 ξ4 Å
18 Number of repeats of bilayer structure No. Repeats N None
19 Thickness heads Thick h th Å
20 Thickness tails Thick t tt Å
21 Thickness solvent Thick sol. tsol Å
22 Volume of heads Vol. h Vh Å3
23 Volume of tails Vol. t Vt Å3
24 Volume of solvent Vol. Sol. Vsol Å3
25 Scattering length - tail b tail bt fm
26 Scattering length - head b head bh fm
27 Area per molecule at interface Ahg in Ai Å2
28 Fractional roughness of bilayer structure Rough f ξf Å2
29 Area per molecule near solvent Ahg out Ao Å2
30 Debye-Waller Factor Debye-W ζ Å

These units assume that the input data to be modelled is reflectivity as a function of momentum transfer, Q given in Å-1. If alternative units for Q are used, the values for the thickness, Area, roughness etc. will also need to be scaled. These parameters are related to the physical model shown in Figure 1. The Debye-Waller term (30) is parameterised by the root mean square fluctuation amplitude, ζ in units of Å

3. Use of Programs

3.1 Starting

Use of Prop and clickfit as well as instructions on the use of FITFUNS can be found in the documentation at the ILL, Grenoble that was described in section 1.

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

Prelude dialogue box

Figure 4. Prelude Dialogue window for 'byban

Once the choices for data format, resolution etc are made, the main program is controlled from a different interactive window that is shown in Figure 5. The default choices in the prelude can be changed by editing the appropriate .fcl file (see 3.4 below).

Parameters and Fitting Options

Figure 5. Clickfit Dialogue window for 'byban


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:

Graphics Window with example fit

Figure 6. Graphics window for 'byban showing data with a model calculation

3.2 Data Files

Seven 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. It is assumed to be the width parameter, σ of a Gaussian resiolution function in the units of Q.

3.3 Hints

In studies of complicated systems make sure that the model for the bare solid surface 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.

Resolution can be included in different ways: the default 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 the resolution for fixed slits with measurements at different angles (for example using the old version of D17 at the ILL.) Data from D17 is no longer normally collected in this way.

If resolution from individual data sets is used in calculating smearing (when information is provided in the fourth column), it is assumed to be the width parameter, ? of a Gaussian resolution function.

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).

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.

Several tools are available to help check that the parameters are physically reasonable and to understand the structure that has been modelled. The button 'Post-fit options' is active only after a fit has been made but then it presents a further dialogue window that is shown in Figure 7. Option 3 provides a simple output of the scattering length density profile as a graph as shown in Figure 8. This data can also be output as an ASCII file (.bsd) for further processing or plotting.

Extra Post-Fit options for output

Figure 7. Post-fit options for 'byban'.

Example of density profile plot

Figure 8. Graphics window for 'byban' showing scattering length density profile for a model calculation.

Option 4 in the 'Post-fit options' provides a simple calculation to estimate how the molecules pack in the first bilayer of the stack that is appended to the program log file (bybannn.log where nnn increases each time the program is run). An example of the text is shown below:

Some physical interpretation of the multibilayer 

 Area per head group Inner (A2)      35.     Surface Excess (A-2)    0.563E-01
 rho sol is     6.35     x 1E-6 A-2
 Head n rho     4.93     x 1E-6 A-2  No. of Solv / Head     3.96    
 Tail rho       3.58     x 1E-6 A-2  No. of Solv/2 tails    -11.3    

This example shows that the packing of the molecules was not physically possible in the model for which the calculation was made as the volume of the heads was larger than the thickness multiplied by the area that would lead to a negative number of water molecules hydrating these groups! Under these circumstances the model needs to be refined not just because it inadequately fits the data.

3.4 Definitions and Starting Parameters

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

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.

Table 3 Scattering Length Densities of Some Materials

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 byban the parameters for the solvent and the molecular moieties that form the bilayer are given in terms of the molecular volume and the scattering length. Some examples of approximate values for these quantites are given in the Table 4.

Table 4 Molecular Volumes and Scattering Lengths of Some Materials

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
Hexaoxaethylene 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.

3.5 Customising

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 new defaults for the parameters when a new fit is attempted or 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 (byban.fcl) is shown below:

prld|title|BYBAN - A.R. Rennie  version 1.7  27 June 20115 
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|9| 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|0| 0 |4|
prld|Resolution: for dQ/Q constant give % resolution |float|2.0|.1|30|
prld|Resolution: for Delta-Q constant give value (A-1)|float|0.01| 1e-5 | 0.1 |
main|wntle|byban - fitting repeating bilayers (heads/tails) at interface
rcmd|wntle|Reading new data
rcmd|title|Reading reflectivity data
rcmd|Data filename with extension |filer|f1234.asc|
hcmd|title|byban - first example of byban+gui
hcmd|View file/View helpfile |filed|byban.hhh
jcmd|wntle|model output
jcmd|title|Write out model for later comparison with data
jcmd|Write out reflectivity file (1), profile as BSD file (2), plot (3), model parameters (4) |float|1|1|4|
jcmd|Reflectivity file: Minimum Q value A-1 |float|0.0|0.0|4.0
jcmd|Reflectivity file: Maximum Q value A-1 |float|0.3|0.05|4.0
jcmd|Reflectivity file: Number of points in output |float|200|50|512
jcmd|Filename for output (no extension)|filew|bybanout.txt
jcmd|Title for reflectivity results|text|Output from byban
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 file.

3.5 Calculation Method and References

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. The agorith used in this program is based on the method of Abeles. Other details on the calculation of reflectivity profiles can be found in the books by O. S. Heavens, 'Optical Properties of Thin Solid Films', Dover and J. Lekner, 'Theory of Reflection', Nijhof.

4. Examples

Studies that have used these programs include self-assembly of surfactants and lipids in lamellar phases at interfaces as well as other multilayer structures. A typical paper that describes this type of investigation is:

5. Legal Notice

The program is made available for non-commercial use without charge. The use 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. Download and use of the programs represents acceptance of this condition.

The programs and this documentation are Copyright of Adrian R. Rennie, 2015.


Thanks are due to to Maja Hellsing for providing Figures to illustrate this document and for testing the program. I am very grateful to Dr Ron Ghosh (ILL, Grenoble and Department of Chemistry, University College London) who has provided the FITFUN and clickfit software and co-operated in the development of the programs.

Professor Adrian R. Rennie
Department of Physics and Astronomy, Uppsala University, Uppsala, Sweden


Program and documentation: Copyright A. R. Rennie Last updated 29 May 2018