Git Product home page Git Product logo

schrodinger's Introduction

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.

schrodinger's People

Contributors

rcarcasses avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

artur-amorim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.