コード例 #1
0
    def __init__(self,
                 path,
                 atoms=None,
                 min_hopping_norm=1e-4,
                 max_distance=None,
                 nelect=0,
                 efermi=0):
        self.path = path
        self.tb_up = pythtb.w90(path, 'wannier90.up')
        self.tb_dn = pythtb.w90(path, 'wannier90.dn')
        self.tbmodel_up = self.tb_up.model(
            min_hopping_norm=min_hopping_norm, max_distance=max_distance)
        self.tbmodel_dn = self.tb_dn.model(
            min_hopping_norm=min_hopping_norm, max_distance=max_distance)
        self.efermi = efermi
        self.nelect = nelect
        self.atoms = atoms
        self.basis = None
        self.kpts = None
        self.kweights = None

        basis_fname = os.path.join(self.path, 'basis.txt')
        if os.path.exists(basis_fname):
            self.basis = read_basis(basis_fname)
        self.nwann = len(self.basis.keys())
        self.block_dict = basis_to_block(self.basis)
コード例 #2
0
ファイル: test_w90_pythtb.py プロジェクト: hao134/TBmodels
def test_consistency_pythtb(prefix, sample):
    """
    Check that a model from Wannier90 output is consistent with a
    PythTB reference from the same files.
    """
    pt_model = pt.w90(sample(""), prefix).model()
    tb_model = tb.Model.from_wannier_files(
        hr_file=sample(prefix + "_hr.dat"),
        win_file=sample(prefix + ".win"),
        # This might be needed if pythtb supports wsvec.dat
        # wsvec_file=sample('silicon_wsvec.dat'),
        xyz_file=sample(prefix + "_centres.xyz"),
    )

    # pylint: disable=protected-access
    assert np.allclose(pt_model._gen_ham([0, 0, 0]),
                       tb_model.hamilton([0, 0, 0]))
    assert np.allclose(pt_model._gen_ham([0, 0, 0]),
                       tb_model.hamilton([0, 0, 0], convention=1))

    k = (0.123412512, 0.6234615, 0.72435235)
    assert np.allclose(pt_model._gen_ham(k), tb_model.hamilton(k,
                                                               convention=1))
    assert np.allclose(pt_model.get_lat(), tb_model.uc)
    assert np.allclose(pt_model.get_orb() % 1, tb_model.pos)
コード例 #3
0
def run(path,
        prefix,
        labels,
        scmat,
        output_figure,
        kvectors,
        knames,
        npoints=200,
        min_hopping_norm=0.0001):
    w90reader = w90(path=path, prefix=prefix)
    tb = w90reader.model(min_hopping_norm=min_hopping_norm)
    #labels = ['pz', 'px', 'py'] * 12 + ['dz2', 'dxy', 'dyz', 'dx2', 'dxz'] * 4
    #scmat=[[1,-1,0],[1,1,0],[0,0,2]]
    u = wannier_unfolder(tb, labels, sc_matrix=scmat)
    u.plot_unfolded_band(
        #kvectors=np.array([[0, 0, 0], [0.5, 0, 0], [0.5, 0.5, 0],
        #                    [0, 0, 0], [.5, .5, .5]]),
        kvectors=kvectors,
        #knames=['$\Gamma$', 'X', 'M', '$\Gamma$', 'R'],
        knames=knames,
        npoints=npoints,
        ax=None,
    )
    plt.savefig(output_figure)
    plt.show()
コード例 #4
0
def test_nodefect():
    w90reader = w90(path='data_nodefect', prefix='wannier90')
    #w90reader = w90(path='data', prefix='wannier90')
    tb = w90reader.model(min_hopping_norm=0.05)
    labels = ['pz', 'px', 'py'] * 12 + ['dz2', 'dxy', 'dyz', 'dx2', 'dxz'] * 4
    scmat=[[1,-1,0],[1,1,0],[0,0,2]]
    u = wannier_unfolder(tb, labels, sc_matrix=scmat)
    u.plot_unfolded_band()
    plt.savefig('STO_nodefect.pdf')
    plt.savefig('STO_nodefect.png')
    plt.show()
コード例 #5
0
    def __init__(self, path, prefix, zero_level=0):
        self.path = path
        self.prefix = prefix
        self.wannier = tb.w90(path, prefix)
        self.zero_level = zero_level

        self._orbital_positons = []
        for orbital_position in self.wannier.red_cen:
            self._orbital_positons.append(list(orbital_position))

        TightBinding.__init__(self, self.create_crystal())

        self.set_model(zero_level=self.zero_level)
