Skip to content

Solves one dimensional Schrodinger problem using several methods.

License

Notifications You must be signed in to change notification settings

rcarcasses/schrodinger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is an R package interface to C++ code that solves the one dimensional time independent Schrodinger equation. There are two ways to find the quantum spectrum, one using a Numerov algorithm implementation and another which uses a Chebyshev polynomial approach. Numerov routine seems to be better suited to compute the first one or two eigenvalues and eigenfunctions but for higher orders the Chebyshev routine seems to perform better (less time to get the same result). The two routines implemented provide a good way to cross check results computed with different methods.

Dependencies

The R package is created with Rcpp. The C++ code depends on the armadillo awesome library, make sure you have it in your path.

Install

# install devtools, ignore if already installed on your system
install.packages('devtools')
# install the library itself
devtools::install_github('rcarcasses/schrodinger')

The specific Chebyshev algorithm implemented is described here.

Usage

An example of how to use it is the following:

library(schrodinger)
# set 'cheb' method (Chebyshev) with 400 interpolation points.
chebSetN(400)
# create a potential: harmonic oscillator
x <- seq(-20, 20, len = 2000)
y <- x^2
# compute the spectrum of this potential, first 30 eigenvalues and eigenfunctions
# s$energies: eigenvalues
# s$wfs: respective eigenfunctions
s <- computeSpectrum(x, y, 30)

Selecting the algorithm

The default algorithm is cheb, which is the Chebyshev version. If you want to use the Numerov version pass 'numerov' as 4th parameter:

s <- computeSpectrum(x, y, 10, 'numerov')

and so on.

C++

You can use the code in src in your own C++ project. Make sure you are linking vs armadillo properly while building.

About

Solves one dimensional Schrodinger problem using several methods.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published