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
b6e89534
Commit
b6e89534
authored
12 years ago
by
Anton Akhmerov
Committed by
Christoph Groth
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
make closed system tutorial use sparse eigenvalues
parent
169eac13
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/source/images/closed_system.py.diff
+4
-4
4 additions, 4 deletions
doc/source/images/closed_system.py.diff
doc/source/tutorial/closed_system.py
+6
-5
6 additions, 5 deletions
doc/source/tutorial/closed_system.py
doc/source/tutorial/tutorial3.rst
+9
-9
9 additions, 9 deletions
doc/source/tutorial/tutorial3.rst
with
19 additions
and
18 deletions
doc/source/images/closed_system.py.diff
+
4
−
4
View file @
b6e89534
--- original
+++ modified
@@ -1
7
,6 +1
7
,7 @@
@@ -1
8
,6 +1
8
,7 @@
# For plotting
from matplotlib import pyplot
...
...
@@ -8,9 +8,9 @@
def make_system(a=1, t=1.0, r=10):
@@ -
69
,19 +7
0
,24 @@
# we only plot the 15 lowest eigenvalues
energies.append(ev
[:15]
)
@@ -
70
,19 +7
1
,24 @@
energies.append(ev)
- pyplot.figure()
+ fig = pyplot.figure()
...
...
This diff is collapsed.
Click to expand it.
doc/source/tutorial/closed_system.py
+
6
−
5
View file @
b6e89534
...
...
@@ -10,11 +10,12 @@
from
cmath
import
exp
import
numpy
as
np
import
kwant
# For eigenvalue computation
#HIDDEN_BEGIN_tibv
import
scipy.linalg
as
la
import
scipy.
sparse.
linalg
as
s
la
#HIDDEN_END_tibv
# For plotting
...
...
@@ -67,12 +68,12 @@ def plot_spectrum(sys, Bfields):
B
=
Bfield
# Obtain the Hamiltonian as a dense matrix
ham_mat
=
sys
.
hamiltonian_submatrix
()
ham_mat
=
sys
.
hamiltonian_submatrix
(
sparse
=
True
)
ev
=
la
.
eigh
(
ham_mat
,
eigvals_only
=
True
)
# we only calculate the 15 lowest eigenvalues
ev
=
sla
.
eigsh
(
ham_mat
,
k
=
15
,
which
=
'
SM
'
,
return_eigenvectors
=
False
)
# we only plot the 15 lowest eigenvalues
energies
.
append
(
ev
[:
15
])
energies
.
append
(
ev
)
pyplot
.
figure
()
pyplot
.
plot
(
Bfields
,
energies
)
...
...
This diff is collapsed.
Click to expand it.
doc/source/tutorial/tutorial3.rst
+
9
−
9
View file @
b6e89534
...
...
@@ -56,16 +56,17 @@ Hamiltonian is approximating.
Closed systems
..............
Although kwant is (currently) mainly aimed towards transport problem, it
Although kwant is (currently) mainly aimed towards transport problem
a
, it
can also easily be used to compute properties of closed systems -- after
all, a closed system is nothing more than a scattering region without leads!
In this example, we compute the
spectrum
of a closed, (approximately)
circular quantum dot a
s a function of magnetic field
(Fock-Darwin spectrum).
In this example, we compute the
wave functions
of a closed, (approximately)
circular quantum dot a
nd its spectrum as a function
of magnetic field
(Fock-Darwin spectrum).
To compute the eigenenergies, we will make use of the linear algebra
functionality of `scipy <www.scipy.org>`_:
To compute the eigenenergies and eigenstates, we will make use of the sparse
linear algebra functionality of `scipy <www.scipy.org>`_, which interfaces
the ARPACK package:
.. literalinclude:: closed_system.py
:start-after: #HIDDEN_BEGIN_tibv
...
...
@@ -90,9 +91,8 @@ system using `~kwant.system.System.hamiltonian_submatrix`:
:start-after: #HIDDEN_BEGIN_yvri
:end-before: #HIDDEN_END_yvri
In this toy model we use dense matrices and dense matrix algebra since
the system is very small. (In a real application one would probably
want to use sparse matrix methods.) Finally, we obtain the result:
Note that we use sparse linear algebra to efficiently calculate only a
few lowest eigenvalues. Finally, we obtain the result:
.. image:: ../images/closed_system_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