Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Wimmer
kwant
Commits
9a07efd5
Commit
9a07efd5
authored
12 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
move modes calculation out of the solvers
parent
0edb95b4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/solvers/common.py
+5
-16
5 additions, 16 deletions
kwant/solvers/common.py
kwant/system.py
+16
-1
16 additions, 1 deletion
kwant/system.py
with
21 additions
and
17 deletions
kwant/solvers/common.py
+
5
−
16
View file @
9a07efd5
...
...
@@ -168,27 +168,16 @@ class SparseSolver(object):
lead_info
=
[]
for
leadnum
,
interface
in
enumerate
(
sys
.
lead_interfaces
):
lead
=
sys
.
leads
[
leadnum
]
if
isinstance
(
lead
,
system
.
InfiniteSystem
)
and
not
force_realspace
:
h
=
lead
.
slice_hamiltonian
(
args
=
args
)
if
check_hermiticity
:
if
not
np
.
allclose
(
h
,
h
.
T
.
conj
(),
rtol
=
1e-13
):
msg
=
"
Lead number {0} has a non-Hermitian
"
\
"
slice Hamiltonian.
"
raise
ValueError
(
msg
.
format
(
leadnum
))
h
-=
energy
*
np
.
identity
(
h
.
shape
[
0
])
v
=
lead
.
inter_slice_hopping
(
args
=
args
)
modes
=
physics
.
modes
(
h
,
v
)
if
hasattr
(
lead
,
'
modes
'
)
and
not
force_realspace
:
modes
=
lead
.
modes
(
energy
,
args
=
args
)
lead_info
.
append
(
modes
)
u
,
ulinv
,
nprop
,
svd_v
=
modes
# Note: np.any(v) returns (at least from NumPy 1.6.1 -
# 1.8-devel) False if v is purely imaginary
if
not
(
np
.
any
(
v
.
real
)
or
np
.
any
(
v
.
imag
)):
if
len
(
u
)
==
0
:
# See comment about zero-shaped sparse matrices at the top.
rhs
.
append
(
np
.
zeros
((
lhs
.
shape
[
1
],
0
)))
continue
u
,
ulinv
,
nprop
,
svd_v
=
modes
if
svd_v
is
not
None
:
svd_v
=
svd_v
.
T
.
conj
()
...
...
This diff is collapsed.
Click to expand it.
kwant/system.py
+
16
−
1
View file @
9a07efd5
...
...
@@ -68,7 +68,8 @@ class FiniteSystem(System):
Instance Variables
------------------
leads : sequence of lead objects
Each lead object has to provide a method ``self_energy(energy, args)``.
Each lead object has to provide a method ``self_energy(energy, args)``
or ``modes(energy, args)`` which calculates its self-energy or modes.
lead_interfaces : sequence of sequences of integers
Each sub-sequence contains the indices of the system sites to which the
lead is connected.
...
...
@@ -145,6 +146,20 @@ class InfiniteSystem(System):
return
self
.
hamiltonian_submatrix
(
slice_sites
,
neighbor_sites
,
sparse
=
sparse
,
args
=
args
)
def
modes
(
self
,
energy
,
args
=
()):
"""
Return self-energy of a lead.
The returned matrix has the shape (n, n), where n is
``sum(self.num_orbitals(i) for i in range(self.slice_size))``.
"""
ham
=
self
.
slice_hamiltonian
(
args
=
args
)
shape
=
ham
.
shape
assert
len
(
shape
)
==
2
assert
shape
[
0
]
==
shape
[
1
]
# Subtract energy from the diagonal.
ham
.
flat
[::
ham
.
shape
[
0
]
+
1
]
-=
energy
return
physics
.
modes
(
ham
,
self
.
inter_slice_hopping
(
args
=
args
))
def
self_energy
(
self
,
energy
,
args
=
()):
"""
Return self-energy of a lead.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment