[ase-users] Question about calculators

Eric Smoll ericsmoll at gmail.com
Mon Nov 10 03:13:16 CET 2014


Hello ASE users,

There are two errors in the "get_charges" method of the "Atoms" class that
prevents calculators from returning charge information to the atoms class
via the calculator "get_charge()" method.

This is the original:

 601     def get_charges(self):
 602         """Get calculated charges."""
 603         if self._calc is None:
 604             raise RuntimeError('Atoms object has no calcula
 605         try:
 606             charges = self._calc.get_charges(self)
 607         except AttributeError:
 608             raise NotImplementedError

This is a corrected version:

 601     def get_charges(self):
 602         """Get calculated charges."""
 603         if self._calc is None:
 604             raise RuntimeError('Atoms object has no calcula
 605         try:
 606             charges = self._calc.get_charges()
 607         except AttributeError:
 608             raise NotImplementedError
 609         return charges

I made two edits. 1.) There was no return statement so even if a
NotImplementedError was not thrown, nothing was returned.
2.) the "get_charges" method on line 606 has 2 references to "self."

Best,
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20141109/441e3ef7/attachment.html>


More information about the ase-users mailing list