diff --git a/berggren.jl b/berggren.jl deleted file mode 100644 index 136ed95..0000000 --- a/berggren.jl +++ /dev/null @@ -1,18 +0,0 @@ -using SparseArrays -include("ho_basis.jl") - -"Basis transformation from HO to momentum space" -function get_W_matrix(basis_p, E_max, Λ, μ1ω1, μ2ω2=μ1ω1; weights=true) - Es, n1s, l1s, n2s, l2s = get_2p_basis(E_max, Λ) - W = zeros(ComplexF64, length(basis_p), length(Es)) - Threads.@threads for idx in CartesianIndices(W) - (i1, i2) = Tuple(idx) - ((j1, j2), (k1, w1), (k2, w2)) = basis_p[i1] - if j1 == l1s[i2] && j2 == l2s[i2] - elem1 = 1/sqrt(sqrt(μ1ω1)) * (-1)^n1s[i2] * ho_basis(j1, n1s[i2], 1/sqrt(μ1ω1) * k1) - elem2 = 1/sqrt(sqrt(μ2ω2)) * (-1)^n2s[i2] * ho_basis(j2, n2s[i2], 1/sqrt(μ2ω2) * k2) - W[idx] = elem1 * elem2 * (weights ? w1 * w2 : 1) - end - end - return sparse(W) -end diff --git a/berggren_3body.jl b/berggren_3body.jl index e4a3d9d..35a5439 100644 --- a/berggren_3body.jl +++ b/berggren_3body.jl @@ -1,7 +1,7 @@ using LinearAlgebra, SparseArrays, Arpack include("helper.jl") include("p_space.jl") -include("berggren.jl") +include("ho_basis.jl") println("No of threads = ", Threads.nthreads()) diff --git a/berggren_3body_resonance.jl b/berggren_3body_resonance.jl index 26d9bfb..bc2897c 100644 --- a/berggren_3body_resonance.jl +++ b/berggren_3body_resonance.jl @@ -1,7 +1,6 @@ using LinearAlgebra, SparseArrays, Arpack include("helper.jl") include("p_space.jl") -include("berggren.jl") println("No of threads = ", Threads.nthreads()) atol = 10^-5 diff --git a/calculations/3body_Berggren_B2R_EC.jl b/calculations/3body_Berggren_B2R_EC.jl index dd2a290..9824e42 100644 --- a/calculations/3body_Berggren_B2R_EC.jl +++ b/calculations/3body_Berggren_B2R_EC.jl @@ -2,7 +2,6 @@ using Arpack, SparseArrays, LRUCache using DelimitedFiles, Plots include("../ho_basis.jl") include("../p_space.jl") -include("../berggren.jl") println("No of threads = ", Threads.nthreads()) diff --git a/calculations/3body_Berggren_R2R_EC.jl b/calculations/3body_Berggren_R2R_EC.jl index bec0ae2..d147e4b 100644 --- a/calculations/3body_Berggren_R2R_EC.jl +++ b/calculations/3body_Berggren_R2R_EC.jl @@ -2,7 +2,6 @@ using Arpack, SparseArrays, LRUCache using DelimitedFiles, Plots include("../ho_basis.jl") include("../p_space.jl") -include("../berggren.jl") println("No of threads = ", Threads.nthreads()) diff --git a/ho_basis.jl b/ho_basis.jl index 63a0d3a..1ba55a8 100644 --- a/ho_basis.jl +++ b/ho_basis.jl @@ -204,4 +204,20 @@ function get_src_V12_matrix(V_of_r, E_max, Λ, μω_global; atol=10^-6, maxevals V12 = U' * V_relative * U return V12 -end \ No newline at end of file +end + +"Basis transformation from HO to momentum space" +function get_W_matrix(basis_p, E_max, Λ, μ1ω1, μ2ω2=μ1ω1; weights=true) + Es, n1s, l1s, n2s, l2s = get_2p_basis(E_max, Λ) + W = zeros(ComplexF64, length(basis_p), length(Es)) + Threads.@threads for idx in CartesianIndices(W) + (i1, i2) = Tuple(idx) + ((j1, j2), (k1, w1), (k2, w2)) = basis_p[i1] + if j1 == l1s[i2] && j2 == l2s[i2] + elem1 = 1/sqrt(sqrt(μ1ω1)) * (-1)^n1s[i2] * ho_basis(j1, n1s[i2], 1/sqrt(μ1ω1) * k1) + elem2 = 1/sqrt(sqrt(μ2ω2)) * (-1)^n2s[i2] * ho_basis(j2, n2s[i2], 1/sqrt(μ2ω2) * k2) + W[idx] = elem1 * elem2 * (weights ? w1 * w2 : 1) + end + end + return sparse(W) +end