Skip to content

Commit

Permalink
Added conversion methods from Debye and Lorentzian to InversePolyKernel
Browse files Browse the repository at this point in the history
  • Loading branch information
cerisola committed Nov 6, 2023
1 parent e776d39 commit 4d3645f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
32 changes: 32 additions & 0 deletions src/InversePolyKernelSD.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@ Construct a InversePolyKernelSD spectral density with the given coefficients.
"""
InversePolyKernelSD(coeffs::AbstractVector) = InversePolyKernelSD(length(coeffs)-1, ComplexF64.(coeffs))

"""
InversePolyKernelSD(J::LorentzianSD)
Construct a InversePolyKernelSD spectral density from a Lorentzian spectral density.
# Arguments
- `J::LorentzianSD`: The Lorentzian spectral density.
# Returns
- An instance of the InversePolyKernelSD that represents the Lorentzian spectral density.
"""
InversePolyKernelSD(J::LorentzianSD) = InversePolyKernelSD([J.ω0^2/J.α, -1im*J.Γ/J.α, -1/J.α])

convert(InversePolyKernelSD, J::LorentzianSD) = InversePolyKernelSD(J)

"""
InversePolyKernelSD(J::DebyeSD)
Construct a InversePolyKernelSD spectral density from a Debye spectral density.
# Arguments
- `J::DebyeSD`: The Debye spectral density.
# Returns
- An instance of the InversePolyKernelSD that represents the Debye spectral density.
"""
InversePolyKernelSD(J::DebyeSD) = InversePolyKernelSD([1/(2*J.α*J.ωc), -1im/(2*J.α*J.ωc^2)])

convert(InversePolyKernelSD, J::DebyeSD) = InversePolyKernelSD(J)

sd(J::InversePolyKernelSD, ω) = imag_memory_kernel_ft(J, ω)/π

imag_memory_kernel_ft(J::InversePolyKernelSD, ω) = imag(memory_kernel_ft(J, ω))
Expand Down
9 changes: 7 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ using Test

@testset "InversePolyKernelSD" begin
α, ω0, Γ = rand(), 2*rand(), rand()/10
coeffs = [ω0^2/α, -1im*Γ/α, -1/α]
Jlor = LorentzianSD(α, ω0, Γ)
Jipk = InversePolyKernelSD(coeffs)
Jipk = InversePolyKernelSD(Jlor)
ωtest = rand(20)
@test Jlor.(ωtest) Jipk.(ωtest)

α, ωc = 10*rand(), 20*rand()
Jdebye = DebyeSD(α, ωc)
Jipk = InversePolyKernelSD(Jdebye)
ωtest = rand(20)
@test Jdebye.(ωtest) Jipk.(ωtest)
end

@testset "Frequency cutoffs" begin
Expand Down

0 comments on commit 4d3645f

Please sign in to comment.