A lightweight tool to analyse neutron reflectivity curves and generate initial refnx fits.
This repository contains the code for a neural network-based pipeline for the automatic estimation of thin film thicknesses and scattering length densities from neutron reflectivity curves of systems containing up to three layers on top of a substrate. Raw instrument data (in our case from the OFFSPEC neutron reflectometer) is processed and passed through the pipeline to produce layer parameter predictions. These predictions are then fed into refnx, and serve as initial "guesses" for further optimisation to yield a model that likely describes a given sample. All that is required from the end user is running the pipeline.py file with their reflectivity data.
The project was motivated by the desire to enable on-experiment analysis of reflectivity data, informing choices about changing experiment conditions or samples in operando.
Please cite the following article if you intend on including elements of this work in your own publications:
Mironov, D., Durant, J. H., Mackenzie, R. and Cooper, J. F. K. Towards automated analysis for neutron reflectivity. Mach. Learn.: Sci. Technol. 2, 035006 (2021).
Or with BibTeX as:
@article{Mironov2021,
author = {Mironov, D. and Durant, J. H. and Mackenzie, R. and Cooper, J. F. K.},
doi = {10.1088/2632-2153/abe7b5},
journal = {Machine Learning: Science and Technology},
month = {Apr},
number = {3},
pages = {035006},
publisher = {{IOP} Publishing},
title = {Towards automated analysis for neutron reflectivity},
url = {https://doi.org/10.1088/2632-2153/abe7b5},
volume = {2},
year = {2021}
}
-
To replicate the development environment with the
Anaconda
distribution, first create an empty conda environment by running:conda create --name neutron-net
-
To activate the environment, run:
conda activate neutron-net
-
Install pip by running:
conda install pip
-
Navigate to the main neutron-net directory. Run the following to install the required packages from the requirements.txt file:
pip install -r requirements.txt
-
You should be able to run the code. Try:
python pipeline.py
Please read usage for detailed instructions on how to use the system.
Additional figures to those seen in the article are available here and training losses for the neutron and x-ray models are available here.
The synthetic data used for training the neutron and x-ray models is available for download here
.
Jos Cooper - jos.cooper@stfc.ac.uk
James Durant - james.durant@warwick.ac.uk
Daniil Mironov - daniil.mironov@stfc.ac.uk
Many thanks for the collaboration of the Scientific Machine Learning group at the Rutherford Appleton Laboratory, their expertise and assistance with this project - in particular, we'd like to thank Rebecca Mackenzie for being so key in laying the groundwork, and giving the project a strong foundation. The authors would like to thank Johnathan Xue, whose initial work and results allowed the project to go ahead. We thank the Ada Lovelace Centre for funding.
This work was partially supported by Wave 1 of The UKRI Strategic Priorities Fund under the EPSRC Grant EP/T001569/1, particularly the “AI for Science” theme within that grant & The Alan Turing Institute.
Contributions are gladly accepted and would be very much appreciated.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a pull request
Distributed under the GNU AGPLv3 license. See license for more information.