Compare commits

...

32 Commits
jacobi ... main

Author SHA1 Message Date
Nuwan Yapa 7545ebf5b5 Update README.md 2026-02-18 01:09:14 +00:00
Nuwan Yapa 840efad148 First version of README.md 2026-02-14 01:02:21 +00:00
Nuwan Yapa cf9de201a9 Julia package dependencies 2026-02-13 23:53:42 +00:00
Nuwan Yapa 37acda8fac Ignore VS Code configuration files 2026-02-13 15:32:27 -05:00
Nuwan Yapa 45b43728fb R2R EC implemented 2024-07-12 18:09:36 -04:00
Nuwan Yapa 850447a507 Merge remote-tracking branch 'origin/calculations' 2024-07-12 14:52:13 -04:00
Nuwan Yapa df0b5820ea Move calculations into folder 2024-07-12 14:48:43 -04:00
Nuwan Yapa 1f4a648d52 Simple 3-body bound system 2024-04-09 18:07:17 -04:00
Nuwan Yapa 8ee4057f7e .gitignore HPC stuff 2024-02-26 10:26:48 -05:00
ysyapa d3a25b2ccf New ComplexScaling-FV calculation 2023-10-21 14:57:45 -04:00
ysyapa 922807eca1 n_imag=1 2023-09-05 16:18:19 +00:00
ysyapa 7cc20a9c27 Fixed GPU related bug 2023-08-27 23:02:51 -04:00
ysyapa 547be9fa98 Changed parameters 2023-08-25 22:09:41 +00:00
ysyapa 7a74745f7e Merge branch 'master' into calculations 2023-08-25 21:21:32 +00:00
ysyapa 3d29c323d0 New calculation for paper 2023-08-25 21:03:25 +00:00
ysyapa 7fdb5947a1 Merge branch 'master' into calculations 2023-08-25 21:02:53 +00:00
Nuwan Yapa 0bcb7b3d16 Ignore calculation outputs 2023-08-14 10:46:22 -04:00
Nuwan Yapa 3f0d7566fa Merge branch 'master' into calculations 2023-08-10 05:45:10 -04:00
Nuwan Yapa 1195e63f51 Merge branch 'master' into calculations 2023-08-10 05:37:12 -04:00
ysyapa b05fb757b1 Merge branch 'master' into calculations 2023-08-10 09:11:19 +00:00
ysyapa 3b6a57c512 New parameters 2023-08-10 09:09:56 +00:00
ysyapa 490e94262b Increase N 2023-08-09 18:22:05 +00:00
ysyapa e6f32295f5 Export .dat file 2023-08-09 18:19:55 +00:00
ysyapa cbd0460600 Chose potential for new paper 2023-08-07 19:46:19 +00:00
ysyapa 911143a9ca Minor fix 2023-05-24 00:46:21 -04:00
ysyapa 8ce0f749b7 Use CPU 2023-05-23 19:13:58 +00:00
ysyapa 700d2b4308 Seperate .jl files instead of notebook 2023-05-23 19:11:36 +00:00
ysyapa d3726c725b Adopt to new interface 2023-05-23 19:08:09 +00:00
ysyapa c831c52f78 Merge branch 'master' into calculations 2023-05-23 18:43:54 +00:00
ysyapa 77eea9319c Not worrying about memory leak 2023-04-20 16:28:08 -04:00
ysyapa 7879f047f2 Merge branch 'master' into calculations 2023-04-20 16:27:33 -04:00
ysyapa 0c3fb156ae 3-body resonance calculation 2023-04-09 20:08:00 -04:00
12 changed files with 243 additions and 2 deletions

6
.gitignore vendored
View File

@ -1,3 +1,9 @@
# VSCode
.vscode/
# HPC scripts and logs
hpc/
# Calculation outputs # Calculation outputs
*.dat *.dat
*.csv *.csv

View File

