|
|
include("Shells.jl") |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
PairParams(atom, normalize=false[, logdev_rate, logdev_max]) |
|
|
|
|
|
Sampling parameters for 2-center 2-shell basis sets. |
|
|
|
|
|
# Note |
|
|
|
|
|
When called as `PairParams(normalize::Bool)`, will sample random atomic numbers |
|
|
within `1:10`. |
|
|
|
|
|
# Arguments |
|
|
- `atom::Vector{Int64}`: length-2 vector of atomic numbers |
|
|
- `normalize::Bool`: whether to normalize integral outputs (if used?) |
|
|
- `logdev_rate::Real`: exponential decay rate of the wavelength logarithm distribution |
|
|
- `logdev_max::Real`: logarithm of the greatest wavelength |
|
|
""" |
|
|
struct PairParams |
|
|
atom::Vector{Int64} |
|
|
normalize::Bool |
|
|
logdev_rate::Real |
|
|
logdev_max::Real |
|
|
end |
|
|
function PairParams(atom::Vector{Int64}, norm::Bool = false) |
|
|
PairParams(atom, norm, 2, .6) |
|
|
end |
|
|
function PairParams(normalize::Bool = false) |
|
|
Z = rand(1:10, 2) |
|
|
return PairParams(Z, normalize) |
|
|
end |
|
|
|
|
|
""" |
|
|
randPair(l1, l2[, params]) |
|
|
|
|
|
Sample a random 2-shell `Basis`. |
|
|
""" |
|
|
function randPair(l1::Int, l2::Int, params::PairParams)::Basis |
|
|
|
|
|
exps = begin |
|
|
max, rate = params.logdev_max, params.logdev_rate |
|
|
log_devs = max .- rand(Exponential(rate), 2) |
|
|
devs = exp.(log_devs) |
|
|
1 ./ (2 .* devs .^ 2) |
|
|
end |
|
|
exp_1 = SVector{1, Float64}(exps[1]) |
|
|
exp_2 = SVector{1, Float64}(exps[2]) |
|
|
|
|
|
xyz = begin |
|
|
exp_12 = exps[1] * exps[2] / (exps[1] + exps[2]) |
|
|
dev_12 = 1 / sqrt(2exp_12) |
|
|
SVector{3, Float64}(dev_12 * randn((3))) |
|
|
end |
|
|
|
|
|
origin = SVector{3, Float64}(0., 0., 0.) |
|
|
pos = (origin, xyz) |
|
|
mol = map(zip(params.atom, pos)) do A |
|
|
Za, ra = A |
|
|
move(atom(Za), ra) |
|
|
end |
|
|
|
|
|
coef :: SMatrix{2, 1, Float64} = |
|
|
params.normalize ? |
|
|
vcat(exp_1, exp_2) ./ 2pi .^ (3 / 4 ) : |
|
|
[1., 1.] |
|
|
shells = [BasisFunction(l1, coef[1,:], exp_1, mol[1]), |
|
|
BasisFunction(l2, coef[2,:], exp_2, mol[2])] |
|
|
return (mol, shells)::Basis |
|
|
return basis |
|
|
end |
|
|
randPair(l1::Int, l2::Int, atom::Vector{Int64}) = randPair(l1, l2, PairParams(atom)) |
|
|
randPair(l1::Int, l2::Int) = begin p = PairParams(); randPair(l1, l2, p); end |
|
|
randPair(l::Int, params::PairParams) = randPair(l, l, params) |
|
|
randPair(l::Int) = randPair(l, l) |
|
|
|
|
|
""" |
|
|
QuadParams(r12_dev[, pair]) |
|
|
|
|
|
Sampling parameters for 4-center basis sets. |
|
|
|
|
|
# Arguments |
|
|
- `r12_dev::Float64`: typical distance between pairwise barycenters |
|
|
- `pair::Vector{PairParams}`: sampling parameters for center pairs |
|
|
""" |
|
|
struct QuadParams |
|
|
r12_dev::Float64 |
|
|
pair::Vector{PairParams} |
|
|
end |
|
|
QuadParams(r12_dev::Float64) = begin |
|
|
p = PairParams([1, 1]) |
|
|
QuadParams(r12_dev, [p, p]) |
|
|
end |
|
|
QuadParams() = QuadParams(.05) |
|
|
|
|
|
""" |
|
|
randQuadruple(l1, l2, l3, l4[, params, shuflle=false) |
|
|
|
|
|
Sample a random quadruple of shells. |
|
|
""" |
|
|
function randQuadruple(l1::Int, l2::Int, l3::Int, l4::Int, params::QuadParams, shuffle::Bool=false) |
|
|
if shuffle |
|
|
p = randperm(4) |
|
|
p_1 = sortperm(p) |
|
|
mol, shells = randQuadruple([l1, l2, l3, l4][p]..., params, false) |
|
|
return mol[p_1], shells[p_1] |
|
|
end |
|
|
|
|
|
r12 = SVector{3, Float64}(params.r12_dev * randn(3)) |
|
|
|
|
|
AB, shells_AB = randPair(l1, l2, params.pair[1]) |
|
|
CD, shells_CD = randPair(l3, l4, params.pair[2]) |
|
|
ABCD = append!(center(AB), center(CD, r12)) |
|
|
shells = append!(shells_AB, shells_CD) |
|
|
shells_ABCD = map(zip(ABCD, shells)) do pair |
|
|
atom, shell = pair |
|
|
BasisFunction(shell.l, shell.coef, shell.exp, atom) |
|
|
end |
|
|
return ABCD, shells_ABCD |
|
|
end |
|
|
function randQuadruple(l1::Int, l2::Int, l3::Int, l4::Int, ps...) |
|
|
p = QuadParams(ps...) |
|
|
randQuadruple(l1, l2, l3, l4, p) |
|
|
end |
|
|
|