Density of States Analysis Example

This example demonatrates a routine procedure of calculating phonon density of states from an experimental NeXus data file for a powder vanadium sample measured at ARCS, a direct-geometry neutron chopper spectrometer at the Spallation Neutron Source (SNS), Oak Ridge National Lab.

  • To use this notebook, first click jupyter menu File->Make a copy.
  • Click the title of the copied jupyter notebook and change it to a new title
  • Start executing cells

Summary of processing steps

  • Gather experimental information and experimental raw data
  • Reduce raw data to S(Q,E), the experimental dynamical structure factor
  • Convert S(Q,E) to phonon DOS

Preparation

Get python tools ready, this may take a while


In [ ]:
import os, numpy as np
import histogram.hdf as hh, histogram as H
from matplotlib import pyplot as plt
%matplotlib notebook
# %matplotlib inline
import mantid
from multiphonon.sqe import plot as plot_sqe
from multiphonon.ui.getdos import Context, NxsWizardStart, QEGridWizardStart, GetDOSWizStart

Create a context for getdos. It stores the processing parameters.


In [ ]:
context=Context()

Create a new working directory and change into it. All intermediate results and final outputs will be in this new directory.

Please modify the following path to suit your need!


In [ ]:
workdir = os.path.abspath('./V_Ei120meV')
!mkdir -p {workdir}
%cd {workdir}

If you want to reuse a previously-saved context, please uncomment the following cell and execute


In [ ]:
# context.from_yaml('getdos2-V_Ei120meV-context.yaml')

Get experimental data

For SNS users, experimental data are available in /SNS/"instrument_name"/IPTS-#### folders at the SNS analysis cluster. Here we will download the required data file from web.

Build download command


In [ ]:
dest = 'ARCS_V_annulus.nxs'
url = "https://mcvine.ornl.gov/multiphonon/ARCS_V_annulus.nxs"
cmd = 'wget %r -O %r' % (url, dest)
print cmd

Download: this will take a while (can be a few minutes to an hour, depending on internet speed)


In [ ]:
%%time
!{cmd} >log.download 2>err.download

The following command should show the downloaded file "ARCS_V_annulus.nxs"


In [ ]:
ls

Set sample_nxs


In [ ]:
context.sample_nxs = './ARCS_V_annulus.nxs'

Experimental data and condition

To start, we need to set the locations of the data files measured for the sample and empty can (for background correction), as well as the experimental conditions such as incident neutron energy (Ei, in meV) and sample temperature (T, in Kelvin). The following wizard help you go through these steps.

Please use these example inputs in the forms of the following wizard:

  • samplenxs: Please choose "ARCS_V_annulus.nxs" in the file-selector, and then click the "select" button
  • mtnxs: Please click "Skip" button. This means we will skip the empty can background subtraction for this example.
  • Ei: 120. This is set by Fermi chopper settings during the experiment. An approximate number is fine. The actual Ei will be caculated from the experimental NeXus file.
  • T: 300. This is set by sample environment. For room temperature measurement, use 300 (K).

In [ ]:
NxsWizardStart(context).show()

Save configuration so you can reuse it


In [ ]:
context.to_yaml('./getdos2-V_Ei120meV-context.yaml')

Obtain S(Q,E)

Now we are ready to reduce the experimental data to obtain the dynamical structure factor, S(Q,E).

S(Q,E) spectra for both the sample and the empty can is the starting point for getdos processing.

Run the following wizard to define the E and Q axes so that S(Q,E) spectra can be obtained the INS raw data.

  • E axis
    • Emin: -115. Usually -Ei
    • Emax: 115. Usually slightly smaller than Ei
    • dE: 1. Usually Ei/100
  • Q axis
    • Qmin: 0. Usually 0
    • Qmax: 17. Usually 2 X E2Q(Ei)
    • dQ: 0.1. Usually Emax/100

After you input Q-axis and E-axis parameters and continue, the data reduction will start to obtain I(Q,E) spectrum from the experimental data. This step takes a little while and the circle at the top-right corner of this notebook interface below the "logout" button will be filled, meaning the notebook is busy computing. Please be patient. Wait until it turns open to continue to the next step.


In [ ]:
QEGridWizardStart(context).show()

Parameters are saved in the work dir. Uncomment the script below to see.


In [ ]:
%%script bash
cat work/raw2iqe-sample.params

Plot sample IQE


In [ ]:
iqe = hh.load('work/iqe.h5')

plt.figure(figsize=(6,4))
plot_sqe(iqe)
# plt.xlim(0, 11)
plt.clim(0, 3e-3)

This is a plot of vanadium S(Q, E) histogram.

  • The colored region is within the dynamical range of the measurement
  • Vanadium is incoherent, therefore the intensity is mostly energy-dependent
  • Make sure the energy and momentum transfer axes are reasonable so that the S(Q,E) spectrum looks reasonable
  • You can improve the Q,E axis parameters if you like, by re-executing the above cell of QEGridWizardStart(context).show()

Now integreate over the Q (momentum transfer) axis to obtain energy spectrum I(E)


In [ ]:
iqe2 = iqe.copy()
I = iqe2.I; I[I!=I] = 0 # remove NaNs
IE = iqe2.sum('Q')  # sum over Q
plt.figure(figsize=(6,4))
plt.plot(IE.energy, IE.I)
  • At the center of this plot there is an enormous peak that is due to elastic scattering, which should be excluded from the phonon DOS calculation
  • Zoom in to see the rough range of the elastic peak and take notes. We need them in the analysis below.

Save configuration so you can reuse it


In [ ]:
context.to_yaml('./getdos2-V_Ei120meV-context.yaml')

Run GetDOS

Phonon DOS will be obtained from SQE histogram by an iterative procedure where multiphonon and multiple scattering corrections are applied to the measured SQE spectrum, assuming incoherent approximation, and the corrected spectrum is then converted to DOS.

Please use the following inputs:

  • Click the "Skip" button to skip initdos selection because for this example, only one measurement of one particular incident energy is used.
  • Input these parameters
    • Emin of elastic peak: -15. Make an estimate from the I(E) spectrum
    • Emax of elastic peak: 7. Make an estimate from the I(E) spectrum
    • Average atomic mass: 50.94. Atomic mass of vanadium
    • mt_faction: 0.9. Depends on the geometrical property of the sample and the empty can. Usually between 0.9 and 1.
    • Max phonon energy: 40. Maximum phonon energy that can be measured.
    • C_ms: 0.26: Ratio of multiple scattering to multiphon scattering. Depends on sample shape.
    • const_bg_fraction: 0.004: Background noise level.

Click "Run" button.


In [ ]:
context.initdos = ''
GetDOSWizStart(context).show()

Save context


In [ ]:
context.to_yaml('./getdos2-V_Ei120meV-context.yaml')

Print context


In [ ]:
# print context

Check output

Results are saved in "work" directory


In [ ]:
ls work/

Plot the final result for DOS


In [ ]:
dos = hh.load('work/final-dos.h5')
plt.figure(figsize=(5,3))
plt.plot(dos.E, dos.I)
plt.xlabel('Energy (meV)')
# plt.xlim(0, 30)
plt.tight_layout()

More plotting utils are available


In [ ]:
from multiphonon.backward import plotutils as pu

In [ ]:
plt.figure(figsize=(5,3))
pu.plot_dos_iteration('work/')

In [ ]:
plt.figure(figsize=(6,4))
pu.plot_residual('work/')

In [ ]:
plt.figure(figsize=(8, 4))
pu.plot_intermediate_result_se('work/round-4')

In [ ]: