API
FewBodyPhysics.Utils.plot_density
— Methodplot_density(c₀, basis_fns; range=(-4.0, 4.0), N=200)
Plots the 2D probability density |ψ₀(x, y)|² in Jacobi space.
FewBodyPhysics.Utils.plot_wavefunction
— Methodplot_wavefunction(c₀, basis_fns; axis=1, range=(-4.0, 4.0), N=400)
Plots a 1D slice of the wavefunction ψ₀(x, 0) or ψ₀(0, y).
FewBodyPhysics.Utils.ψ₀
— Methodψ₀(r::Vector{Float64}, c₀::Vector{Float64}, basis_fns::Vector{<:GaussianBase})
Evaluates the ground state wavefunction ψ₀ at position r
.
FewBodyPhysics.Sampling.compute_ground_state_energy
— Methodcomputegroundstate_energy(basis::BasisSet, ops::Vector{Operator})
Construct the Hamiltonian and overlap matrices and return the lowest eigenvalue.
FewBodyPhysics.Sampling.corput
— Functioncorput(n::Int, b::Int=2)
Computes the n-th number in the van der Corput sequence in base b
using digit reversal. Follows the standard definition: qₙ = ∑ dₖ(n) * b^(-k-1)
FewBodyPhysics.Sampling.generate_basis
— Functiongenerate_basis(widths::Vector{Matrix{Float64}}, rank::Int=0)
Construct a BasisSet
from a list of correlation matrices and optional rank.
FewBodyPhysics.Sampling.generate_bij
— Methodgenerate_bij(method::Symbol, i::Int, n_terms::Int, b1::Float64) -> Vector{Float64}
Generate a bij vector using the specified sampling method. Supported methods: :quasirandom, :psudorandom
FewBodyPhysics.Sampling.halton
— Methodhalton(n::Int, d::Int)
Generates the nth Halton sequence vector in d
dimensions.
FewBodyPhysics.Coordinates.ParticleSystem
— Typestruct ParticleSystem
A structure representing a system of particles with associated masses and coordinate transformations.
Fields
masses::Vector{Float64}
: A vector containing the masses of the particles in the system. Must contain at least two elements.J::Matrix{Float64}
: The Jacobi transformation matrix for the particle system, computed based on the masses.U::Matrix{Float64}
: An auxiliary transformation matrix for the particle system, computed based on the masses.scale::Union{Symbol,Nothing}
: An optional symbol indicating the scale of the system (e.g.,:atomic
,:molecular
,:nuclear
). Defaults tonothing
.
Constructor
ParticleSystem(masses::Vector{Float64}; scale::Union{Symbol,Nothing}=nothing)
: Creates a newParticleSystem
instance. Themasses
vector must contain at least two elements. Thescale
parameter is optional and can be used to specify the scale of the system. The Jacobi and auxiliary transformation matrices (J
andU
) are computed internally using thejacobi_transform
function.
FewBodyPhysics.Coordinates.default_b0
— Methoddefault_b0(scale::Union{Symbol,Nothing}) -> Float64
Returns a default value for the parameter b0
based on the provided scale
.
Arguments
scale::Union{Symbol,Nothing}
: A symbol representing the scale type ornothing
.:atomic
: Returns1.0
, corresponding to the Bohr radius in atomic units.:molecular
: Returns3.0
, representing a typical molecular bond length.:nuclear
: Returns0.03
, approximately 1 femtometer in atomic units.nothing
: Returns1.0
as a fallback default.
FewBodyPhysics.Coordinates.jacobi_transform
— Methodjacobi_transform(masses::Vector{Float64})::Tuple{Matrix{Float64}, Matrix{Float64}}
Computes the Jacobi transformation matrix J
and its pseudoinverse U
for a given vector of masses.
Arguments
masses::Vector{Float64}
: A vector of masses for the system. Must contain at least two masses.
Returns
Tuple{Matrix{Float64}, Matrix{Float64}}
: A tuple containing:J::Matrix{Float64}
: The Jacobi transformation matrix.U::Matrix{Float64}
: The pseudoinverse of the Jacobi transformation matrix.
Details
The Jacobi transformation is used to convert the coordinates of a system of particles into a set of relative coordinates. The transformation matrix J
is constructed based on the masses of the particles, and its pseudoinverse U
is computed using the pinv
function.
Constraints
- The input vector
masses
must have a length of at least 2. An assertion is raised if this condition is not met.
FewBodyPhysics.Coordinates.shift_vectors
— Functionshift_vectors(a::Matrix{Float64}, b::Matrix{Float64}, mat::Union{Nothing, Matrix{Float64}}=nothing) -> Float64
Compute a weighted sum of dot products between columns of two matrices a
and b
, optionally using a weighting matrix mat
.
Arguments
a::Matrix{Float64}
: A matrix where each column represents a vector.b::Matrix{Float64}
: A matrix where each column represents a vector. Must have the same number of columns asa
.mat::Union{Nothing, Matrix{Float64}}
: An optional square weighting matrix. Ifnothing
is provided, the identity matrix is used.
Returns
Float64
: The computed weighted sum of dot products.
Constraints
- The number of columns in
a
andb
must be the same. - If
mat
is provided, it must be a square matrix with dimensions equal to the number of columns ina
andb
.
FewBodyPhysics.Coordinates.transform_list
— Methodtransform_list(α::Vector{Float64})::Vector{Matrix{Float64}}
Transforms a vector of Float64
values into a vector of Matrix{Float64}
objects. Each element of the input vector α
is wrapped into a 1x1 matrix and returned as an element of the resulting vector.
Arguments
α::Vector{Float64}
: A vector ofFloat64
values to be transformed.
Returns
Vector{Matrix{Float64}}
: A vector where each element is a 1x1 matrix containing the corresponding value from the input vectorα
.
FewBodyPhysics.Optimization.optimize_ground_state_energy
— Methodoptimizegroundstateenergy(initwidths::Vector{Matrix{Float64}}, ops::Vector{Operator}; max_iter=100)
Uses local optimization (Nelder-Mead) on Gaussian widths to minimize ground state energy.