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.
Get python tools ready. This may takes 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 import getdos
from multiphonon.sqe import plot as plot_sqe
Create a new working directory and change into it. All inputs, intermediate results and final outputs will be in this new directory.
In [ ]:
projectdir = os.path.abspath('./V_Ei120meV-noUI')
!mkdir -p {projectdir}
%cd {projectdir}
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
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 example inputs explained:
In [ ]:
samplenxs = './ARCS_V_annulus.nxs'
mtnxs = None
Ei = 120
T = 300
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.
The Q and E axes need to be define:
In [ ]:
Qaxis = Qmin, Qmax, dQ = 0, 17, 0.1
Eaxis = Emin, Emax, dE = -115., 115., 1.
workdir = 'work'
iqe_h5 = 'iqe.h5'
In [ ]:
from multiphonon import getdos
In [ ]:
%%time
for m in getdos.reduce2iqe(samplenxs,
Emin=Emin, Emax=Emax, dE=dE, Qmin=Qmin, Qmax=Qmax, dQ=dQ,
iqe_h5=iqe_h5, workdir=workdir):
print m
In [ ]:
ls -tl {workdir}/{iqe_h5}
Plot sample IQE
In [ ]:
iqe = hh.load(os.path.join(workdir, 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.
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)
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.
Input parameters
In [ ]:
for msg in getdos.getDOS(
samplenxs, mt_fraction=0.9, const_bg_fraction=0.004,
Emin=Emin, Emax=Emax, dE=dE, Qmin=Qmin, Qmax=Qmax, dQ=dQ,
T=300., Ecutoff=40.,
elastic_E_cutoff=(-15, 7.),
M=50.94,
C_ms = 0.26,
Ei = 120,
initdos=None,
workdir = workdir,
):
print msg
Results are saved in "work" directory
In [ ]:
ls {workdir}/
Plot the final result for DOS
In [ ]:
dos = hh.load(os.path.join(workdir, 'final-dos.h5'))
plt.figure(figsize=(5,3))
plt.plot(dos.E, dos.I)
plt.xlabel('Energy (meV)')
plt.xlim(0, 50)
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(workdir)
plt.xlim(0, 50)
In [ ]:
plt.figure(figsize=(6,4))
pu.plot_residual(workdir)
In [ ]:
plt.figure(figsize=(8, 4))
pu.plot_intermediate_result_se(os.path.join(workdir, 'round-4'))