コード例 #6
0
def get_pythtb(wan_calculation, xyz_workaround=False):
    tmpdir = tempfile.mkdtemp()

    seedname = os.path.splitext(wan_calculation._INPUT_FILE)[0]
    out_dir = os.path.join(wan_calculation.out.retrieved.folder.abspath,
                           "path")
    for filepath in [
            os.path.join(wan_calculation.folder.abspath, "raw_input",
                         "{}.win".format(seedname)),
            os.path.join(out_dir, "{}.wout".format(seedname)),
            os.path.join(out_dir, "{}_hr.dat".format(seedname)),
            os.path.join(out_dir, "{}_wsvec.dat".format(seedname)),
            os.path.join(out_dir, "{}_centres.xyz".format(seedname)),
            os.path.join(out_dir, "{}_band.kpt".format(seedname)),
            os.path.join(out_dir, "{}_band.dat".format(seedname)),
    ]:
        if os.path.exists(filepath):
            shutil.copy(filepath,
                        os.path.join(tmpdir, os.path.basename(filepath)))
        else:
            print("Skipping {}".format(os.path.basename(filepath)))

    if xyz_workaround:
        parsed = raw_wout_parser(
            open(os.path.join(out_dir,
                              "{}.wout".format(seedname))).readlines())
        num_atoms = len(wan_calculation.inp.structure.sites)
        num_wf = len(parsed['wannier_functions_output'])

        xyz = []
        xyz.append(str(num_atoms + num_wf))
        xyz.append(str(num_atoms + num_wf))
        for wf in parsed['wannier_functions_output']:
            xyz.append("X {} {} {}".format(wf['coordinates'][0],
                                           wf['coordinates'][1],
                                           wf['coordinates'][2]))
        for site in wan_calculation.inp.structure.sites:
            xyz.append("{} {} {} {}".format(site.kind_name, site.position[0],
                                            site.position[1],
                                            site.position[2]))
        with open(os.path.join(tmpdir, "{}_centres.xyz".format(seedname)),
                  'w') as f:
            f.write("\n".join(xyz))

    tb_w90 = pythtb.w90(tmpdir, seedname)
    # Remove the folder
    shutil.rmtree(tmpdir)

    return tb_w90
コード例 #7
0
def test_defect():
    w90reader = w90(path='data', prefix='wannier90')
    tb = w90reader.model(min_hopping_norm=0.05)
    labels = ['pz', 'px', 'py'] * 12 + ['dz2', 'dxy', 'dyz', 'dx2', 'dxz'] * 4
    scmat=[[1,-1,0],[1,1,0],[0,0,2]]
    u = wannier_unfolder(tb, labels, sc_matrix=scmat)
    u.plot_unfolded_band(
            kvectors=np.array([[0, 0, 0], [0.5, 0, 0], [0.5, 0.5, 0],
                                [0, 0, 0], [.5, .5, .5]]),
            knames=['$\Gamma$', 'X', 'M', '$\Gamma$', 'R'],
            npoints=200,
            ax=None, 
            )
    plt.savefig('STO_defect.pdf')
    plt.savefig('STO_defect.png')
    plt.show()
コード例 #8
0
def test_si_pythtb():
    pt_model = pt.w90(SAMPLES_DIR, 'silicon').model()
    tb_model = tb.Model.from_wannier_files(
        hr_file=os.path.join(SAMPLES_DIR, 'silicon_hr.dat'),
        win_file=os.path.join(SAMPLES_DIR, 'silicon.win'),
        # This might be needed if pythtb supports wsvec.dat
        # wsvec_file=os.path.join(SAMPLES_DIR, 'silicon_wsvec.dat'),
        xyz_file=os.path.join(SAMPLES_DIR, 'silicon_centres.xyz')
    )

    assert np.allclose(pt_model._gen_ham([0, 0, 0]), tb_model.hamilton([0, 0, 0]))
    assert np.allclose(pt_model._gen_ham([0, 0, 0]), tb_model.hamilton([0, 0, 0], convention=1))

    k = (0.123412512, 0.6234615, 0.72435235)
    assert np.allclose(pt_model._gen_ham(k), tb_model.hamilton(k, convention=1))
    assert np.allclose(pt_model.get_lat(), tb_model.uc)
    assert np.allclose(pt_model.get_orb() % 1, tb_model.pos)
コード例 #9
0
ファイル: test_YNO.py プロジェクト: suthzx/pyDFTutils
def test_1d(dt=0.0, t=1):
    mymodel = pythtb.w90(path='../test',
                         prefix='wannier90.up').model(min_hopping_norm=0.001)
    kpath = np.array([[0.0, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 0], [1, 1, 1],
                      [0, 1, 0]]) / 2.0
    kpath = np.dot(kpath, np.array([[1, -1, 0], [1, 1, 0], [0, 0, 2]]))
    kpoints, zs, special_zs = ase.dft.kpoints.bandpath(kpath,
                                                       cell=np.eye(3),
                                                       npoints=210)
    xticks = (['GM', 'X', 'M', 'GM', 'R', 'X'], special_zs)
    evals = mymodel.solve_all(kpoints)
    myanatb = anatb(mymodel, kpts=kpoints)
    myanatb.plot_COHP_fatband(k_x=zs,
                              xticks=xticks,
                              iblock=range(0, 36),
                              jblock=range(36, 56))
    return
コード例 #10
0
def test_consistency_pythtb(prefix, sample):
    pt_model = pt.w90(sample(''), prefix).model()
    tb_model = tb.Model.from_wannier_files(
        hr_file=sample(prefix + '_hr.dat'),
        win_file=sample(prefix + '.win'),
        # This might be needed if pythtb supports wsvec.dat
        # wsvec_file=sample('silicon_wsvec.dat'),
        xyz_file=sample(prefix + '_centres.xyz'))

    assert np.allclose(pt_model._gen_ham([0, 0, 0]),
                       tb_model.hamilton([0, 0, 0]))
    assert np.allclose(pt_model._gen_ham([0, 0, 0]),
                       tb_model.hamilton([0, 0, 0], convention=1))

    k = (0.123412512, 0.6234615, 0.72435235)
    assert np.allclose(pt_model._gen_ham(k), tb_model.hamilton(k,
                                                               convention=1))
    assert np.allclose(pt_model.get_lat(), tb_model.uc)
    assert np.allclose(pt_model.get_orb() % 1, tb_model.pos)