[ase-users] Question about calculators

Jakob Schiøtz schiotz at fysik.dtu.dk
Mon Nov 10 08:23:01 CET 2014


Your first edit, the return statement, is of course correct.  The fix has apparently already been made in the code (quite recent change, the return statement is inside the try clause, but that is ok).

The second is not correct.  You need the two selfs, the first one self._calc identifies the calculator.  The second self is passed as an argument to the calculator, as one calculator may be used for several atoms, so it needs to know which atoms it is operating on.

Thank you very much for your bug report!

Best regards

Jakob



On 10 Nov 2014, at 3:13, Eric Smoll ericsmoll at gmail.com wrote:

> 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
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users

--
Jakob Schiøtz, professor, Ph.D.
Department of Physics
Technical University of Denmark
DK-2800 Kongens Lyngby, Denmark
http://www.fysik.dtu.dk/~schiotz/







More information about the ase-users mailing list