예제 #1
0
    def test2a(self):
        "sqe2dos: V exp"
        iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
        from multiphonon.sqe import interp
        newiqe = interp(iqehist, newE=np.arange(-15, 80, 1.))
        hh.dump(newiqe, 'V-iqe-interped.h5')
        iterdos = sqe2dos.sqe2dos(newiqe,
                                  T=300,
                                  Ecutoff=55.,
                                  elastic_E_cutoff=(-12., 6.7),
                                  M=50.94,
                                  C_ms=.2,
                                  Ei=120.,
                                  workdir='work-V')

        with warnings.catch_warnings(record=True) as ws:
            warnings.simplefilter('always')
            for i, dos in enumerate(iterdos):
                # print dos
                # plot
                if interactive:
                    # print '*' * 70
                    pylab.plot(dos.E, dos.I, label='%d' % i)
                    pass
            # check warning
            for w in ws:
                assert 'Scaling factor' not in str(w)

        path = os.path.join(here, 'expected_results',
                            'sqe2dos-test2a-final-dos.h5')
        # hh.dump(dos, path)
        expected = hh.load(path)
        self.assert_(np.allclose(dos.I, expected.I))
        self.assert_(np.allclose(dos.E2, expected.E2))
        if interactive:
            pylab.figure()
            pylab.errorbar(dos.E,
                           dos.I + dos.I.max() / 5.,
                           dos.E2**.5,
                           label='new')
            pylab.errorbar(expected.E,
                           expected.I,
                           expected.E2**.5,
                           label='expected')
            pylab.legend()
            pylab.show()
        return
예제 #2
0
    def test2b(self):
        iqehist = hh.load(os.path.join(datadir, "Al-iqe.h5"))
        from multiphonon.sqe import interp

        newiqe = interp(iqehist, newE=np.arange(-40, 70, 1.0))
        hh.dump(newiqe, "Al-iqe-interped.h5")
        iterdos = sqe2dos.sqe2dos(
            newiqe, T=300, Ecutoff=50.0, elastic_E_cutoff=(-10.0, 7), M=26.98, C_ms=0.2, Ei=80.0, workdir="work-Al"
        )
        for i, dos in enumerate(iterdos):
            # print dos
            # plot
            if interactive:
                # print '*' * 70
                pylab.plot(dos.E, dos.I, label="%d" % i)
        if interactive:
            pylab.legend()
            pylab.show()
        return
예제 #3
0
 def test2c2(self):
     iqehist = hh.load(os.path.join(datadir, "DJX-iqe-Ei_20.h5"))
     # iqehist -= hh.load(os.path.join(datadir, "DJX-mtiqe-Ei_20.h5"))*(0.1, 0)
     initdos = hh.load(os.path.join(datadir, "DJX-dos-Ei_80.h5"))
     iterdos = sqe2dos.sqe2dos(iqehist,
                               T=300,
                               Ecutoff=17.1,
                               elastic_E_cutoff=(-3., 2),
                               M=79.452,
                               C_ms=0.02,
                               Ei=20.,
                               workdir='work-DJX',
                               initdos=initdos)
     for i, dos in enumerate(iterdos):
         # print dos
         # plot
         if interactive:
             # print '*' * 70
             pylab.errorbar(dos.E, dos.I, dos.E2**.5, label='%d' % i)
     return
예제 #4
0
 def test2a(self):
     "sqe2dos: V exp"
     iqehist = hh.load(os.path.join(datadir, 'XYZ2-iqe-Ei_20.h5'))
     initdos = hh.load(os.path.join(datadir, 'XYZ2-initdos-Ei_80.h5'))
     iterdos = sqe2dos.sqe2dos(iqehist,
                               T=300,
                               Ecutoff=17.1,
                               elastic_E_cutoff=(-3., 1.1),
                               M=79.452,
                               C_ms=.05,
                               Ei=20.,
                               workdir='work-XYZ2',
                               initdos=initdos)
     list(iterdos)
     if interactive:
         dos = hh.load('work-XYZ2/final-dos.h5')
         pylab.errorbar(dos.E, dos.I, dos.E2**.5, label='final')
         pylab.legend()
         pylab.show()
     return
