Example #1
0
    def read(self, reader, parallel, kd, bd):
        if reader['version'] > 0.3:
            density_error = reader['DensityError']
            if density_error is not None:
                self.mixer.set_charge_sloshing(density_error)

        if not reader.has_array('PseudoElectronDensity'):
            return

        hdf5 = hasattr(reader, 'hdf5')
        nt_sG = self.gd.empty(self.nspins)
        if hdf5:
            # Read pseudoelectron density on the coarse grid
            # and broadcast on kpt_comm and band_comm:
            indices = [slice(0, self.nspins)] + self.gd.get_slice()
            do_read = (kd.comm.rank == 0) and (bd.comm.rank == 0)
            reader.get('PseudoElectronDensity', out=nt_sG, parallel=parallel,
                       read=do_read, *indices)  # XXX read=?
            kd.comm.broadcast(nt_sG, 0)
            bd.comm.broadcast(nt_sG, 0)
        else:
            for s in range(self.nspins):
                self.gd.distribute(reader.get('PseudoElectronDensity', s),
                                   nt_sG[s])

        # Read atomic density matrices
        D_asp = {}
        natoms = len(self.setups)
        self.rank_a = np.zeros(natoms, int)
        all_D_sp = reader.get('AtomicDensityMatrices', broadcast=True)
        if self.gd.comm.rank == 0:
            D_asp = read_atomic_matrices(all_D_sp, self.setups)

        self.initialize_directly_from_arrays(nt_sG, D_asp)
Example #2
0
    def read(self, reader, parallel, kptband_comm):
        if reader['version'] > 0.3:
            density_error = reader['DensityError']
            if density_error is not None:
                self.mixer.set_charge_sloshing(density_error)

        if not reader.has_array('PseudoElectronDensity'):
            return

        hdf5 = hasattr(reader, 'hdf5')
        nt_sG = self.gd.empty(self.nspins)
        if hdf5:
            # Read pseudoelectron density on the coarse grid
            # and broadcast on kpt_comm and band_comm:
            indices = [slice(0, self.nspins)] + self.gd.get_slice()
            do_read = (kptband_comm.rank == 0)
            reader.get('PseudoElectronDensity', out=nt_sG, parallel=parallel,
                       read=do_read, *indices)  # XXX read=?
            kptband_comm.broadcast(nt_sG, 0)
        else:
            for s in range(self.nspins):
                self.gd.distribute(reader.get('PseudoElectronDensity', s),
                                   nt_sG[s])

        # Read atomic density matrices
        D_asp = {}
        natoms = len(self.setups)
        self.rank_a = np.zeros(natoms, int)
        all_D_sp = reader.get('AtomicDensityMatrices', broadcast=True)
        if self.gd.comm.rank == 0:
            D_asp = read_atomic_matrices(all_D_sp, self.setups)

        self.initialize_directly_from_arrays(nt_sG, D_asp)
Example #3
0
    def read(self, reader, parallel):
        self.Ekin = reader['Ekin']
        self.Epot = reader['Epot']
        self.Ebar = reader['Ebar']
        try:
            self.Eext = reader['Eext']
        except (AttributeError, KeyError):
            self.Eext = 0.0
        self.Exc = reader['Exc']
        self.S = reader['S']
        self.Etot = reader.get('PotentialEnergy',
                               broadcast=True) - 0.5 * self.S

        if not reader.has_array('PseudoPotential'):
            return

        hdf5 = hasattr(reader, 'hdf5')
        version = reader['version']

        # Read pseudo potential on the coarse grid
        # and broadcast on kpt/band comm:
        if version > 0.3:
            self.vt_sG = self.gd.empty(self.nspins)
            if hdf5:
                indices = [
                    slice(0, self.nspins),
                ] + self.gd.get_slice()
                do_read = (self.kptband_comm.rank == 0)
                reader.get('PseudoPotential',
                           out=self.vt_sG,
                           parallel=parallel,
                           read=do_read,
                           *indices)  # XXX read=?
                self.kptband_comm.broadcast(self.vt_sG, 0)
            else:
                for s in range(self.nspins):
                    self.gd.distribute(reader.get('PseudoPotential', s),
                                       self.vt_sG[s])

        # Read non-local part of hamiltonian
        self.dH_asp = {}
        natoms = len(self.setups)
        self.rank_a = np.zeros(natoms, int)
        if version > 0.3:
            all_H_sp = reader.get('NonLocalPartOfHamiltonian', broadcast=True)

        if self.gd.comm.rank == 0 and version > 0.3:
            self.dH_asp = read_atomic_matrices(all_H_sp, self.setups)
