[ase-users] FixAtoms doesn't have an indices parameter?

Jens Jørgen Mortensen jensj at fysik.dtu.dk
Fri Jun 3 15:18:24 CEST 2016


On 05/18/2016 04:00 PM, John Kitchin wrote:
> Here is the example.
>
> #+BEGIN_SRC python
> from ase.structure import molecule
> import numpy as np
> from ase.constraints import FixAtoms
>
> atoms = molecule('NH3')
> constraint = FixAtoms(mask=[atom.symbol == 'N' for atom in atoms])
> atoms.set_constraint(constraint)
>
> print atoms[np.array([1, 2, 3, 0])]
> #+END_SRC
>
> This came up because I was reading the indices from an ase-db which
> returns the list as an array.
>
> The slice2enlist checks for a list or tuple, and since an array went in,
> it gets passed to the third line of the function.

Thanks.  I've fixed it in the latest master branch.

Jens Jørgen

>
> Jens Jørgen Mortensen writes:
>
>> Den 17-05-2016 kl. 23:29 skrev John Kitchin via ase-users:
>>> That is partly right. If you try to resort with an array you get this
>>> error.
>> Can you create a simple example that shows this error?
>>
>> Jens Jørgen
>>
>>> On Tuesday, May 17, 2016, Ask Hjorth Larsen <asklarsen at gmail.com
>>> <mailto:asklarsen at gmail.com>> wrote:
>>>
>>>      Hi
>>>
>>>      2016-05-17 3:16 GMT+02:00 John Kitchin via ase-users
>>>      <ase-users at listserv.fysik.dtu.dk <javascript:;>>:
>>>      > I got this error after I read a POSCAR in that had a fixed atom,
>>>      then I
>>>      > tried resorting it. Does this make sense? Shouldn't the FixAtoms
>>>      constraint
>>>      > have an indices attribute?
>>>      >
>>>      >   File
>>>      "/home-research/jkitchin/kitchin-python/vasp/vasp/readers.py", line
>>>      > 305, in read
>>>      >     atoms = atoms[self.resort]
>>>      >   File "/opt/kitchingroup/vasp-5.3.5/ase-s16/ase/atoms.py", line
>>>      893, in
>>>      > __getitem__
>>>      >     con.index_shuffle(self, i)
>>>      >   File
>>>      "/opt/kitchingroup/vasp-5.3.5/ase-s16/ase/constraints.py", line 130,
>>>      > in index_shuffle
>>>      >     for new, old in slice2enlist(ind, len(atoms)):
>>>      >   File
>>>      "/opt/kitchingroup/vasp-5.3.5/ase-s16/ase/constraints.py", line 23,
>>>      > in slice2enlist
>>>      >     return enumerate(range(*s.indices(n)))
>>>      > AttributeError: 'numpy.ndarray' object has no attribute 'indices'
>>>      > John
>>>
>>>      Judging from the error message, the problem is that 's' by some
>>>      mistake is a numpy array and not a FixAtoms.
>>>
>>>      Best regards
>>>      Ask
>>>
>>>      >
>>>      > -----------------------------------
>>>      > Professor John Kitchin
>>>      > Doherty Hall A207F
>>>      > Department of Chemical Engineering
>>>      > Carnegie Mellon University
>>>      > Pittsburgh, PA 15213
>>>      > 412-268-7803
>>>      > @johnkitchin
>>>      > http://kitchingroup.cheme.cmu.edu
>>>      >
>>>      >
>>>      > _______________________________________________
>>>      > ase-users mailing list
>>>      > ase-users at listserv.fysik.dtu.dk <javascript:;>
>>>      > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>>
>>>
>>>
>>> --
>>> John
>>>
>>> -----------------------------------
>>> Professor John Kitchin
>>> Doherty Hall A207F
>>> Department of Chemical Engineering
>>> Carnegie Mellon University
>>> Pittsburgh, PA 15213
>>> 412-268-7803
>>> @johnkitchin
>>> http://kitchingroup.cheme.cmu.edu
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ase-users mailing list
>>> ase-users at listserv.fysik.dtu.dk
>>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
> --
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu



More information about the ase-users mailing list