Exemple #1
0
    def read(self, reader):
        FDPWWaveFunctions.read(self, reader)

        if 'values' not in reader.wave_functions:
            return

        c = reader.bohr**1.5
        if reader.version < 0:
            c = 1  # old gpw file
        for kpt in self.kpt_u:
            # We may not be able to keep all the wave
            # functions in memory - so psit_nG will be a special type of
            # array that is really just a reference to a file:
            kpt.psit_nG = reader.wave_functions.proxy('values', kpt.s, kpt.k)
            kpt.psit_nG.scale = c

        if self.world.size == 1:
            return

        # Read to memory:
        for kpt in self.kpt_u:
            psit_nG = kpt.psit_nG
            kpt.psit_nG = self.empty(self.bd.mynbands)
            # Read band by band to save memory
            for myn, psit_G in enumerate(kpt.psit_nG):
                n = self.bd.global_index(myn)
                # XXX number of bands could have been rounded up!
                if n >= len(psit_nG):
                    break
                if self.gd.comm.rank == 0:
                    big_psit_G = np.asarray(psit_nG[n], self.dtype)
                else:
                    big_psit_G = None
                self.gd.distribute(big_psit_G, psit_G)
Exemple #2
0
    def read(self, reader):
        FDPWWaveFunctions.read(self, reader)

        if 'values' not in reader.wave_functions:
            return

        c = reader.bohr**1.5
        if reader.version < 0:
            c = 1  # old gpw file

        for kpt in self.kpt_u:
            # We may not be able to keep all the wave
            # functions in memory - so psit_nG will be a special type of
            # array that is really just a reference to a file:
            psit_nG = reader.wave_functions.proxy('values', kpt.s, kpt.k)
            psit_nG.scale = c

            kpt.psit = UniformGridWaveFunctions(self.bd.nbands,
                                                self.gd,
                                                self.dtype,
                                                psit_nG,
                                                kpt=kpt.q,
                                                dist=(self.bd.comm,
                                                      self.bd.comm.size),
                                                spin=kpt.s,
                                                collinear=True)

        if self.world.size > 1:
            # Read to memory:
            for kpt in self.kpt_u:
                kpt.psit.read_from_file()
Exemple #3
0
    def read(self, reader):
        FDPWWaveFunctions.read(self, reader)

        if 'coefficients' not in reader.wave_functions:
            return

        Q_kG = reader.wave_functions.indices
        for kpt in self.kpt_u:
            if kpt.s == 0:
                Q_G = Q_kG[kpt.k]
                ng = self.ng_k[kpt.k]
                assert (Q_G[:ng] == self.pd.Q_qG[kpt.q]).all()
                assert (Q_G[ng:] == -1).all()

        c = reader.bohr**1.5
        if reader.version < 0:
            c = 1  # old gpw file
        for kpt in self.kpt_u:
            ng = self.ng_k[kpt.k]
            kpt.psit_nG = reader.wave_functions.proxy('coefficients',
                                                      kpt.s, kpt.k)
            kpt.psit_nG.scale = c
            kpt.psit_nG.length_of_last_dimension = ng

        if self.world.size == 1:
            return

        # Read to memory:
        for kpt in self.kpt_u:
            psit_nG = kpt.psit_nG
            kpt.psit_nG = self.empty(self.bd.mynbands, q=kpt.q)
            ng = self.ng_k[kpt.k]
            for myn, psit_G in enumerate(kpt.psit_nG):
                n = self.bd.global_index(myn)
                # XXX number of bands could have been rounded up!
                if n < len(psit_nG):
                    psit_G[:] = psit_nG[n]