Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

QMsolve: A module for solving and visualizing the Schrödinger equation

PyPi Python Versions PyPI Version Chat

animation

QMsolve seeks to provide a solid and easy to use solver, capable of solving the Schrödinger equation for one and two particles, and creating descriptive and stunning visualizations of its solutions both in 1D, 2D, and 3D.

Installation

pip install qmsolve

3D plotting requires to have installed Mayavi. To install Mayavi directly along with QMsolve, you can type:

pip install qmsolve[with_mayavi]

How it works

The way this simulator works is by discretizing the Hamiltonian with an arbitrary potential, specified as a function of the particle observables. This is achieved with the Hamiltonian constructor.

Then, the Hamiltonian.solve method efficiently diagonalizes the Hamiltonian and outputs the energies and the eigenstates of the system. Finally, the eigenstates can be plotted with the use of the visualization class.

The visualization.superpositions method features the possibility of interactively visualizing a superposition of the computed eigenstates and studying the time dependence of the resulting wavefunction.

For a quick start, take a look to the examples found in the examples subdirectory.

Examples

To perform the simulations, just run from the corresponding Python scripts on the command prompt.

python 1D_harmonic_oscillator.py

animation

python 1D_interactive_fermions_HO.py

animation

python 1D_non_interactive_fermions_HO.py

animation

python 3D_four_gaussian_wells.py

animation

In the two interactive particle examples from above you can check how in the non interactive case the energy levels are equally spaced and degenerated, however in the interactive case the degeneracy is broken. As a starting point I suggest you to modify the confinement and the interaction potential to see what happens!

The interface use Hartree atomic units for input. In the file constants.py there is a list of common conversion factors from other units, that can be imported and used to build your potential.

3D examples are considerably faster when using a GPU. GPU acceleration requires having CuPy and CUDA installed in your computer.

To use GPU acceleration in your 3D simulations, add the argument method ='lobpcg-cupy' in the Hamiltonian solve method. For example:

eigenstates = H.solve( max_states = 50, method ='lobpcg-cupy')

Contributors