Closed prtkm closed 9 years ago
This is a known "feature" if you change the number of atoms after adding constraints bad things happen. It is an ase issue, not a jasp one.
That's strange. If I use write_vasp from ase.io.vasp I get Identical POSCARs in both cases.
**\ 1
from ase.lattice.surface import fcc111, add_adsorbate from ase.constraints import FixAtoms from ase.io.vasp import write_vasp
metals = ['Au'] positions = ['ontop']
for metal in metals: for position in positions: atoms = fcc111(metal, size=(2,2,4), vacuum=10.0) constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint) add_adsorbate(atoms, 'H', height=1.2, position=position) write_vasp('POSCAR-1'.format(metal, position), atoms)
cat POSCAR-1
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 27.0667672948810143 16 1 Selective dynamics Cartesian 0.0000000000000000 0.0000000000000000 10.0000000000000000 F F F 2.8849956672411143 0.0000000000000000 10.0000000000000000 F F F 1.4424978336205572 2.4984795376388416 10.0000000000000000 F F F 4.3274935008616717 2.4984795376388416 10.0000000000000000 F F F 1.4424978336205572 0.8328265125462805 12.3555890982936738 F F F 4.3274935008616717 0.8328265125462805 12.3555890982936738 F F F 2.8849956672411143 3.3313060501851219 12.3555890982936738 F F F 5.7699913344822287 3.3313060501851219 12.3555890982936738 F F F 0.0000000000000000 1.6656530250925610 14.7111781965873476 T T T 2.8849956672411148 1.6656530250925610 14.7111781965873476 T T T 1.4424978336205569 4.1641325627314023 14.7111781965873476 T T T 4.3274935008616717 4.1641325627314023 14.7111781965873476 T T T 0.0000000000000000 0.0000000000000000 17.0667672948810178 T T T 2.8849956672411143 0.0000000000000000 17.0667672948810178 T T T 1.4424978336205572 2.4984795376388416 17.0667672948810178 T T T 4.3274935008616717 2.4984795376388416 17.0667672948810178 T T T 0.0000000000000000 0.0000000000000000 18.2667672948810171 T T T
**\ 2
from ase.lattice.surface import fcc111, add_adsorbate from ase.constraints import FixAtoms from ase.io.vasp import write_vasp
metals = ['Au'] positions = ['ontop']
for metal in metals: for position in positions: atoms = fcc111(metal, size=(2,2,4), vacuum=10.0) add_adsorbate(atoms, 'H', height=1.2, position=position) constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint) write_vasp('POSCAR-2'.format(metal, position), atoms)
cat POSCAR-2
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 27.0667672948810143 16 1 Selective dynamics Cartesian 0.0000000000000000 0.0000000000000000 10.0000000000000000 F F F 2.8849956672411143 0.0000000000000000 10.0000000000000000 F F F 1.4424978336205572 2.4984795376388416 10.0000000000000000 F F F 4.3274935008616717 2.4984795376388416 10.0000000000000000 F F F 1.4424978336205572 0.8328265125462805 12.3555890982936738 F F F 4.3274935008616717 0.8328265125462805 12.3555890982936738 F F F 2.8849956672411143 3.3313060501851219 12.3555890982936738 F F F 5.7699913344822287 3.3313060501851219 12.3555890982936738 F F F 0.0000000000000000 1.6656530250925610 14.7111781965873476 T T T 2.8849956672411148 1.6656530250925610 14.7111781965873476 T T T 1.4424978336205569 4.1641325627314023 14.7111781965873476 T T T 4.3274935008616717 4.1641325627314023 14.7111781965873476 T T T 0.0000000000000000 0.0000000000000000 17.0667672948810178 T T T 2.8849956672411143 0.0000000000000000 17.0667672948810178 T T T 1.4424978336205572 2.4984795376388416 17.0667672948810178 T T T 4.3274935008616717 2.4984795376388416 17.0667672948810178 T T T 0.0000000000000000 0.0000000000000000 18.2667672948810171 T T T
diff POSCAR-1 POSCAR-2
That does make it sound like a jasp issue then ;)
I cannot recall any way that jasp modifies how these are written out though.
A better question is what happens if you use ase.calculators.vasp instead of jasp. does the same thing happen?
Prateek Mehta writes:
That's strange. If I use write_vasp from ase.io.vasp I get Identical POSCARs in both cases.
**\ 1
+BEGIN_SRC python
from ase.lattice.surface import fcc111, add_adsorbate from ase.constraints import FixAtoms from ase.io.vasp import write_vasp
metals = ['Au'] positions = ['ontop']
for metal in metals: for position in positions: atoms = fcc111(metal, size=(2,2,4), vacuum=10.0) constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint) add_adsorbate(atoms, 'H', height=1.2, position=position) write_vasp('POSCAR-1'.format(metal, position), atoms)
+END_SRC
+RESULTS:
+BEGIN_SRC sh
cat POSCAR-1
+END_SRC
+RESULTS:
+begin_example
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 27.0667672948810143 16 1 Selective dynamics Cartesian 0.0000000000000000 0.0000000000000000 10.0000000000000000 F F F 2.8849956672411143 0.0000000000000000 10.0000000000000000 F F F 1.4424978336205572 2.4984795376388416 10.0000000000000000 F F F 4.3274935008616717 2.4984795376388416 10.0000000000000000 F F F 1.4424978336205572 0.8328265125462805 12.3555890982936738 F F F 4.3274935008616717 0.8328265125462805 12.3555890982936738 F F F 2.8849956672411143 3.3313060501851219 12.3555890982936738 F F F 5.7699913344822287 3.3313060501851219 12.3555890982936738 F F F 0.0000000000000000 1.6656530250925610 14.7111781965873476 T T T 2.8849956672411148 1.6656530250925610 14.7111781965873476 T T T 1.4424978336205569 4.1641325627314023 14.7111781965873476 T T T 4.3274935008616717 4.1641325627314023 14.7111781965873476 T T T 0.0000000000000000 0.0000000000000000 17.0667672948810178 T T T 2.8849956672411143 0.0000000000000000 17.0667672948810178 T T T 1.4424978336205572 2.4984795376388416 17.0667672948810178 T T T 4.3274935008616717 2.4984795376388416 17.0667672948810178 T T T 0.0000000000000000 0.0000000000000000 18.2667672948810171 T T T
+end_example
**\ 2
+BEGIN_SRC python
from ase.lattice.surface import fcc111, add_adsorbate from ase.constraints import FixAtoms from ase.io.vasp import write_vasp
metals = ['Au'] positions = ['ontop']
for metal in metals: for position in positions: atoms = fcc111(metal, size=(2,2,4), vacuum=10.0) add_adsorbate(atoms, 'H', height=1.2, position=position) constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint) write_vasp('POSCAR-2'.format(metal, position), atoms)
+END_SRC
+RESULTS:
+BEGIN_SRC sh
cat POSCAR-2
+END_SRC
+RESULTS:
+begin_example
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 27.0667672948810143 16 1 Selective dynamics Cartesian 0.0000000000000000 0.0000000000000000 10.0000000000000000 F F F 2.8849956672411143 0.0000000000000000 10.0000000000000000 F F F 1.4424978336205572 2.4984795376388416 10.0000000000000000 F F F 4.3274935008616717 2.4984795376388416 10.0000000000000000 F F F 1.4424978336205572 0.8328265125462805 12.3555890982936738 F F F 4.3274935008616717 0.8328265125462805 12.3555890982936738 F F F 2.8849956672411143 3.3313060501851219 12.3555890982936738 F F F 5.7699913344822287 3.3313060501851219 12.3555890982936738 F F F 0.0000000000000000 1.6656530250925610 14.7111781965873476 T T T 2.8849956672411148 1.6656530250925610 14.7111781965873476 T T T 1.4424978336205569 4.1641325627314023 14.7111781965873476 T T T 4.3274935008616717 4.1641325627314023 14.7111781965873476 T T T 0.0000000000000000 0.0000000000000000 17.0667672948810178 T T T 2.8849956672411143 0.0000000000000000 17.0667672948810178 T T T 1.4424978336205572 2.4984795376388416 17.0667672948810178 T T T 4.3274935008616717 2.4984795376388416 17.0667672948810178 T T T 0.0000000000000000 0.0000000000000000 18.2667672948810171 T T T
+end_example
+BEGIN_SRC sh
diff POSCAR-1 POSCAR-2
+END_SRC
+RESULTS:
Reply to this email directly or view it on GitHub: https://github.com/jkitchin/jasp/issues/31#issuecomment-74802488
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
I think in jasp and in ase.calculators.vasp there is some resorting the atoms during construction of the POTCARs which probably messes things up.
The initialize function here is probably where the "feature" is. https://trac.fysik.dtu.dk/projects/ase/browser/trunk/ase/calculators/vasp.py#L428
I'll check with ase.calculators.vasp and let you know. I have a feeling that it will give me the same error.
Interestingly, write_vasp with sort=True preserves the constraints in both cases.
I just checked, the error is in ase.calculators.vasp.
Constraints are written(or not written) to POSCAR depending on the order you add adsorbates!
\ Set constraints before adding adsorbates: Works Fine
+BEGIN_SRC python
from ase.lattice.surface import fcc111, add_adsorbate from jasp import * from ase.constraints import FixAtoms
atoms = fcc111('Au', size=(2,2,3), vacuum=10.0) add_adsorbate(atoms, 'H', height=1.2, position='fcc') constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint)
print atoms.constraints
with jasp('Debugging/test-constraint-1', atoms = atoms, xc = 'PW91', encut=300, ismear=1) as calc:
+END_SRC
+RESULTS:
: [FixAtoms(mask=[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, ...])]
+BEGIN_SRC sh
cat Debugging/test-constraint-1/POSCAR
+END_SRC
+RESULTS:
+begin_example
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 24.7111781965873476 12 1 Selective dynamics Cartesian 1.4424978336205572 0.8328265125462805 10.0000000000000000 F F F 4.3274935008616717 0.8328265125462805 10.0000000000000000 F F F 2.8849956672411143 3.3313060501851219 10.0000000000000000 F F F 5.7699913344822287 3.3313060501851219 10.0000000000000000 F F F 0.0000000000000000 1.6656530250925610 12.3555890982936738 T T T 2.8849956672411148 1.6656530250925610 12.3555890982936738 T T T 1.4424978336205569 4.1641325627314023 12.3555890982936738 T T T 4.3274935008616717 4.1641325627314023 12.3555890982936738 T T T 0.0000000000000000 0.0000000000000000 14.7111781965873476 T T T 2.8849956672411143 0.0000000000000000 14.7111781965873476 T T T 1.4424978336205572 2.4984795376388416 14.7111781965873476 T T T 4.3274935008616717 2.4984795376388416 14.7111781965873476 T T T 1.4424978336205572 0.8328265125462805 15.9111781965873469 T T T
+end_example
\ Add adsorbate before setting constraints: Fails
+BEGIN_SRC python
from ase.lattice.surface import fcc111, add_adsorbate from jasp import * from ase.constraints import FixAtoms
atoms = fcc111('Au', size=(2,2,3), vacuum=10.0) constraint = FixAtoms(mask=[atom.tag >=3 for atom in atoms]) atoms.set_constraint(constraint) add_adsorbate(atoms, 'H', height=1.2, position='fcc')
print atoms.constraints
with jasp('Debugging/test-constraint-2', atoms = atoms, xc = 'PW91', encut=300, ismear=1) as calc:
+END_SRC
+RESULTS:
: [FixAtoms(mask=[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, ...])]
+BEGIN_SRC sh
cat Debugging/test-constraint-2/POSCAR
+END_SRC
+RESULTS:
+begin_example
Au H 1.0000000000000000 5.7699913344822287 0.0000000000000000 0.0000000000000000 2.8849956672411143 4.9969590752776831 0.0000000000000000 0.0000000000000000 0.0000000000000000 24.7111781965873476 12 1 Cartesian 1.4424978336205572 0.8328265125462805 10.0000000000000000 4.3274935008616717 0.8328265125462805 10.0000000000000000 2.8849956672411143 3.3313060501851219 10.0000000000000000 5.7699913344822287 3.3313060501851219 10.0000000000000000 0.0000000000000000 1.6656530250925610 12.3555890982936738 2.8849956672411148 1.6656530250925610 12.3555890982936738 1.4424978336205569 4.1641325627314023 12.3555890982936738 4.3274935008616717 4.1641325627314023 12.3555890982936738 0.0000000000000000 0.0000000000000000 14.7111781965873476 2.8849956672411143 0.0000000000000000 14.7111781965873476 1.4424978336205572 2.4984795376388416 14.7111781965873476 4.3274935008616717 2.4984795376388416 14.7111781965873476 1.4424978336205572 0.8328265125462805 15.9111781965873469
+end_example