|
我自己写了一小段代码,看了一下你最后一步的力是7e-3左右,下面的代码我没有考虑原子固定的情况,实际上要处理固定也不麻烦,欢迎坛友有兴趣自己来扩展。
- import sys
- import re
- from io import StringIO
- import numpy as np
- """
- 使用方法:python3 get_max_forces.py OUTCAR
- """
- class VaspData(object):
- def __init__(self, outcar) -> None:
- self.outcar = outcar
- @property
- def max_forces(self):
- pattern = '(.*?)'.join(['TOTAL-FORCE \(eV/Angst\)\n ?-+\n',
- '-+\n +total drift'])
- string = re.findall(pattern, self.outcar, re.S)
- forces = [np.loadtxt(StringIO(s)).reshape(-1, 6)[:, 3:]
- for s in string]
- max_forces = [np.max(np.linalg.norm(f, axis=1)) for f in forces]
- return max_forces
- if __name__ == '__main__':
- with open(sys.argv[1]) as f:
- outcar = f.read()
- outputs = VaspData(outcar)
- for i, fmax in enumerate(outputs.max_forces):
- print('%5d %.3e' % (i, fmax))
复制代码
|
|