[ase-users] ase-users Digest, Vol 114, Issue 11
fabian
Fabian.T89 at web.de
Thu Jan 18 15:24:35 CET 2018
Hi,
If i use this code :
import numpy as np
from ase import Atoms
from ase.io import read
from ase.visualize import view
from ase.constraints import FixAtoms
from ase.io import write
from ase.utils.geometry import wrap_positions
atoms = read('POSCAR') # The first one in the previous mail
indices = np.arange(len(atoms))
indices[38] = 0
indices[0] = 38
atoms[indices]
print(atoms)
write('POSCAR_NEW', atoms, vasp5=True, sort=True,
direct=True,long_format=True, format='vasp')
to generate the case were the Co atom is first, i get this error:
CURRENTPATH>shuffleatoms.py
Traceback (most recent call last):
File "CURRENTPATH\shuffleatoms.py", line 14, in <module>
atoms[indices]
File "PYTHONPATH\Python27\lib\site-packages\ase\atoms.py", line 877,
in __getitem__
con.index_shuffle(self, i)
File "PYTHONPATH)\Python27\lib\site-packages\ase\constraints.py",
line 133, in index_shuffle
for new, old in slice2enlist(ind, len(atoms)):
File "PYTHONPATH\Python27\lib\site-packages\ase\constraints.py", line
22, in slice2enlist
return enumerate(range(*s.indices(n)))
AttributeError: 'numpy.ndarray' object has no attribute 'indices'
I abbreviated some pathes as they are really long...
Can this be related to the fact that i use an older version of ASE on my PC?
Ifi add
atoms.set_constraint(None)
before
indices = np.arange(len(atoms))
It works but the constraints are gone.
Al the best
fabian
Am 18.01.2018 um 14:26 schrieb Ask Hjorth Larsen:
> Hi,
>
> 2018-01-18 11:13 GMT+01:00 fabian <Fabian.T89 at web.de>:
>> Dear Ask
>>
>>
>> Here are two example files in POSCAR format to illustrate my problem:
>>
>> The initial file looks like this and i want to move the Atom with the number
>> 138 ( Co ) and Nr 28 (Ag) to the
>> top position. I want to do this for core level calculations in VASP. Line 1
>> , 6 and 7 need to
>> be changed accordingly. The constraints should be kept.
>>
>> This is the original file:
> (snip)
>
> Okay, so I try to do an arbitrary permutation, e.g.:
>
> from ase.io import read
> import numpy as np
>
> atoms = read('POSCAR') # The first one in the previous mail
> indices = np.arange(len(atoms))
> indices[6] = 0
> indices[0] = 6
> atoms[indices]
> print(atoms)
>
> The above works for me and keeps the constraints. Which exact
> permutation causes the problem?
>
> Best regards
> Ask
More information about the ase-users
mailing list