Skip to content

Commit 07fa7aa

Browse files
committed
bug: fixed #207, spin-box change-gauge requires repeat
Signed-off-by: Nick Papior <[email protected]>
1 parent 1399f33 commit 07fa7aa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sisl/physics/electron.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,13 @@ def change_gauge(self, gauge):
17941794
g = self.parent.geometry
17951795
phase = dot(g.xyz[g.o2a(_a.arangei(g.no)), :], dot(k, g.rcell))
17961796

1797+
try:
1798+
if self.parent.spin.has_noncolinear:
1799+
# for NC/SOC we have a 2x2 spin-box per orbital
1800+
phase = np.repeat(phase, 2)
1801+
except:
1802+
pass
1803+
17971804
if gauge == 'r':
17981805
self.state *= np.exp(1j * phase).reshape(1, -1)
17991806
elif gauge == 'R':

sisl/physics/tests/test_hamiltonian.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,10 @@ def test_non_colinear1(self, setup):
979979
DOS = es.DOS(np.linspace(-1, 1, 100))
980980
assert np.allclose(PDOS.sum(1)[0, :], DOS)
981981

982+
# Ensure we can change gauge for NC stuff
983+
es.change_gauge('R')
984+
es.change_gauge('r')
985+
982986
def test_non_colinear_non_orthogonal(self, setup):
983987
g = Geometry([[i, 0, 0] for i in range(10)], Atom(6, R=1.01), sc=SuperCell(100, nsc=[3, 3, 1]))
984988
H = Hamiltonian(g, dtype=np.float64, orthogonal=False, spin=Spin.NONCOLINEAR)
@@ -1081,6 +1085,10 @@ def test_so1(self, setup):
10811085
DOS = es.DOS(np.linspace(-1, 1, 100))
10821086
assert np.allclose(PDOS.sum(1)[0, :], DOS)
10831087

1088+
# Ensure we can change gauge for SO stuff
1089+
es.change_gauge('R')
1090+
es.change_gauge('r')
1091+
10841092
def test_finalized(self, setup):
10851093
assert not setup.H.finalized
10861094
setup.H.H[0, 0] = 1.

0 commit comments

Comments
 (0)