-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcheckmag.py
More file actions
executable file
·21 lines (18 loc) · 817 Bytes
/
checkmag.py
File metadata and controls
executable file
·21 lines (18 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/env python3
from pymatgen.io.vasp.outputs import Outcar
from math import fabs
import sys
import argparse
parser = argparse.ArgumentParser()
parser.description='Report ion magnetization data from a VASP OUTCAR file'
parser.add_argument( '-o', '--outcar', help='OUTCAR file to read from', default='OUTCAR' )
parser.add_argument( '-t', '--threshold', help='only report magnetic moments larger than this threshold.', default=0.5, type=float )
if __name__ == '__main__':
args = parser.parse_args()
try:
outcar = Outcar( args.outcar )
except:
raise
selected_atoms = [ [ i, m ] for i, m in enumerate( outcar.magnetization ) if fabs( m['tot'] ) > args.threshold ]
for a in selected_atoms:
print( a[0]+1, ' '.join( [ "{}: {}".format( k, a[1][k] ) for k in a[1] ] ) )