Пример #1
0
    def get_atoms(self, geometry=True):
        """Return an ASE Atoms object with additional
        information such as coverage and Turn-over-frequencies
        attached."""

        if geometry:
            ase = import_ase()
            atoms = ase.atoms.Atoms()
            for i in xrange(lattice.system_size[0]):
                for j in xrange(lattice.system_size[1]):
                    for k in xrange(lattice.system_size[2]):
                        for n in xrange(1, 1 + lattice.spuck):
                            species = lattice.get_species([i, j, k, n])
                            if self.species_representation[species]:
                                atom = deepcopy(
                                    self.species_representation[species])
                                atom.translate(np.dot(lattice.unit_cell_size,
                                np.array([i, j, k]) \
                                + lattice.site_positions[n - 1]))
                                atoms += atom
                        lattice_repr = deepcopy(self.lattice_representation)
                        lattice_repr.translate(
                            np.dot(lattice.unit_cell_size, np.array([i, j,
                                                                     k])))
                        atoms += lattice_repr
            atoms.set_cell(self.cell_size)
        else:

            class Expando():
                pass

            atoms = Expando()
        atoms.calc = None
        atoms.kmc_time = base.get_kmc_time()
        atoms.kmc_step = base.get_kmc_step()

        # calculate TOF since last call
        atoms.procstat = np.zeros((proclist.nr_of_proc, ))
        atoms.occupation = proclist.get_occupation()
        for i in range(proclist.nr_of_proc):
            atoms.procstat[i] = base.get_procstat(i + 1)
        delta_t = (atoms.kmc_time - self.time)
        size = self.size**lattice.model_dimension
        if delta_t == 0. and atoms.kmc_time > 0:
            print(
                "Warning: numerical precision too low, to resolve time-steps")
            print('         Will reset kMC for next step')
            base.set_kmc_time(0.0)
            atoms.tof_data = np.zeros_like(self.tof_matrix[:, 0])
        else:
            atoms.tof_data = np.dot(self.tof_matrix,
                                    (atoms.procstat - self.procstat) /
                                    delta_t / size)

        # update trackers for next call
        self.procstat[:] = atoms.procstat
        self.time = atoms.kmc_time

        return atoms
Пример #2
0
    def get_atoms(self, geometry=True):
        """Return an ASE Atoms object with additional
        information such as coverage and Turn-over-frequencies
        attached."""

        if geometry:
            ase = import_ase()
            atoms = ase.atoms.Atoms()
            for i in xrange(lattice.system_size[0]):
                for j in xrange(lattice.system_size[1]):
                    for k in xrange(lattice.system_size[2]):
                        for n in xrange(1, 1 + lattice.spuck):
                            species = lattice.get_species([i, j, k, n])
                            if self.species_representation[species]:
                                atom = deepcopy(
                                    self.species_representation[species])
                                atom.translate(np.dot(lattice.unit_cell_size,
                                np.array([i, j, k]) \
                                + lattice.site_positions[n - 1]))
                                atoms += atom
                        lattice_repr = deepcopy(self.lattice_representation)
                        lattice_repr.translate(np.dot(lattice.unit_cell_size,
                                    np.array([i, j, k])))
                        atoms += lattice_repr
            atoms.set_cell(self.cell_size)
        else:

            class Expando():
                pass
            atoms = Expando()
        atoms.calc = None
        atoms.kmc_time = base.get_kmc_time()
        atoms.kmc_step = base.get_kmc_step()

        # calculate TOF since last call
        atoms.procstat = np.zeros((proclist.nr_of_proc,))
        atoms.occupation = proclist.get_occupation()
        for i in range(proclist.nr_of_proc):
            atoms.procstat[i] = base.get_procstat(i + 1)
        delta_t = (atoms.kmc_time - self.time)
        size = self.size ** lattice.model_dimension
        if delta_t == 0. and atoms.kmc_time > 0:
            print(
                "Warning: numerical precision too low, to resolve time-steps")
            print('         Will reset kMC for next step')
            base.set_kmc_time(0.0)
            atoms.tof_data = np.zeros_like(self.tof_matrix[:, 0])
        else:
            atoms.tof_data = np.dot(self.tof_matrix,
                            (atoms.procstat - self.procstat) / delta_t / size)

        # update trackers for next call
        self.procstat[:] = atoms.procstat
        self.time = atoms.kmc_time

        return atoms
Пример #3
0
    def put(self, site, species):
        """Puts a certain species at a certain site.
        (Not implemented)
        """
        species = species.lower()

        cell, name = np.array(site[:3]), site[3].lower()
        site_nr = eval('lattice.%s' % name)
        site = np.array(list(cell) + [site_nr])
        species = lattice.get_species(site)
        if species:
            pass
Пример #4
0
    def put(self, site, species):
        """Puts a certain species at a certain site.
        (Not implemented)
        """
        species = species.lower()

        cell, name = np.array(site[:3]), site[3].lower()
        site_nr = eval('lattice.%s' % name)
        site = np.array(list(cell) + [site_nr])
        species = lattice.get_species(site)
        if species:
            pass
