def gen_test_data(datadir: str, params_fd: dict, supercell): from gpaw.elph.electronphonon import ElectronPhononCoupling params_gs = copy.deepcopy(params_fd) atoms = Cluster(ase.build.bulk('C')) calc_gs = GPAW(**params_gs) atoms.calc = calc_gs atoms.get_potential_energy() atoms.calc.write("gs.gpw", mode="all") # Make sure the real space grid matches the original. # (basically we multiply the number of grid points in each dimension by the supercell dimension) params_fd['gpts'] = calc_gs.wfs.gd.N_c * list(supercell) if 'h' in params_fd: del params_fd['h'] del calc_gs if world.rank == 0: os.makedirs(datadir, exist_ok=True) calc_fd = GPAW(**params_fd) elph = ElectronPhononCoupling(atoms, calc=calc_fd, supercell=supercell, calculate_forces=True, name=f'{datadir}/elph') elph.run() calc_fd.wfs.gd.comm.barrier() elph = ElectronPhononCoupling(atoms, calc=calc_fd, supercell=supercell) elph.set_lcao_calculator(calc_fd) elph.calculate_supercell_matrix(dump=1)
def elph_do_supercell_matrix(log, calc, supercell): from gpaw.elph.electronphonon import ElectronPhononCoupling # calculate_supercell_matrix breaks if parallelized over domains so parallelize over kpt instead # (note: it prints messages from all processes but it DOES run faster with more processes) supercell_atoms = GPAW('supercell.eq.gpw', txt=log, parallel={'domain': (1,1,1), 'band': 1, 'kpt': world.size}).get_atoms() elph = ElectronPhononCoupling(calc.atoms, supercell=supercell, calc=supercell_atoms.calc) elph.set_lcao_calculator(supercell_atoms.calc) # to initialize bfs.M_a ensure_gpaw_setups_initialized(supercell_atoms.calc, supercell_atoms) elph.calculate_supercell_matrix(dump=1) world.barrier()
def main__brute_gpw(structure_path, supercell, log): from gpaw.elph.electronphonon import ElectronPhononCoupling from gpaw import GPAW calc = GPAW(structure_path) supercell_atoms = make_gpaw_supercell(calc, supercell, txt=log) # NOTE: confusingly, Elph wants primitive atoms, but a calc for the supercell elph = ElectronPhononCoupling(calc.atoms, calc=supercell_atoms.calc, supercell=supercell, calculate_forces=True) elph.run() supercell_atoms.calc.wfs.gd.comm.barrier() elph = ElectronPhononCoupling(calc.atoms, calc=supercell_atoms.calc, supercell=supercell) elph.set_lcao_calculator(supercell_atoms.calc) elph.calculate_supercell_matrix(dump=1) return
'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)