In this example, we want to demonstrate how to fit experimental reflectivity data that was obtained by a time-of-flight experiment with unpolarized neutrons. Experimental data is available for a sample of a roughly 50 nm thick platinum layer on top of a silicon substrate that is published in this repository.
The mesaurements were made by Timothy Charlton, Haile Ambaye and Michael Fitzsimmons (ORNL) on a sample provided by Eric Fullerton (UCSD).
We describe the above experiment by a three-layer model, where as usual the top layer is the vacuum and the substrate layer is the silicon substrate. On top of the silicon substrate, we place the platinum layer. The materials of both layers are described by their SLD, where we use literature values for both silicon as well as platinum and keep them constant throughout the fitting procedure.
The main parameters of the sample are stored in dictionary, where they are defined by a unique name
and the following six parameters are utilized:
Beam intensity: intensity
We explicitly fit the beam intensity, in order to compensate for possible experimental errors and to circumvent problems with the rather large variance in the reflectivity data at low $Q$-values.
Roughness on top of the Pt layer: r_pt/nm
Roughness on top of the Si substrate: r_si/nm
Thickness of the Pt layer: t_pt/nm
The relative $Q$-resolution: q_res/q
(c.f.)
A $Q$-offset: q_offset
This global offset is introduced to account for uncertainties in the angle at which the measurement is performed.
Due to saturation of the detector it is possible that the intensity at low $Q$-values (i.e. at high count rates) is underestimated. Furthermore, there is a rather large variance in the data that also leads to a rather bad fit in this region. Therefore, we neglect the data in the low $Q$-region by choosing a cutoff at $Q_{\text{min}} = $ 0.18. This value is selected by hand after performing several fits and visually selecting a good result.
Currently, BornAgain does not have an API support for an offset of the $Q$-axis. Therefore, we need to shift the $Q$-axis before performing a simulation
q_axis = q_axis + parameters["q_offset"]
This shift then needs to be counter-transformed when returning the results in the qr(result)
function
q = numpy.array(result.result().axis(ba.Axes.QSPACE)) - q_offset
In order to successfully fit this example, we chose some sane starting values and the example code that is fully given below, can be run with the following command:
python3 Pt_layer_fit.py fit
This performs a simulation with the initial parameters and yields the following result:
Immediately afterwards the fit is performed.
In order to run the fitting procedure, the following command can be issued:
python3 Pt_layer_fit.py fit
We need to allow a few seconds computational time and BornAgain should compute the following result
If the fit
keyword is omitted from the command line
python3 Pt_layer_fit.py
a simulation is performed with our fit results and one should obtain the result shown above.
|
|
Data to be fitted: RvsQ_36563_36662.txt.gz