Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
kwant
kwant
Commits
3979c0cc
Commit
3979c0cc
authored
13 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
check for Hamiltonian hermiticity (catch a potentially common error)
Conflicts: kwant/solvers/sparse.py
parent
2cc0bff0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwant/solvers/sparse.py
+10
-0
10 additions, 0 deletions
kwant/solvers/sparse.py
kwant/system.py
+2
-0
2 additions, 0 deletions
kwant/system.py
with
12 additions
and
0 deletions
kwant/solvers/sparse.py
+
10
−
0
View file @
3979c0cc
...
...
@@ -119,6 +119,10 @@ def make_linear_sys(sys, out_leads, in_leads, energy=0,
h_sys
=
sys
.
hamiltonian_submatrix
(
sparse
=
True
).
tocsc
()
h_sys
=
h_sys
-
energy
*
sp
.
identity
(
h_sys
.
shape
[
0
],
format
=
'
csc
'
)
# Hermiticity check.
if
np
.
any
(
np
.
abs
((
h_sys
-
h_sys
.
T
.
conj
()).
data
)
>
1e-13
):
raise
ValueError
(
'
System Hamiltonian is not Hermitian.
'
)
norb
,
num_nodes
=
sys
.
num_orbitals
,
sys
.
graph
.
num_nodes
norb_arr
=
np
.
array
([
norb
(
i
)
for
i
in
xrange
(
num_nodes
)],
int
)
offsets
=
np
.
zeros
(
norb_arr
.
shape
[
0
]
+
1
,
int
)
...
...
@@ -135,6 +139,12 @@ def make_linear_sys(sys, out_leads, in_leads, energy=0,
lead
=
sys
.
leads
[
leadnum
]
if
isinstance
(
lead
,
system
.
InfiniteSystem
)
and
not
force_realspace
:
h
=
lead
.
slice_hamiltonian
()
# Hermiticity check.
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
()
if
not
np
.
any
(
v
):
...
...
This diff is collapsed.
Click to expand it.
kwant/system.py
+
2
−
0
View file @
3979c0cc
...
...
@@ -268,6 +268,8 @@ class InfiniteSystem(System):
"""
result
=
Energies
()
result
.
ham
=
self
.
slice_hamiltonian
()
if
not
np
.
allclose
(
result
.
ham
,
result
.
ham
.
T
.
conj
()):
raise
ValueError
(
'
The slice Hamiltonian is not Hermitian.
'
)
hop
=
self
.
inter_slice_hopping
()
result
.
hop
=
np
.
empty
(
result
.
ham
.
shape
,
dtype
=
complex
)
result
.
hop
[:,
:
hop
.
shape
[
1
]]
=
hop
...
...
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