File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from pymatgen .io .vasp import Outcar
1+ from pymatgen .io .vasp import Oszicar , Outcar
22
3- __all__ = ["parse_total_magnetization" , "parse_last_total_magnetization " ]
3+ __all__ = ["MagnetizationParser " ]
44
55
6- def parse_total_magnetization (file ):
7- try :
8- outcar = Outcar (file )
9- data = outcar .magnetization
10- if not data :
6+ class MagnetizationParser :
7+ @staticmethod
8+ def from_outcar (file ):
9+ try :
10+ outcar = Outcar (file )
11+ data = outcar .magnetization
12+ if not data :
13+ return None
14+ return sum (datum ["tot" ] for datum in data )
15+ except Exception :
16+ return None
17+
18+ @staticmethod
19+ def from_oszicar (file ):
20+ try :
21+ oszicar = Oszicar (file )
22+ last_step = oszicar .ionic_steps [- 1 ]
23+ mag = last_step .get ("mag" , None )
24+ return mag
25+ except Exception :
1126 return None
12- # Sum the "tot" field for all atoms
13- return sum (datum ["tot" ] for datum in data )
14- except Exception :
15- return None
You can’t perform that action at this time.
0 commit comments