def test1(self): "multiphonon.forward.phonon.computeAnESet" from dos import loadDOS E, g = loadDOS() dE = E[1] - E[0] # expand E a bit E = np.arange(E[0], 70, dE) g = np.concatenate((g, np.zeros(len(E) - len(g)))) g /= g.sum() * dE from multiphonon.forward.phonon import computeAnESet kelvin2mev = 0.0862 beta = 1. / (300 * kelvin2mev) E, An_set = computeAnESet(N=5, E=E, g=g, beta=beta, dE=dE) self._check( E, np.load(os.path.join(expected_results_dir, 'phonon.test1.E.npy'))) self._check( An_set, np.load( os.path.join(expected_results_dir, 'phonon.test1.An_set.npy'))) if interactive: import pylab for An in An_set: pylab.plot(E, An) continue pylab.show() return
def test2(self): "mccomponents.sample.phonon.multiphonon.computeSQESet" from dos import loadDOS dos = loadDOS() E = dos.energy; g = dos.I # expand E a bit dE = E[1] - E[0] E = numpy.arange(E[0], 70, dE) g = numpy.concatenate((g, numpy.zeros(len(E)-len(g)))) int_g = numpy.sum(g) * dE g/=int_g Q = numpy.arange(0, 10, 0.1) dQ = Q[1] - Q[0] kelvin2mev = 0.0862 beta = 1./(300*kelvin2mev) M = 50. from mccomponents.sample.phonon.multiphonon import computeSQESet Q, E, S_set= computeSQESet(5, Q, dQ, E, dE, M, g, beta) import histogram as H, histogram.hdf as hh def save(S, name): saveSQE(Q,E,S,name) # import pylab for i, Sn in enumerate(S_set): # pylab.imshow(Sn.T) # pylab.show() save(Sn, 'S%s' % (i+1)) continue summed = S_set.sum(axis=0) save(summed, 'S') return
def test1(self): "mccomponents.sample.phonon.multiphonon.computeAnESet" from dos import loadDOS dos = loadDOS() E = dos.energy dE = E[1] - E[0] g = dos.I # expand E a bit E = numpy.arange(E[0], 70, dE) g = numpy.concatenate((g, numpy.zeros(len(E)-len(g)))) g/=g.sum()*dE from mccomponents.sample.phonon.multiphonon import computeAnESet kelvin2mev = 0.0862 beta = 1./(300*kelvin2mev) E, An_set = computeAnESet(N=5, E=E, g=g, beta=beta, dE=dE) # check sum rule for An in An_set: self.assertAlmostEqual(An.sum() * dE, 1.) if interactive: import pylab for An in An_set: pylab.plot(E, An) continue pylab.show() return
def test1a(self): "singlephonon_sqe2dos: simulated vanadium SQE -> DOS" S = hh.load(os.path.join(datadir, "V-S1.h5")) with warnings.catch_warnings(record=True) as ws: warnings.simplefilter('always') DOS = sqe2dos.singlephonon_sqe2dos(S, T=300, Ecutoff=55., elastic_E_cutoff=(0., 0.), M=50.94) for w in ws: assert 'Scaling factor' not in str(w) E = DOS.E g = DOS.I # compare to the original dos data E1, g1 = loadDOS() ginterp = np.interp(E1, E, g) self.assert_(np.allclose(g1, ginterp)) # plot if interactive: import pylab pylab.plot(E1, g1, label="Original DOS") pylab.plot(E1, ginterp, label="DOS from SQE") pylab.legend() pylab.show() return
def test3(self): "multiphonon.forward.phonon.sqe" from dos import loadDOS E,g = loadDOS() from multiphonon.forward.phonon import sqe Q, E, S = sqe(E,g, N=4) saveSQE(Q,E,S, 'S_2..5') return
def test3(self): "multiphonon.forward.phonon.sqe" from dos import loadDOS E, g = loadDOS() from multiphonon.forward.phonon import sqe Q, E, S = sqe(E, g, N=4) # saveSQE(Q,E,S, 'S_2..5') self._check(S, hh.load(os.path.join(expected_results_dir, 'S_2..5.h5')).I) return
def test3(self): "mccomponents.sample.phonon.multiphonon.sqe" from dos import loadDOS dos = loadDOS() assert dos.__class__.__name__ == 'Histogram', "%s is not a histogram" % (dos,) E = dos.energy g = dos.I from mccomponents.sample.phonon.multiphonon import sqe Q, E, S = sqe(E,g, N=4) saveSQE(Q,E,S, 'S_2..5') return
def test1(self): from dos import loadDOS dos = loadDOS() E = dos.energy; g = dos.I import pylab pylab.plot(E, g) pylab.show() from mccomponents.sample.phonon.utils import fitparabolic E, g = fitparabolic(E,g) pylab.plot(E,g) pylab.show() return
def test3(self): "mccomponents.sample.phonon.multiphonon.sqe" from dos import loadDOS dos = loadDOS() assert dos.__class__.__name__ == 'Histogram', "%s is not a histogram" % ( dos, ) E = dos.energy g = dos.I from mccomponents.sample.phonon.multiphonon import sqe Q, E, S = sqe(E, g, N=4) saveSQE(Q, E, S, 'S_2..5') return
def test1(self): from dos import loadDOS dos = loadDOS() E = dos.energy g = dos.I import pylab pylab.plot(E, g) pylab.show() from mccomponents.sample.phonon.utils import fitparabolic E, g = fitparabolic(E, g) pylab.plot(E, g) pylab.show() return
def test1(self): "multiphonon.forward.dos2sqe" from dos import loadDOS E, g = loadDOS() Eaxis = H.axis('E', unit='meV', centers=E) doshist = H.histogram('DOS', [Eaxis], g) dE = E[1] - E[0] iqe = hh.load(os.path.join(datadir, 'V-iqe.h5')) from multiphonon.sqe import interp newiqe = interp(iqe, newE=np.arange(iqe.energy[0], 80., dE)) hh.dump(newiqe, 'V-iqe-interped.h5') from multiphonon.forward import dos2sqe sqe = dos2sqe(doshist, 0.01, newiqe, 300, 50.94, 120.) return
def test1a(self): S = hh.load(os.path.join(datadir, "V-S1.h5")) DOS = sqe2dos.singlephonon_sqe2dos(S, T=300, Ecutoff=55.0, elastic_E_cutoff=(0.0, 0.0), M=50.94) E = DOS.E g = DOS.I # compare to the original dos data E1, g1 = loadDOS() ginterp = np.interp(E1, E, g) self.assert_(np.allclose(g1, ginterp)) # plot if interactive: import pylab pylab.plot(E1, g1) pylab.plot(E1, ginterp) pylab.show() return
def test1(self): "multiphonon.forward.phonon.DWExp" from multiphonon.forward.phonon import DWExp from dos import loadDOS E, g = loadDOS() dE = E[1] - E[0] import numpy as np Q = np.arange(0, 20, 0.1) M = 50.94 # vanadium # M = 58.6934 # nicole kelvin2mev = 0.0862 T = 300 beta = 1. / (T * kelvin2mev) dwexp = DWExp(Q, M, E, g, beta, dE) print dwexp return
def test1(self): "multiphonon.forward.phonon.DWExp" from multiphonon.forward.phonon import DWExp from dos import loadDOS E, g = loadDOS() dE = E[1]-E[0] import numpy as np Q = np.arange(0,20,0.1) M = 50.94 # vanadium # M = 58.6934 # nicole kelvin2mev = 0.0862 T = 300 beta = 1./(T*kelvin2mev) dwexp = DWExp(Q, M, E,g, beta, dE) print dwexp return
def test1(self): from dos import loadDOS dos = loadDOS() # from histogram import plot # plot(dos) # create c object from mccomponents.sample.phonon.bindings.BoostPythonBinding import New b = New() bpdos = b.dos_fromhistogram(dos) mass = 51 temperature = 300 nsampling = 100 bpdw = b.dwfromDOS(bpdos, mass, temperature, nsampling) self.assertAlmostEqual(bpdw.core(), 0.0067, places=4) return
def test1(self): "multiphonon.forward.phonon.computeAnESet" from dos import loadDOS E, g = loadDOS() dE = E[1] - E[0] # expand E a bit E = numpy.arange(E[0], 70, dE) g = numpy.concatenate((g, numpy.zeros(len(E)-len(g)))) g/=g.sum()*dE from multiphonon.forward.phonon import computeAnESet kelvin2mev = 0.0862 beta = 1./(300*kelvin2mev) E, An_set = computeAnESet(N=5, E=E, g=g, beta=beta, dE=dE) if interactive: import pylab for An in An_set: pylab.plot(E, An) continue pylab.show() return
def test2(self): "multiphonon.forward.phonon.computeSQESet" from dos import loadDOS E, g = loadDOS() # expand E a bit dE = E[1] - E[0] E = np.arange(E[0], 70, dE) g = np.concatenate((g, np.zeros(len(E) - len(g)))) int_g = np.sum(g) * dE g /= int_g Q = np.arange(0, 10, 0.1) dQ = Q[1] - Q[0] kelvin2mev = 0.0862 beta = 1. / (300 * kelvin2mev) M = 50. from multiphonon.forward.phonon import computeSQESet Q, E, S_set = computeSQESet(5, Q, dQ, E, dE, M, g, beta) import histogram as H, histogram.hdf as hh def save(S, name): saveSQE(Q, E, S, name) # import pylab for i, Sn in enumerate(S_set): # pylab.imshow(Sn.T) # pylab.show() # save(Sn, 'S%s' % (i+1)) self._check( Sn, hh.load( os.path.join(expected_results_dir, 'S%s.h5' % (i + 1, ))).I) continue summed = S_set.sum(axis=0) save(summed, 'S') return
def test2(self): "mccomponents.sample.phonon.multiphonon.computeSQESet" from dos import loadDOS dos = loadDOS() E = dos.energy g = dos.I # expand E a bit dE = E[1] - E[0] E = numpy.arange(E[0], 70, dE) g = numpy.concatenate((g, numpy.zeros(len(E) - len(g)))) int_g = numpy.sum(g) * dE g /= int_g Q = numpy.arange(0, 10, 0.1) dQ = Q[1] - Q[0] kelvin2mev = 0.0862 beta = 1. / (300 * kelvin2mev) M = 50. from mccomponents.sample.phonon.multiphonon import computeSQESet Q, E, S_set = computeSQESet(5, Q, dQ, E, dE, M, g, beta) import histogram as H, histogram.hdf as hh def save(S, name): saveSQE(Q, E, S, name) # import pylab for i, Sn in enumerate(S_set): # pylab.imshow(Sn.T) # pylab.show() save(Sn, 'S%s' % (i + 1)) continue summed = S_set.sum(axis=0) save(summed, 'S') return
def test1(self): "mccomponents.sample.phonon.multiphonon.computeAnESet" from dos import loadDOS dos = loadDOS() E = dos.energy dE = E[1] - E[0] g = dos.I # expand E a bit E = numpy.arange(E[0], 70, dE) g = numpy.concatenate((g, numpy.zeros(len(E) - len(g)))) g /= g.sum() * dE from mccomponents.sample.phonon.multiphonon import computeAnESet kelvin2mev = 0.0862 beta = 1. / (300 * kelvin2mev) E, An_set = computeAnESet(N=5, E=E, g=g, beta=beta, dE=dE) if interactive: import pylab for An in An_set: pylab.plot(E, An) continue pylab.show() return