@@ -1637,6 +1637,9 @@ def __init__(self, filename):
1637
1637
mag_x = []
1638
1638
mag_y = []
1639
1639
mag_z = []
1640
+ orbmom_x = []
1641
+ orbmom_y = []
1642
+ orbmom_z = []
1640
1643
header = []
1641
1644
run_stats = {}
1642
1645
total_mag = nelect = efermi = e_fr_energy = e_wo_entrp = e0 = None
@@ -1705,9 +1708,12 @@ def __init__(self, filename):
1705
1708
read_mag_x = False
1706
1709
read_mag_y = False # for SOC calculations only
1707
1710
read_mag_z = False
1711
+ read_orbmom_x = False # For SOC calculations with LORBMOM=.TRUE.
1712
+ read_orbmom_y = False
1713
+ read_orbmom_z = False
1708
1714
all_lines .reverse ()
1709
1715
for clean in all_lines :
1710
- if read_charge or read_mag_x or read_mag_y or read_mag_z :
1716
+ if read_charge or read_mag_x or read_mag_y or read_mag_z or read_orbmom_x or read_orbmom_y or read_orbmom_z :
1711
1717
if clean .startswith ("# of ion" ):
1712
1718
header = re .split (r"\s{2,}" , clean .strip ())
1713
1719
header .pop (0 )
@@ -1724,29 +1730,102 @@ def __init__(self, filename):
1724
1730
mag_y .append (dict (zip (header , tokens )))
1725
1731
elif read_mag_z :
1726
1732
mag_z .append (dict (zip (header , tokens )))
1733
+ elif read_orbmom_x :
1734
+ orbmom_x .append (dict (zip (header , tokens )))
1735
+ elif read_orbmom_y :
1736
+ orbmom_y .append (dict (zip (header , tokens )))
1737
+ elif read_orbmom_z :
1738
+ orbmom_z .append (dict (zip (header , tokens )))
1727
1739
elif clean .startswith ("tot" ):
1728
1740
read_charge = False
1729
1741
read_mag_x = False
1730
1742
read_mag_y = False
1731
1743
read_mag_z = False
1744
+ read_orbmom_x = False
1745
+ read_orbmom_y = False
1746
+ read_orbmom_z = False
1732
1747
if clean == "total charge" :
1733
1748
charge = []
1734
1749
read_charge = True
1735
- read_mag_x , read_mag_y , read_mag_z = False , False , False
1750
+ read_mag_x , read_mag_y , read_mag_z , read_orbmom_x , read_orbmom_y , read_orbmom_z = (
1751
+ False ,
1752
+ False ,
1753
+ False ,
1754
+ False ,
1755
+ False ,
1756
+ False ,
1757
+ )
1736
1758
elif clean == "magnetization (x)" :
1737
1759
mag_x = []
1738
1760
read_mag_x = True
1739
- read_charge , read_mag_y , read_mag_z = False , False , False
1761
+ read_charge , read_mag_y , read_mag_z , read_orbmom_x , read_orbmom_y , read_orbmom_z = (
1762
+ False ,
1763
+ False ,
1764
+ False ,
1765
+ False ,
1766
+ False ,
1767
+ False ,
1768
+ )
1740
1769
elif clean == "magnetization (y)" :
1741
1770
mag_y = []
1742
1771
read_mag_y = True
1743
- read_charge , read_mag_x , read_mag_z = False , False , False
1772
+ read_charge , read_mag_x , read_mag_z , read_orbmom_x , read_orbmom_y , read_orbmom_z = (
1773
+ False ,
1774
+ False ,
1775
+ False ,
1776
+ False ,
1777
+ False ,
1778
+ False ,
1779
+ )
1744
1780
elif clean == "magnetization (z)" :
1745
1781
mag_z = []
1746
1782
read_mag_z = True
1747
- read_charge , read_mag_x , read_mag_y = False , False , False
1783
+ read_charge , read_mag_x , read_mag_y , read_orbmom_x , read_orbmom_y , read_orbmom_z = (
1784
+ False ,
1785
+ False ,
1786
+ False ,
1787
+ False ,
1788
+ False ,
1789
+ False ,
1790
+ )
1791
+ elif clean == "orbital moment (x)" :
1792
+ orbmom_x = []
1793
+ read_orbmom_x = True
1794
+ read_charge , read_mag_x , read_mag_y , read_mag_z , read_orbmom_y , read_orbmom_z = (
1795
+ False ,
1796
+ False ,
1797
+ False ,
1798
+ False ,
1799
+ False ,
1800
+ False ,
1801
+ )
1802
+ elif clean == "orbital moment (y)" :
1803
+ orbmom_y = []
1804
+ read_orbmom_y = True
1805
+ read_charge , read_mag_x , read_mag_y , read_mag_z , read_orbmom_x , read_orbmom_z = (
1806
+ False ,
1807
+ False ,
1808
+ False ,
1809
+ False ,
1810
+ False ,
1811
+ False ,
1812
+ )
1813
+ elif clean == "orbital moment (z)" :
1814
+ orbmom_z = []
1815
+ read_orbmom_z = True
1816
+ read_charge , read_mag_x , read_mag_y , read_mag_z , read_orbmom_x , read_orbmom_y = (
1817
+ False ,
1818
+ False ,
1819
+ False ,
1820
+ False ,
1821
+ False ,
1822
+ False ,
1823
+ )
1748
1824
elif re .search ("electrostatic" , clean ):
1749
- read_charge , read_mag_x , read_mag_y , read_mag_z = (
1825
+ read_charge , read_mag_x , read_mag_y , read_mag_z , read_orbmom_x , read_orbmom_y , read_orbmom_z = (
1826
+ False ,
1827
+ False ,
1828
+ False ,
1750
1829
False ,
1751
1830
False ,
1752
1831
False ,
@@ -1761,6 +1840,13 @@ def __init__(self, filename):
1761
1840
mag .append ({key : Magmom ([mag_x [idx ][key ], mag_y [idx ][key ], mag_z [idx ][key ]]) for key in mag_x [0 ]})
1762
1841
else :
1763
1842
mag = mag_x
1843
+ # merge x, y and z components of orbmoms if present (SOC calculation with LORBMOM=.TRUE.)
1844
+ orbmom = []
1845
+ if orbmom_x and orbmom_y and orbmom_z :
1846
+ for idx in range (len (orbmom_x )):
1847
+ orbmom .append (
1848
+ {key : Magmom ([orbmom_x [idx ][key ], orbmom_y [idx ][key ], orbmom_z [idx ][key ]]) for key in orbmom_x [0 ]}
1849
+ )
1764
1850
1765
1851
# data from beginning of OUTCAR
1766
1852
run_stats ["cores" ] = None
@@ -1780,6 +1866,7 @@ def __init__(self, filename):
1780
1866
1781
1867
self .run_stats = run_stats
1782
1868
self .magnetization = tuple (mag )
1869
+ self .orbital_moment = tuple (orbmom )
1783
1870
self .charge = tuple (charge )
1784
1871
self .efermi = efermi
1785
1872
self .nelect = nelect
0 commit comments