@ -68,8 +68,8 @@ end
"cuTENSOR contraction and accumulation (C = A * B + C)" "cuTENSOR contraction and accumulation (C = A * B + C)"
function contract_accumulate!(C::CuTensor, A::CuTensor, B::CuTensor)::CuTensor function contract_accumulate!(C::CuTensor, A::CuTensor, B::CuTensor)::CuTensor
CUTENSOR.contraction!(one(eltype(C)), A.data, A.inds, CUTENSOR.CUTENSOR_OP_IDENTITY, B.data, B.inds, CUTENSOR.CUTENSOR_OP_IDENTITY, cuTENSOR.contraction!(one(eltype(C)), A.data, A.inds, cuTENSOR.CUTENSOR_OP_IDENTITY, B.data, B.inds, cuTENSOR.CUTENSOR_OP_IDENTITY,
one(eltype(C)), C.data, C.inds, CUTENSOR.CUTENSOR_OP_IDENTITY, CUTENSOR.CUTENSOR_OP_IDENTITY) one(eltype(C)), C.data, C.inds, cuTENSOR.CUTENSOR_OP_IDENTITY, cuTENSOR.CUTENSOR_OP_IDENTITY)
return C return C
end end

2
LocalPreferences.toml Normal file
View File

@ -0,0 +1,2 @@
[TensorOperations]
precompile_workload = true

7
Project.toml Normal file
View File

