diff --git a/xtb/ase/calculator.py b/xtb/ase/calculator.py index c893f59..5a2f187 100644 --- a/xtb/ase/calculator.py +++ b/xtb/ase/calculator.py @@ -47,6 +47,8 @@ Keyword Default Description ======================== ============ ============================================ method "GFN2-xTB" Underlying method for energy and forces + charge None Total charge of the system + multiplicity None Total multiplicity of the system accuracy 1.0 Numerical accuracy of the calculation electronic_temperature 300.0 Electronic temperatur for TB methods max_iterations 250 Iterations for self-consistent evaluation @@ -132,6 +134,22 @@ def set(self, **kwargs) -> dict: return changed_parameters + @property + def _charge(self) -> int: + return ( + self.atoms.get_initial_charges().sum() + if self.parameters.charge is None + else self.parameters.charge + ) + + @property + def _uhf(self) -> int: + return ( + int(self.atoms.get_initial_magnetic_moments().sum().round()) + if self.parameters.multiplicity is None + else self.parameters.multiplicity - 1 + ) + def _check_parameters(self, parameters: dict) -> None: """Verifiy provided parameters are valid""" @@ -187,8 +205,8 @@ def _create_api_calculator(self) -> Calculator: 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()) + _charge = self._charge + _uhf = self._uhf calc = Calculator( _method,