Skip to content

Commit

Permalink
bug: fixed reading TSHS files
Browse files Browse the repository at this point in the history
The ISC array offsets were read as C ordered arrays, but f2py returns
F ordered arrays.

Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Feb 23, 2017
1 parent b4cec55 commit 8f843e1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
0.8.X
=====

- Fix a bug when reading non-Gamma TSHS files, now the
supercell information is correct.

- tbtncSileSiesta now distinguishes between:
electronic_temperature [K]
and
Expand Down
18 changes: 15 additions & 3 deletions sisl/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1779,24 +1779,36 @@ def osc2uc(self, orbs, uniq=False):

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

def a2sc(self, a):
"""
Returns the super-cell offset for a specific atom
"""
return self.sc_offset(self.sc.sc_off[self.a2isc(a), :])

def o2isc(self, o):
"""
Returns the super-cell index for a specific orbital.
Hence one can easily figure out the supercell
Returns a vector of 3 numbers with integers.
"""
o = ensure_array(o)
idx = np.where(o < self.no * np.arange(1, self.n_s + 1))[0][0]
return self.sc.sc_off[idx, :]

def o2sc(self, o):
"""
Returns the super-cell offset for a specific orbital.
"""
return self.sc_offset(self.sc.sc_off[self.o2isc(o), :])

@classmethod
def fromASE(cls, aseg):
""" Returns geometry from an ASE object.
Expand Down
11 changes: 6 additions & 5 deletions sisl/io/siesta/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ def read_sc(self):

n_s = _siesta.read_tshs_sizes(self.file)[3]
arr = _siesta.read_tshs_cell(self.file, n_s)
nsc = np.array(arr[0], np.int32)
cell = np.array(arr[1], np.float64)
nsc = np.array(arr[0].T, np.int32)
cell = np.array(arr[1].T, np.float64)
cell.shape = (3, 3)
isc = np.array(arr[2], np.int32)
sc = np.array(arr[2], np.float64)
isc = np.array(arr[2].T, np.int32)
isc.shape = (-1, 3)

SC = SuperCell(cell, nsc=nsc)
SC.sc_off = np.dot(sc.T, cell.T)
SC.sc_off = isc
return SC

def read_geom(self):
Expand Down Expand Up @@ -109,6 +109,7 @@ def read_es(self, **kwargs):

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

Expand Down
3 changes: 1 addition & 2 deletions sisl/supercell.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def rotate(self, angle, v, only='abc', radians=False):
return self.__class__(cell, nsc=np.copy(self.nsc))

def offset(self, isc=None):
""" Returns the supercell offset of the supercell index
"""
""" Returns the supercell offset of the supercell index """
if isc is None:
return np.array([0, 0, 0], np.float64)
return np.dot(isc, self.cell)
Expand Down

0 comments on commit 8f843e1

Please sign in to comment.