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): ...@@ -1051,10 +1051,11 @@ def _velocity(hamiltonian, params, op_type, positions):
elif isinstance(op_type, str): elif isinstance(op_type, str):
direction = directions[op_type] direction = directions[op_type]
if isinstance(hamiltonian, system.System): if isinstance(hamiltonian, system.System):
operator = hamiltonian.hamiltonian_submatrix(params=params, operator, norbs, norbs = hamiltonian.hamiltonian_submatrix(
sparse=True) params=params, sparse=True, return_norb=True
positions = np.array([site.pos for site in hamiltonian.sites )
for iorb in range(]) positions = np.vstack([[hamiltonian.pos(i)] * norb
for i, norb in enumerate(norbs)])
elif positions is not None: elif positions is not None:
operator = coo_matrix(hamiltonian, copy=True) operator = coo_matrix(hamiltonian, copy=True)
displacements = positions[operator.col] - positions[operator.row] displacements = positions[operator.col] - positions[operator.row]
Supports Markdown
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