Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation plots to use CompactBases.ShiftAndInvert #16

Open
jagot opened this issue Jul 9, 2020 · 0 comments
Open

Update documentation plots to use CompactBases.ShiftAndInvert #16

jagot opened this issue Jul 9, 2020 · 0 comments

Comments

@jagot
Copy link
Member

jagot commented Jul 9, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant