Skip to content

Bug in FDM #73

Closed
Closed

Description

@o0muay72670o

I found a bug in FDM when solving charmonium system

# method

FiniteDifferenceMethod(Δr=0.01, rₘₐₓ=100.0, R=0.01:0.01:100.0, l=0, direction=c, solver=ArnoldiMethod)

# eigenvalue

ERROR: LoadError: BoundsError: attempt to access 0-element Vector{Float64} at index [1]
Stacktrace:
 [1] throw_boundserror(A::Vector{Float64}, I::Tuple{Int64})
   @ Base .\essentials.jl:15
 [2] getindex(A::Vector{Float64}, i::Int64)
   @ Base .\essentials.jl:919
 [3] solve(hamiltonian::Hamiltonian, method::FiniteDifferenceMethod; perturbation::Hamiltonian, info::Int64, nₘₐₓ::Int64)
   @ TwoBody C:\Users\poomj\.julia\packages\TwoBody\5xYmP\src\FDM.jl:93
 [4] solve(hamiltonian::Hamiltonian, method::FiniteDifferenceMethod)
   @ TwoBody C:\Users\poomj\.julia\packages\TwoBody\5xYmP\src\FDM.jl:66
 [5] top-level scope
   @ C:\Users\poomj\source\repos\heavyquark\heavy-quark-twobody\src\MWOfinitediff:32
 [6] include(mapexpr::Function, mod::Module, _path::String)
   @ Base .\Base.jl:307
 [7] top-level scope
   @ REPL[3]:1

Activity

  1. MartinMikkelsen commented on Sep 2, 2026

    @MartinMikkelsen
    Member

    I assume this is the Hamiltonian from this discussion, #39
    I think the problem is due to a too small Krylov subspace in this line
    I will add a line to enlarge the Krylov subspace when the ArnoldiMethod does not converge in #75

  2. MartinMikkelsen commented on Sep 3, 2026

    @MartinMikkelsen
    Member

    The enlarged Krylov subspace method seems to be working

    m₁    = 1.836
    m₂    = 1.836
    σσ   = -3
    l      = 0
    m      = 0
    Λ     = 0.8321
    λ     = 0.1653
    p      = 1
    κ     = 0.5069
    κκ    = 1.8609
    A      = 1.6553
    B      = 0.2204
    μ     = 1 / (1/m₁ + 1/m₂) # reduction mass
    r₀     = A*(2*m₁*m₂/(m₁+m₂))^(-B)
    H = Hamiltonian(
                      RestEnergy(c=1, m=m₁),
                      RestEnergy(c=1, m=m₂),
                      Kinetic(hbar=1, m=μ),
                      Coulomb(-κ),
                      Linear(λ),
                      Constant(-Λ),
                      Gaussian(2*π*κκ/3/m₁/m₂ / ((sqrt(π)*r₀)^3) * σσ, 1/r₀^2))
    
    FDM = FiniteDifferenceMethod(Δr=0.01, rₘₐₓ=100.0, R=0.01:0.01:100.0, l=0, direction=:c, solver=:ArnoldiMethod)
    
    println(solve(H, FDM, info=0, nₘₐₓ=4).E)

    which prints

    [3.005250358496244, 3.6082255845239786, 4.013370356782439, 4.353297108700312]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions