Datasets:

Modalities:
Image
Size:
< 1K
Libraries:
Datasets
License:
File size: 3,066 Bytes
61e6ac9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
        # sample 4-center basis set
        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
    # compute integral
    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