Get forces information in OUTCAR

Create OutCar object


In [1]:
from vaspy.iter import OutCar

outcar = OutCar('OUTCAR')

Iterate force info in OUTCAR


In [2]:
# Only get force information in the first step here
for f in outcar.iforces:
    if f.step == 1:
        break

Force info item


In [3]:
f


Out[3]:
ForceItem(step=1, coordinates=[[1.78441, 0.85618, 2.29204], [0.16369, 0.85618, 4.58407], [0.97405, -0.5474, 0.0], [0.97405, -0.5474, 6.87611], [4.21548, -0.5474, 2.29204], [2.59476, -0.5474, 4.58407], [3.40512, -1.95098, 0.0], [3.40512, -1.95098, 6.87611], [6.64655, -1.95098, 2.29204], [5.02584, -1.95098, 4.58407], [5.83619, -3.35456, 0.0], [5.83619, -3.35456, 6.87611], [1.78441, 3.66334, 2.29204], [0.16369, 3.66334, 4.58407], [0.97405, 2.25976, 0.0], [0.97405, 2.25976, 6.87611], [4.21548, 2.25976, 2.29204], [2.59476, 2.25976, 4.58407], [3.40512, 0.85618, 0.0], [3.40512, 0.85618, 6.87611], [6.64655, 0.85618, 2.29204], [5.02584, 0.85618, 4.58407], [5.83619, -0.5474, 0.0], [5.83619, -0.5474, 6.87611], [1.78441, 6.4705, 2.29204], [0.16369, 6.4705, 4.58407], [0.97405, 5.06692, 0.0], [0.97405, 5.06692, 6.87611], [4.21548, 5.06692, 2.29204], [2.59476, 5.06692, 4.58407], [3.40512, 3.66334, 0.0], [3.40512, 3.66334, 6.87611], [6.64655, 3.66334, 2.29204], [5.02584, 3.66334, 4.58407], [5.83619, 2.25976, 0.0], [5.83619, 2.25976, 6.87611]], forces=[[-0.0, 0.0, 0.243298], [0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [-0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [-0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [0.0, -0.0, -0.243458], [-0.0, 0.0, -0.103119], [-0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [-0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [-0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [-0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, -0.0, 0.103279], [-0.0, 0.0, 0.243298], [0.0, -0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, 0.0, 0.103279], [-0.0, 0.0, 0.243298], [0.0, 0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, 0.0, 0.103279], [-0.0, 0.0, 0.243298], [0.0, -0.0, -0.243458], [-0.0, 0.0, -0.103119], [0.0, 0.0, 0.103279]])

Force info item includes 3 attributes

ionic step number


In [4]:
f.step


Out[4]:
1

current coordinates of atoms


In [5]:
f.coordinates


Out[5]:
[[1.78441, 0.85618, 2.29204],
 [0.16369, 0.85618, 4.58407],
 [0.97405, -0.5474, 0.0],
 [0.97405, -0.5474, 6.87611],
 [4.21548, -0.5474, 2.29204],
 [2.59476, -0.5474, 4.58407],
 [3.40512, -1.95098, 0.0],
 [3.40512, -1.95098, 6.87611],
 [6.64655, -1.95098, 2.29204],
 [5.02584, -1.95098, 4.58407],
 [5.83619, -3.35456, 0.0],
 [5.83619, -3.35456, 6.87611],
 [1.78441, 3.66334, 2.29204],
 [0.16369, 3.66334, 4.58407],
 [0.97405, 2.25976, 0.0],
 [0.97405, 2.25976, 6.87611],
 [4.21548, 2.25976, 2.29204],
 [2.59476, 2.25976, 4.58407],
 [3.40512, 0.85618, 0.0],
 [3.40512, 0.85618, 6.87611],
 [6.64655, 0.85618, 2.29204],
 [5.02584, 0.85618, 4.58407],
 [5.83619, -0.5474, 0.0],
 [5.83619, -0.5474, 6.87611],
 [1.78441, 6.4705, 2.29204],
 [0.16369, 6.4705, 4.58407],
 [0.97405, 5.06692, 0.0],
 [0.97405, 5.06692, 6.87611],
 [4.21548, 5.06692, 2.29204],
 [2.59476, 5.06692, 4.58407],
 [3.40512, 3.66334, 0.0],
 [3.40512, 3.66334, 6.87611],
 [6.64655, 3.66334, 2.29204],
 [5.02584, 3.66334, 4.58407],
 [5.83619, 2.25976, 0.0],
 [5.83619, 2.25976, 6.87611]]

forces on all atoms


In [6]:
f.forces


Out[6]:
[[-0.0, 0.0, 0.243298],
 [0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [-0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [-0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [0.0, -0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [-0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [-0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [-0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [-0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, -0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [0.0, -0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, 0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [0.0, 0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, 0.0, 0.103279],
 [-0.0, 0.0, 0.243298],
 [0.0, -0.0, -0.243458],
 [-0.0, 0.0, -0.103119],
 [0.0, 0.0, 0.103279]]

Get the maximum force


In [7]:
natom, force = outcar.fmax(f.forces)  # atom number, force vector along x y z axis

In [8]:
natom


Out[8]:
2

In [9]:
force


Out[9]:
[0.0, 0.0, -0.243458]