Commit b0825885 authored by Joseph Weston's avatar Joseph Weston
Browse files

use 'norbs' returned by 'hamiltonian_submatrix' in 'kpm.conductivity'

This does not require assuming that site families have 'norbs' set.

Closes #313.
parent 5b2bc6a4
......@@ -1051,10 +1051,11 @@ def _velocity(hamiltonian, params, op_type, positions):
elif isinstance(op_type, str):
direction = directions[op_type]
if isinstance(hamiltonian, system.System):
operator = hamiltonian.hamiltonian_submatrix(params=params,
sparse=True)
positions = np.array([site.pos for site in hamiltonian.sites
for iorb in range(site.family.norbs)])
operator, norbs, norbs = hamiltonian.hamiltonian_submatrix(
params=params, sparse=True, return_norb=True
)
positions = np.vstack([[hamiltonian.pos(i)] * norb
for i, norb in enumerate(norbs)])
elif positions is not None:
operator = coo_matrix(hamiltonian, copy=True)
displacements = positions[operator.col] - positions[operator.row]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment