Compare commits
2 Commits
main
...
ho_basis_f
| Author | SHA1 | Date |
|---|---|---|
|
|
036986709e | |
|
|
d62825aeb7 |
27
ho_basis.jl
27
ho_basis.jl
|
|
@ -1,7 +1,7 @@
|
||||||
using SparseArrays
|
using SparseArrays
|
||||||
using NuclearToolkit
|
|
||||||
using SpecialFunctions
|
using SpecialFunctions
|
||||||
include("helper.jl")
|
include("helper.jl")
|
||||||
|
include("osbrackets.jl")
|
||||||
|
|
||||||
# Gaussian potentials in HO space
|
# Gaussian potentials in HO space
|
||||||
inv_factorial(n) = Iterators.prod(inv.(1:n))
|
inv_factorial(n) = Iterators.prod(inv.(1:n))
|
||||||
|
|
@ -36,7 +36,7 @@ function get_2p_basis(E_max)
|
||||||
l2s = Int[]
|
l2s = Int[]
|
||||||
|
|
||||||
# E = 2*n1 + l1 + 2*n2 + l2
|
# E = 2*n1 + l1 + 2*n2 + l2
|
||||||
for E in 0 : 2*E_max
|
for E in 2*E_max : -2 : 0
|
||||||
for n1 in 0 : E ÷ 2
|
for n1 in 0 : E ÷ 2
|
||||||
for n2 in 0 : (E - 2*n1) ÷ 2
|
for n2 in 0 : (E - 2*n1) ÷ 2
|
||||||
for l1 in 0 : (E - 2*n1 - 2*n2)
|
for l1 in 0 : (E - 2*n1 - 2*n2)
|
||||||
|
|
@ -84,15 +84,17 @@ function sp_V_matrix(V_l, ns, ls; mask=trues(length(ns),length(ns)), dtype=Float
|
||||||
end
|
end
|
||||||
|
|
||||||
function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)
|
function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)
|
||||||
E_max = maximum(Es)
|
Emax = maximum(Es) ÷ 2 # TODO: Too many steps. Simplify.
|
||||||
j_max = 2 * E_max + 1
|
|
||||||
l_max = j_max
|
ul1s = unique(l1s)
|
||||||
to = 0 # unused
|
ul2s = unique(l2s)
|
||||||
|
BRACs = Matrix{Array}(undef, length(ul1s), length(ul2s))
|
||||||
dtri = NuclearToolkit.prep_dtri(l_max + 1);
|
for l1 in ul1s
|
||||||
dcgm0 = NuclearToolkit.prep_dcgm0(l_max);
|
for l2 in ul2s
|
||||||
d6j = nothing # NuclearToolkit.prep_d6j_int(E_max, j_max, to);
|
BRACs[l1, l2] = cal_BRAC(Emax, Λ, l1, l2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
mat = spzeros(length(Es), length(Es))
|
mat = spzeros(length(Es), length(Es))
|
||||||
s = hcat(Es, n1s, l1s, n2s, l2s)
|
s = hcat(Es, n1s, l1s, n2s, l2s)
|
||||||
for idx in CartesianIndices(mat)
|
for idx in CartesianIndices(mat)
|
||||||
|
|
@ -100,7 +102,8 @@ function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)
|
||||||
(Elhs, N, L, n, l) = s[i, :]
|
(Elhs, N, L, n, l) = s[i, :]
|
||||||
(Erhs, n1, l1, n2, l2) = s[j, :]
|
(Erhs, n1, l1, n2, l2) = s[j, :]
|
||||||
if Elhs == Erhs
|
if Elhs == Erhs
|
||||||
mat[i, j] = NuclearToolkit.HObracket_d6j(N, L, n, l, n1, l1, n2, l2, Λ, 1.0, dtri, dcgm0, d6j)
|
phase = (-1)^(N + n + n1 + n2)
|
||||||
|
mat[i, j] = phase * get_bracket(BRACs[l1, l2], Emax, Λ, N, L, n, l, n1, n2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
# compile using
|
||||||
|
# gfortran -shared -fPIC osbrac.f90 -o osbrac.so
|
||||||
|
# gfortran -shared -fPIC allosbrac.f90 -o allosbrac.so
|
||||||
|
|
||||||
|
using Libdl
|
||||||
|
|
||||||
|
function cal_BRAC(Emax, Λ, l1, l2)
|
||||||
|
ϵ = (2 * Emax - Λ) % 2
|
||||||
|
N = (l1 - l2 + Λ - ϵ) ÷ 2
|
||||||
|
M = (l1 + l2 - Λ - ϵ) ÷ 2
|
||||||
|
L = Λ
|
||||||
|
NQMAX = 2 * Emax
|
||||||
|
CO = 1/sqrt(2)
|
||||||
|
SI = 1/sqrt(2)
|
||||||
|
FIRSTCALL = true
|
||||||
|
# dimensions BRAC(0:L,0:(NQMAX-L)/2,0:(NQMAX-L)/2,0:(NQMAX-L)/2,0:(NQMAX-L)/2)
|
||||||
|
BRAC = zeros(Float64, 1 + L, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2, 1 + (NQMAX - L) ÷ 2)
|
||||||
|
|
||||||
|
lib = Libdl.dlopen("OSBRACKETS/osbrac.so") # Open the library explicitly.
|
||||||
|
sym = Libdl.dlsym(lib, :osbrac_) # Get a symbol for the function to call.
|
||||||
|
# call signature OSBRAC(N,M,L,NQMAX,CO,SI,FIRSTCALL,BRAC)
|
||||||
|
@ccall $sym(N::Ref{Int32},M::Ref{Int32},L::Ref{Int32},NQMAX::Ref{Int32},CO::Ref{Float64},SI::Ref{Float64},FIRSTCALL::Ref{UInt8},BRAC::Ptr{Array{Float64}})::Cvoid
|
||||||
|
Libd.dlclose(lib)
|
||||||
|
|
||||||
|
return BRAC
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_bracket(BRAC, Emax, Λ, n1′, l1′, n2′, l2′, n1, n2)
|
||||||
|
ϵ = (2 * Emax - Λ) % 2
|
||||||
|
NP = (l1′ - l2′ + Λ - ϵ) ÷ 2
|
||||||
|
N1P = n1′
|
||||||
|
MP = (l1′ + l2′ - Λ - ϵ) ÷ 2
|
||||||
|
N1 = n1
|
||||||
|
N2 = n2
|
||||||
|
N2P = n2′
|
||||||
|
if MP+N1P+N2P == M+N1+N2
|
||||||
|
# BRAC(NP,N1P,MP,N1,N2)
|
||||||
|
return BRAC[1 + NP, 1 + N1P, 1 + MP, 1 + N1, 1 + N2]
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue