Database

The internal database provides benchmark Hamiltonians and reference energies for testing solvers. Each Hamiltonian can be passed to a solver and its result compared with the reference energy. The database is not exported because it is intended for package development.

Usage

using TwoBody

Retrieve a benchmark using its key:

julia> entry = TwoBody.db(:hydrogen)TwoBody.DatabaseEntry{Float64}(Hamiltonian(Kinetic(hbar=1.0, m=1.0), Coulomb(coefficient=-1.0)), -0.5)
julia> entry.hamiltonianHamiltonian(Kinetic(hbar=1.0, m=1.0), Coulomb(coefficient=-1.0))
julia> entry.energy-0.5

Add a benchmark using TwoBody.put!:

julia> hamiltonian = Hamiltonian(
           Kinetic(hbar = 1.0, m = 1.0),
           Coulomb(coefficient = -1.0),
       )

julia> TwoBody.put!(:example, hamiltonian, -0.5)

Duplicate keys are rejected, and Hamiltonians are copied on registration and lookup to protect stored benchmarks.

Data

KeySystemReference energy
:hydrogenHydrogen ground state-0.5
:positroniumPositronium ground state-0.25
:harmonic_oscillatorThree-dimensional harmonic oscillator ground state1.5

API

TwoBody.DatabaseEntryType
DatabaseEntry(hamiltonian, energy)

A benchmark problem stored in the database. hamiltonian is ready to be passed to a solver and energy is its reference energy.

source
Base.put!Function
put!(key, hamiltonian, energy)

Add a benchmark problem to the database. key may be a Symbol or string, hamiltonian must be a Hamiltonian, and energy must be real. Registering the same key twice throws an ArgumentError.

source
TwoBody.dbFunction
db(key::Union{Symbol,AbstractString}) -> DatabaseEntry

Return the benchmark Hamiltonian and reference energy associated with key. The returned Hamiltonian is independent of the stored value and can safely be modified by callers.

Examples

entry = db(:hydrogen)
result = solve(entry.hamiltonian, method)
isapprox(result.values[1], entry.energy)
source
TwoBody.dbkeysFunction
dbkeys() -> Vector{Symbol}

Return the available database keys in deterministic order.

source