[ase-users] SyntaxError: non-keyword arg after keyword arg

Punit Kumar ip.punit.2016 at gmail.com
Sat Dec 31 06:34:31 CET 2016

Hi, all
I am trying to calculate initial and final state for dissociative
adsorption of hydrogen molecule on Ni surface. For that the code I have
written is

from __future__ import print_function
from ase import Atoms
from ase.build import fcc111, add_adsorbate
from ase.calculators.emt import EMT
from ase.constraints import FixAtoms
from ase.optimize import QuasiNewton
from ase.io import write
from math import sin, pi

# Find the initial and final states for the reaction.

# Set up a (2 x 2 x 3) three layer slab of Ni:
slab = fcc111('Ni',size=(2, 2, 3))
a = slab.get_distance(0,1)
slab.center(vacuum=6, axis=2)
slab.set_pbc((True, True, True))

# Initial state.
d = 0.74 # H2 bond length
H2mol = Atoms('H2', positions=[(0, 0, 0), (0, 0, d)])
H2mol.set_pbc((True, True, True))

# adsorption of H-atom on Ni fcc site
fcc_1 = [a/2., a*sin(pi/3.)/3.]
add_adsorbate(slab, H2mol, height=0.85, fcc_1)

# Use the EMT calculator for the forces and energies:

# fix the bottom two layer
constraint = FixAtoms(mask=[i.tag > 1 for i in slab])

# Relax the structure
dyn = QuasiNewton(slab, trajectory='H2.traj')

fd = open('adsorption.txt', 'w')
print('initial state:', slab.get_potential_energy())

# Now the final state.
# Move the second H atom to a neighboring hollow site:
slab[-1].position[0] = slab[-2].position[0] + 0.25 * slab.cell[0,0]
slab[-1].position[1] = slab[-2].position[1]

# Relax the structure
dyn = QuasiNewton(slab, trajectory='2H.traj')

fd = open('dissociation.txt', 'w')
print('final state:  ', slab.get_potential_energy())

but when I run this code it gives me syntax error as

File "H2_dissociation_Ni.py", line 25
    add_adsorbate(slab, H2mol, height=0.85, fcc_1)
SyntaxError: non-keyword arg after keyword arg

Can someone help me where I am doing it wrong.

Thank You
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20161231/0f06ccb6/attachment.html>

More information about the ase-users mailing list