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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Joseph Weston
kwant
Commits
708d1a3e
Commit
708d1a3e
authored
10 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
indeed allow out_leads and in_leads to be general sequences
parent
73231c91
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kwant/solvers/common.py
+19
-15
19 additions, 15 deletions
kwant/solvers/common.py
with
19 additions
and
15 deletions
kwant/solvers/common.py
+
19
−
15
View file @
708d1a3e
# Copyright 2011-201
3
Kwant authors.
# Copyright 2011-201
4
Kwant authors.
#
# This file is part of Kwant. It is subject to the license terms in the
# LICENSE file found in the top-level directory of this distribution and at
...
...
@@ -326,11 +326,13 @@ class SparseSolver(object):
n
=
len
(
sys
.
lead_interfaces
)
if
in_leads
is
None
:
in_leads
=
range
(
n
)
else
:
in_leads
=
list
(
in_leads
)
if
out_leads
is
None
:
out_leads
=
range
(
n
)
if
(
sorted
(
in_leads
)
!=
in_leads
or
sorted
(
out_leads
)
!=
out_leads
or
len
(
set
(
in_leads
))
!=
len
(
in
_leads
)
or
len
(
set
(
out
_leads
)
)
!
=
len
(
out_leads
)):
else
:
out_leads
=
list
(
out
_leads
)
if
(
np
.
any
(
np
.
diff
(
in
_leads
)
<
=
0
)
or
np
.
any
(
np
.
diff
(
out_leads
)
<=
0
)
):
raise
ValueError
(
"
Lead lists must be sorted and
"
"
with unique entries.
"
)
if
len
(
in_leads
)
==
0
or
len
(
out_leads
)
==
0
:
...
...
@@ -409,11 +411,13 @@ class SparseSolver(object):
n
=
len
(
sys
.
lead_interfaces
)
if
in_leads
is
None
:
in_leads
=
range
(
n
)
else
:
in_leads
=
list
(
in_leads
)
if
out_leads
is
None
:
out_leads
=
range
(
n
)
if
(
sorted
(
in_leads
)
!=
in_leads
or
sorted
(
out_leads
)
!=
out_leads
or
len
(
set
(
in_leads
))
!=
len
(
in
_leads
)
or
len
(
set
(
out
_leads
)
)
!
=
len
(
out_leads
)):
else
:
out_leads
=
list
(
out
_leads
)
if
(
np
.
any
(
np
.
diff
(
in
_leads
)
<
=
0
)
or
np
.
any
(
np
.
diff
(
out_leads
)
<=
0
)
):
raise
ValueError
(
"
Lead lists must be sorted and
"
"
with unique entries.
"
)
if
len
(
in_leads
)
==
0
or
len
(
out_leads
)
==
0
:
...
...
@@ -557,13 +561,13 @@ class BlockResult(object):
def
__init__
(
self
,
data
,
lead_info
,
out_leads
,
in_leads
,
sizes
):
self
.
data
=
data
self
.
lead_info
=
lead_info
self
.
out_leads
=
out_leads
self
.
in_leads
=
in_leads
self
.
sizes
=
np
.
array
(
sizes
)
self
.
in_offsets
=
np
.
zeros
(
len
(
self
.
in_leads
)
+
1
,
int
)
self
.
in_offsets
[
1
:]
=
np
.
cumsum
(
self
.
sizes
[
self
.
in_leads
])
self
.
out_leads
=
out_leads
=
list
(
out_leads
)
self
.
in_leads
=
in_leads
=
list
(
in_leads
)
self
.
sizes
=
sizes
=
np
.
array
(
sizes
)
self
.
in_offsets
=
np
.
zeros
(
len
(
in_leads
)
+
1
,
int
)
self
.
in_offsets
[
1
:]
=
np
.
cumsum
(
self
.
sizes
[
in_leads
])
self
.
out_offsets
=
np
.
zeros
(
len
(
self
.
out_leads
)
+
1
,
int
)
self
.
out_offsets
[
1
:]
=
np
.
cumsum
(
self
.
sizes
[
self
.
out_leads
])
self
.
out_offsets
[
1
:]
=
np
.
cumsum
(
self
.
sizes
[
out_leads
])
def
block_coords
(
self
,
lead_out
,
lead_in
):
"""
...
...
@@ -613,7 +617,7 @@ class SMatrix(BlockResult):
matrix.
lead_info : list of data
a list containing `kwant.physics.PropagatingModes` for each lead.
out_leads, in_leads :
list
of integers
out_leads, in_leads :
sequence
of integers
indices of the leads where current is extracted (out) or injected
(in). Only those are listed for which SMatrix contains the
calculated result.
...
...
@@ -656,7 +660,7 @@ class GreensFunction(BlockResult):
function.
lead_info : list of matrices
a list with self-energies of each lead.
out_leads, in_leads :
list
of integers
out_leads, in_leads :
sequence
of integers
indices of the leads where current is extracted (out) or injected
(in). Only those are listed for which SMatrix contains the
calculated result.
...
...
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