TwoBody.jl

Stable Dev Build Status

TwoBody.jl: a Julia package for two-body problems

Install

Run the following code on the REPL or Jupyter Notebook to install this package.

import Pkg; Pkg.add(url="https://github.com/ohno/TwoBody.jl.git")

Usage

Run the following code before each use.

using TwoBody

Define the Hamiltoninan. This is an example for the non-relativistic Hamiltonian of hydrogen atom in atomic units:

\[\hat{H} = - \frac{1}{2} \nabla^2 - \frac{1}{r}\]

hamiltonian = Hamiltonian(
  NonRelativisticKinetic(ℏ = 1 , m = 1),
  CoulombPotential(coefficient = -1),
)

The usage depends on the method. Define the basis set for the Rayleigh–Ritz method:

\[\begin{aligned} \phi_1(r) &= \exp(-13.00773 ~r^2), \\ \phi_2(r) &= \exp(-1.962079 ~r^2), \\ \phi_3(r) &= \exp(-0.444529 ~r^2), \\ \phi_4(r) &= \exp(-0.1219492 ~r^2). \end{aligned}\]

basisset = BasisSet(
  SimpleGaussianBasis(13.00773),
  SimpleGaussianBasis(1.962079),
  SimpleGaussianBasis(0.444529),
  SimpleGaussianBasis(0.1219492),
)

You should find

\[E_{n=1} = -0.499278~E_\mathrm{h},\]

which is amazingly good for only four basis functions according to Thijssen(2007). The exact ground-state energy is $-0.5~E_\mathrm{h}$.

julia> solve(hamiltonian, basisset)
n 	basis function φₙ
1	SimpleGaussianBasis(a=13.00773)
2	SimpleGaussianBasis(a=1.962079)
3	SimpleGaussianBasis(a=0.444529)
4	SimpleGaussianBasis(a=0.1219492)

n 	wavefuntion ψₙ
1	 + 0.096102 φ₁ + 0.163017 φ₂ + 0.185587 φ₃ + 0.073701 φ₄
2	 + 0.119454 φ₁ + 0.081329 φ₂ + 0.496216 φ₃ - 0.205916 φ₄
3	 - 0.010362 φ₁ + 1.744891 φ₂ - 0.629196 φ₃ + 0.097774 φ₄
4	 - 6.155100 φ₁ + 1.240202 φ₂ - 0.226412 φ₃ + 0.030780 φ₄

n 	norm, <ψ|ψ> = c' * S * c
1	0.9999999999999998
2	1.0000000000000004
3	1.0000000000000007
4	0.9999999999999988

n 	eigenvalue, E
1	-0.4992784056674876
2	0.11321392045798988
3	2.592299571959808
4	21.144365190122507

n 	expectation value of the Hamiltonian, <ψ|H|ψ> = c' * H * c
1	-0.49927840566748577
2	0.11321392045798652
3	2.592299571959811
4	21.14436519012249

n 	expectation value of NonRelativisticKinetic(ħ=1, m=1)
1	0.4992783686700055
2	0.8428088332141157
3	4.432656608731447
4	26.465623640332108

n 	expectation value of CoulombPotential(coefficient=-1)
1	-0.9985567743374912
2	-0.7295949127561296
3	-1.8403570367716342
4	-5.321258450209621

(hamiltonian = Hamiltonian(NonRelativisticKinetic(ħ=1, m=1), CoulombPotential(coefficient=-1)), basisset = BasisSet(SimpleGaussianBasis(a=13.00773), SimpleGaussianBasis(a=1.962079), SimpleGaussianBasis(a=0.444529), SimpleGaussianBasis(a=0.1219492)), E = [-0.4992784056674876, 0.11321392045798988, 2.592299571959808, 21.144365190122507], C = [0.09610151618612488 0.1194538057449333 -0.010362061881687392 -6.155100006789123; 0.16301716963905885 0.08132945379475047 1.7448913023470436 1.2402020851506472; 0.18558698714513683 0.49621626366832666 -0.6291955141735303 -0.22641160819529882; 0.07370076069275631 -0.20591550816511817 0.09777447415099819 0.030779842546714373], S = [0.041964064408426524 0.0961391814715395 0.11285790355607861 0.11704251263182287; 0.0961391814715395 0.7163167080668228 1.4914777365294443 1.8508423236885296; 0.11285790355607861 1.4914777365294443 6.642471010530628 13.060205391889545; 0.11704251263182287 1.8508423236885296 13.060205391889545 46.22866820431064], H = [0.5772684658780091 0.072002466903411 -0.32154049871511875 -0.43612626272313476; 0.072002466903411 0.5070499286923358 -0.9891848263978418 -2.377419924763058; -0.3215404987151187 -0.9891848263978418 -2.6380824346106566 -7.342216931051755; -0.43612626272313476 -2.3774199247630583 -7.342216931051756 -17.30516271277891])

API reference