Esempio n. 1
0
    def check_state(self, atoms, tol=1e-15):
        """Check for system changes since last calculation."""
        def compare_dict(d1, d2):
            """Helper function to compare dictionaries"""
            # Use symmetric difference to find keys which aren't shared
            # for python 2.7 compatiblity
            if set(d1.keys()) ^ set(d2.keys()):
                return False

            # Check for differences in values
            for key, value in d1.items():
                if np.any(value != d2[key]):
                    return False
            return True

        # First we check for default changes
        system_changes = FileIOCalculator.check_state(self, atoms, tol=tol)

        # We now check if we have made any changes to the input parameters
        # XXX: Should we add these parameters to all_changes?
        for param_string, old_dict in self.param_state.items():
            param_dict = getattr(self, param_string)  # Get current param dict
            if not compare_dict(param_dict, old_dict):
                system_changes.append(param_string)

        return system_changes
Esempio n. 2
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell for molecules:
     if not atoms.pbc.any() and 'cell' in system_changes:
         system_changes.remove('cell')
     if self.pcpot and self.pcpot.mmpositions is not None:
         system_changes.append('positions')
     return system_changes
Esempio n. 3
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell for molecules:
     if not atoms.pbc.any() and 'cell' in system_changes:
         system_changes.remove('cell')
     if self.pcpot and self.pcpot.mmpositions is not None:
         system_changes.append('positions')
     return system_changes
Esempio n. 4
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell and boundary conditions:
     if 'cell' in system_changes:
         system_changes.remove('cell')
     if 'pbc' in system_changes:
         system_changes.remove('pbc')
     return system_changes
Esempio n. 5
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell and boundary conditions:
     if 'cell' in system_changes:
         system_changes.remove('cell')
     if 'pbc' in system_changes:
         system_changes.remove('pbc')
     return system_changes
Esempio n. 6
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell and boundary conditions:
     if "cell" in system_changes:
         system_changes.remove("cell")
     if "pbc" in system_changes:
         system_changes.remove("pbc")
     return system_changes
Esempio n. 7
0
    def check_state(self, atoms):
        system_changes = FileIOCalculator.check_state(self, atoms)

        ignore = ['cell', 'pbc']
        for change in system_changes:
            if change in ignore:
                system_changes.remove(change)

        return system_changes
Esempio n. 8
0
    def check_state(self, atoms):
        system_changes = FileIOCalculator.check_state(self, atoms)

        ignore = ['cell', 'pbc']
        for change in system_changes:
            if change in ignore:
                system_changes.remove(change)

        return system_changes
    def check_state(self, atoms=None):
        """Check if any changes exist that require new calculations."""
        if atoms is None:
            atoms = self.get_atoms()

        log.debug('atoms IMM: {}'.format(atoms.get_initial_magnetic_moments()))
        system_changes = FileIOCalculator.check_state(self, atoms)
        # Ignore boundary conditions:
        if 'pbc' in system_changes:
            system_changes.remove('pbc')

        s = 'FileIOCalculator reports these changes: {}'
        log.debug(s.format(system_changes))
        # if dir is empty, there is nothing to read here.
        if self.get_state() == Vasp.EMPTY:
            return system_changes

        # Check if the parameters have changed
        file_params = {}
        file_params.update(self.read_incar())

        if 'rwigs' in file_params:
            # This gets read as a list.
            with open(self.potcar) as f:
                lines = f.readlines()

            # symbols are in the # FIXME: first line of each potcar
            symbols = [lines[0].split()[1]]
            for i, line in enumerate(lines):
                if 'End of Dataset' in line and i != len(lines) - 1:
                    symbols += [lines[i + 1].split()[1]]

            file_params['rwigs'] = dict(
                list(zip(symbols, file_params['rwigs'])))
        file_params.update(self.read_potcar())
        file_params.update(self.read_kpoints())

        xc_keys = sorted(Vasp.xc_defaults,
                         key=lambda k: len(Vasp.xc_defaults[k]),
                         reverse=True)

        for ex in xc_keys:
            pd = {k: file_params.get(k, None) for k in Vasp.xc_defaults[ex]}
            if pd == Vasp.xc_defaults[ex]:
                file_params['xc'] = ex.lower()
                break

        # reconstruct ldau_luj if necessary
        if 'ldauu' in file_params:
            ldaul = file_params['ldaul']
            ldauj = file_params['ldauj']
            ldauu = file_params['ldauu']

            with open(self.potcar) as f:
                lines = f.readlines()

            # symbols are in the first line of each potcar
            symbols = [lines[0].split()[1]]
            for i, line in enumerate(lines):
                if 'End of Dataset' in line and i != len(lines) - 1:
                    symbols += [lines[i + 1].split()[1]]

            ldau_luj = {}
            for sym, l, j, u in zip(symbols, ldaul, ldauj, ldauu):
                ldau_luj[sym] = {'L': l, 'U': u, 'J': j}

            file_params['ldau_luj'] = ldau_luj

        if not {
                k: v
                for k, v in list(self.parameters.items()) if v is not None
        } == file_params:
            new_keys = set(self.parameters.keys()) - set(file_params.keys())
            missing_keys = (set(file_params.keys()) -
                            set(self.parameters.keys()))
            log.debug('New keys: {}'.format(new_keys))
            log.debug('Missing keys: {}'.format(missing_keys))
            log.debug('params_on_file do not match.')
            log.debug('file-params: {}'.format(file_params))
            log.debug('compared to: {}'.format({
                k: v
                for k, v in list(self.parameters.items()) if v is not None
            }))
            system_changes += ['params_on_file']

        log.debug('System changes: {}'.format(system_changes))
        return system_changes
