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
fdb68031
Commit
fdb68031
authored
11 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
make selfenergy_from_modes a method of StabilizedModes
parent
46f0f24c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/source/reference/kwant.physics.rst
+0
-1
0 additions, 1 deletion
doc/source/reference/kwant.physics.rst
kwant/builder.py
+4
-4
4 additions, 4 deletions
kwant/builder.py
kwant/physics/leads.py
+25
-37
25 additions, 37 deletions
kwant/physics/leads.py
kwant/system.py
+4
-2
4 additions, 2 deletions
kwant/system.py
with
33 additions
and
44 deletions
doc/source/reference/kwant.physics.rst
+
0
−
1
View file @
fdb68031
...
...
@@ -11,6 +11,5 @@ Leads
Bands
modes
selfenergy
selfenergy_from_modes
PropagatingModes
StabilizedModes
This diff is collapsed.
Click to expand it.
kwant/builder.py
+
4
−
4
View file @
fdb68031
...
...
@@ -479,7 +479,7 @@ class ModesLead(Lead):
"""
def
__init__
(
self
,
modes_func
,
interface
):
self
.
_
modes_func
=
modes_func
self
.
modes_func
=
modes_func
self
.
interface
=
tuple
(
interface
)
def
finalized
(
self
):
...
...
@@ -487,11 +487,11 @@ class ModesLead(Lead):
return
self
def
modes
(
self
,
energy
,
args
=
()):
return
self
.
_
modes_func
(
energy
,
args
)
return
self
.
modes_func
(
energy
,
args
)
def
selfenergy
(
self
,
energy
,
args
=
()):
modes
=
self
.
modes
(
energy
,
args
)
return
physics
.
selfenergy
_from_modes
(
modes
=
modes
)
propagating
,
stabilized
=
self
.
modes
(
energy
,
args
)
return
stabilized
.
selfenergy
(
)
...
...
This diff is collapsed.
Click to expand it.
kwant/physics/leads.py
+
25
−
37
View file @
fdb68031
...
...
@@ -17,8 +17,7 @@ from .. import linalg as kla
dot
=
np
.
dot
__all__
=
[
'
selfenergy
'
,
'
modes
'
,
'
PropagatingModes
'
,
'
StabilizedModes
'
,
'
selfenergy_from_modes
'
]
__all__
=
[
'
selfenergy
'
,
'
modes
'
,
'
PropagatingModes
'
,
'
StabilizedModes
'
]
# Container classes
...
...
@@ -103,6 +102,25 @@ class StabilizedModes(object):
def
__getitem__
(
self
,
item
):
return
(
self
.
vecs
,
self
.
vecslmbdainv
,
self
.
nmodes
,
self
.
sqrt_hop
)[
item
]
def
selfenergy
(
self
):
"""
Compute the self-energy generated by lead modes.
Returns
-------
Sigma : numpy array, real or complex, shape (M,M)
The computed self-energy. Note that even if `h_cell` and `h_hop` are
both real, `Sigma` will typically be complex. (More precisely, if
there is a propagating mode, `Sigma` will definitely be complex.)
"""
v
=
self
.
sqrt_hop
vecs
=
self
.
vecs
[:,
self
.
nmodes
:]
vecslmbdainv
=
self
.
vecslmbdainv
[:,
self
.
nmodes
:]
if
v
is
not
None
:
return
dot
(
v
,
dot
(
vecs
,
la
.
solve
(
vecslmbdainv
,
v
.
T
.
conj
())))
else
:
return
la
.
solve
(
vecslmbdainv
.
T
,
vecs
.
T
).
T
# Auxiliary functions that perform different parts of the calculation.
def
setup_linsys
(
h_cell
,
h_hop
,
tol
=
1e6
,
stabilization
=
None
):
...
...
@@ -534,9 +552,9 @@ def modes(h_cell, h_hop, tol=1e6, stabilization=None):
Returns
-------
PropagatingModes(wave_functions, momenta, velocities) : object
A c
ontain
ed for
the array of the wave functions of propagating modes,
their
momenta, and their velocities. It can be used to identify the
gauge in
which the scattering problem is solved. See
C
ontain
s
the array of the wave functions of propagating modes,
their
momenta, and their velocities. It can be used to identify the
gauge in
which the scattering problem is solved. See
`~kwant.physics.PropagatingModes` for details.
StabilizedModes(vecs, vecslmbdainv, nmodes, sqrt_hop) : object
A basis of propagating and evanescent modes used by the solvers.
...
...
@@ -597,37 +615,6 @@ def modes(h_cell, h_hop, tol=1e6, stabilization=None):
return
real_space_data
,
StabilizedModes
(
vecs
,
vecslmbdainv
,
nrightmovers
,
v
)
def
selfenergy_from_modes
(
lead_modes
):
"""
Compute the self-energy generated by lead modes.
Parameters
----------
lead_modes : StabilizedModes(vecs, vecslmbdainv, nmodes, v) a named tuple
The modes in the lead, with format defined in
`~kwant.physics.StabilizedMods`.
Returns
-------
Sigma : numpy array, real or complex, shape (M,M)
The computed self-energy. Note that even if `h_cell` and `h_hop` are
both real, `Sigma` will typically be complex. (More precisely, if there
is a propagating mode, `Sigma` will definitely be complex.)
Notes
-----
For simplicity this function relies on the calculation of modes as input.
This may cause a small slowdown, and can be improved if necessary.
"""
vecs
,
vecslmbdainv
,
nmodes
,
v
=
lead_modes
vecs
=
vecs
[:,
nmodes
:]
vecslmbdainv
=
vecslmbdainv
[:,
nmodes
:]
if
v
is
not
None
:
return
dot
(
v
,
dot
(
vecs
,
la
.
solve
(
vecslmbdainv
,
v
.
T
.
conj
())))
else
:
return
la
.
solve
(
vecslmbdainv
.
T
,
vecs
.
T
).
T
def
selfenergy
(
h_cell
,
h_hop
,
tol
=
1e6
):
"""
Compute the self-energy generated by the lead.
...
...
@@ -655,7 +642,8 @@ def selfenergy(h_cell, h_hop, tol=1e6):
For simplicity this function internally calculates the modes first.
This may cause a small slowdown, and can be improved if necessary.
"""
return
selfenergy_from_modes
(
modes
(
h_cell
,
h_hop
,
tol
)[
1
])
propagating
,
stabilized
=
modes
(
h_cell
,
h_hop
,
tol
)
return
stabilized
.
selfenergy
()
def
square_selfenergy
(
width
,
hopping
,
fermi_energy
):
...
...
This diff is collapsed.
Click to expand it.
kwant/system.py
+
4
−
2
View file @
fdb68031
...
...
@@ -102,7 +102,9 @@ class FiniteSystem(System):
Numbers of the leads to be precalculated. If `None`, all are
precalculated.
calculate_selfenergy : bool
Whether to calculate self-energy if modes are available.
Whether to calculate self-energy if modes are available. Defaults
to `False`. Disabling this saves a typically negligible amount of
time and memory.
Returns
-------
...
...
@@ -127,7 +129,7 @@ class FiniteSystem(System):
try
:
modes
=
lead
.
modes
(
energy
,
args
)
if
calculate_selfenergy
:
selfenergy
=
physics
.
selfenergy
_from_modes
(
modes
)
selfenergy
=
modes
[
1
]
.
selfenergy
(
)
except
AttributeError
:
selfenergy
=
lead
.
selfenergy
(
energy
,
args
)
new_leads
.
append
(
PrecalculatedLead
(
modes
,
selfenergy
))
...
...
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