[ase-users] Constraints issue in vasp calculator

Protik Das protik77 at gmail.com
Tue Mar 28 19:20:03 CEST 2017


Oh, I see. That must have been missed while copying. Sorry for the
misunderstanding.

Your solution worked perfectly. I used my code in my local machine to
create a POSCAR and worked. But was showing the error while using with vasp.

Thanks!

On Tue, Mar 28, 2017 at 7:29 AM Eric Hermes <ehermes at chem.wisc.edu> wrote:

> On Mon, 2017-03-27 at 20:09 +0000, Protik Das wrote:
> > The error I posted is indeed the full error message. Here is a script
> > that reproduces the error:
> >
> > from ase.build import mx2
> > from ase.constraints import FixedPlane
> > import numpy as np
> > from ase.calculators.vasp import Vasp
> >
> > calc = Vasp(prec = 'Accurate',
> >     pp = 'pbe',
> >     istart=0,
> >     ismear=1,
> >     sigma=0.01,
> >     lcharg=False,
> >     lwave=False,
> >     lreal = False,
> >     encut = 550,
> >     algo='Normal',
> >     ncore=10,
> >     ediff=1e-6,
> >     ibrion=1,
> >     nsw=150,
> >     isym=0,
> >     nelmin=4,
> >     nelm=200,
> >     ediffg=-0.01,
> >     ivdw=1,
> >     isif=2,
> >     kpts = [8, 8, 1],
> >     gamma=True)
> >
> > mx2 = mx2(formula='MoS2', kind='1T', a=3.179, thickness=3.86,
> > size=(1,1,1),
> >           vacuum=1.5)
> > mx2.center(vacuum=15, axis=2)
> > plane = FixedPlane(range(len(mx2)), (0, 0, 1))
> > mx2.set_constraint(plane)
> > interface = mx2.copy()
> > mx2.set_calculator(calc)
> > energ1 = mx2.get_potential_energy()
> >
> > And the error:
> >
> > Traceback (most recent call last):
> >   File "isif.py", line 44, in <module>
> >     energ1 = mx2.get_potential_energy()
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/atoms.py", line 682, in get_potential_energy
> >     energy = self._calc.get_potential_energy(self)
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/calculators/vasp.py", line 835, in get_potential_energy
> >     self.update(atoms)
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/calculators/vasp.py", line 492, in update
> >     self.calculate(atoms)
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/calculators/vasp.py", line 684, in calculate
> >     self.initialize(atoms)
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/calculators/vasp.py", line 592, in initialize
> >     self.atoms_sorted = atoms[self.sort]
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/atoms.py", line 949, in __getitem__
> >     con.index_shuffle(self, i)
> >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > packages/ase/constraints.py", line 86, in index_shuffle
> >     if old == self.a:
> > ValueError: The truth value of an array with more than one element is
> > ambiguous. Use a.any() or a.all()
> >
>
> Not to belabor the point, but your initial email only had the traceback
> and didn't contain the actual error message :)
>
> FixedPlane is a FixConstraintSingle, and as such only takes a single
> atom index as an argument. Try doing the following instead:
>
> plane = [FixedPlane(atom.index, (0, 0, 1)) for atom in mx2]
> mx2.set_constraint(plane)
>
>
> >
> >
> > On Mon, Mar 27, 2017 at 7:07 AM Eric Hermes <ehermes at chem.wisc.edu>
> > wrote:
> > > On Mon, 2017-03-27 at 07:21 +0000, Protik Das via ase-users wrote:
> > > > Hi,
> > > >
> > > > I am using ase in a python 3.6 environment to do some vasp
> > > > calculations. I am using plane constraint to fix all the atoms in
> > > z
> > > > direction. I am getting the following error before the
> > > calculation
> > > > starts:
> > > >
> > > > Traceback (most recent call last):
> > > >   File "isif.py", line 109, in <module>
> > > >     energ1 = interface.get_potential_energy()
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/atoms.py", line 682, in get_potential_energy
> > > >     energy = self._calc.get_potential_energy(self)
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/calculators/vasp.py", line 835, in
> > > get_potential_energy
> > > >     self.update(atoms)
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/calculators/vasp.py", line 492, in update
> > > >     self.calculate(atoms)
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/calculators/vasp.py", line 684, in calculate
> > > >     self.initialize(atoms)
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/calculators/vasp.py", line 592, in initialize
> > > >     self.atoms_sorted = atoms[self.sort]
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/atoms.py", line 949, in __getitem__
> > > >     con.index_shuffle(self, i)
> > > >   File "/home/protik/anaconda3/envs/ase/lib/python3.6/site-
> > > > packages/ase/constraints.py", line 86, in index_shuffle
> > > >     if old == self.a:
> > > >
> > > > I tried using the equal function from ase.calculators.calculator,
> > > but
> > > > that did not work. Any help regarding this?
> > > > --
> > > > Protik Das,
> > > > ECE Graduate Student,
> > > > LATTE (http://latte.ece.ucr.edu),
> > > > University of California, Riverside.
> > > > _______________________________________________
> > > > ase-users mailing list
> > > > ase-users at listserv.fysik.dtu.dk
> > > > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> > >
> > > Could you please post the *full* error message, as well as a short
> > > script that exhibits the problem?
> > >
> > > Eric
> > --
> > Protik Das,
> > ECE Graduate Student,
> > LATTE (http://latte.ece.ucr.edu),
> > University of California, Riverside.

-- 
Protik Das,
ECE Graduate Student,
LATTE (http://latte.ece.ucr.edu),
University of California, Riverside.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20170328/5c77e9ef/attachment-0001.html>


More information about the ase-users mailing list