Example #4
0
    def read(self, reader, parallel, kd, bd):
        self.Ekin = reader['Ekin']
        self.Epot = reader['Epot']
        self.Ebar = reader['Ebar']
        try:
            self.Eext = reader['Eext']
        except (AttributeError, KeyError):
            self.Eext = 0.0
        self.Exc = reader['Exc']
        self.S = reader['S']
        self.Etot = reader.get('PotentialEnergy',
                               broadcast=True) - 0.5 * self.S

        if not reader.has_array('PseudoPotential'):
            return

        hdf5 = hasattr(reader, 'hdf5')
        version = reader['version']

        # Read pseudo potential on the coarse grid
        # and broadcast on kd.comm and bd.comm:
        if version > 0.3:
            self.vt_sG = self.gd.empty(self.nspins)
            if hdf5:
                indices = [slice(0, self.nspins), ] + self.gd.get_slice()
                do_read = (kd.comm.rank == 0) and (bd.comm.rank == 0)
                reader.get('PseudoPotential', out=self.vt_sG,
                           parallel=parallel,
                           read=do_read, *indices)  # XXX read=?
                kd.comm.broadcast(self.vt_sG, 0)
                bd.comm.broadcast(self.vt_sG, 0)
            else:
                for s in range(self.nspins):
                    self.gd.distribute(reader.get('PseudoPotential', s),
                                       self.vt_sG[s])

        # Read non-local part of hamiltonian
        self.dH_asp = {}
        natoms = len(self.setups)
        self.rank_a = np.zeros(natoms, int)
        if version > 0.3:
            all_H_sp = reader.get('NonLocalPartOfHamiltonian', broadcast=True)

        if self.gd.comm.rank == 0 and version > 0.3:
            self.dH_asp = read_atomic_matrices(all_H_sp, self.setups)
    def read(self, reader, parallel):
        self.Ekin = reader["Ekin"]
        self.Epot = reader["Epot"]
        self.Ebar = reader["Ebar"]
        try:
            self.Eext = reader["Eext"]
        except (AttributeError, KeyError):
            self.Eext = 0.0
        self.Exc = reader["Exc"]
        self.S = reader["S"]
        self.Etot = reader.get("PotentialEnergy", broadcast=True) - 0.5 * self.S

        if not reader.has_array("PseudoPotential"):
            return

        hdf5 = hasattr(reader, "hdf5")
        version = reader["version"]

        # Read pseudo potential on the coarse grid
        # and broadcast on kpt/band comm:
        if version > 0.3:
            self.vt_sG = self.gd.empty(self.nspins)
            if hdf5:
                indices = [slice(0, self.nspins)] + self.gd.get_slice()
                do_read = self.kptband_comm.rank == 0
                reader.get("PseudoPotential", out=self.vt_sG, parallel=parallel, read=do_read, *indices)  # XXX read=?
                self.kptband_comm.broadcast(self.vt_sG, 0)
            else:
                for s in range(self.nspins):
                    self.gd.distribute(reader.get("PseudoPotential", s), self.vt_sG[s])

        # Read non-local part of hamiltonian
        self.dH_asp = {}
        natoms = len(self.setups)
        self.rank_a = np.zeros(natoms, int)
        if version > 0.3:
            all_H_sp = reader.get("NonLocalPartOfHamiltonian", broadcast=True)

        if self.gd.comm.rank == 0 and version > 0.3:
            self.dH_asp = read_atomic_matrices(all_H_sp, self.setups)