stress.py 648 Bytes
Newer Older
1
import numpy as np
2
from ase.build import bulk
tolsen's avatar
tolsen committed
3 4 5 6 7
from ase.optimize.bfgs import BFGS
from ase.constraints import UnitCellFilter
from gpaw import GPAW
from gpaw import PW

8
si = bulk('Si', 'fcc', a=6.0)
tolsen's avatar
tolsen committed
9 10
# Experimental Lattice constant is a=5.421 A

11 12 13 14 15
si.calc = GPAW(xc='PBE',
               mode=PW(400, dedecut='estimate'),
               kpts=(4, 4, 4),
               # convergence={'eigenstates': 1.e-10},  # converge tightly!
               txt='stress.txt')
tolsen's avatar
tolsen committed
16

17
uf = UnitCellFilter(si)
tolsen's avatar
tolsen committed
18
relax = BFGS(uf)
dulak's avatar
dulak committed
19
relax.run(fmax=0.05)  # Consider much tighter fmax!
tolsen's avatar
tolsen committed
20

21 22
a = np.linalg.norm(si.cell[0]) * 2**0.5
print('Relaxed lattice parameter: a = {} Ang'.format(a))