Skip to content
forked from kenokrieger/QmPy

Python package containing routines to numerically solve and visualize the schroedinger equation for different potentials. It also features an executable script.

License

Notifications You must be signed in to change notification settings

helmutwecke/QmPy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QmPy is a python package containing routines to numerically solve and visualize the schroedinger equation for different potentials. Its main purpose is to support an executable script called qmsolve which combines the functionalities above.

Disclaimer

This is a student project. It utilizes very unstable and simple numerical algorithms.

Requirements

This package requires Python 3.6 or higher and the packages numpy, scipy, matplotlib and os.

Installation

For easy installation with pip use:

pip install -i https://test.pypi.org/simple/ qmpy-schrodinger

Usage

Using the script

The script requires a configuration file which contains all the necessary information about the quantum mechanical system. This file needs to be named 'schrodinger.inp' and must have the following structure:

float # mass
flaot float float/int # xMin xMax nPoint
int int # first and last eigenvalue to include in the output
str # interpolation type
int # nr. of interpolation points and xy declarations
float float
float float
... ...

By default qmsolve will look for the 'schrodinger.inp' file in the directory where it is run. You can, however, specify the path to the file with the -i option.
The script can be run via the command line by either using

./qmsolve -C -V

where the script file is stored, or

qmsolve -C -V

anywhere if the package was installed using pip.

It supports computing energies, wavefunctions and expected values for the x-coordinate, which is done by selecting the option -C. The results may also be visualized by selecting -V. It also takes numerous optional arguments which will be listed when using the -h option.

Using the modules

Calculating the first four energies and wavefunctions of a particle in a box aswell as the expected values and uncertainties for the x-xoordinate for each state.

from qmpy.solvers import schroedinger, calculate_expval, calculate_uncertainty
from numpy import linspace, zeros

mass = 2.0
xcords = linspace(-2, 2, 1999)
pot = zeros((1999, ))

vals = {'mass': mass,
        'xcords': xcords,
        'potential': pot}

# returns the first four energies and wavefunctions
energies, wfuncs = schroedinger(vals, select_range=(0, 3))

# calculate the expected value for the x-coordinate for each state
expvals = calculate_expval(xcoords, wfuncs)

# calculate the uncertainty of the x-coordinate for each state
uncs = calculate_uncertainty(xcoords, wfuncs)

Plotting numerical data contained in a directory

from qmpy.graphics import qm_plottings

# directory containing the files potential.dat, energies.dat,
# wavefuncs.dat, and expvalues.dat.
datadir = 'myqmdata/'

# plot the data and save the plot as 'my_plot.png'
qm_plottings(datadir, sname='my_plot.png')

Documentation

The documentation can be found at kenokrieger.github.io/qmpy. If you want to create the documentation yourself using sphinx you may do so by changing in the docs/ directory and executing the command make html.

Tests

Tests for the package are located in the tests/ directory. The tests can all be run via pytest through the command line (python3 -m pytest in the highest directory).

Contributing

Contributions are always welcome. To contribute fork the repository from github and develop your feature including unit tests. For your contribution to be incorporated in the main build issue a pull request.

License

BSD 2-Clause License
See LICENSE.txt for further information.

About

Python package containing routines to numerically solve and visualize the schroedinger equation for different potentials. It also features an executable script.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%