Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kwant/kwant
  • jbweston/kwant
  • anton-akhmerov/kwant
  • cwg/kwant
  • Mathieu/kwant
  • slavoutich/kwant
  • pacome/kwant
  • behrmann/kwant
  • michaelwimmer/kwant
  • albeercik/kwant
  • eunjongkim/kwant
  • basnijholt/kwant
  • r-j-skolasinski/kwant
  • sahmed95/kwant
  • pablopiskunow/kwant
  • mare/kwant
  • dvarjas/kwant
  • Paul/kwant
  • bbuijtendorp/kwant
  • tkloss/kwant
  • torosdahl/kwant
  • kel85uk/kwant
  • kpoyhonen/kwant
  • Fromeworld/kwant
  • quaeritis/kwant
  • marwahaha/kwant
  • fernandodfufrpe/kwant
  • oly/kwant
  • jiamingh/kwant
  • mehdi2369/kwant
  • ValFadeev/kwant
  • Kostas/kwant
  • chelseabaptiste03/kwant
33 results
Show changes
Commits on Source (686)
Showing
with 1001 additions and 1195 deletions
kwant/_kwant_version.py export-subst
......@@ -2,20 +2,14 @@
*.pyc
*.pyo
*.so
*.pyd
/kwant/*.c
/kwant/*/*.c
/tutorial
/build
/dist
/doc/build
/doc/source/reference/generated/
/doc/source/code/include/*.py
/doc/source/code/figure/*.png
/doc/source/code/figure/*.pdf
/doc/source/code/figure/.*_flag
/doc/source/code/figure/[a-zA-Z]*.py
/doc/source/code/figure/*.txt
/doc/source/code/download/
/doc/source/figure/*.pdf
/build.conf
/kwant.egg-info/
/MANIFEST.in
......@@ -23,3 +17,4 @@
.coverage
.eggs/
htmlcov/
.ipynb_checkpoints/
image: kwant/testing
image: gitlab.kwant-project.org:5005/kwant/kwant
stages:
- build-env
- build
- test
- deploy
- release
before_script:
# Here and below, a workaround for gitlab runner not fetching tags
# See https://gitlab.com/gitlab-org/gitaly/-/issues/2221
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
variables:
# rsync is used to send documentation to our web servers: we never send any
# secret information, and using 'ssh-keyscan' causes the CI server's IP to be blacklisted
IGNORE_HOSTKEY: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
# Turn off threading to avoid slowdowns
OPENBLAS_NUM_THREADS : 1
OMP_NUM_THREADS : 1
MKL_DYNAMIC : FALSE
MKL_NUM_THREADS : 1
## Building Docker environments
## Only runs when docker specifications change
.build-env:
stage: build-env
when: manual
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
build-env:ubuntu:
extends: .build-env
script:
- /kaniko/executor
--context $CI_PROJECT_DIR/docker
--dockerfile $CI_PROJECT_DIR/docker/Dockerfile.ubuntu
--destination $CI_REGISTRY_IMAGE/ubuntu
mirror repository:
stage: build
only:
- branches@kwant/kwant
allow_failure: true
variables:
REPOS: "git@github.com:kwant-project/kwant.git git@gitlab.com:kwant/kwant.git"
before_script:
- HOSTS=$(for REPO in $REPOS; do echo ${REPO%:*} | cut -d'@' -f2; done)
- mkdir ~/.ssh && chmod 700 ~/.ssh
- for HOST in $HOSTS; do ssh-keyscan $HOST >> ~/.ssh/known_hosts; done
- echo "$DEPLOY_KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
after_script:
- rm -rf ~/.ssh
script:
- ORIGIN_URL=$(git config --get remote.origin.url)
- cd $(mktemp -d); git clone --bare $ORIGIN_URL .
- for REPO in $REPOS; do git push --mirror $REPO; done
build package:
build-env:debian:
extends: .build-env
script:
- /kaniko/executor
--context $CI_PROJECT_DIR/docker
--dockerfile $CI_PROJECT_DIR/docker/Dockerfile.debian
--destination $CI_REGISTRY_IMAGE/debian
build-env:default:
extends: .build-env
script:
- /kaniko/executor
--context $CI_PROJECT_DIR/docker
--dockerfile $CI_PROJECT_DIR/docker/Dockerfile.conda
--destination $CI_REGISTRY_IMAGE
## Build environment specifications
.build:
stage: build
script:
- echo -e "[DEFAULT]\ndefine_macros = CYTHON_TRACE=1" >build.conf
- echo -e "[DEFAULT]\ndefine_macros = CYTHON_TRACE=1 NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION" >build.conf
- ./setup.py build
- ./setup.py build_ext -i
artifacts:
untracked: true
expire_in: 1 hour
expire_in: 2 hour
.stable-env:
before_script:
- eval "$(micromamba shell hook --shell bash)"
- micromamba activate kwant-stable
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
.no-extras-env:
before_script:
- eval "$(micromamba shell hook --shell bash)"
- micromamba activate kwant-stable-no-extras
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
# Note that this is 'latest' as of when the image was last built
.latest-env:
before_script:
- eval "$(micromamba shell hook --shell bash)"
- micromamba activate kwant-latest
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
.bleeding-edge-env:
before_script:
- eval "$(micromamba shell hook --shell bash)"
- micromamba activate kwant-latest
- micromamba update --all
- git config --global --add safe.directory /builds/kwant/kwant
- git fetch --tags
.ubuntu-env:
image: gitlab.kwant-project.org:5005/kwant/kwant/ubuntu
.debian-env:
image: gitlab.kwant-project.org:5005/kwant/kwant/debian
## Build Jobs
build:ubuntu:
extends:
- .build
- .ubuntu-env
build:debian:
extends:
- .build
- .debian-env
build:stable:
extends:
- .build
- .stable-env
build:no-extras:
extends:
- .build
- .no-extras-env
build:latest:
extends:
- .build
- .latest-env
build:bleeding-edge:
extends:
- .build
- .bleeding-edge-env
only:
- schedules
allow_failure: true
## Test Jobs
check whitespace style:
stage: build
stage: test
script: ./check_whitespace
allow_failure: true
check for dependencies installed:
stage: test
script:
......@@ -54,83 +161,155 @@ check for dependencies installed:
allow_failure: true
build documentation:
.test:
stage: test
script:
- pip3 install sympy
- make -C doc realclean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -W' REFNAME="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}" SOURCE_URL="$CI_PROJECT_URL"/blob
- py.test -r w --flakes kwant --junitxml=tests.xml --durations=10
artifacts:
paths:
- doc/build/html/
expire_in: 1 month
reports:
junit: tests.xml
run tests:
.coverage:
stage: test
script:
- pip3 install sympy
- py.test -r w --cov=kwant --cov-report term --cov-report html --flakes kwant
- py.test -r w --cov=kwant --cov-report term --cov-report html --flakes kwant --junitxml=tests.xml --durations=10
artifacts:
paths:
- htmlcov
reports:
junit: tests.xml
test:stable:
extends:
- .test
- .stable-env
dependencies:
- build:stable
test:no-extras:
extends:
- .test
- .no-extras-env
dependencies:
- build:no-extras
test:ubuntu:
extends:
- .test
- .ubuntu-env
dependencies:
- build:ubuntu
test:debian:
extends:
- .test
- .debian-env
dependencies:
- build:debian
test:latest:
extends:
- .test
- .latest-env
dependencies:
- build:latest
test:bleeding-edge:
extends:
- .test
- .bleeding-edge-env
dependencies:
- build:bleeding-edge
only:
- schedules
allow_failure: true
check for broken links in doc:
stage: test
test:python-mumps:
extends:
- .test
- .latest-env
dependencies:
- build:latest
script:
- pip3 install sympy
- make -C doc linkcheck
allow_failure: true
- micromamba install -y -c conda-forge python-mumps
- py.test -r w --flakes kwant --junitxml=tests.xml --durations=10
coverage:latest:
extends:
- .coverage
- .latest-env
dependencies:
- build:latest
only:
- schedules
## Documentation building
.conda-template: &conda_job
stage: deploy
image: condaforge/linux-anvil
script:
- yum install -y devtoolset-2-gcc-gfortran
- git clone https://gitlab.kwant-project.org/kwant/conda-recipes.git
- conda config --add channels kwant
- conda build --python 3.5 conda-recipes/kwant-dev
- conda build --python 3.6 conda-recipes/kwant-dev
- mv /opt/conda/conda-bld/linux-64/kwant-dev*.tar.bz2 .
- if [ ! -z $ANACONDA_TOKEN ]; then anaconda --token=$ANACONDA_TOKEN upload --force kwant-dev*tar.bz2; fi
build documentation:
extends: .latest-env
dependencies:
- build:latest
stage: test
script:
- pip install --editable . # Makefile executes from folders
- python -c 'from matplotlib import pyplot' # Pre-generate font cache
- pip install ipykernel # Temporary, should be removed after a jupyter-sphinx feedstock update.
- python -m ipykernel install --user --name kwant-latest # Register the kernel
- make -C doc clean; make -C doc html SPHINXOPTS='-A website_deploy=True -n -D jupyter_execute_default_kernel=kwant-latest' SOURCE_LINK_TEMPLATE="$CI_PROJECT_URL"/blob/\$\$r/\$\$f
artifacts:
paths:
- kwant-dev*.tar.bz2
- doc/build/html/
expire_in: 1 month
build PDF documentation:
extends: .latest-env
dependencies:
- build:latest
stage: test
script:
- pip install --editable . # Makefile executes from folders
- python -c 'from matplotlib import pyplot' # Pre-generate font cache
- pip install ipykernel # Temporary, should be removed after a jupyter-sphinx feedstock update.
- python -m ipykernel install --user --name kwant-latest # Register the kernel
- make -C doc latex SPHINXOPTS='-n -D jupyter_execute_default_kernel=kwant-latest'
- cd doc/build/latex
- make all-pdf
artifacts:
paths:
- doc/build/latex/kwant.pdf
expire_in: 1 month
# build on master always
build and upload conda package:
<<: *conda_job
only:
- master
check for broken links in doc:
extends: .latest-env
dependencies:
- build:latest
stage: test
script:
- pip install --editable . # Makefile executes from folders
- pip install ipykernel # Temporary, should be removed after a jupyter-sphinx feedstock update.
- python -m ipykernel install --user --name kwant-latest # Register the kernel
- make -C doc linkcheck SPHINXOPTS='-n -D jupyter_execute_default_kernel=kwant-latest'
allow_failure: true
# manual triggers for branches other than master possible
build and upload conda package (manual):
<<: *conda_job
except:
- master
when: manual
## Upload coverage reports and dev documentation
upload coverage:
stage: deploy
only:
- branches@kwant/kwant
- schedules
dependencies:
- coverage:latest
environment:
name: coverage/$CI_BUILD_REF_NAME
url: https://kwant-project.org/coverage/$CI_BUILD_REF_SLUG
name: coverage/$CI_COMMIT_REF_NAME
url: https://kwant-project.org/coverage/$CI_COMMIT_REF_SLUG
on_stop: remove_coverage
before_script:
- mkdir -p ~/.ssh
- echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
script:
- mv htmlcov $CI_BUILD_REF_SLUG
- rsync -rlv -e "$IGNORE_HOSTKEY" --delete --relative $CI_BUILD_REF_SLUG kwant@kwant-project.org:coverage/
after_script:
- rm -rf ~/.ssh
- eval $(ssh-agent -s)
- echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
- mv htmlcov $CI_COMMIT_REF_SLUG
- rsync -rlv -e "$SSH_COMMAND" --delete --relative $CI_COMMIT_REF_SLUG kwant@kwant-project.org:coverage/
remove_coverage:
......@@ -139,33 +318,27 @@ remove_coverage:
- branches@kwant/kwant
when: manual
environment:
name: coverage/$CI_BUILD_REF_NAME
name: coverage/$CI_COMMIT_REF_NAME
action: stop
before_script:
- mkdir -p ~/.ssh
- echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
script:
- eval $(ssh-agent -s)
- echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
- mkdir empty/
- rsync -rlv -e "$IGNORE_HOSTKEY" --delete empty/ kwant@kwant-project.org:coverage/$CI_BUILD_REF_SLUG
after_script:
- rm -rf ~/.ssh
- rsync -rlv -e "$SSH_COMMAND" --delete empty/ kwant@kwant-project.org:coverage/$CI_COMMIT_REF_SLUG
upload documentation to the test server:
stage: deploy
environment:
name: docs review/$CI_BUILD_REF_NAME
url: https://test.kwant-project.org/doc/$CI_BUILD_REF_SLUG
name: docs review/$CI_COMMIT_REF_NAME
url: https://test.kwant-project.org/doc/$CI_COMMIT_REF_SLUG
on_stop: remove_docs
only:
- branches@kwant/kwant
before_script:
- mkdir -p ~/.ssh
- echo $TEST_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
script:
- rsync -rlv -e "$IGNORE_HOSTKEY" --delete doc/build/html/* kwant@kwant-project.org:doc/$CI_BUILD_REF_SLUG
after_script:
- rm -rf ~/.ssh
- eval $(ssh-agent -s)
- echo $TEST_WEBSITE_KEY | base64 -d | ssh-add -
- rsync -rlv -e "$SSH_COMMAND" --delete doc/build/html/* kwant2@test.kwant-project.org:doc/$CI_COMMIT_REF_SLUG
remove_docs:
......@@ -174,16 +347,13 @@ remove_docs:
only:
- branches@kwant/kwant
environment:
name: docs review/$CI_BUILD_REF_NAME
name: docs review/$CI_COMMIT_REF_NAME
action: stop
before_script:
- mkdir -p ~/.ssh
- echo $TEST_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
script:
- eval $(ssh-agent -s)
- echo $TEST_WEBSITE_KEY | base64 -d | ssh-add -
- mkdir empty
- rsync -arv -e "$IGNORE_HOSTKEY" --delete empty/ kwant@kwant-project.org:doc/$CI_BUILD_REF_SLUG/
after_script:
- rm -rf ~/.ssh
- rsync -arv -e "$SSH_COMMAND" --delete empty/ kwant2@test.kwant-project.org:doc/$CI_COMMIT_REF_SLUG/
upload dev version docs:
......@@ -191,27 +361,30 @@ upload dev version docs:
environment:
name: production
url: https://kwant-project.org/doc/dev
only:
- master@kwant/kwant
before_script:
- mkdir -p ~/.ssh
- echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_PATH == "kwant/kwant"
script:
- rsync -rlv -e "$IGNORE_HOSTKEY" --delete doc/build/html/* kwant@kwant-project.org:doc/dev
after_script:
- rm -rf ~/.ssh
- eval $(ssh-agent -s)
- echo $MASTER_WEBSITE_KEY | base64 -d | ssh-add -
- rsync -rlv -e "$SSH_COMMAND" --delete doc/build/html/* kwant@kwant-project.org:doc/dev
upload docs of tagged build:
stage: deploy
environment:
name: production
only:
- /^v[0-9]+\.[0-9]+.[0-9]+$/@kwant/kwant
before_script:
- mkdir -p ~/.ssh
- echo $MASTER_WEBSITE_KEY | base64 -d > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
## Build documentation for tagged releases
.tagged-version:
only:
- /^v[0-9]+\.[0-9]+.[0-9]+$/@kwant/kwant
gather release artifacts:
extends: .tagged-version
stage: release
script:
- rsync -rlv -e "$IGNORE_HOSTKEY" --delete doc/build/html/* kwant@kwant-project.org:doc/$(echo $CI_BUILD_TAG | sed 's/v\([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/')
after_script:
- rm -rf ~/.ssh
- ./setup.py sdist
- mkdir docs
- mv doc/build/latex/kwant.pdf docs/kwant-doc-${CI_COMMIT_TAG//v}.pdf
- mv doc/build/html docs/html
- zip -r docs/kwant-doc-${CI_COMMIT_TAG//v}.zip docs/html
artifacts:
paths:
- docs
- dist
# Release %vX.Y.Z **UPDATE THIS**
This is a checklist based on the [release document](RELEASE.rst); consult it for more details.
## Preflight checks
- [ ] All the issues from this milestone are resolved
- [ ] Ensure that tests pass on [main](https://gitlab.kwant-project.org/kwant/kwant/tree/main) branch
- [ ] Documentation looks correct https://test.kwant-project.org/doc/main
- [ ] [Whatnew](doc/source/pre/whatsnew) is up to date
- [ ] `AUTHORS.rst` and `.mailmap` are up to date (run `git shortlog -s | sed -e "s/^ *[0-9\t ]*//"| xargs -i sh -c 'grep -q "{}" AUTHORS.rst || echo "{}"'`)
## Make a release, but do not publish it yet
- [ ] Tag the release
- [ ] Build the source tarball and inspect it
- [ ] Build the documentation
## Test packaging
These steps may be done in parallel
### Debian
- [ ] Follow the steps for building the Debian packages from [RELEASE.rst](RELEASE.rst)
### Conda
- [ ] Publish the release candidate source tarball "somewhere on the internet" (SOTI)
- [ ] open a PR to the [conda-forge/kwant-feedstock](https://github.com/conda-forge/kwant-feedstock/) repo on Github. Make sure to mark the PR as WIP so that it doesn't get merged in accidentally
- [ ] set the upstream tarball URL (in meta.yaml) to SOTI
- [ ] update the tarball hash in meta.yaml
- [ ] See if the package builds
## Publish the release
- [ ] push the tag
- [ ] upload the source tarball to PyPI
- [ ] upload the source tarball to the Kwant website
- [ ] publish the debian packages
- [ ] publish the ubuntu packages
- [ ] create a new version of the Kwant conda-forge feedstock, and open a pull request to upstream
- [ ] upload the documentation to the Kwant website
- [ ] update the Kwant website to say that Conda is the preferred way to install Kwant on Windows
## Announce the release
- [ ] Write a short post summarizing the highlights on the Kwant website
- [ ] post to the Kwant mailing list
## Working towards next release
- [ ] add a whatsnew file for the next release
- [ ] tag this release with an `a0` suffix
- [ ] push this tag to the official Kwant repository
- [ ] create a milestone for the next release
Thomas Kloss <kloss@itp.uni-frankfurt.de>
<joseph@weston.cloud> <joseph.weston08@gmail.com>
<joseph@weston.cloud> <joseph.weston@cea.fr>
<joseph@weston.cloud> <me@josephweston.org>
<joseph@weston.cloud> <v-josewe@microsoft.com>
Tómas Örn Rosdahl <torosdahl@gmail.com>
<slavoutich@ostroukh.me> <ostroukh@lorentz.leidenuniv.nl>
<m.t.wimmer@tudelft.nl> <wimmer@lorentz.leidenuniv.nl>
Dániel Varjas <dvarjas@gmail.com>
Pablo Pérez Piskunow <pablo.perez.piskunow@gmail.com>
Michał Nowak <albeercik@gmail.com>
Paul Clisson <clissonpaul@gmail.com>
Jörg Behrmann <behrmann@physik.fu-berlin.de>
Rafał Skolasiński <r.j.skolasinski@gmail.com>
......@@ -6,17 +6,22 @@ The Kwant authors can be reached at authors@kwant-project.org.
The principal developers of Kwant are
* `Christoph W. Groth <mailto://christoph.groth@cea.fr>`_ (CEA Grenoble)
* `Christoph Groth <mailto:christoph.groth@cea.fr>`_ (CEA Grenoble)
* `Michael Wimmer <https://michaelwimmer.org>`_ (TU Delft)
* `Anton R. Akhmerov <http://antonakhmerov.org>`_ (TU Delft)
* `Xavier Waintal <http://inac.cea.fr/Pisp/xavier.waintal>`_ (CEA Grenoble)
* `Joseph Weston <http://josephweston.org>`_ (TU Delft)
* `Anton Akhmerov <https://antonakhmerov.org>`_ (TU Delft)
* `Xavier Waintal <https://www.pheliqs.fr/en/Pages/Portrait/Xavier-Waintal.aspx>`_ (CEA Grenoble)
* `Joseph Weston <https://joseph.weston.cloud>`_ (TU Delft)
Contributors to Kwant include
* Jörg Behrmann (FU Berlin)
* Pierre Carmier (CEA Grenoble)
* Paul Clisson (CEA Grenoble)
* `Dennis Heffels <mailto:d.heffels@fz-juelich.de>`_ (FZJ PGI-9)
* Mathieu Istas (CEA Grenoble)
* Daniel Jaschke (CEA Grenoble)
* Thomas Kloss (CEA Grenoble)
* Kelvin Loh (TNO)
* Bas Nijholt (TU Delft)
* Michał Nowak (TU Delft)
* Viacheslav Ostroukh (Leiden University)
......@@ -25,10 +30,12 @@ Contributors to Kwant include
* Sebastian Rubbert (TU Delft)
* Rafał Skolasiński (TU Delft)
* Adrien Sorgniard (CEA Grenoble)
* Dániel Varjas (TU Delft)
* Kostas Vilkelis (TU Delft)
We thank Christoph Gohlke for the creation of installers for Microsoft Windows.
`CEA <http://www.cea.fr>`_ is the French Commissariat à l'énergie atomique et aux
`CEA <https://www.cea.fr>`_ is the French Commissariat à l'énergie atomique et aux
énergies alternatives. The CEA is the copyright holder for the contributions of
C. W. Groth, X. Waintal, and its other employees involved in Kwant.
......
......@@ -15,7 +15,7 @@ cite the main paper that introduces Kwant:
C. W. Groth, M. Wimmer, A. R. Akhmerov, X. Waintal,
*Kwant: a software package for quantum transport*,
`New J. Phys. 16, 063065 (2014)
<https://iopscience.iop.org/1367-2630/16/6/063065/article>`_.
<https://doi.org/10.1088/1367-2630/16/6/063065>`_.
Other references we ask you to consider
......@@ -26,7 +26,7 @@ also cite the upcoming paper that describes the relevant algorithms. The
reference will also be added here once it is available.
Kwant owes much of its current performance to the use of the `MUMPS
<http://graal.ens-lyon.fr/MUMPS/>`_ library for solving systems of sparse linear
<https://graal.ens-lyon.fr/MUMPS/>`_ library for solving systems of sparse linear
equations. If you have done high-performance calculations, we suggest citing
P. R. Amestoy, I. S. Duff, J. S. Koster, J. Y. L’Excellent, SIAM. J. Matrix
......
......@@ -4,11 +4,8 @@ Contributing to Kwant and reporting problems
We see Kwant not just as a package with fixed functionality, but rather as a
framework for implementing different physics-related algorithms using a common
set of concepts and, if possible, a shared interface. We have designed it
leaving room for growth, and plan to keep extending it.
External contributions to Kwant are highly welcome. You can help to advance
the project not only by writing code, but also by reporting bugs, and
fixing/improving the documentation. Please see the `Kwant website
<https://kwant-project.org/community>`_ for information on how to get in touch
with the Kwant community.
set of concepts. Contributions to Kwant are highly welcome. You can help the
project not only by writing code, but also by reporting bugs, and
fixing/improving the website and the documentation. Please see the
`"Contributing" page <https://kwant-project.org/contribute>`_ of the Kwant
website for more information.
......@@ -20,7 +20,7 @@ Obtaining the source code
Source distributions of Kwant (and Tinyarray) are available at the `downloads
section of the Kwant website <https://downloads.kwant-project.org/kwant/>`_ as well
as `PyPI <https://pypi.python.org/pypi/kwant>`_. The sources may be also
as `PyPI <https://pypi.org/project/kwant>`_. The sources may be also
cloned directly from the `official Kwant git repository
<https://gitlab.kwant-project.org/kwant/kwant>`_.
......@@ -29,32 +29,32 @@ Prerequisites
=============
Building Kwant requires
* `Python <https://www.python.org/>`_ 3.5 or above (Kwant 1.1 is the last
version to support Python 2),
* `NumPy <http://numpy.org/>`_ 1.11.0 or newer,
* `SciPy <https://scipy.org/>`_ 0.17.0 or newer,
* `LAPACK <http://netlib.org/lapack/>`_ and `BLAS <http://netlib.org/blas/>`_,
* `Python <https://www.python.org/>`_ 3.8 or above,
* `NumPy <https://numpy.org/>`_ 1.18.0 or newer,
* `SciPy <https://www.scipy.org/>`_ 1.3.0 or newer,
* `LAPACK <https://netlib.org/lapack/>`_ and `BLAS <https://netlib.org/blas/>`_,
(For best performance we recommend the free `OpenBLAS
<http://www.openblas.net/>`_ or the nonfree `MKL
<https://software.intel.com/en-us/intel-mkl>`_.)
* `Tinyarray <https://gitlab.kwant-project.org/kwant/tinyarray>`_ 1.2 or newer,
<https://www.openblas.net/>`_ or the nonfree `MKL
<https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html>`_.)
* `Tinyarray <https://gitlab.kwant-project.org/kwant/tinyarray>`_ 1.2.2 or newer,
a NumPy-like Python package optimized for very small arrays,
* An environment which allows to compile Python extensions written in C and
C++.
The following software is highly recommended though not strictly required:
* `matplotlib <http://matplotlib.org/>`_ 1.5.1 or newer, for the module `kwant.plotter` and the tutorial,
* `SymPy <http://sympy.org/>`_ 0.7.6 or newer, for the subpackage `kwant.continuum`.
* `MUMPS <http://graal.ens-lyon.fr/MUMPS/>`_, a sparse linear algebra library
* `matplotlib <https://matplotlib.org/>`_ 3.2.2 or newer, for the module `kwant.plotter` and the tutorial,
* `SymPy <https://sympy.org/>`_ 1.5.1 or newer, for the subpackage `kwant.continuum`.
* `Qsymm <https://pypi.org/project/qsymm/>`_ 1.2.6 or newer, for the subpackage `kwant.qsymm`.
* `MUMPS <https://mumps-solver.org/>`_, a sparse linear algebra library
that will in many cases speed up Kwant several times and reduce the memory
footprint. (Kwant uses only the sequential, single core version
of MUMPS. The advantages due to MUMPS as used by Kwant are thus independent
of the number of CPU cores of the machine on which Kwant runs.)
* The `py.test testing framework <http://pytest.org/>`_ 2.8 or newer for running the
* The `py.test testing framework <https://docs.pytest.org/>`_ 3.3.2 or newer for running the
tests included with Kwant.
In addition, to build a copy of Kwant that has been checked-out directly from
version control, you will also need `Cython <http://cython.org/>`_ 0.22 or
version control, you will also need `Cython <https://cython.org/>`_ 3.0 or
newer. You do not need Cython to build Kwant that has been unpacked from a
source .tar.gz-file.
......@@ -62,9 +62,8 @@ source .tar.gz-file.
Building and installing Kwant
=============================
Kwant can be built and installed following the `usual Python conventions
<https://docs.python.org/3/install/index.html>`_ by running the following
commands in the root directory of the Kwant distribution. ::
Kwant can be built and installed by running the following commands in the root
directory of the Kwant distribution. ::
python3 setup.py build
python3 setup.py install
......@@ -100,13 +99,13 @@ sections, one for each extension module that is contained in Kwant, led by a
``[section name]`` header and followed by ``key = value`` lines.
The sections bear the names of the extension modules, for example
``[kwant.operator]`` or ``[kwant.linalg.lapack]``. There can be also a
``[kwant.operator]``. There can be also a
``[DEFAULT]`` section that provides default values for all extensions, also
those not explicitly present in the file.
Possible keys are the keyword arguments for ``distutils.core.Extension`` (For a
Possible keys are the keyword arguments for ``setuptools.Extension`` (For a
complete list, see its `documentation
<https://docs.python.org/3/distutils/apiref.html#distutils.core.Extension>`_).
<https://setuptools.pypa.io/en/latest/userguide/ext_modules.html>`_).
The corresponding values are whitespace-separated lists of strings.
Example ``build.conf`` for compiling Kwant with C assertions and Cython's line
......@@ -116,35 +115,23 @@ trace feature::
undef_macros = NDEBUG
define_macros = CYTHON_TRACE=1
Kwant must be linked against LAPACK & BLAS, and, optionally, MUMPS. The main
Kwant can optionally be linked against MUMPS. The main
application of build configuration is adopting the build process to the various
(deployment) variants of these libraries. By default ``setup.py`` assumes that
LAPACK and BLAS can be found under their usual names. MUMPS will be not linked
deployments of MUMPS. MUMPS will be not linked
against by default, except on Debian-based systems when the package
``libmumps-scotch-dev`` is installed.
The sections ``[kwant.linalg.lapack]`` and ``[kwant.linalg._mumps]`` may be
used to adapt the build process. (For simplicity and backwards compatibility,
``[lapack]`` and ``[mumps]`` are aliases for the above.)
The section ``[kwant.linalg._mumps]`` may be used to adapt the build process.
(For simplicity and backwards compatibility, ``[mumps]`` is an aliases for the above.)
The section ``[lapack]`` configures the linking against LAPACK _AND_ BLAS, the
section ``[mumps]`` against MUMPS. The contents of ``[lapack]`` are
appended to the configuration for MUMPS itself needs LAPACK and BLAS as well.
Example ``build.conf`` for linking Kwant against a self-compiled MUMPS, `SCOTCH
<http://www.labri.fr/perso/pelegrin/scotch/>`_ and `METIS
<https://www.labri.fr/perso/pelegrin/scotch/>`_ and `METIS
<http://glaros.dtc.umn.edu/gkhome/metis/metis/overview>`_::
[mumps]
libraries = zmumps mumps_common pord metis esmumps scotch scotcherr mpiseq gfortran
Example ``build.conf`` for linking Kwant with Intel MKL.::
[lapack]
libraries = mkl_intel_lp64 mkl_sequential mkl_core mkl_def
library_dirs = /opt/intel/mkl/lib/intel64
extra_link_args = -Wl,-rpath=/opt/intel/mkl/lib/intel64
The detailed syntax of ``build.conf`` is explained in the `documentation of
Python's configparser module
<https://docs.python.org/3/library/configparser.html#supported-ini-file-structure>`_.
......@@ -154,10 +141,13 @@ Building the documentation
==========================
To build the documentation, the `Sphinx documentation generator
<http://www.sphinx-doc.org/en/stable/>`_ is required with ``numpydoc`` extension
(version 0.5 or newer). If PDF documentation is to be built, the tools
from the `libRSVG <https://wiki.gnome.org/action/show/Projects/LibRsvg>`_ (Debian/Ubuntu package
``librsvg2-bin``) are needed to convert SVG drawings into the PDF format.
<https://www.sphinx-doc.org/en/stable/>`_ is required with ``numpydoc`` extension
(version 0.5 or newer), as well as ``jupyter-sphinx`` (version 0.2 or newer).
If PDF documentation is to be built, the tools
from the `libRSVG <https://wiki.gnome.org/action/show/Projects/LibRsvg>`_
(Debian/Ubuntu package ``librsvg2-bin``) and a Sphinx extension
``sphinxcontrib-svg2pdfconverter`` are needed to convert SVG drawings into the
PDF format.
As a prerequisite for building the documentation, Kwant must have been built
successfully using ``python3 setup.py build`` as described above (or Kwant must
......@@ -171,25 +161,6 @@ Because of some quirks of how Sphinx works, it might be necessary to execute
done, Sphinx may mistakenly use PNG files for PDF output or other problems may
appear.
When ``make html`` is run, modified tutorial example scripts are executed to
update any figures that might have changed. The machinery behind this works as
follows. The canonical source for a tutorial script, say ``graphene.py`` is
the file ``doc/source/images/graphene.py.diff``. This diff file contains the
information to recreate two versions of ``graphene.py``: a version that is
presented in the documentation (``doc/source/tutorial/graphene.py``), and a
version that is used to generate the figures for the documentation
(``doc/source/images/graphene.py``). Both versions are related but differ
e.g. in the details of the plotting. When ``make html`` is run, both versions
are extracted form the diff file.
The diff file may be modified directly. Another possible way of working is to
directly modify either the tutorial script or the figure generation script.
Then ``make html`` will use the command line tool `wiggle
<http://neil.brown.name/wiggle/>`_ to propagate the modifications accordingly.
This will often just work, but may sometimes result in conflicts, in which case
a message will be printed. The conflicts then have to be resolved much like
with a version control system.
****************************
Hints for specific platforms
****************************
......@@ -206,7 +177,7 @@ root.
1. Install the required packages. On Debian-based systems like Ubuntu this can
be done by running the command ::
sudo apt-get install python3-dev python3-setuptools python3-scipy python3-matplotlib python3-pytest python3-sympy g++ gfortran libopenblas-dev liblapack-dev libmumps-scotch-dev
sudo apt-get install python3-dev python3-setuptools python3-scipy python3-matplotlib python3-pytest python3-sympy g++ gfortran libmumps-scotch-dev
2. Unpack Tinyarray, enter its directory. To build and install, run ::
......@@ -222,74 +193,6 @@ By default the package will be installed under ``/usr/local``. Run ``python3
setup.py --help install`` for installation options.
Mac OS X: MacPorts
==================
The following instructions are valid for Kwant 1.1 with Python 2.7. They need
to be updated for Kwant 1.2. (Help is welcome.)
The required dependencies of Kwant are best installed with one of the packaging
systems. Here we only consider the case of `MacPorts
<https://www.macports.org>`_ in detail. Some remarks for homebrew are given
below.
1. Install a recent version of MacPorts, as explained in the `installation
instructions of MacPorts <https://www.macports.org/install.php>`_.
2. Install the required dependencies::
sudo port install gcc47 python27 py27-numpy py27-scipy py27-matplotlib mumps_seq
sudo port select --set python python27
3. Unpack Tinyarray, enter its directory, build and install::
python setup.py build
sudo python setup.py install
4. Unpack Kwant, go to the Kwant directory, and edit ``build.conf`` to read::
[lapack]
extra_link_args = -Wl,-framework -Wl,Accelerate
[mumps]
include_dirs = /opt/local/include
library_dirs = /opt/local/lib
libraries = zmumps_seq mumps_common_seq pord_seq esmumps scotch scotcherr mpiseq gfortran
5. Then, build and install Kwant. ::
CC=gcc-mp-4.7 LDSHARED='gcc-mp-4.7 -shared -undefined dynamic_lookup' python setup.py build
sudo python setup.py install
You might note that installing Kwant on Mac OS X is somewhat more involved than
installing on Linux. Part of the reason is that we need to mix Fortran and C
code in Kwant: While C code is usually compiled using Apple compilers,
Fortran code must be compiled with the Gnu Fortran compiler (there is
no Apple Fortran compiler). For this reason we force the Gnu compiler suite
with the environment variables ``CC`` and ``LDSHARED`` as shown above.
Mac OS X: homebrew
==================
The following instructions are valid for Kwant 1.1 with Python 2.7. They need
to be updated for Kwant 1.2. (Help is welcome.)
It is also possible to build Kwant using homebrew. The dependencies can be
installed as ::
brew install gcc python
brew tap homebrew/science
brew tap homebrew/python
brew tap kwant-project/kwant
pip install pytest pytest-runner six
brew install numpy scipy matplotlib
Note that during the installation you will be told which paths to add when you
want to compile/link against scotch/metis/mumps; you need to add these to the
build.conf file. Also, when linking against MUMPS, one needs also to link
against METIS (in addition to the libraries needed for MacPorts).
Microsoft Windows
=================
......
......@@ -28,14 +28,11 @@ Kwant can calculate
Other computations involving tight-binding Hamiltonians can be implemented
easily.
See the `Kwant web site <http://kwant-project.org/>`_ for the latest stable
See the `Kwant website <https://kwant-project.org/>`_ for the latest stable
version. The current development version is available via the `Kwant gitlab
instance <https://gitlab.kwant-project.org/kwant/kwant>`_. Contributions are
welcome.
A `mailing list <http://kwant-project.org/community>`_ exists for general
A `mailing list <https://kwant-project.org/community>`_ exists for general
discussions related to Kwant. Please report bugs and other issues using the
`issue tracker <https://gitlab.kwant-project.org/kwant/kwant/issues>`_.
See also in this directory: `<INSTALL.rst>`_, `<LICENSE.rst>`_, `<AUTHORS.rst>`_,
`<CITING.rst>`_, `<CONTRIBUTE.rst>`_.
Making a Kwant release
======================
This document guides a contributor through creating a release of Kwant.
Create a release issue
######################
Use the correct `issue template <gitlab.kwant-project.org/kwant/kwant/issues/new?issuable_template=release>`_, adjust it if necessary.
Preflight checks
################
The following checks should be made *before* tagging the release.
Check that all issues are resolved
----------------------------------
Check that all the issues and merge requests for the appropriate
`milestone <https://gitlab.kwant-project.org/kwant/kwant/milestones>`_
have been resolved. Any unresolved issues should have their milestone
bumped.
Ensure that all tests pass
--------------------------
For major and minor releases we will be tagging the ``master`` branch.
For patch releases, the ``stable`` branch.
This should be as simple as verifying that the latest CI pipeline succeeded,
however in ``stable`` branch also manually trigger CI task of building the
conda package and verify that it, too, succeeds.
Inspect the documentation
-------------------------
If the CI pipeline succeeded, then the latest docs should be available at:
https://test.kwant-project.org/doc/<branch name>
Check that there are no glaring deficiencies.
Update the ``whatsnew`` file
----------------------------
For each new minor release, check that there is an appropriate ``whatsnew`` file
in ``doc/source/pre/whatsnew``. This should be named as::
<major>.<minor>.rst
and referenced from ``doc/source/pre/whatsnew/index.rst``. It should contain a
list of the user-facing changes that were made in the release. With any luck
this file will have been updated at the same time as a feature was implemented,
if not then you can see what commits were introduced since the last release using
``git log``. You can also see what issues were assigned to the release's
milestones and get an idea of what was introduced from there.
Starting with Kwant 1.4, we also mention user-visible changes in bugfix
releases in the whatsnew files.
Verify that ``AUTHORS.rst`` and ``.mailmap`` are up-to-date
-----------------------------------------
The following command shows if there are any committers that are missing from
``AUTHORS.rst``::
git shortlog -s | sed -e "s/^ *[0-9\t ]*//"| xargs -i sh -c 'grep -q "{}" AUTHORS.rst || echo "{}"'
If it outputs anything, then either add the new contributors to the list, or add
new identities of old contributors to the ``.mailmap``
Make a release, but do not publish it yet
#########################################
Various problems can surface only during the process of preparing a release and
make it necessary to fix the codebase. It would be a pity to have to succeed
the freshly released version by a minor release just to correct a glitch that
was detected too late. Therefore it is a good idea to pursue the release as
far as possible without announcing it, such that it can be undone and corrected
if necessary. In the past tests that failed on the x86-32 architecture and
wrongly declared dependencies have been detected in this way.
Tag the release
---------------
Make an *annotated*, *signed* tag for the release. The tag must have the name::
git tag -s v<version> -m "version <version>"
Be sure to respect the format of the tag name (leading "v", e.g. "v1.2.3").
The tag message format is the one that has been used so far.
Do *not* yet push the tag anywhere; it might have to be undone!
Build a source tarball and inspect it
-------------------------------------
./setup.py sdist
This creates the file dist/kwant-<version>.tar.gz. It is a good idea to unpack it
in /tmp and inspect that builds in isolation and that the tests run::
cd /tmp
tar xzf ~/src/kwant/dist/kwant-<version>.tar.gz
cd kwant-<version>
./setup.py build
./setup.py build_ext -i
py.test
Build the documentation
-----------------------
Building the documentation requires 'sphinx' and a Latex installation.
First build the HTML and PDF documentation::
./setup.py build
make -C doc realclean
make -C doc html latex
make -C doc/build/latex all-pdf
Then create a zipped version of the HTML documentation and name the PDF
consistently, storing them, for example, in the "dist" directory along with the
source tarballs::
version=$(git describe | sed 's/^v//') # Assumes that we are on a tag.
ln -s `pwd`/doc/build/html /tmp/kwant-doc-$version
(cd /tmp/; zip -r kwant-doc-$version.zip kwant-doc-$version)
mv /tmp/kwant-doc-$version.zip dist
mv doc/build/latex/kwant.pdf dist/kwant-doc-$version.pdf
Finally, rebuild the documentation for the website (including the web analysis javascript code)::
make -C doc html SPHINXOPTS='-A website_deploy=True -n -W'
Clone the repository of the Kwant Debian package
------------------------------------------------
This step needs to be performed only once. The cloned repository can be reused
for subsequent releases.
Clone the "kwant-debian" repository and go into its root directory. If you
keep the Kwant source in "src/kwant", a good location for the Debian package
repository is "src/debian/kwant". The packaging process creates many files
that are placed into the parent directory of the packaging repository, hence
having an additional directory level ("src/debian") is a good way to keep these
files separate::
mkdir debian
cd debian
git clone ssh://git@gitlab.kwant-project.org:443/kwant/debian-kwant.git kwant
cd kwant
Create a local upstream branch::
git branch upstream origin/upstream
Add a remote for the repository that contains the previously created tag::
git remote add upstream_repo ~/src/kwant
Make sure that::
git config --get user.name
git config --get user.email
show correct information.
Release a new version of the Kwant Debian package
-------------------------------------------------
Fetch packaging work (from origin) and the git tag created above (from
upstream_repo) into the packaging repo::
git fetch --all
Make sure that the branches ``master`` and ``upstream`` are up-to-date::
git checkout upstream
git merge --ff-only origin/upstream
git checkout master
git merge --ff-only origin/master
Debian packages may include "quilt" patches that are applied on top of the
pristine tarball. The tool `gbp pq` manages these patches as a git branch
``patch-queue/master. Execute the following commands to (re)create
that branch based on the patches in ``debian/patches``::
gbp pq --force import
git checkout master
Now it is time to import the new source code. There are two options. If, as
recommended above, the tarball of the new version has not been made public yet,
it must be imported as follows::
gbp import-orig ~/src/kwant/dist/kwant-<version>.tar.gz
Alternatively, the following commands will import the newest version from PyPI::
uscan --report # This will report if a newer version exists on PyPI
gbp import-orig --uscan
Now it is time to review the patch queue. Rebase and checkout the ``patch-queue/master`` branch using::
gbp pq rebase
As ususal, the rebase might require manual intervention. Once done, review all
the commits of the ``patch-queue/master`` branch. Are all patches still
needed, should any be removed? When done (even if no changes were needed), recreate the files in ``debian/patches`` using::
gbp pq export
If ``git diff`` reports any changes, be sure to commit them.
Now is the right moment to verify and modify the packaging information inside
the ``debian/`` directory. For example, are the dependencies and versions
stated in ``debian/control`` up-to-date?
When all changes are commited, it is time to finalize by updating the Debian
changelog file. Add a point "New upstream release" if there was one, and
describe any other changes to the Debian *packaging*::
DEBEMAIL=<your-email> gbp dch -R --commit --distribution testing
Now verify that the package builds with::
git clean -i
gbp buildpackage
This is *not* how the package should be built for distribution. For that, see
the following two sections.
If problems surface that require changing the packaging, undo the changelog
commit, modify the packaging, and re-iterate. If the problems require fixing
Kwant, you will have to go back all the way to recreating the source tarball.
If the version to be packaged has been released publicly already, this will require a new bugfix version.
Setup git-pbuilder to build Debian packages
-------------------------------------------
Pbuilder is a tool to build Debian packages in an isolated chroot. This allows
to verify that the package indeed only has the declared dependencies. It also
allows to cross-build packages for i386 on amd64.
The following describes how to setup git-pbuilder, see also
https://wiki.debian.org/git-pbuilder. This procedure needs to be executed only
once for a Debian system.
Install the Debian package git-buildpackage.
As root, add the following lines to /etc/sudoers or /etc/sudoers.d/local
Cmnd_Alias BUILD = /usr/sbin/cowbuilder
and
user ALL = SETENV: BUILD
Now create pbuilder images. In the following, replace ``<dist>`` by the
current Debian testing codename, e.g. "buster"::
ARCH=i386 DIST=<dist> git-pbuilder create
ARCH=amd64 DIST=<dist> git-pbuilder create
If the packages to be built have special dependencies, use the trick described in https://wiki.debian.org/git-pbuilder#Using_Local_Packages
Build Kwant packages using git-pbuilder
---------------------------------------
Update the builder environment (again, replace ``<dist>`` with the name of the
current Debian testing)::
ARCH=i386 DIST=<dist> git-pbuilder update
ARCH=amd64 DIST=<dist> git-pbuilder update
Make sure that the working directory is completely clear::
git clean -id
(Note that pytest has the nasty habit of creating a hidden ``.pytest_cache``
directory which gitignores itself. The above command will not delete this
directory, but git-pbuilder will complain.)
Now build the packages. First the i386 package. The option "--git-tag" tags
and signs the tag if the build is successful. In a second step, the package is
built for amd64, but only the architecture-dependent files (not the
documentation package)::
gbp buildpackage --git-pbuilder --git-arch=i386 --git-dist=<dist> --git-tag
gbp buildpackage --git-pbuilder --git-arch=amd64 --git-dist=<dist> --git-pbuilder-options='--binary-arch'
Another example: build source package only::
gbp buildpackage --git-export-dir=/tmp -S
Build backports for the current Debian stable
---------------------------------------------
Create a changelog entry for the backport::
DEBEMAIL=<your-email> dch --bpo
As shown above, run ``git-pbuilder update`` for the appropriate distribution
codename.
Build backported packages::
gbp buildpackage --git-pbuilder --git-ignore-new --git-arch=i386 --git-dist=<dist>
gbp buildpackage --git-pbuilder --git-ignore-new --git-arch=amd64 --git-dist=<dist> --git-pbuilder-options='--binary-arch'
Do not commit anything.
Publish the release
###################
If the Debian packages build correctly that means that all tests pass both on
i386 and amd64, and that no undeclared dependencies are needed. We can be
reasonably sure that the release is ready to be published.
git
---
Push the tag to the official Kwant repository::
git push origin v<version>
PyPI
----
Install `twine <https://pypi.org/project/twine>`_ and run the following
(this requires a file ~/.pypirc with a valid username and password: ask
Christoph Groth to add you as a maintainer on PyPI, if you are not already)::
twine upload -s dist/kwant-<version>.tar.gz
It is very important that the tarball uploaded here is the same (bit-by-bit,
not only the contents) as the one used for the Debian packaging. Otherwise it
will not be possible to build the Debian package based on the tarball from
PyPI.
Kwant website
-------------
The following requires ssh access to ``kwant-project.org`` (ask Christoph
Groth). The tarball and its signature (generated by the twine command above) should be
uploaded to the downloads section of the website::
scp dist/kwant-<version>.tar.gz* kwant:web/downloads/kwant
Debian packages
---------------
Go to the Debian packaging repository and push out the changes::
git push --tags origin master upstream
Now the Debian packages that we built previously need to be added to the
repository of Debian packages on the Kwant website. So far the full
version of this repository is kept on Christoph Groth's machine, so these
instructions are for reference only.
Go to the reprepro repository directory and verify that the configuration file
"conf/distributions" looks up-to-date. It should look something like this (be
sure to update the codenames and the versions)::
Origin: Kwant project
Suite: stretch-backports
Codename: stretch-backports
Version: 9.0
Architectures: i386 amd64 source
Components: main
Description: Unofficial Debian package repository of https://kwant-project.org/
SignWith: C3F147F5980F3535
Origin: Kwant project
Suite: testing
Codename: buster
Version: 10.0
Architectures: i386 amd64 source
Components: main
Description: Unofficial Debian package repository of https://kwant-project.org/
SignWith: C3F147F5980F3535
If the config had to be updated execute::
reprepro --delete clearvanished
reprepro export
reprepro --delete createsymlinks
In addition to the above, if distributions were removed from the
configuration file the corresponding directories must be removed
manually from under the `dists` subdirectory.
Now the source and binary Debian packages can be added. The last line has to
be executed for all the .deb files and may be automated with a shell loop. (Be
sure to use the appropriate <dist>: for the above configuratoin file either
"testing" or "stretch-backports".)::
reprepro includedsc <dist> ../../src/kwant_<version>-1.dsc
reprepro includedeb <dist> python3-kwant_<version>-1_amd64.deb
Once all the packages have been added, upload the repository::
rsync -avz --delete dists pool kwant-project.org:webapps/downloads/debian
Ubuntu packages
---------------
Packages for Ubuntu are provided as a PPA (Personal Package Archive):
https://launchpad.net/~kwant-project/+archive/ubuntu/ppa
Make sure ~/.dput.cf has something like this::
[ubuntu-ppa-kwant]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~kwant-project/ppa/ubuntu/
login = anonymous
allow_unsigned_uploads = 0
We will also use the following script (prepare_ppa_upload)::
#!/bin/sh
if [ $# -eq 0 ]; then
echo -e "\nUsage: $(basename $0) lousy mourning2 nasty\n"
exit
fi
version=`dpkg-parsechangelog --show-field Version`
mv debian/changelog /tmp/changelog.$$
for release in $@; do
cp /tmp/changelog.$$ debian/changelog
DEBEMAIL=christoph.groth@cea.fr dch -b -v "$version~$release" -u low 'Ubuntu PPA upload'
sed -i -e "1,1 s/UNRELEASED/${release%[0-9]}/" debian/changelog
debuild -S -sa
done
mv /tmp/changelog.$$ debian/changelog
Make sure that the Debian package builds correctly and go to its directory.
Check https://wiki.ubuntu.com/Releases for the relevant releases (we want to
provide packages at least for the current LTS release and the newer non-LTS
releases) and execute::
prepare_ppa_upload <dist0> <dist1> <dist2>
(if a second upload of the same Debian version is needed, something like "vivid2" instead of "vivid" can be used.)
Now the changes files are "put" to start the build process on the PPA servers::
cd ..
dput ubuntu-ppa-kwant *~*.changes
Clone the repository of the Kwant conda-forge package
-----------------------------------------------------
This step needs to be performed only once. The cloned repository can be reused
for subsequent releases.
Clone the "Kwant feedstock" repository and go into its root directory. If you
keep the Kwant source in "src/kwant", a good location for the Conda package
repository is "src/conda-forge/kwant"::
cd ~/src
mkdir conda-forge
cd conda-forge
git clone https://github.com/conda-forge/kwant-feedstock kwant
cd kwant
Rename the default remote to ``upstream``::
git remote rename origin upstream
Create a new version of the Kwant conda-forge package
-----------------------------------------------------
Edit the file ``recipe/meta.yml``. Correctly set the ``version``
at the top of the file to the version of this release. Set the ``sha256``
string in the ``source`` section near the top of the file to the SHA256 hash
of the kwant source tarball that we previously created. You can find the
SHA256 hash by running ``openssl sha256 <filename>`` on Linux and Mac OSX.
Commit your changes.
Conda forge
-----------
This step requires a GitHub account, as Conda forge packages are autobuilt
from repositories hosted on GitHub.
Fork the `Kwant feedstock <https://github.com/conda-forge/kwant-feedstock>`_
repository and add your fork as a remote to the copy that you previously cloned::
cd ~/conda-forge/kwant
git remote add myfork https://github.com/<your-gh-username>/kwant-feedstock
Push the changes that you previously commited to your fork::
git push myfork master
Open a pull request to Kwant feedstock repository. Ask Bas Nijholt or
Joseph Weston to review and accept the pull request.
Documentation
-------------
The following requires ssh access to ``kwant-project.org``.
Ask Christoph Groth if you need to be granted access.
Upload the zipped HTML and PDF documentation::
scp dist/kwant-doc-<version>.{zip,pdf} kwant:web/downloads/doc
Upload the HTML documentation for the website::
rsync -rlv --delete doc/build/html/* kwant:web/main/doc/<short-version>
where in the above ``<short-version>`` is just the major and minor version numbers.
Finally, create symbolic links for the website::
ssh kwant
for e in zip pdf; do ln -sf kwant-doc-<version>.$e webapps/downloads/doc/latest.$e; done
ln -nsf <short-version> webapps/kwant/doc/<major>
exit
Announce the release
####################
Write a short post summarizing the highlights of the release on the
`Kwant website <https://gitlab.kwant-project.org/kwant/website>`, then
post this to the mailing list kwant-discuss@kwant-project.org.
Working towards the next release
################################
After finalizing a release, a new ``whatsnew`` file should be created for
the *next* release, and this addition should be committed and tagged as::
<new major>.<new minor>.<new patch>a0
This tag should be pushed to Kwant Gitlab, and a new milestone for the next
release should be created.
# Copyright 2011-2017 Kwant authors.
# Copyright 2011-2018 Kwant authors.
#
# This file is part of Kwant. It is subject to the license terms in the file
# LICENSE.rst found in the top-level directory of this distribution and at
# http://kwant-project.org/license. A list of Kwant authors can be found in
# https://kwant-project.org/license. A list of Kwant authors can be found in
# the file AUTHORS.rst at the top-level directory of this distribution and at
# http://kwant-project.org/authors.
# https://kwant-project.org/authors.
"""Pytest plugin to ignore packages that have uninstalled dependencies.
This ignores packages on test collection, which is required when the
......@@ -17,7 +17,8 @@ import importlib
# map from subpackage to sequence of dependency module names
subpackage_dependencies = {
'kwant/continuum': ['sympy']
'kwant/continuum': ['sympy'],
'kwant/tests/test_qsymm': ['qsymm', 'sympy'],
}
......
# Makefile for Sphinx documentation
# Copyright 2011-2017 Kwant authors.
# Minimal makefile for Sphinx documentation
#
# This file is part of Kwant. It is subject to the license terms in the file
# LICENSE.rst found in the top-level directory of this distribution and at
# http://kwant-project.org/license. A list of Kwant authors can be found in
# the file AUTHORS.rst at the top-level directory of this distribution and at
# http://kwant-project.org/authors.
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python3 -c 'import sys, sphinx; sys.exit(sphinx.main(sys.argv))'
PAPER =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# We convert all SVG files to PDF for LaTeX output. For HTML output, we don't
# create PNGs but rather use the SVG files directly.
FIGURESOURCES = $(shell find source -name "*.svg")
GENERATEDPDF = $(patsubst %.svg,%.pdf,$(FIGURESOURCES))
# Figure generation from patched tutorial scripts
#
# As make does not support the generation of multiple targets by a single
# invocation of a (non-implicit) rule, we use a trick: We pretend to be
# generating a single (empty) flag file per invocation. The figure files are
# generated as well, but only as side-effects. Each flag file is used to
# remember the time at which the corresponding figure-generating script was run.
# This works perfectly unless the actual output files are deleted without
# deleting the corresponding flag file.
FIGSCRIPTS = $(patsubst %.diff,%,$(notdir $(wildcard source/code/figure/*.py.diff)))
FIGURES = $(patsubst %.py,source/code/figure/.%_flag,$(FIGSCRIPTS))
SCRIPTS = $(sort $(FIGSCRIPTS) $(notdir $(wildcard source/code/include/*.py)))
INCLUDES = $(patsubst %,source/code/include/%,$(SCRIPTS))
DOWNLOADS = $(patsubst %,source/code/download/%,$(SCRIPTS))
.PHONY: help clean realclean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
# Put it first so that "make" without argument is like "make help".
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo
@echo "Append SPHINXOPTS='-A website_deploy=True' to include web analytics code."
clean:
-rm -rf $(BUILDDIR)/* $(GENERATEDPDF)
-rm -rf source/reference/generated
realclean: clean
-rm -f $(FIGURES)
-rm -f $(patsubst %,source/code/include/%,$(FIGSCRIPTS))
-rm -f $(DOWNLOADS)
-rm -f $(patsubst %,source/code/figure/%,$(FIGSCRIPTS))
-rm -f $(patsubst %.py,source/code/figure/%_*.png,$(FIGSCRIPTS))
-rm -f $(patsubst %.py,source/code/figure/%_*.pdf,$(FIGSCRIPTS))
html: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
pickle: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
.PHONY: help Makefile
json: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp: $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/kwant.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/kwant.qhc"
latex: $(GENERATEDPDF) $(FIGURES) $(INCLUDES) $(DOWNLOADS)
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
%.pdf: %.svg
rsvg-convert -f pdf -o $@ $<
# Make tutorial scripts by extracting the (complete!) context of the "patches".
# We make sure not to use 'wiggle' here.
.SECONDARY:
source/code/include/%.py: source/code/figure/%.py.diff
@sed -n '/^[- ]/ s/^.//p' <$< >$@
@touch -r $< $@
source/code/download/%.py: source/code/include/%.py
@mkdir -p source/code/download
@grep -v '^#HIDDEN' <$< >$@
# Make the figure generation scripts by patching tutorial scripts. If the
# tutorial scripts haven't been modified, don't patch but directly extract the
# figure generation scripts. This means that 'wiggle' is only needed when the
# tutorial scripts have been modified.
.SECONDARY:
source/code/figure/%.py: source/code/include/%.py
@if [ $< -nt $@.diff ]; then \
cp $< $@; \
rm -f $@.porig; \
if ! wiggle --replace $@ $@.diff; then \
command -v wiggle >/dev/null 2>&1 && \
echo "Resolve conflicts by editing the files named below"; \
touch -d@0 $@; \
exit 1; \
fi \
else \
sed -n '/^[+ ]/ s/^.//p' <$@.diff >$@; \
touch -r $@.diff $@; \
fi
clean:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Make the figure generation scripts also depend on the diffs.
define makedep
source/code/figure/$(1): source/code/figure/$(1).diff
endef
$(foreach name,$(FIGSCRIPTS),$(eval $(call makedep,$(name))))
latex:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Run an figure generation script. When successful, and if the script is newer
# than the corresponding diff, recreate the latter. Note that the
# corresponding tutorial script cannot be newer, since if it is, the figure
# generation script is generated from it by patching.
source/code/figure/.%_flag: source/code/figure/%.py
cd $(dir $<) && python3 $(notdir $<)
@if [ ! -f $<.diff -o $< -nt $<.diff ]; then \
wiggle --diff --lines source/code/include/$(notdir $<) $< >$<.diff; \
touch -r $< $<.diff; \
fi
@rm -f $<.porig
@touch $@
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
/* This theme is based on pydoctheme by Georg Brandl. */
@import url("default.css");
body {
background-color: white;
margin-left: 1em;
margin-right: 1em;
}
/* Disable typewriter font in headings. */
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
font-family: "Bitstream Vera Sans", Verdana, sans-serif;
font-size: 100%;
}
div.body p, div.body dd, div.body li {
-webkit-hyphens: auto;
-moz-hyphens: auto;
-ms-hyphens: auto;
-o-hyphens: auto;
hyphens: auto;
}
div.related {
margin-bottom: 1.2em;
padding: 0.5em 0;
border-top: 1px solid #ccc;
margin-top: 0.5em;
}
dt:target, .highlighted {
background-color: #fbf1aa;
}
div.related:first-child {
border-top: 0;
border-bottom: 1px solid #ccc;
}
div.sphinxsidebar {
background-color: #eeeeee;
border-radius: 5px;
line-height: 130%;
font-size: smaller;
overflow: hidden;
}
div.sphinxsidebar h3, div.sphinxsidebar h4 {
margin-top: 1.5em;
}
div.sphinxsidebarwrapper > h3:first-child {
margin-top: 0.2em;
}
div.sphinxsidebarwrapper > ul > li > ul > li {
margin-bottom: 0.4em;
}
div.sphinxsidebar input {
font-family: 'Bitstream Vera Serif', Georgia, serif
border: 1px solid #999999;
font-size: smaller;
border-radius: 3px;
}
div.sphinxsidebar input[type=text] {
max-width: 220px;
}
div.body {
padding: 0 0 0 1.2em;
}
div.body p {
line-height: 140%;
}
div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 {
margin: 0;
border: 0;
padding: 0.3em 0;
}
div.body hr {
border: 0;
background-color: #ccc;
height: 1px;
}
div.body pre {
border-radius: 3px;
border: 1px solid #ac9;
}
div.body div.admonition, div.body div.impl-detail {
border-radius: 3px;
}
div.body div.impl-detail > p {
margin: 0;
}
div.body div.seealso {
border: 1px solid #dddd66;
}
tt, pre {
font-family: monospace, sans-serif;
font-size: 96.5%;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
-o-hyphens: none;
hyphens: none;
}
div.body tt {
border-radius: 3px;
}
div.body tt.descname {
font-size: 120%;
}
div.body tt.xref, div.body a tt {
font-weight: normal;
}
p.deprecated {
border-radius: 3px;
}
table.docutils {
border: 1px solid #ddd;
min-width: 20%;
border-radius: 3px;
margin-top: 10px;
margin-bottom: 10px;
}
table.docutils td, table.docutils th {
border: 1px solid #ddd !important;
border-radius: 3px;
}
table p, table li {
text-align: left !important;
}
table.docutils th {
background-color: #eee;
padding: 0.3em 0.5em;
}
table.docutils td {
background-color: white;
padding: 0.3em 0.5em;
}
table.footnote, table.footnote td {
border: 0 !important;
}
div.footer {
line-height: 150%;
margin-top: -2em;
text-align: right;
width: auto;
margin-right: 10px;
}
/* have arguments of functions or classes also a monospace font */
table.longtable.docutils > tbody > tr > td:first-child,
dl.function > dt,
dl.class > dt,
dl.method > dt
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 96.5%;
}
/* rescale font for <tt> so that it is again 96.5% with respect to body */
table.longtable.docutils > tbody > tr > td:first-child tt,
dl.function > dt tt,
dl.class > dt tt,
dl.method > dt tt
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 100%;
}
td.field-body strong
{
font-family: "Bitstream Vera Sans Mono", monospace, serif;
font-size: 96.5%;
}
# This theme is based on pydoctheme by Georg Brandl
[theme]
inherit = default
stylesheet = kwantdoctheme.css
pygments_style = sphinx
[options]
bodyfont = "Bitstream Vera Serif", Georgia, serif
headfont = "Bitstream Vera Sans", Verdana, sans-serif
footerbgcolor = white
footertextcolor = #555555
relbarbgcolor = white
relbartextcolor = #666666
relbarlinkcolor = #444444
sidebarbgcolor = white
sidebartextcolor = #444444
sidebarlinkcolor = #444444
sidebarwidth = 300
bgcolor = white
textcolor = black
linkcolor = #045e94
visitedlinkcolor = #045e94
headtextcolor = black
headbgcolor = white
headlinkcolor = #aaaaaa
@import "kwantdoctheme.css";
/* spacing around blockquoted fields in parameters/attributes/returns */
/* Essential. Otherwise there is way too much space around*/
td.field-body > blockquote {
margin-top: 0.1em;
margin-bottom: 0.5em;
}
.field-list th {
/* color: rgb(0,50,150); */
/* background-color: #EEE8AA; */
white-space: nowrap; /* Essential. Otherwise the colons can break
into a new line */
}
table.field-list {
border-collapse: separate; /* Essential. Otherwise Parameters and Returns
are sharing one solid colored field. That looks
weird. */
border-spacing: 10px;
border-style: hidden;
}
div.specialnote-title {
font-size: 105%;
font-weight: bold;
font-color: #3B4D3C;
background-color: #DCE4DC;
padding: 1em;
padding-top: 0.4em;
padding-bottom: 0.4em;
margin-top: 10px;
margin-bottom: 10px;
border-width: 1px;
border-color: #546C55;
border-style: solid;
}
div.specialnote-body {
background-color: #DCE4DC;
padding: 1em;
padding-top: 0.1em;
padding-bottom: 0.4em;
margin-top: -10px;
margin-bottom: 10px;
border-width: 1px;
border-top-width: 0px;
border-color: #546C55;
border-style: solid;
}
################################################################
# Make matplotlib work without X11
################################################################
import matplotlib
matplotlib.use('Agg')
################################################################
# Prepend Kwant's build directory to sys.path
################################################################
import sys
from distutils.util import get_platform
sys.path.insert(0, "../../../../build/lib.{0}-{1}.{2}".format(
get_platform(), *sys.version_info[:2]))
################################################################
# Define constants for plotting
################################################################
pt_to_in = 1. / 72.
# Default width of figures in pts
figwidth_pt = 600
figwidth_in = figwidth_pt * pt_to_in
# Width for smaller figures
figwidth_small_pt = 400
figwidth_small_in = figwidth_small_pt * pt_to_in
# Sizes for matplotlib figures
mpl_width_in = figwidth_pt * pt_to_in
mpl_label_size = None # font sizes in points
mpl_tick_size = None
# dpi for conversion from inches
dpi = 90
@@ -1,127 +1,196 @@
# Tutorial 2.3.3. Nontrivial shapes
# =================================
#
# Physics background
# ------------------
# Flux-dependent transmission through a quantum ring
#
# Kwant features highlighted
# --------------------------
# - More complex shapes with lattices
# - Allows for discussion of subtleties of `attach_lead` (not in the
# example, but in the tutorial main text)
# - Modifcations of hoppings/sites after they have been added
+import _defs
from cmath import exp
from math import pi
import kwant
# For plotting
from matplotlib import pyplot
#HIDDEN_BEGIN_eusz
def make_system(a=1, t=1.0, W=10, r1=10, r2=20):
# Start with an empty tight-binding system and a single square lattice.
# `a` is the lattice constant (by default set to 1 for simplicity).
lat = kwant.lattice.square(a)
syst = kwant.Builder()
#### Define the scattering region. ####
# Now, we aim for a more complex shape, namely a ring (or annulus)
def ring(pos):
(x, y) = pos
rsq = x ** 2 + y ** 2
return (r1 ** 2 < rsq < r2 ** 2)
#HIDDEN_END_eusz
# and add the corresponding lattice points using the `shape`-function
#HIDDEN_BEGIN_lcak
syst[lat.shape(ring, (0, r1 + 1))] = 4 * t
syst[lat.neighbors()] = -t
#HIDDEN_END_lcak
# In order to introduce a flux through the ring, we introduce a phase on
# the hoppings on the line cut through one of the arms. Since we want to
# change the flux without modifying the Builder instance repeatedly, we
# define the modified hoppings as a function that takes the flux as its
# parameter phi.
#HIDDEN_BEGIN_lvkt
def hopping_phase(site1, site2, phi):
return -t * exp(1j * phi)
def crosses_branchcut(hop):
ix0, iy0 = hop[0].tag
# builder.HoppingKind with the argument (1, 0) below
# returns hoppings ordered as ((i+1, j), (i, j))
return iy0 < 0 and ix0 == 1 # ix1 == 0 then implied
# Modify only those hopings in x-direction that cross the branch cut
def hops_across_cut(syst):
for hop in kwant.builder.HoppingKind((1, 0), lat, lat)(syst):
if crosses_branchcut(hop):
yield hop
syst[hops_across_cut] = hopping_phase
#HIDDEN_END_lvkt
#### Define the leads. ####
# left lead
#HIDDEN_BEGIN_qwgr
sym_lead = kwant.TranslationalSymmetry((-a, 0))
lead = kwant.Builder(sym_lead)
def lead_shape(pos):
(x, y) = pos
return (-W / 2 < y < W / 2)
lead[lat.shape(lead_shape, (0, 0))] = 4 * t
lead[lat.neighbors()] = -t
#HIDDEN_END_qwgr
#### Attach the leads and return the system. ####
#HIDDEN_BEGIN_skbz
syst.attach_lead(lead)
syst.attach_lead(lead.reversed())
#HIDDEN_END_skbz
return syst
+def make_system_note1(a=1, t=1.0, W=10, r1=10, r2=20):
+ lat = kwant.lattice.square(a)
+ syst = kwant.Builder()
+ def ring(pos):
+ (x, y) = pos
+ rsq = x**2 + y**2
+ return ( r1**2 < rsq < r2**2)
+ syst[lat.shape(ring, (0, 11))] = 4 * t
+ syst[lat.neighbors()] = -t
+ sym_lead0 = kwant.TranslationalSymmetry((-a, 0))
+ lead0 = kwant.Builder(sym_lead0)
+ def lead_shape(pos):
+ (x, y) = pos
+ return (-1 < x < 1) and ( 0.5 * W < y < 1.5 * W )
+ lead0[lat.shape(lead_shape, (0, W))] = 4 * t
+ lead0[lat.neighbors()] = -t
+ lead1 = lead0.reversed()
+ syst.attach_lead(lead0)
+ syst.attach_lead(lead1)
+ return syst
+
+
+def make_system_note2(a=1, t=1.0, W=10, r1=10, r2=20):
+ lat = kwant.lattice.square(a)
+ syst = kwant.Builder()
+ def ring(pos):
+ (x, y) = pos
+ rsq = x**2 + y**2
+ return ( r1**2 < rsq < r2**2)
+ syst[lat.shape(ring, (0, 11))] = 4 * t
+ syst[lat.neighbors()] = -t
+ sym_lead0 = kwant.TranslationalSymmetry((-a, 0))
+ lead0 = kwant.Builder(sym_lead0)
+ def lead_shape(pos):
+ (x, y) = pos
+ return (-1 < x < 1) and ( -W/2 < y < W/2 )
+ lead0[lat.shape(lead_shape, (0, 0))] = 4 * t
+ lead0[lat.neighbors()] = -t
+ lead1 = lead0.reversed()
+ syst.attach_lead(lead0)
+ syst.attach_lead(lead1, lat(0, 0))
+ return syst
+
+
def plot_conductance(syst, energy, fluxes):
# compute conductance
normalized_fluxes = [flux / (2 * pi) for flux in fluxes]
data = []
for flux in fluxes:
smatrix = kwant.smatrix(syst, energy, args=[flux])
data.append(smatrix.transmission(1, 0))
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(normalized_fluxes, data)
- pyplot.xlabel("flux [flux quantum]")
- pyplot.ylabel("conductance [e^2/h]")
- pyplot.show()
+ pyplot.xlabel("flux [flux quantum]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("conductance [e^2/h]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ fig.savefig("ab_ring_result.pdf")
+ fig.savefig("ab_ring_result.png", dpi=_defs.dpi)
def main():
syst = make_system()
# Check that the system looks as intended.
- kwant.plot(syst)
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+ for extension in ('pdf', 'png'):
+ kwant.plot(syst, file="ab_ring_syst." + extension,
+ fig_size=size, dpi=_defs.dpi)
+
# Finalize the system.
syst = syst.finalized()
# We should see a conductance that is periodic with the flux quantum
plot_conductance(syst, energy=0.15, fluxes=[0.01 * i * 3 * 2 * pi
for i in range(100)])
+ # Finally, some plots needed for the notes
+ syst = make_system_note1()
+ for extension in ('pdf', 'png'):
+ kwant.plot(syst, file="ab_ring_note1." + extension,
+ fig_size=size, dpi=_defs.dpi)
+ syst = make_system_note2()
+ for extension in ('pdf', 'png'):
+ kwant.plot(syst, file="ab_ring_note2." + extension,
+ fig_size=size, dpi=_defs.dpi)
+
+
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
@@ -1,52 +1,62 @@
# Tutorial 2.4.1. Band structure calculations
# ===========================================
#
# Physics background
# ------------------
# band structure of a simple quantum wire in tight-binding approximation
#
# Kwant features highlighted
# --------------------------
# - Computing the band structure of a finalized lead.
+import _defs
import kwant
# For plotting.
from matplotlib import pyplot
#HIDDEN_BEGIN_zxip
def make_lead(a=1, t=1.0, W=10):
# Start with an empty lead with a single square lattice
lat = kwant.lattice.square(a)
sym_lead = kwant.TranslationalSymmetry((-a, 0))
lead = kwant.Builder(sym_lead)
# build up one unit cell of the lead, and add the hoppings
# to the next unit cell
for j in range(W):
lead[lat(0, j)] = 4 * t
if j > 0:
lead[lat(0, j), lat(0, j - 1)] = -t
lead[lat(1, j), lat(0, j)] = -t
return lead
#HIDDEN_END_zxip
#HIDDEN_BEGIN_pejz
def main():
lead = make_lead().finalized()
- kwant.plotter.bands(lead, show=False)
- pyplot.xlabel("momentum [(lattice constant)^-1]")
- pyplot.ylabel("energy [t]")
- pyplot.show()
+ fig = kwant.plotter.bands(lead, show=False)
+ pyplot.xlabel("momentum [(lattice constant)^-1]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [t]", fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("band_structure_result." + extension, dpi=_defs.dpi)
+
#HIDDEN_END_pejz
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()
@@ -1,140 +1,157 @@
# Tutorial 2.4.2. Closed systems
# ==============================
#
# Physics background
# ------------------
# Fock-darwin spectrum of a quantum dot (energy spectrum in
# as a function of a magnetic field)
#
# Kwant features highlighted
# --------------------------
# - Use of `hamiltonian_submatrix` in order to obtain a Hamiltonian
# matrix.
+import _defs
from cmath import exp
import numpy as np
import kwant
# For eigenvalue computation
#HIDDEN_BEGIN_tibv
import scipy.sparse.linalg as sla
#HIDDEN_END_tibv
# For plotting
from matplotlib import pyplot
def make_system(a=1, t=1.0, r=10):
# Start with an empty tight-binding system and a single square lattice.
# `a` is the lattice constant (by default set to 1 for simplicity).
#HIDDEN_BEGIN_qlyd
lat = kwant.lattice.square(a, norbs=1)
syst = kwant.Builder()
# Define the quantum dot
def circle(pos):
(x, y) = pos
rsq = x ** 2 + y ** 2
return rsq < r ** 2
def hopx(site1, site2, B=0):
# The magnetic field is controlled by the parameter B
y = site1.pos[1]
return -t * exp(-1j * B * y)
syst[lat.shape(circle, (0, 0))] = 4 * t
# hoppings in x-direction
syst[kwant.builder.HoppingKind((1, 0), lat, lat)] = hopx
# hoppings in y-directions
syst[kwant.builder.HoppingKind((0, 1), lat, lat)] = -t
# It's a closed system for a change, so no leads
return syst
#HIDDEN_END_qlyd
#HIDDEN_BEGIN_yvri
def plot_spectrum(syst, Bfields):
# In the following, we compute the spectrum of the quantum dot
# using dense matrix methods. This works in this toy example, as
# the system is tiny. In a real example, one would want to use
# sparse matrix methods
energies = []
for B in Bfields:
# Obtain the Hamiltonian as a dense matrix
ham_mat = syst.hamiltonian_submatrix(args=[B], sparse=True)
# we only calculate the 15 lowest eigenvalues
ev = sla.eigsh(ham_mat, k=15, which='SM', return_eigenvectors=False)
energies.append(ev)
- pyplot.figure()
+ fig = pyplot.figure()
pyplot.plot(Bfields, energies)
- pyplot.xlabel("magnetic field [arbitrary units]")
- pyplot.ylabel("energy [t]")
- pyplot.show()
+ pyplot.xlabel("magnetic field [arbitrary units]",
+ fontsize=_defs.mpl_label_size)
+ pyplot.ylabel("energy [t]", fontsize=_defs.mpl_label_size)
+ pyplot.setp(fig.get_axes()[0].get_xticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ pyplot.setp(fig.get_axes()[0].get_yticklabels(),
+ fontsize=_defs.mpl_tick_size)
+ fig.set_size_inches(_defs.mpl_width_in, _defs.mpl_width_in * 3. / 4.)
+ fig.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
+ for extension in ('pdf', 'png'):
+ fig.savefig("closed_system_result." + extension, dpi=_defs.dpi)
#HIDDEN_END_yvri
#HIDDEN_BEGIN_wave
def plot_wave_function(syst):
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+
# Calculate the wave functions in the system.
ham_mat = syst.hamiltonian_submatrix(sparse=True)
evecs = sla.eigsh(ham_mat, k=20, which='SM')[1]
# Plot the probability density of the 10th eigenmode.
- kwant.plotter.map(syst, np.abs(evecs[:, 9])**2,
- colorbar=False, oversampling=1)
+ for extension in ('pdf', 'png'):
+ kwant.plotter.map(
+ syst, np.abs(evecs[:, 9])**2, colorbar=False, oversampling=1,
+ file="closed_system_eigenvector." + extension,
+ fig_size=size, dpi=_defs.dpi)
#HIDDEN_END_wave
#HIDDEN_BEGIN_current
def plot_current(syst):
+ size = (_defs.figwidth_in, _defs.figwidth_in)
+
# Calculate the wave functions in the system.
ham_mat = syst.hamiltonian_submatrix(sparse=True)
evecs = sla.eigsh(ham_mat, k=20, which='SM')[1]
# Calculate and plot the local current of the 10th eigenmode.
J = kwant.operator.Current(syst)
current = J(evecs[:, 9])
- kwant.plotter.current(syst, current, colorbar=False)
+ for extension in ('pdf', 'png'):
+ kwant.plotter.current(
+ syst, current, colorbar=False,
+ file="closed_system_current." + extension,
+ fig_size=size, dpi=_defs.dpi)
#HIDDEN_END_current
def main():
syst = make_system()
- # Check that the system looks as intended.
- kwant.plot(syst)
-
# Finalize the system.
syst = syst.finalized()
# The following try-clause can be removed once SciPy 0.9 becomes uncommon.
try:
# We should observe energy levels that flow towards Landau
# level energies with increasing magnetic field.
plot_spectrum(syst, [iB * 0.002 for iB in range(100)])
# Plot an eigenmode of a circular dot. Here we create a larger system for
# better spatial resolution.
syst = make_system(r=30).finalized()
plot_wave_function(syst)
plot_current(syst)
except ValueError as e:
if e.message == "Input matrix is not real-valued.":
print("The calculation of eigenvalues failed because of a bug in SciPy 0.9.")
print("Please upgrade to a newer version of SciPy.")
else:
raise
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()