| include("ShellGen.jl") |
| include("Integrals.jl") |
|
|
| "Alias for vectorized pair parameters" |
| const NPairParams = Vector{PairParams} |
|
|
| "Generate `n` mono-electronic integrals with pairs of momenta `(l1, l2)`." |
| function mono_integrals(l1::Int, l2::Int, n::Int) |
| dset = Vector{MonoIntegral}(undef, n) |
| map!(dset, 1:n) do _ |
| p = PairParams() |
| basis = randPair(l1, l2, p) |
| mono_integral(basis) |
| end |
| end |
|
|
| """Generate a random 2-electron sparse integral.""" |
| function rand_bi_integral(l::Vector{Int}, param::Union{PairParams, QuadParams}) |
| if size(l, 1) == 4 |
| |
| l1, l2, l3, l4 = l |
| basis = randQuadruple(l1, l2, l3, l4, param, true) |
| elseif size(l, 1) == 2 |
| l1, l2 = l |
| basis = randPair(l1, l2, param) |
| end |
| |
| bi_integral(basis) |
| end |
| function rand_bi_integral(l::Vector{Int}) |
| rand_bi_integral(l, size(l, 1) == 4 ? QuadParams() : PairParams()) |
| end |
|
|
| "Generate `n` bi-electronic integrals with momenta quadruple `l`." |
| function bi_integrals(l::Vector{Int64}, n::Int) |
| dset = Vector{BiIntegral4c}(undef, n) |
| map!(dset, 1:n) do _ |
| rand_bi_integral(l) |
| end |
| stack(dset) |
| end |
|
|
| "Enumerate quadruples `[l1, l2, l3, l4]`." |
| function bi_grid(lmax::Int) |
| out = Vector{Int64}[] |
| for l1 in 0:lmax |
| for l2 in l1:lmax |
| for l3 in l1:lmax |
| for l4 in l3:lmax |
| if l1 == l3 & l2 > l4 |
| continue |
| end |
| l::Vector{Int64} = [l1, l2, l3, l4] |
| push!(out, l) |
| end |
| end |
| end |
| end |
| out |
| end |
|
|
| "Enumerate pairs `[l1, l2]`." |
| function mono_grid(lmax::Int) |
| out = Vector{Int64}[] |
| for l1 in 0:lmax |
| for l2 in l1:lmax |
| push!(out, [l1, l2]) |
| end |
| end |
| out |
| end |
|
|
|
|
| """ |
| dump_mono_grid(lmax, n[, out[, h5=True]]) |
| |
| Dump mono-electronic integrals for `0 <= l1 <= l2 <= lmax` |
| """ |
| function dump_mono_grid(lmax::Int, n::Int, out::String, h5=true) |
| for (l1, l2) in mono_grid(lmax) |
| dset = stack(mono_integrals(l1, l2, n)) |
| out_12 = out * "_$(l1)_$(l2)" * (h5 ? ".h5" : ".json") |
| h5 ? h5dump(out_12, dset) : dump(out_12, dset) |
| println("> $(out_12)") |
| end |
| end |
| function dump_mono_grid(lmax::Int, n::Int) |
| dump_mono_grid(lmax, n, "out/mono_$(n)") |
| end |
|
|
| """ |
| dump_bi_grid(lmax, n[, out[, h5=true]]) |
| |
| Dump bi-electronic integrals. |
| """ |
| function dump_bi_grid(grid::Vector{Vector{Int}}, n::Int, out::String, h5=true) |
| for l in grid |
| try |
| B = bi_integrals(l, n) |
| out_l = out * "_" * join(l, "_") |
| h5 ? h5dump(out_l * ".h5", B) : JSONdump(out_l * "*.json", B) |
| println("> " * out_l) |
| catch e |
| println(l, e) |
| throw(e) |
| end |
| end |
| end |
| function dump_bi_grid(lmax::Int, n::Int, out::String, h5::Bool=true, shells::Int64=4) |
| shells == 4 ? |
| dump_bi_grid(bi_grid(lmax), n, out, h5) : |
| dump_bi_grid(mono_grid(lmax), n, out, h5) |
| end |
|
|