@ -0,0 +1,7 @@
[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# DVR-jl
Solves the quantum $n$-body problem in finite volume (lattice) with periodic boundary conditions. Uses discrete variable representation (DVR) with optional support for complex scaling to study resonances. All details can be found in [H. Yu, N. Yapa, and S. König, Complex scaling in finite volume, Phys. Rev. C 109, 014316 (2024)](https://doi.org/10.1103/PhysRevC.109.014316).
Written in Julia with optional CUDA GPU acceleration (experimental).
## Installation
Make sure you have Julia installed. Required packages can be installed with a single command:
```bash
julia --project=. -e 'import Pkg; Pkg.instantiate()'
```
## Usage
See `calculations/3b_bound.jl` for an example on a 3-body bound state.
See `calculations/3b_res_from_paper.jl` for an example of a 3-body resonance via complex scaling.
## Planned features
- [ ] Spin and isospin degrees of freedom for nuclear calculations
- [ ] Multi-node HPC support
- [ ] Parity and cubic symmetries ($S_4$)
## Acknowledgments
The author gratefully acknowledges the guidance from Sebastian König.

19
calculations/3b_bound.jl Normal file
View File

@ -0,0 +1,19 @@
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32
V_gauss(r2) = -2 * exp(-r2 / 4)
d = 3
n = 3
N = 20
L = 15
n_imag = 1
ϕ = 0
s = system{T}(d, n, N, L)
H = Hamiltonian{T}(s, V_gauss, ϕ, n_imag, mode)
@time evals, _, info = eig(H, 5)
print(info.numops, " operations")
display(evals)

View File

@ -0,0 +1,36 @@
# 10.1007/s00601-020-01550-8
# Fig. 7
# E_R = 4.18(8)
#./En.run -d 3 -n 3 -N 16 -c pot=v_shifted_gauss,v0=2.0,r=1.5,a=3.0 -c n_eig=20 -c which=li -c tol=1e-6 -L 16 -c phi=0.3 -v
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32 # single-precision mode
using Plots
V_gauss(r2) =
2 * exp(-((sqrt(r2) - 3) / 1.5) ^ 2)
d = 3
n = 3
N = 16
L = 16
n_imag = 0
for ϕ::T in 0.2:0.05:0.4
s = system{T}(d, n, N, L)
H = Hamiltonian{T}(s, V_gauss, ϕ, n_imag, mode)
@time evals, _, info = eig(H, 20)
print(info.numops, " operations")
display(evals)
scatter(real.(evals), imag.(evals); legend=false)
xlabel!("Re E")
ylabel!("Im E")
xlims!(0, 6)
ylims!(-0.6, 0)
savefig("temp/phi$(Int(round(ϕ * 100))).png")
end

View File

@ -0,0 +1,24 @@
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32 # single-precision mode
V_gauss(r2) =
-10 * exp(-(sqrt(r2)) ^ 2)
d = 3
n = 2
N = 96
ϕ = pi/6
n_imag = 1
open("ComplexScaling-FV-P-res.dat", "w") do f
for L = range(20, 35, length=16)
println("Calculating L=", L)
s = system{T}(d, n, N, L)
H = Hamiltonian{T}(s, V_gauss, ϕ, n_imag, mode)
@time evals, _, info = eig(H, 40)
dataline = vcat([L], hcat(real.(evals), imag.(evals))'[:])
println(f, join(dataline, '\t'))
end
end

View File

@ -0,0 +1,24 @@
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32 # single-precision mode
V_gauss(r2) =
-10 * exp(-(sqrt(r2)) ^ 2)
d = 3
n = 2
N = 30
L = 6
n_imag = 1
open("ComplexScaling-FV-S-bound-phi.dat", "w") do f
for ϕ = range(0.0, 0.5, length=11)
println("Calculating ϕ=", ϕ)
s = system{T}(d, n, N, L)
H = Hamiltonian{T}(s, V_gauss, ϕ, n_imag, mode)
@time evals, _, info = eig(H, 10, resonances = false)
dataline = vcat([ϕ], hcat(real.(evals), imag.(evals))'[:])
println(f, join(dataline, '\t'))
end
end

View File

@ -0,0 +1,24 @@
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32 # single-precision mode
V_gauss(r2) =
2 * exp(- ((sqrt(r2)-3)/1.5) ^ 2)
d = 3
n = 2
N = 96
L = 30
n_imag = 1
open("ComplexScaling-FV-S-res-phi.dat", "w") do f
for ϕ = range(0.1, 0.6, length=26)
println("Calculating ϕ=", ϕ)
s = system{T}(d, n, N, L)
H = Hamiltonian{T}(s, V_gauss, ϕ, n_imag, mode)
@time evals, _, info = eig(H, 40, resonances = true)
dataline = vcat([ϕ], hcat(real.(evals), imag.(evals))'[:])
println(f, join(dataline, '\t'))
end
end

67
calculations/EC-R2R-S.jl Normal file
View File

@ -0,0 +1,67 @@
using Plots, Arpack
include("../helper.jl")
include("../Hamiltonian.jl")
mode = cpu_tensor
T = Float32 # single-precision mode
V_r2(c) = r2 -> c * (-5 * exp(-r2/3) + 2 * exp(-r2/10))
d = 3
n = 2
N = 48
L = 30
ϕ = pi/6
n_imag = 1
s = system{T}(d, n, N, L)
train_cs = range(0.78, 0.45, length=5)
train_ref = reverse([0.05387926313545913-0.008900278182520881im,
0.11254295298924327-0.020515067379548786im,
0.16060154707503538-0.03716539208626717im,
0.19741353362674618-0.05994519982799412im,
0.2219100763497223-0.08959449893439568im])
extrapolate_cs = range(0.38, 0.22, length=5)
extrapolate_ref = reverse([0.23165109150003316-0.12052751440975719im,
0.23190549514995962-0.1406687118589838im,
0.22763660218046278-0.1626190970863793im,
0.21807104244164865-0.18635600686249373im,
0.2020979906072586-0.21180157628258728im])
training_E = ComplexF64[]
training_vec = Array[]
exact_E = ComplexF64[]
extrapolated_E = ComplexF64[]
for c in train_cs
println("Training c=", c)
H = Hamiltonian{T}(s, V_r2(c), ϕ, n_imag, mode)
@time evals, evecs, info = eig(H, 20, resonances = true)
i = nearestIndex(evals, pop!(train_ref))
push!(training_E, evals[i])
push!(training_vec, evecs[i])
end
N_EC = [sum(x .* y) for (x, y) in Iterators.product(training_vec, training_vec)]
for c in extrapolate_cs
println("Extrapolating c=", c)
H = Hamiltonian{T}(s, V_r2(c), ϕ, n_imag, mode)
@time evals, _, info = eig(H, 40, resonances = true)
nearestE = nearest(evals, pop!(extrapolate_ref))
push!(exact_E, nearestE)
# EC extrapolation
H_training_vec = H.(training_vec)
H_EC = [sum(x .* y) for (x, y) in Iterators.product(training_vec, H_training_vec)]
evals = eigvals(H_EC, N_EC)
push!(extrapolated_E, nearestE)
end
scatter(real.(training_E), imag.(training_E), label="training")
scatter!(real.(exact_E), imag.(exact_E), label="exact")
scatter!(real.(extrapolated_E), imag.(extrapolated_E), label="extrapolated")
savefig("temp/EC-R2R-S.pdf")

5
helper.jl Normal file
View File

@ -0,0 +1,5 @@
"Index of the nearest value in a list to a given reference point"
nearestIndex(list::Array, ref) = argmin(norm.(list .- ref))
"Nearest value in a list to a given reference point"
nearest(list::Array, ref) = list[nearestIndex(list, ref)]