Skip to content

Update documentation plots to use CompactBases.ShiftAndInvert #16

@jagot

Description

@jagot

Should use built-in functionality instead of duplicating

struct ShiftAndInvert{TA,TB,TT}
A⁻¹::TA
B::TB
temp::TT
end
Base.size(S::ShiftAndInvert, args...) = size(S.A⁻¹, args...)
Base.eltype(S::ShiftAndInvert) = eltype(S.A⁻¹)
function LinearAlgebra.mul!(y,M::ShiftAndInvert,x)
mul!(M.temp, M.B, x)
ldiv!(y, M.A⁻¹, M.temp)
end
construct_linear_map(A,B,σ=0) =
ShiftAndInvert(factorize(A-σ*B),B,Vector{eltype(A)}(undef, size(A,1)))
function bsplines_hydrogen_eigenstates()
k = 7
N = 31
a,b = 0,70
coulomb(r) = -1/r
nev = 5
σ = -0.5
n = 1:nev
cfigure("Hydrogen", figsize=(7,9)) do
for (j,(t,x,tol)) in enumerate([(LinearKnotSet(k, a, b, N),
range(a, stop=b, length=500)[2:end-1],
9e-3),
(ExpKnotSet(k, -1.0, log10(b), N),
10 .^ range(-1.0, stop=log10(b), length=500)[2:end-1],
2e-7)])
B = BSpline(t)[:,2:end-1]
xx = axes(B, 1)
S = B'B
χ = B[x,:]
D = Derivative(xx)
∇² = B'*D'*D*B
T = -∇²/2
V = B'*QuasiDiagonal(coulomb.(xx))*B
H = T + V
schurQR,history = partialschur(construct_linear_map(H, S, σ), nev=nev)

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