Beispiel #1
0
    def _create_api_calculator(self) -> Calculator:
        """Create a new API calculator object"""

        _method = get_method(self.parameters.method)
        if _method is None:
            raise ase_calc.InputError("Invalid method {} provided".format(
                self.parameters.method))

        try:
            _cell = self.atoms.cell
            _periodic = self.atoms.pbc
            _charge = self.atoms.get_initial_charges().sum()
            _uhf = int(self.atoms.get_initial_magnetic_moments().sum().round())

            calc = Calculator(
                _method,
                self.atoms.numbers,
                self.atoms.positions / Bohr,
                _charge,
                _uhf,
                _cell / Bohr,
                _periodic,
            )
            calc.set_verbosity(VERBOSITY_MUTED)
            calc.set_accuracy(self.parameters.accuracy)
            calc.set_electronic_temperature(
                self.parameters.electronic_temperature)
            calc.set_max_iterations(self.parameters.max_iterations)
            calc.set_solvent(get_solvent(self.parameters.solvent))

        except XTBException:
            raise ase_calc.InputError("Cannot construct calculator for xtb")

        return calc
Beispiel #2
0
    def _check_parameters(self, parameters: dict) -> None:
        """Verifiy provided parameters are valid"""

        if "method" in parameters and get_method(parameters["method"]) is None:
            raise ase_calc.InputError(
                "Invalid method {} provided".format(parameters["method"])
            )