Пример #5
0
Файл: run.py Проект: lulzzz/kmos
    def get_atoms(self, geometry=True):
        """Return an ASE Atoms object with additional
        information such as coverage and Turn-over-frequencies
        attached."""

        if geometry:
            kmos_tags = {}
            ase = import_ase()
            atoms = ase.atoms.Atoms()
            for i in xrange(lattice.system_size[0]):
                for j in xrange(lattice.system_size[1]):
                    for k in xrange(lattice.system_size[2]):
                        for n in xrange(1, 1 + lattice.spuck):
                            species = lattice.get_species([i, j, k, n])
                            if self.species_representation[species]:
                                # create the ad_atoms
                                ad_atoms = deepcopy(
                                    self.species_representation[species])

                                # move to the correct location
                                ad_atoms.translate(
                                    np.dot(
                                        np.array([i, j, k]) +
                                        lattice.site_positions[n - 1],
                                        lattice.unit_cell_size))
                                # add to existing slab
                                atoms += ad_atoms
                                if self.species_tags:
                                    for atom in range(
                                            len(atoms) - len(ad_atoms),
                                            len(atoms)):
                                        kmos_tags[
                                            atom] = self.species_tags.values(
                                            )[species]

                        lattice_repr = deepcopy(self.lattice_representation)
                        lattice_repr.translate(
                            np.dot(np.array([i, j, k]),
                                   lattice.unit_cell_size))
                        atoms += lattice_repr
            atoms.set_cell(self.cell_size)

            # workaround for older ASE < 3.6
            if not hasattr(atoms, 'info'):
                atoms.info = {}

            atoms.info['kmos_tags'] = kmos_tags
        else:

            class Expando():
                pass

            atoms = Expando()
        atoms.calc = None
        atoms.kmc_time = base.get_kmc_time()
        atoms.kmc_step = base.get_kmc_step()

        # calculate TOF since last call
        atoms.procstat = np.zeros((proclist.nr_of_proc, ))
        atoms.occupation = proclist.get_occupation()
        for i in range(proclist.nr_of_proc):
            atoms.procstat[i] = base.get_procstat(i + 1)
        delta_t = (atoms.kmc_time - self.time)
        size = self.size**lattice.model_dimension
        if delta_t == 0. and atoms.kmc_time > 0:
            print(
                "Warning: numerical precision too low, to resolve time-steps")
            print('         Will reset kMC time to 0s.')
            base.set_kmc_time(0.0)
            atoms.tof_data = np.zeros_like(self.tof_matrix[:, 0])
        else:
            atoms.tof_data = np.dot(self.tof_matrix,
                                    (atoms.procstat - self.procstat) /
                                    delta_t / size)

        atoms.delta_t = delta_t

        # update trackers for next call
        self.procstat[:] = atoms.procstat
        self.time = atoms.kmc_time

        return atoms
Пример #6
0
Файл: run.py Проект: lulzzz/kmos
    def get_atoms(self, geometry=True):
        """Return an ASE Atoms object with additional
        information such as coverage and Turn-over-frequencies
        attached."""

        if geometry:
            kmos_tags = {}
            ase = import_ase()
            atoms = ase.atoms.Atoms()
            for i in xrange(lattice.system_size[0]):
                for j in xrange(lattice.system_size[1]):
                    for k in xrange(lattice.system_size[2]):
                        for n in xrange(1, 1 + lattice.spuck):
                            species = lattice.get_species([i, j, k, n])
                            if self.species_representation[species]:
                                # create the ad_atoms
                                ad_atoms = deepcopy(
                                    self.species_representation[species])

                                # move to the correct location
                                ad_atoms.translate(
                                    np.dot(
                                        np.array([i, j, k]) +
                                        lattice.site_positions[n - 1],
                                            lattice.unit_cell_size))
                                # add to existing slab
                                atoms += ad_atoms
                                if self.species_tags:
                                    for atom in range(len(atoms) - len(ad_atoms), len(atoms)):
                                        kmos_tags[atom] = self.species_tags.values()[species]

                        lattice_repr = deepcopy(self.lattice_representation)
                        lattice_repr.translate(np.dot(np.array([i, j, k]),
                                                      lattice.unit_cell_size))
                        atoms += lattice_repr
            atoms.set_cell(self.cell_size)

            # workaround for older ASE < 3.6
            if not hasattr(atoms, 'info'):
                atoms.info = {}

            atoms.info['kmos_tags'] = kmos_tags
        else:

            class Expando():
                pass
            atoms = Expando()
        atoms.calc = None
        atoms.kmc_time = base.get_kmc_time()
        atoms.kmc_step = base.get_kmc_step()

        # calculate TOF since last call
        atoms.procstat = np.zeros((proclist.nr_of_proc,))
        atoms.occupation = proclist.get_occupation()
        for i in range(proclist.nr_of_proc):
            atoms.procstat[i] = base.get_procstat(i + 1)
        delta_t = (atoms.kmc_time - self.time)
        size = self.size ** lattice.model_dimension
        if delta_t == 0. and atoms.kmc_time > 0:
            print(
                "Warning: numerical precision too low, to resolve time-steps")
            print('         Will reset kMC time to 0s.')
            base.set_kmc_time(0.0)
            atoms.tof_data = np.zeros_like(self.tof_matrix[:, 0])
        else:
            atoms.tof_data = np.dot(self.tof_matrix,
                            (atoms.procstat - self.procstat) / delta_t / size)

        atoms.delta_t = delta_t

        # update trackers for next call
        self.procstat[:] = atoms.procstat
        self.time = atoms.kmc_time

        return atoms