Esempio n. 10
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore boundary conditions (ELK always uses them):
     if 'pbc' in system_changes:
         system_changes.remove('pbc')
     return system_changes
Esempio n. 11
0
	def check_state(self, atoms):	
		# from the standard ase.calculators 
                system_changes = FileIOCalculator.check_state(self, atoms)
                return system_changes
Esempio n. 12
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell for molecules:
     if not atoms.pbc.any() and 'cell' in system_changes:
         system_changes.remove('cell')
     return system_changes
Esempio n. 13
0
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     return system_changes
Esempio n. 14
0
File: aims.py Progetto: PHOTOX/fuase
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore unit cell for molecules:
     if not atoms.pbc.any() and 'cell' in system_changes:
         system_changes.remove('cell')
     return system_changes
Esempio n. 15
0
File: elk.py Progetto: PHOTOX/fuase
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore boundary conditions (ELK always uses them):
     if 'pbc' in system_changes:
         system_changes.remove('pbc')
     return system_changes
Esempio n. 16
0
File: mopac.py Progetto: grhawk/ASE
 def check_state(self, atoms):
     system_changes = FileIOCalculator.check_state(self, atoms)
     return system_changes
Esempio n. 17
0
 def check_state(self, atoms, tol=1e-15):
     system_changes = FileIOCalculator.check_state(self, atoms)
     # Ignore boundary conditions:
     if 'pbc' in system_changes:
         system_changes.remove('pbc')
     return system_changes
Esempio n. 18
0
    def check_state(self, atoms=None):
        """Check if any changes exist that require new calculations."""
        if atoms is None:
            atoms = self.get_atoms()

        log.debug('atoms IMM: {}'.format(atoms.get_initial_magnetic_moments()))
        system_changes = FileIOCalculator.check_state(self, atoms)
        # Ignore boundary conditions:
        if 'pbc' in system_changes:
            system_changes.remove('pbc')

        s = 'FileIOCalculator reports these changes: {}'
        log.debug(s.format(system_changes))
        # if dir is empty, there is nothing to read here.
        if self.get_state() == Vasp.EMPTY:
            return system_changes

        # Check if the parameters have changed
        file_params = {}
        file_params.update(self.read_incar())
        file_params.update(self.read_potcar())
        file_params.update(self.read_kpoints())

        xc_keys = sorted(Vasp.xc_defaults,
                         key=lambda k: len(Vasp.xc_defaults[k]),
                         reverse=True)

        for ex in xc_keys:
            pd = {k: file_params.get(k, None)
                  for k in Vasp.xc_defaults[ex]}
            if pd == Vasp.xc_defaults[ex]:
                file_params['xc'] = ex.lower()
                break

        # reconstruct ldau_luj if necessary
        if 'ldauu' in file_params:
            ldaul = file_params['ldaul']
            ldauj = file_params['ldauj']
            ldauu = file_params['ldauu']

            with open(self.potcar) as f:
                lines = f.readlines()

            # symbols are in the first line of each potcar
            symbols = [lines[0].split()[1]]
            for i, line in enumerate(lines):
                if 'End of Dataset' in line and i != len(lines) - 1:
                    symbols += [lines[i + 1].split()[1]]

            ldau_luj = {}
            for sym, l, j, u in zip(symbols, ldaul, ldauj, ldauu):
                ldau_luj[sym] = {'L': l, 'U': u, 'J': j}

            file_params['ldau_luj'] = ldau_luj

        if not {k: v for k, v in self.parameters.iteritems()
                if v is not None} == file_params:
            new_keys = set(self.parameters.keys()) - set(file_params.keys())
            missing_keys = (set(file_params.keys()) -
                            set(self.parameters.keys()))
            log.debug('New keys: {}'.format(new_keys))
            log.debug('Missing keys: {}'.format(missing_keys))
            log.debug('params_on_file do not match.')
            log.debug('file-params: {}'.format(file_params))
            log.debug('compared to: {}'.format({k: v for k, v in
                                                self.parameters.iteritems()
                                                if v is not None}))
            system_changes += ['params_on_file']

        log.debug('System changes: {}'.format(system_changes))
        return system_changes