Esempio n. 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
Esempio n. 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
Esempio n. 3
0
    def post_mortem(self, steps=None, propagate=False, err_code=None):
        """Accepts an integer and generates a post-mortem report
        by running that many steps and returning which process
        would be executed next without executing it.
        """
        if err_code is not None:
            old, new, found, err_site, steps = err_code
            err_site = self.nr2site(err_site)
            if old >= 0:
                old = sorted(settings.representations.keys())[old]
            else:
                old = 'NULL'

            if new >= 0:
                new = sorted(settings.representations.keys())[new]
            else:
                new = 'NULL'

            if found >= 0:
                found = sorted(settings.representations.keys())[found]
            else:
                found = 'NULL'

            self.do_steps(steps)
            nprocess, nsite = proclist.get_kmc_step()
            process = list(sorted(settings.rate_constants.keys()))[nprocess -
                                                                   1]
            site = self.nr2site(nsite)
            print('=====================================')
            print('Post-Mortem Error Report')
            print('=====================================')
            print('  kmos ran %s steps and the next process is "%s"' %
                  (steps, process))
            print('  on site %s,  however this causes oops' % site)
            print('  on site %s because it trys to' % err_site)
            print('  replace "%s" by "%s" but it will find "%s".' %
                  (old, new, found))
            print('  Go fish!')

        else:
            if steps is not None:
                self.do_steps(steps)
            else:
                steps = base.get_kmc_step()
            nprocess, nsite = proclist.get_kmc_step()
            process = list(sorted(settings.rate_constants.keys()))[nprocess -
                                                                   1]
            site = self.nr2site(nsite)

            res = "kmos ran %s steps and next it will execute\n" % steps
            res += "process '%s' on site %s." % (process, site)
            print(res)

            if propagate:
                proclist.run_proc_nr(nprocess, nsite)
Esempio n. 4
0
    def post_mortem(self, steps=None, propagate=False, err_code=None):
        """Accepts an integer and generates a post-mortem report
        by running that many steps and returning which process
        would be executed next without executing it.
        """
        if err_code is not None:
            old, new, found, err_site, steps = err_code
            err_site = self.nr2site(err_site)
            if old >= 0:
                old = sorted(settings.representations.keys())[old]
            else:
                old = 'NULL'

            if new >= 0:
                new = sorted(settings.representations.keys())[new]
            else:
                new = 'NULL'

            if found >= 0:
                found = sorted(settings.representations.keys())[found]
            else:
                found = 'NULL'

            self.do_steps(steps)
            nprocess, nsite = proclist.get_kmc_step()
            process = list(
                sorted(settings.rate_constants.keys()))[nprocess - 1]
            site = self.nr2site(nsite)
            print('=====================================')
            print('Post-Mortem Error Report')
            print('=====================================')
            print('  kmos ran %s steps and the next process is "%s"' %
                    (steps, process))
            print('  on site %s,  however this causes oops' % site)
            print('  on site %s because it trys to' % err_site)
            print('  replace "%s" by "%s" but it will find "%s".' %
                  (old, new, found))
            print('  Go fish!')

        else:
            if steps is not None:
                self.do_steps(steps)
            else:
                steps = base.get_kmc_step()
            nprocess, nsite = proclist.get_kmc_step()
            process = list(
                sorted(settings.rate_constants.keys()))[nprocess - 1]
            site = self.nr2site(nsite)

            res = "kmos ran %s steps and next it will execute\n" % steps
            res += "process '%s' on site %s." % (process, site)
            print(res)

            if propagate:
                proclist.run_proc_nr(nprocess, nsite)
Esempio n. 5
0
File: run.py Progetto: 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
Esempio n. 6
0
File: run.py Progetto: 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