Пример #1
0
    def test_calculate_effmass(self):
        kpt, stepsize, band, prg, basis = emc.parse_inpcar(
            self.inpcar_fh, debug=False)  # will need band and stepsize later

        energies = emc.parse_EIGENVAL_VASP(self.eigenval_fh,
                                           band,
                                           len(emc.st3),
                                           debug=False)
        m = emc.fd_effmass_st3(energies, stepsize)
        self.assertListAlmostEqual(
            m[0], [-2.90687, 0.0, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[1], [0.0, -2.90687, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[2], [0.0, 0.0, -2.90687],
            places=5,
            msg='Failed to calculate effective mass tensor')

        masses, vecs_cart, vecs_frac, vecs_n = emc.get_eff_masses(m, basis)
        self.assertListAlmostEqual(masses, [-0.344013] * 3,
                                   places=5,
                                   msg='Effective mass calculations failed')
Пример #2
0
 def test_parabolic_fit(self):
     print ""
     kpt, stepsize, band, prg, basis = emc.parse_inpcar(self.inpcar_fh, debug=False) # will need stepsize later
     st = []
     st.append([-5.0, -5.0, 0.0])
     st.append([-4.0, -4.0, 0.0])
     st.append([-3.0, -3.0, 0.0])
     st.append([-2.0, -2.0, 0.0])
     st.append([-1.0, -1.0, 0.0])
     st.append([0.0, 0.0, 0.0])
     st.append([1.0, 1.0, 0.0])
     st.append([2.0, 2.0, 0.0])
     st.append([3.0, 3.0, 0.0])
     st.append([4.0, 4.0, 0.0])
     st.append([5.0, 5.0, 0.0])
     #
     kpts = emc.generate_kpoints(kpt, st, stepsize, prg, basis)
     #print kpts
     kpoints_fh = open('KPOINTS', 'w')
     kpoints_fh.write("EMC \n")
     kpoints_fh.write("%d\n" % len(kpts))
     kpoints_fh.write("Reciprocal\n")
     #
     for i, kpt in enumerate(kpts):
         kpoints_fh.write( '%15.10f %15.10f %15.10f 0.01\n' % (kpt[0], kpt[1], kpt[2]) )
     #
     kpoints_fh.close()
Пример #3
0
 def test_parse_inpcar(self):
     kpt, stepsize, band, prg, basis = emc.parse_inpcar(self.inpcar_fh, debug=False) # will need stepsize later
     self.assertListEqual(kpt, [0.0, 0.0, 0.0], msg='Failed to parse K-point')
     self.assertEquals(stepsize, 0.01, msg='Failed to parse stepsize')
     self.assertEquals(band, 16, msg='Failed to parse band')
     self.assertEquals(prg, 'V', msg='Failed to parse program identifier')
     self.assertListEqual(basis, [[5.648, 0.0, 0.0],[0.0, 5.648, 0.0],[0.0, 0.0, 5.648]], msg='Failed to parse basis')
Пример #4
0
    def test_calculate_effmass(self):
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in

        # See NbFeSb-CASTEP/emcpy.out_electrons_band19
        inpcar_fn = os.path.join(script_dir, 'NbFeSb-CASTEP', 'input_el')
        inpcar_fh = open(inpcar_fn, 'r')
        eigenval_fn = os.path.join(script_dir, 'NbFeSb-CASTEP',
                                   'NbFeSb.electrons.bands')
        eigenval_fh = open(eigenval_fn, 'r')

        kpt, stepsize, band, prg, basis = emc.parse_inpcar(
            inpcar_fh, debug=False)  # will need band and stepsize later

        energies = emc.parse_bands_CASTEP(eigenval_fh,
                                          band,
                                          len(emc.st3),
                                          debug=False)
        m = emc.fd_effmass_st3(energies, stepsize)
        self.assertListAlmostEqual(
            m[0], [3.459576, 0.0, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[1], [0.0, 3.459576, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[2], [0.0, 0.0, 1.759904],
            places=5,
            msg='Failed to calculate effective mass tensor')
Пример #5
0
    def test_calculate_effmass(self):
        kpt, stepsize, band, prg, basis = emc.parse_inpcar(self.inpcar_fh, debug=False) # will need band and stepsize later

        energies = emc.parse_EIGENVAL_VASP(self.eigenval_fh, band, len(emc.st3), debug=False)
        m = emc.fd_effmass_st3(energies, stepsize)
        self.assertListAlmostEqual(m[0], [-2.90687, 0.0, 0.0], places=5, msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(m[1], [0.0, -2.90687, 0.0], places=5, msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(m[2], [0.0, 0.0, -2.90687], places=5, msg='Failed to calculate effective mass tensor')

        masses, vecs_cart, vecs_frac, vecs_n = emc.get_eff_masses(m, basis)
        self.assertListAlmostEqual(masses, [-0.344013]*3, places=5, msg='Effective mass calculations failed')
Пример #6
0
 def test_parse_inpcar(self):
     kpt, stepsize, band, prg, basis = emc.parse_inpcar(
         self.inpcar_fh, debug=False)  # will need stepsize later
     self.assertListEqual(kpt, [0.0, 0.0, 0.0],
                          msg='Failed to parse K-point')
     self.assertEquals(stepsize, 0.01, msg='Failed to parse stepsize')
     self.assertEquals(band, 16, msg='Failed to parse band')
     self.assertEquals(prg, 'V', msg='Failed to parse program identifier')
     self.assertListEqual(
         basis, [[5.648, 0.0, 0.0], [0.0, 5.648, 0.0], [0.0, 0.0, 5.648]],
         msg='Failed to parse basis')
Пример #7
0
    def test_kpoints(self):
        kpt, stepsize, band, prg, basis = emc.parse_inpcar(self.inpcar_fh, debug=False) # will need stepsize later
        kpts = emc.generate_kpoints(kpt, emc.st3, stepsize, prg, basis)

        self.kpoints_fh.readline() # title
        nkpt = int(self.kpoints_fh.readline()) # Reciprocal
        self.assertEquals(nkpt, len(kpts), msg='Length of the list is not equal to the number from KPOINTS')
        self.kpoints_fh.readline() # Reciprocal

        for i in range(len(kpts)):
            kp = [float(x) for x in self.kpoints_fh.readline().split()[0:3]] # kx ky kz w
            self.assertListAlmostEqual(kpts[i], kp, places=5, msg='K-point %d is not equal to that from the KPOINTS file' % i)
Пример #8
0
 def test_parse_inpcar(self):
     kpt, stepsize, band, prg, basis = emc.parse_inpcar(
         self.inpcar_fh, debug=False)  # will need stepsize later
     self.assertListEqual(kpt, [0.0, 0.0, 0.0],
                          msg='Failed to parse K-point')
     self.assertEquals(stepsize, 0.01, msg='Failed to parse stepsize')
     self.assertEquals(band, 1, msg='Failed to parse band')
     self.assertEquals(prg, 'C', msg='Failed to parse program identifier')
     self.assertListEqual(basis,
                          [[13.8324582, -0.0965703, 0.0],
                           [0.0, 27.4955152, 0.0], [0.0, 0.0, 20.5602203]],
                          msg='Failed to parse basis')
Пример #9
0
    def test_calculate_effmass(self):
        script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in

        # See NbFeSb-CASTEP/emcpy.out_electrons_band19
        inpcar_fn = os.path.join(script_dir, 'NbFeSb-CASTEP', 'input_el')
        inpcar_fh = open(inpcar_fn, 'r')
        eigenval_fn = os.path.join(script_dir, 'NbFeSb-CASTEP', 'NbFeSb.electrons.bands')
        eigenval_fh = open(eigenval_fn, 'r')

        kpt, stepsize, band, prg, basis = emc.parse_inpcar(inpcar_fh, debug=False) # will need band and stepsize later

        energies = emc.parse_bands_CASTEP(eigenval_fh, band, len(emc.st3), debug=False)
        m = emc.fd_effmass_st3(energies, stepsize)
        self.assertListAlmostEqual(m[0], [3.459576, 0.0, 0.0], places=5, msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(m[1], [0.0, 3.459576, 0.0], places=5, msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(m[2], [0.0, 0.0, 1.759904], places=5, msg='Failed to calculate effective mass tensor')
Пример #10
0
    def test_kpoints(self):
        kpt, stepsize, band, prg, basis = emc.parse_inpcar(
            self.inpcar_fh, debug=False)  # will need stepsize later
        kpts = emc.generate_kpoints(kpt, emc.st3, stepsize, prg, basis)

        self.kpoints_fh.readline()  # title
        nkpt = int(self.kpoints_fh.readline())  # Reciprocal
        self.assertEquals(
            nkpt,
            len(kpts),
            msg='Length of the list is not equal to the number from KPOINTS')
        self.kpoints_fh.readline()  # Reciprocal

        for i in range(len(kpts)):
            kp = [float(x) for x in self.kpoints_fh.readline().split()[0:3]
                  ]  # kx ky kz w
            self.assertListAlmostEqual(
                kpts[i],
                kp,
                places=5,
                msg='K-point %d is not equal to that from the KPOINTS file' %
                i)
Пример #11
0
    def test_calculate_effmass(self):
        kpt, stepsize, band, prg, basis = emc.parse_inpcar(
            self.inpcar_fh, debug=False)  # will need band and stepsize later

        energies = emc.parse_EIGENVAL_VASP(self.eigenval_fh,
                                           band,
                                           len(emc.st3),
                                           debug=False)
        m = emc.fd_effmass_st3(energies, stepsize)
        self.assertListAlmostEqual(
            m[0], [-1.23535, 0.04464, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[1], [0.04464, -0.45875, 0.0],
            places=5,
            msg='Failed to calculate effective mass tensor')
        self.assertListAlmostEqual(
            m[2], [0.0, 0.0, -0.67875],
            places=5,
            msg='Failed to calculate effective mass tensor')

        print ''
        print 'Effective mass values and directions for Perylene-TCNQ crystal'
        print 'are tested against data computed in the JLB group'
        print ''
        masses, vecs_cart, vecs_frac, vecs_n = emc.get_eff_masses(m, basis)
        self.assertListAlmostEqual(masses, [-0.808, -1.473, -2.192],
                                   places=3,
                                   msg='Effective mass calculations failed')
        self.assertListAlmostEqual(vecs_n[0], [1.0, -0.02531, 0.0],
                                   places=5,
                                   msg='Effective mass direction 1 failed')
        self.assertListAlmostEqual(vecs_n[1], [0.0, 0.0, 1.0],
                                   places=5,
                                   msg='Effective mass direction 2 failed')
        self.assertListAlmostEqual(vecs_n[2], [0.11385, 1.0, 0.0],
                                   places=5,
                                   msg='Effective mass direction 3 failed')