Skip to main content

Useful towel-related stuff.

Project description

ReflModel

The purpose of ReflModel is several-fold. First it offers a way to model neutron reflectivity from both TOF and monochromatic beams accounting for instrumental parameters. If you contact an instrument scientist to find the instrument parameters listed in this document you will be able to see what is possible to observe in an actual experiment. This code accounts for incoherent and absorption in the films and backing medium so you can calculate reflectivity accounting for wavelength dependence for both monochromatic and TOF instruments. If your sample has a lot of hydrogen or a strong absorber it is likely your sample will suffer from effects due to imaginary terms in the wave vector. This is generally not an issue for monochromatic sources, but can cause significant shifts in TOF data depending upon the incident wavelength dispersion.

This code can calculate both polarized and unpolarized neutron reflectivity. Only in-plane magnetic moments are considered, and the user has to input the expected magnitude of the magnetic SLD contribution. This implementation does not directly utilize the pauli-matricies to determine the polarization contribution. Instead it uses a rotation matrix to determine the spin-flip contribution and assumes the SLD-change in the z-direction due to applied magnetic field is known by the user. All functions can be used with polarized or unpolarized neutrons except the dynamics functions.

ReflModel allows you to estimate background contribution from the thin-film layers and the backing medium. It does not currently calculate the expected reflection from the backside of the backing medium substrate or the stage the sample is resting on (both of these can introduce background). The same process allows modeling of absorption or incoherent processes. As an example: If there is a buried neutron absorbing layer which will emit a gamma-ray, the gamma intensity as a function of incident neutron angle can be calculated by determining the fraction of neutrons which are absorbed. As another example: For samples with large incoherent scattering cross sections, the number of incoherent scatters can be calculated. Coupling these calculations to a solid-angle calculator which computes the average solid-angle means you can calculate how many incoherent neutrons arrive at a detector be it the reflectivity detector to estimate background, or some other detector.

As a necessity for calculating probability of scatter or absorption the wave equation is solved and wave-field plots can be produced. These plots are generally un-interesting after the critical edge, but in the total reflection plateau they can show very interesting features such as standing wave densities under certain situations.

ReflModel uses probability denisty functions to model the incident beam, and slabs to model interfaces.

This means the code is not fast. A typical calculation of reflectivty for a monochromatic instrument over 60 points and a total film thickness of 1200 Anstroms takes 3 minutes on an 8 core laptop. Similarly a calculation of reflectivity for three TOF angles using 100 wavelength bins take 2.5 minutes. Some functions such as parallelS_mag can take up to 8 minutes for 60 points and a total film thickness of 1200 Anstroms.

Memory is of a concern in this program. In general I tried to minimize memory useage, but it is not perfect. Calculations involving the wave solution are quite large. The wave array is of size [theta,lambda,z] where theta is the number of bins describing the angular divergence PDF, lambda is the number of bins describing the wavelength dispersion, and z is of length (total thickness)/(slab thickness). For thick samples, and fine binning of divergence/dispersion can mean huge arrays.

The upside

In general assumptions used to fit/model neutron reflectometry data are valid, but there are occasions where they break down. When the sample has large incoherent/absorption cross sections current modelling software often do not account for the varying wave vector. This is a much larger problem for TOF instruments than monochromatic.

Wavefield plots can show interesting information about the behaviour of the neutron wave in the sample at grazing incidence. Calculating the wave can also be helpful in determining the incoherent or absorbtion probabilities so they can be accounted for in fitting data.

As attempts to implement dynamics measurements in thin-films are pursued, this code will enable modelling of those dynamics to determine the expected lineshape, and number of neutrons which are scattered into some Q space.

To install

For Linux This is simple. pip install ReflModel

For Windows Should be something like: python pip install ReflModel

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page