Skip to content

McStasMcXtrace/semsans

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design and analysis of a SEMSANS instrument for a cold source

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.

Requirements

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.

Overview

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 $G_0(\delta)$ as it appears in Chapter 2. In addition to code relevant for each chapter, the code used to render the cover image using PlotOptiX is included as well as plots that were used in the presentation. Lastly, cx-numerical-G.ipynb contains code exploring how $G(\delta)$ can be computed from $d\Sigma/d\Omega(Q)$ using either the Hankel transform (for isotropic samples) or a combination of a projection and a cosine transform.

Simulation procedure

A simulated measurement over a given $B$-field range with and without sample and with analyser in $\pm x$ ('up', and 'down') directions can be performed by running full-simulation.sh. This will invoke 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 $\delta$-constraints. This class is also used in instrument optimization in c5-optimization.ipynb.

Finally, c6-data-analysis.ipynb can be used to analyze the simulation data and make plots of $P_{exp}(\delta)$ and analytical $P(\delta)$, reproducing those given in the thesis.

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 81.4%
  • Python 13.0%
  • Shell 5.6%