Skip to content

Commit 8f843e1

Browse files
committed
bug: fixed reading TSHS files
The ISC array offsets were read as C ordered arrays, but f2py returns F ordered arrays. Signed-off-by: Nick Papior <nickpapior@gmail.com>
1 parent b4cec55 commit 8f843e1

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
0.8.X
22
=====
33

4+
- Fix a bug when reading non-Gamma TSHS files, now the
5+
supercell information is correct.
6+
47
- tbtncSileSiesta now distinguishes between:
58
electronic_temperature [K]
69
and

sisl/geometry.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,24 +1779,36 @@ def osc2uc(self, orbs, uniq=False):
17791779

17801780
def a2isc(self, a):
17811781
"""
1782-
Returns the super-cell index for a specific atom
1782+
Returns the super-cell index for a specific/list atom
17831783
1784-
Hence one can easily figure out the supercell
1784+
Returns a vector of 3 numbers with integers.
17851785
"""
17861786
a = ensure_array(a)
17871787
idx = np.where(a < self.na * np.arange(1, self.n_s + 1))[0][0]
17881788
return self.sc.sc_off[idx, :]
17891789

1790+
def a2sc(self, a):
1791+
"""
1792+
Returns the super-cell offset for a specific atom
1793+
"""
1794+
return self.sc_offset(self.sc.sc_off[self.a2isc(a), :])
1795+
17901796
def o2isc(self, o):
17911797
"""
17921798
Returns the super-cell index for a specific orbital.
17931799
1794-
Hence one can easily figure out the supercell
1800+
Returns a vector of 3 numbers with integers.
17951801
"""
17961802
o = ensure_array(o)
17971803
idx = np.where(o < self.no * np.arange(1, self.n_s + 1))[0][0]
17981804
return self.sc.sc_off[idx, :]
17991805

1806+
def o2sc(self, o):
1807+
"""
1808+
Returns the super-cell offset for a specific orbital.
1809+
"""
1810+
return self.sc_offset(self.sc.sc_off[self.o2isc(o), :])
1811+
18001812
@classmethod
18011813
def fromASE(cls, aseg):
18021814
""" Returns geometry from an ASE object.

sisl/io/siesta/binaries.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def read_sc(self):
3333

3434
n_s = _siesta.read_tshs_sizes(self.file)[3]
3535
arr = _siesta.read_tshs_cell(self.file, n_s)
36-
nsc = np.array(arr[0], np.int32)
37-
cell = np.array(arr[1], np.float64)
36+
nsc = np.array(arr[0].T, np.int32)
37+
cell = np.array(arr[1].T, np.float64)
3838
cell.shape = (3, 3)
39-
isc = np.array(arr[2], np.int32)
40-
sc = np.array(arr[2], np.float64)
39+
isc = np.array(arr[2].T, np.int32)
40+
isc.shape = (-1, 3)
4141

4242
SC = SuperCell(cell, nsc=nsc)
43-
SC.sc_off = np.dot(sc.T, cell.T)
43+
SC.sc_off = isc
4444
return SC
4545

4646
def read_geom(self):
@@ -109,6 +109,7 @@ def read_es(self, **kwargs):
109109

110110
H._data._D = np.empty([nnz, spin+1], np.float64)
111111
for i in range(spin):
112+
# this is because of the F-ordering
112113
H._data._D[:, i] = dH[:, i]
113114
H._data._D[:, spin] = dS[:]
114115

sisl/supercell.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ def rotate(self, angle, v, only='abc', radians=False):
196196
return self.__class__(cell, nsc=np.copy(self.nsc))
197197

198198
def offset(self, isc=None):
199-
""" Returns the supercell offset of the supercell index
200-
"""
199+
""" Returns the supercell offset of the supercell index """
201200
if isc is None:
202201
return np.array([0, 0, 0], np.float64)
203202
return np.dot(isc, self.cell)

0 commit comments

Comments
 (0)