Repository for my bachelor thesis project about the analysis, design and optimization of a spin-echo modulated small angle neutron scattering (SEMSANS) instrument to potentially be realized at the new cold source at the Reactor Institute in Delft. The goal of the project is to explore the possibility for an instrument that can measure at characteristic lengths from 10 nm to 5 μm at a single sample to detector range, making it possible to study time processes such as milk turning into yoghurt or curd that span this entire range without moving the sample during measurement.
To run the instrument simulations, first install McStas 3.4. At the time of writing for Ubuntu, sudo apt install mcstas-suite-python-ng
installs everything you need. In order to run GPU accelerated simulations, a Nvidia GPU and an installation of the Nvidia HPC SDK is required but simulations can also be performed on CPU. Invoking McStas and basic data operations are performed using shell scripts, requiring use of Linux or alternatives like Windows Subsystem for Linux (WSL).
Python 3.12.3 is used and the usual complement of scientific Python packages like numpy
and scipy
is required to run notebooks and scripts that are used for simulation script generation, data analysis, instrument optimization and other purposes.
McStas instrument files (.instr
) and components (.comp
) are used to define simulations and can be found in instr. foil.instr
, iwsp.instr
and iso.instr
represent SEMSANS instruments with respectively ferromagnetic foil flippers, (idealized) Wollaston prisms and isosceles triangles as precession devices. These instruments contain a sample, empty instruments are also provided for easy simulation with and without sample. The corresponding precession device components used by each of these are Foil_flipper_magnet.comp
, Pol_triafield_y
and Pol_IdealWSP
.
Jupyter notebooks take the chapter they are related to in their name as a prefix. For instance, c2-analytical-G-P.ipynb code for plotting
A simulated measurement over a given mcrun
4 times and it can be run on the CPU or GPU depending on the mode
parameter passed to full-simulation.sh
. To simulate many different measurements using various instruments and samples, c6-simulation-driver.ipynb can be used to generate a script called simulate.sh
, which can be run to perform all measurement simulations performed for this project. This will take a couple of hours depending on the hardware configuration and GPU support. The simulated instruments are specified in instruments.csv, with simulations of instruments 2a
through 3c
being included in the paper. These can be loaded as Instrument
objects (as defined in instrument.py), which also makes it possible to automatically compute estimates of
Finally, c6-data-analysis.ipynb can be used to analyze the simulation data and make plots of