예제 #5
0
 def test2a2(self):
     "sqe2dos: check energy axis"
     iqehist = hh.load(os.path.join(datadir, "V-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-15.5, 80, 1.))
     iterdos = sqe2dos.sqe2dos(newiqe,
                               T=300,
                               Ecutoff=55.,
                               elastic_E_cutoff=(-12., 6.7),
                               M=50.94,
                               C_ms=.2,
                               Ei=120.,
                               workdir='work-V')
     from multiphonon.backward.singlephonon_sqe2dos import EnergyAxisMissingBinCenterAtZero
     with self.assertRaises(EnergyAxisMissingBinCenterAtZero):
         for i, dos in enumerate(iterdos):
             # print dos
             # plot
             if interactive:
                 # print '*' * 70
                 pylab.plot(dos.E, dos.I, label='%d' % i)
     return
예제 #6
0
 def test2b(self):
     iqehist = hh.load(os.path.join(datadir, "Al-iqe.h5"))
     from multiphonon.sqe import interp
     newiqe = interp(iqehist, newE=np.arange(-40, 70, 1.))
     hh.dump(newiqe, 'Al-iqe-interped.h5')
     iterdos = sqe2dos.sqe2dos(newiqe,
                               T=300,
                               Ecutoff=50.,
                               elastic_E_cutoff=(-10., 7),
                               M=26.98,
                               C_ms=0.2,
                               Ei=80.,
                               workdir='work-Al')
     for i, dos in enumerate(iterdos):
         # print dos
         # plot
         if interactive:
             # print '*' * 70
             pylab.plot(dos.E, dos.I, label='%d' % i)
     path = os.path.join(here, 'expected_results',
                         'sqe2dos-test2b-final-dos.h5')
     # hh.dump(dos, path)
     expected = hh.load(path)
     self.assert_(np.allclose(dos.I, expected.I))
     self.assert_(np.allclose(dos.E2, expected.E2))
     if interactive:
         pylab.figure()
         pylab.errorbar(dos.E,
                        dos.I + dos.I.max() / 5,
                        dos.E2**.5,
                        label='new')
         pylab.errorbar(expected.E,
                        expected.I,
                        expected.E2**.5,
                        label='expected')
         pylab.legend()
         pylab.show()
     return
예제 #7
0
 def test2c(self):
     iqehist = hh.load(os.path.join(datadir, "graphite-Ei_130-iqe.h5"))
     initdos = hh.load(os.path.join(datadir, "graphite-Ei_300-dos.h5"))
     iterdos = sqe2dos.sqe2dos(iqehist,
                               T=300,
                               Ecutoff=100.,
                               elastic_E_cutoff=(-30., 15),
                               M=12.,
                               C_ms=0.02,
                               Ei=130.,
                               workdir='work-graphite',
                               initdos=initdos)
     for i, dos in enumerate(iterdos):
         # print dos
         # plot
         if interactive:
             # print '*' * 70
             pylab.errorbar(dos.E, dos.I, dos.E2**.5, label='%d' % i)
     path = os.path.join(here, 'expected_results',
                         'sqe2dos-test2c-final-dos.h5')
     # hh.dump(dos, path)
     expected = hh.load(path)
     self.assert_(np.allclose(dos.I, expected.I))
     # self.assert_(np.allclose(dos.E2, expected.E2))
     if interactive:
         pylab.figure()
         pylab.errorbar(dos.E,
                        dos.I + dos.I.max() / 5,
                        dos.E2**.5,
                        label='new')
         pylab.errorbar(expected.E,
                        expected.I,
                        expected.E2**.5,
                        label='expected')
         pylab.legend()
         pylab.show()
     return
예제 #8
0
# create a histogram object from the numpy arrays
iqehist = H.histogram('IQE', [('Q', Q, '1./angstrom'), ('E', E, 'meV')], data=I, errors=E2)

# interpolate I(Q, E) data so that the energy axis has "zero" as a bin center
from multiphonon.sqe import interp
newiqe = interp(iqehist, newE = np.arange(-40, 70, 1.))

# save interpolated data just in case we need it later
hh.dump(newiqe, 'data/Al-iqe-interped.h5')

# create processing engine with processing parameters
from multiphonon.backward import sqe2dos
workdir='work-Al-from-nparrs'
iterdos = sqe2dos.sqe2dos(
    newiqe, T=300, Ecutoff=50., 
    elastic_E_cutoff=(-10., 7), M=26.98,
    C_ms=0.2, Ei=80., workdir=workdir)
# process and plot
for i, dos in enumerate(iterdos): 
    print "* Iteration", i
    if not headless:
        plt.plot(dos.E, dos.I, label='%d' % i)
    continue
        
if not headless:
    plt.legend()
    plt.show()

print "Intermediate and final results are stored in directory %r" % workdir
예제 #9
0
if not headless:
    print "* Plotting S(Q,E) from $E_i=130$..."
    plt.figure()
    plot_sqe(iqe_130)
    plt.xlim(0, 18)
    plt.ylim(-100, 120)
    plt.clim(0, 1e-4)
    plt.show()
# It is clear here only phonons with $E<120meV$ were measured in this dataset.

print "* Processing and stitching..."
iterdos = sqe2dos.sqe2dos(iqe_130,
                          T=300,
                          Ecutoff=100.,
                          elastic_E_cutoff=(-30., 15),
                          M=12.,
                          C_ms=0.02,
                          Ei=130.,
                          workdir='work-graphite',
                          initdos=dos_300)
doslist = list(iterdos)
lastdos = doslist[-1]
# plot the partial DOS
partial_dos = lastdos[(None, 100)]
if not headless:
    print "* Plotting the partial DOS from Ei=130 ..."
    plt.figure()
    plt.plot(partial_dos.E, partial_dos.I)
    plt.show()
# plot the final DOS
if not headless: