Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge flake8 formatter into workflow #7

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application
name: Build and test

on:
push:
Expand All @@ -26,8 +26,14 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest flake8
pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# Quantum electron solver
![example workflow](https://github.com/gkoolstra/quantum_electron/actions/workflows/python-app.yml/badge.svg)
# Quantum Electron Solver
![image info](./images/electron_results.png)
## Main use cases
This package has two main functions
1. It can simulate electron positions in a two dimensional plane for electrons confined in an electrostatic potential. The electron-electron interactions are also taken into account.
2. It can solve the Schrodinger equation for a single electron confined in an electrostatic potential.
1. It simulates electron positions in a two dimensional plane for electrons confined in an electrostatic potential $\phi$. Electron-electron interactions are also taken into account. Physically, it minimizes the total energy of an $N$-electron system, which is given by:

In both cases there are methods to calculate couplings to a resonator and resonator frequency shifts due to electrons. This is useful the electrons are detected with a microwave resonator. If your experimental setup does not contain a resonator, you can safely ignore the methods in this library without compromise of the results.
$$ -e\sum_i \phi(\mathbf{r}_i) + \sum_{i<j} \frac{e^2}{4\pi \epsilon_0} \frac{1}{|\mathbf{r}_i - \mathbf{r}_j|}$$

After installation, it is advised to take a look at the `examples` folder to explore some of the functionalities of this module.
2. It calculates properties of in-plane electron modes. This is useful in two cases: (a) the electron motional states can be used for quantum computation, and this package can help to determine eigenfrequencies and eigenvectors of electron clusters (b) in the large $N$ limit the electron motional modes are also known as plasmons. There is an abundance of literature about these charge density waves, and many of the properties can be reproduced with this module.

![image info](./images/electron_results.png)
### Features
- Robust operation through the use of the `scipy.optimize.minimize` library. We assure proper and fast convergence because the force (gradient of the energy) is supplied as an argument of the minimizer.
- Supply arbitrary potential energies $\phi$, as long as they're on a rectangular grid.
- Handles problems up to $N \approx 400$ electrons in less than 1 minute on a laptop computer.
- Periodic boundary condition support for systems with open boundaries.
- Seemless integration with finite element modeling software ZeroHeliumKit.

## Installation

Expand All @@ -21,21 +28,14 @@ In a terminal window, change into the cloned directory:
cd quantum_electron
pip install -e .
```
After installation, it is advised to take a look at the `examples` folder to explore some of the functionalities of this module.

### Additional packages
To generate animations, this module relies on `ffmpeg`. On MacOS this can be easily installed using [homebrew](https://formulae.brew.sh/formula/ffmpeg) from the Terminal. On Windows it can be installed using the following [link](https://www.ffmpeg.org/download.html).

This module also integrates well with the output of the FEM software [ZeroHeliumKit](https://github.com/eeroqlab/zeroheliumkit). Please refer to any dependencies for ZHK on the linked github page.

## To-do list
- [ ] Standardize units of the arguments. Sometimes it is unclear whether to use microns or meters.
- [ ] Figure out how to handle warning messages for convergence issues. Why do problems sometimes have a hard time converging?
- [ ] Write documentation for example notebook 03
- [ ] Find a place for the code in example notebook 04.
- [ ] Split off the Schrodinger solver?
- [ ] Add some documentation to the library folder

## Test suite
## Tests
To test the performance of the minimization, we're building and expanding a suite of tests based on the `pytest` framework. To run these tests, `cd` into the main module directory and run `pytest`. Currently, we have implemented a test in `test_wigner_molecules.py`, which compares the energy per particle of Wigner molecules in a parabolic confinement to known tabulated values.

## Getting started
Expand Down Expand Up @@ -68,10 +68,22 @@ options = {"include_screening" : True, # Include screening of electron-electron
"max_y_displacement" : 0.1e-6} # Maximum y-displacement of solved electron positions during annealing.
```


## Tips for the initial condition
The initial condition can affect the final minimization result quite strongly. If there are issues with convergence you can first check convergence with `f.plot_convergence()`. A good final value for the cost function is ~1-500 eV/m. If the lowest value of the cost function is signifantly higher than this, or if warnings appear, here are some rules of thumb for successful convergence:
The initial condition can affect the final minimization result quite strongly. We encourage you to take a look at the example notebook about initial conditions. If there are issues with convergence you can first check convergence with `f.plot_convergence()`. A good final value for the cost function is ~1-500 eV/m. If the lowest value of the cost function is signifantly higher than this, or if warnings appear, here are some rules of thumb for successful convergence:
1. Don't create an initial condition where too many electrons are placed in a small area.
2. Don't place electrons in an initial condition where the potential is too flat, such as on a ground plane.
3. Be mindful of electron sinks, i.e. channels for electrons to escape. These can appear if an electrode is adjacent to the ground plane, and has an applied voltage that is more positive than the ground plane.

## Contributing
Contributions to this growing repository are welcome. Please feel free to create a fork and create a pull request with your suggested changes.

## Credit
If you found this module useful in your research, please consider citing this code in your publication using a hyperlink.

## To-do list
- [ ] Standardize units of the arguments. Sometimes it is unclear whether to use microns or meters.
- [ ] Figure out how to handle warning messages for convergence issues. Why do problems sometimes have a hard time converging?
- [ ] Write documentation for example notebook 03
- [ ] Find a place for the code in example notebook 04.
- [ ] Split off the Schrodinger solver?
- [ ] Performance metrics
1,261 changes: 630 additions & 631 deletions examples/00_harmonic_well.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion quantum_electron/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .electron_counter import FullModel
from .schrodinger_solver import QuantumAnalysis
from .utils import PotentialVisualization, package_versions
from ._version import __version__
from ._version import __version__
2 changes: 1 addition & 1 deletion quantum_electron/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# 1) we don't load dependencies by storing it in __init__.py
# 2) we can import it in setup.py for the same reason
# 3) we can import it into your module module
__version__ = '0.2.0'
__version__ = '0.2.1'
Loading
Loading