def initialize_wave_functions_from_basis_functions(self, basis_functions, density, hamiltonian, spos_ac): # if self.initksl is None: # raise RuntimeError('use fewer bands or more basis functions') self.timer.start('LCAO initialization') lcaoksl, lcaobd = self.initksl, self.initksl.bd lcaowfs = LCAOWaveFunctions(lcaoksl, self.gd, self.nvalence, self.setups, lcaobd, self.dtype, self.world, self.kd, self.kptband_comm, nulltimer) lcaowfs.basis_functions = basis_functions lcaowfs.timer = self.timer self.timer.start('Set positions (LCAO WFS)') lcaowfs.set_positions(spos_ac, self.atom_partition) self.timer.stop('Set positions (LCAO WFS)') if self.collinear: eigensolver = DirectLCAO() else: from gpaw.xc.noncollinear import NonCollinearLCAOEigensolver eigensolver = NonCollinearLCAOEigensolver() eigensolver.initialize(self.gd, self.dtype, self.setups.nao, lcaoksl) # XXX when density matrix is properly distributed, be sure to # update the density here also eigensolver.iterate(hamiltonian, lcaowfs) # Transfer coefficients ... for kpt, lcaokpt in zip(self.kpt_u, lcaowfs.kpt_u): kpt.C_nM = lcaokpt.C_nM self.wfs_mover.initialize(lcaowfs) # and get rid of potentially big arrays early: del eigensolver, lcaowfs with self.timer('LCAO to grid'): self.initialize_from_lcao_coefficients(basis_functions) if self.collinear and self.bd.mynbands > lcaobd.mynbands: # Add extra states. If the number of atomic orbitals is # less than the desired number of bands, then extra random # wave functions are added. self.random_wave_functions(lcaobd.mynbands) # IMPORTANT: This intersperses random wavefunctions # with those from LCAO depending on band parallelization. # This is presumably okay as long as the FD/PW eigensolver # is called again before using the wavefunctions/occupations. # # Indeed as of writing this, the initialization appears to # call these things in the correct order, but there is no # telling when this will break due to some unrelated change. self.timer.stop('LCAO initialization') return lcaobd.nbands
def initialize_wave_functions_from_basis_functions(self, basis_functions, density, hamiltonian, spos_ac): if 0: self.timer.start('Random wavefunction initialization') for kpt in self.kpt_u: kpt.psit_nG = self.gd.zeros(self.mynbands, self.dtype) if extra_parameters.get('sic'): kpt.W_nn = np.zeros((self.nbands, self.nbands), dtype=self.dtype) self.random_wave_functions(0) self.timer.stop('Random wavefunction initialization') return self.timer.start('LCAO initialization') lcaoksl, lcaobd = self.initksl, self.initksl.bd lcaowfs = LCAOWaveFunctions(lcaoksl, self.gd, self.nvalence, self.setups, lcaobd, self.dtype, self.world, self.kd) lcaowfs.basis_functions = basis_functions lcaowfs.timer = self.timer self.timer.start('Set positions (LCAO WFS)') lcaowfs.set_positions(spos_ac) self.timer.stop('Set positions (LCAO WFS)') eigensolver = get_eigensolver('lcao', 'lcao') eigensolver.initialize(self.gd, self.dtype, self.setups.nao, lcaoksl) # XXX when density matrix is properly distributed, be sure to # update the density here also eigensolver.iterate(hamiltonian, lcaowfs) # Transfer coefficients ... for kpt, lcaokpt in zip(self.kpt_u, lcaowfs.kpt_u): kpt.C_nM = lcaokpt.C_nM # and get rid of potentially big arrays early: del eigensolver, lcaowfs self.timer.start('LCAO to grid') for kpt in self.kpt_u: kpt.psit_nG = self.gd.zeros(self.mynbands, self.dtype) if extra_parameters.get('sic'): kpt.W_nn = np.zeros((self.nbands, self.nbands), dtype=self.dtype) basis_functions.lcao_to_grid(kpt.C_nM, kpt.psit_nG[:lcaobd.mynbands], kpt.q) kpt.C_nM = None self.timer.stop('LCAO to grid') if self.mynbands > lcaobd.mynbands: # Add extra states. If the number of atomic orbitals is # less than the desired number of bands, then extra random # wave functions are added. self.random_wave_functions(lcaobd.mynbands) self.timer.stop('LCAO initialization')
def initialize_wave_functions_from_basis_functions(self, basis_functions, density, hamiltonian, spos_ac): if self.initksl is None: raise RuntimeError('use fewer bands or more basis functions') self.timer.start('LCAO initialization') lcaoksl, lcaobd = self.initksl, self.initksl.bd lcaowfs = LCAOWaveFunctions(lcaoksl, self.gd, self.nvalence, self.setups, lcaobd, self.dtype, self.world, self.kd, self.kptband_comm, nulltimer) lcaowfs.basis_functions = basis_functions lcaowfs.timer = self.timer self.timer.start('Set positions (LCAO WFS)') lcaowfs.set_positions(spos_ac) self.timer.stop('Set positions (LCAO WFS)') eigensolver = DirectLCAO() eigensolver.initialize(self.gd, self.dtype, self.setups.nao, lcaoksl) # XXX when density matrix is properly distributed, be sure to # update the density here also eigensolver.iterate(hamiltonian, lcaowfs) # Transfer coefficients ... for kpt, lcaokpt in zip(self.kpt_u, lcaowfs.kpt_u): kpt.C_nM = lcaokpt.C_nM # and get rid of potentially big arrays early: del eigensolver, lcaowfs self.timer.start('LCAO to grid') self.initialize_from_lcao_coefficients(basis_functions, lcaobd.mynbands) self.timer.stop('LCAO to grid') if self.bd.mynbands > lcaobd.mynbands: # Add extra states. If the number of atomic orbitals is # less than the desired number of bands, then extra random # wave functions are added. self.random_wave_functions(lcaobd.mynbands) self.timer.stop('LCAO initialization')
def set_positions(self, spos_ac): LCAOWaveFunctions.set_positions(self, spos_ac) for kpt in self.kpt_u: kpt.C_nM = None kpt.C_nsM = np.empty((self.bd.mynbands, 2, self.ksl.nao), complex)