Пример #1
0
    def get_property(self, name, atoms=None, allow_calculation=True):
        dft_result = None
        if self.dft is not None:
            dft_result = self.dft.get_property(name, atoms, allow_calculation)

        dftd3_result = Calculator.get_property(self, name, atoms, allow_calculation)

        if dft_result is None and dftd3_result is None:
            return None
        elif dft_result is None:
            return dftd3_result
        elif dftd3_result is None:
            return dft_result
        else:
            return dft_result + dftd3_result
Пример #2
0
    def get_property(self, name, atoms=None, allow_calculation=True):
        """Taken from the dftd3-calculator in ASE.

        Here we are performing the dispersion correction first,
        if it fails the time for the DFT calculation is not wasted."""

        self_result = Calculator.get_property(self, name, atoms,
                                              allow_calculation)
        calc_result = None
        if self.calc is not None:
            calc_result = self.calc.get_property(name, atoms,
                                                 allow_calculation)
            # little hack for get_potential_energy bypassing this routine
            # in case of force_consistent=True
            if 'free_energy' in self.calc.results:
                # in case we request 'free_energy' with get_property,
                # it will work the first time, the second call will pile
                # up 'free_energy' in the results-array of the dispersion
                # correction and return a wrong value...
                self.results['free_energy'] = self.results['energy'] \
                                              + self.calc.results['free_energy']
                # so here is a really ugly fix to also account for this case
                # -> fix the calculator interface, pls.
                if name == 'free_energy':
                    self_result = self.results['free_energy']
                    calc_result = None
            else:
                del self.results['free_energy']

        if calc_result is None and self_result is None:
            return None
        if calc_result is None:
            return self_result
        if self_result is None:
            return calc_result
        return calc_result + self_result