Example #1
0
    def test_projector(self):
        print("TEST PROJ")
        sys.stdout.flush()
        # test ae projections
        wf1 = Wavefunction.from_directory(".", False)
        basis = Wavefunction.from_directory(".", False)
        pr = Projector(wf1, basis)
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        generator = Projector.setup_multiple_projections(".", [".", "."])
        for wf_dir, wf in generator:
            wf.defect_band_analysis(4, 10, spinpol=True)

        wf1 = Wavefunction.from_directory(".", False)
        basis = Wavefunction.from_directory(".", False)
        pr = Projector(wf1, basis, "aug_recip")
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        wf1 = Wavefunction.from_directory(".", False)
        basis = Wavefunction.from_directory(".", False)
        pr = Projector(wf1, basis, "realspace")
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        with assert_raises(ValueError):
            pr.proportion_conduction(100)
            pr.proportion_conduction(-1)
Example #2
0
    def test_projector(self):
        print("TEST PROJ")
        sys.stdout.flush()
        # test ae projections
        wf1 = Wavefunction.from_directory('.', False)
        basis = Wavefunction.from_directory('.', False)
        pr = Projector(wf1, basis)
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        generator = Projector.setup_multiple_projections('.', ['.', '.'])
        for wf_dir, wf in generator:
            wf.defect_band_analysis(4, 10, spinpol=True)

        wf1 = Wavefunction.from_directory('.', False)
        basis = Wavefunction.from_directory('.', False)
        pr = Projector(wf1, basis, 'aug_recip')
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        wf1 = Wavefunction.from_directory('.', False)
        basis = Wavefunction.from_directory('.', False)
        pr = Projector(wf1, basis, 'realspace')
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)
Example #3
0
    def test_projector_gz(self):
        print("TEST PROJGZ")
        sys.stdout.flush()
        # test ae projections
        wf1 = Wavefunction.from_files("CONTCAR", "WAVECAR2.gz", "POTCAR",
                                      "vasprun.xml", False)
        basis = Wavefunction.from_directory(".", False)
        pr = Projector(wf1, basis)
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            if b < 6:
                assert_almost_equal(v, 1, decimal=4)
                assert_almost_equal(c, 0, decimal=8)
            else:
                assert_almost_equal(v, 0, decimal=8)
                assert_almost_equal(c, 1, decimal=4)

        generator = Projector.setup_multiple_projections(".", [".", "."])
        for wf_dir, wf in generator:
            wf.defect_band_analysis(4, 10, spinpol=True)
Example #4
0
    def test_offsite(self):
        Projector = DummyProjector
        print("TEST OFFSITE")
        sys.stdout.flush()
        wf1 = Wavefunction.from_directory("nosym", False)
        basis = Wavefunction.from_directory("nosym", False)
        print("ENCUT", wf1.encut, basis.encut)
        pr = Projector(wf1, basis)
        test_vals = {}
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            print("CHECK_VALS", v, c)
            test_vals[b] = (v, c)
        for b in range(wf1.nband // 2):
            if b < 6:
                assert_almost_equal(test_vals[b][0], 1, decimal=2)
                assert_almost_equal(test_vals[b][1], 0, decimal=4)
            else:
                assert_almost_equal(test_vals[b][0], 0, decimal=4)
                assert_almost_equal(test_vals[b][1], 1, decimal=2)

        generator = Projector.setup_multiple_projections(".", [".", "."])
        for wf_dir, wf in generator:
            wf.defect_band_analysis(4, 10, spinpol=True)

        wf1 = Wavefunction.from_directory("nosym", False)
        basis = Wavefunction.from_directory("nosym", False)
        print("ENCUT", wf1.encut, basis.encut)
        pr = Projector(wf1, basis, "aug_recip")
        test_vals = {}
        for b in range(wf1.nband):
            v, c = pr.proportion_conduction(b)
            print("CHECK_VALS", v, c)
            test_vals[b] = (v, c)
        for b in range(wf1.nband // 2):
            if b < 6:
                assert_almost_equal(test_vals[b][0], 1, decimal=2)
                assert_almost_equal(test_vals[b][1], 0, decimal=4)
            else:
                assert_almost_equal(test_vals[b][0], 0, decimal=4)
                assert_almost_equal(test_vals[b][1], 1, decimal=2)
Example #5
0
 def setup(self):
     os.chdir(os.path.join(MODULE_DIR, '../../../test_files'))
     generator = Projector.setup_multiple_projections('.', ['.', '.'])
     self.bes = BasisExpansion.makeit(generator)
Example #6
0
 def setup(self):
     os.chdir(os.path.join(MODULE_DIR, '../../../test_files'))
     generator = Projector.setup_multiple_projections('.', ['.', '.'])
     self.bcs = BulkCharacter.makeit(generator)