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 TwoBodyRetrieve 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
| Key | System | Reference energy |
|---|---|---|
:hydrogen | Hydrogen ground state | -0.5 |
:positronium | Positronium ground state | -0.25 |
:harmonic_oscillator | Three-dimensional harmonic oscillator ground state | 1.5 |
API
TwoBody.DatabaseEntry — Type
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.
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.
TwoBody.db — Function
db(key::Union{Symbol,AbstractString}) -> DatabaseEntryReturn 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)TwoBody.dbkeys — Function
dbkeys() -> Vector{Symbol}Return the available database keys in deterministic order.