Beispiel #1
0
def get_elph_elements(atoms,
                      gpw_name,
                      calc_fd,
                      sc=(1, 1, 1),
                      basename=None,
                      phononname='phonon'):
    """
        Evaluates the dipole transition matrix elements

        Input
        ----------
        params_fd : Calculation parameters used for the phonon calculation
        sc (tuple): Supercell, default is (1,1,1) used for gamma phonons
        basename  : If you want give a specific name (gqklnn_{}.pckl)

        Output
        ----------
        gqklnn.pckl, the electron-phonon matrix elements
    """
    from ase.phonons import Phonons
    from gpaw.elph.electronphonon import ElectronPhononCoupling

    calc_gs = GPAW(gpw_name)
    world = calc_gs.wfs.world

    #calc_fd = GPAW(**params_fd)
    calc_gs.initialize_positions(atoms)
    kpts = calc_gs.get_ibz_k_points()
    nk = len(kpts)
    gamma_kpt = [[0, 0, 0]]
    nbands = calc_gs.wfs.bd.nbands
    qpts = gamma_kpt

    # calc_fd.get_potential_energy()  # XXX needed to initialize C_nM ??????

    # Phonon calculation, We'll read the forces from the elph.run function
    # This only looks at gamma point phonons
    ph = Phonons(atoms=atoms, name=phononname, supercell=sc)
    ph.read()
    frequencies, modes = ph.band_structure(qpts, modes=True)

    if world.rank == 0:
        print("Phonon frequencies are loaded.")

    # Find el-ph matrix in the LCAO basis
    elph = ElectronPhononCoupling(atoms, calc=None, supercell=sc)

    elph.set_lcao_calculator(calc_fd)
    elph.load_supercell_matrix()
    if world.rank == 0:
        print("Supercell matrix is loaded")

    # Non-root processes on GD comm seem to be missing kpoint data.
    assert calc_gs.wfs.gd.comm.size == 1, "domain parallelism not supported"  # not sure how to fix this, sorry

    gcomm = calc_gs.wfs.gd.comm
    kcomm = calc_gs.wfs.kd.comm
    if gcomm.rank == 0:
        # Find the bloch expansion coefficients
        c_kn = np.empty((nk, nbands, calc_gs.wfs.setups.nao), dtype=complex)
        for k in range(calc_gs.wfs.kd.nibzkpts):
            c_k = calc_gs.wfs.collect_array("C_nM", k, 0)
            if kcomm.rank == 0:
                c_kn[k] = c_k
        kcomm.broadcast(c_kn, 0)

        # And we finally find the electron-phonon coupling matrix elements!
        g_qklnn = elph.bloch_matrix(c_kn=c_kn,
                                    kpts=kpts,
                                    qpts=qpts,
                                    u_ql=modes)

    if world.rank == 0:
        print("Saving the elctron-phonon coupling matrix")
        np.save("gqklnn{}.npy".format(make_suffix(basename)),
                np.array(g_qklnn))
Beispiel #2
0
    'basis': 'dzp',
    'symmetry': {
        'point_group': False
    },
    'xc': 'PBE'
}
elph_calc = GPAW(**parameters)
atoms.set_calculator(elph_calc)
atoms.get_potential_energy()
gamma_bands = elph_calc.wfs.kpt_u[0].C_nM

elph = ElectronPhononCoupling(atoms,
                              elph_calc,
                              supercell=supercell,
                              calculate_forces=True)
elph.run()

parameters['parallel'] = {'domain': 1}
elph_calc = GPAW(**parameters)
elph = ElectronPhononCoupling(atoms, calc=None, supercell=supercell)
elph.set_lcao_calculator(elph_calc)
elph.calculate_supercell_matrix(dump=1)

ph = Phonons(atoms=atoms, name='phonons', supercell=supercell, calc=None)
ph.read()
kpts = [[0, 0, 0]]
frequencies, modes = ph.band_structure(kpts, modes=True)

c_kn = np.array([[gamma_bands[0]]])
g_qklnn = elph.bloch_matrix(c_kn=c_kn, kpts=kpts, qpts=kpts, u_ql=modes)