-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from krivenko/dev/exact_atomic_ppgf
Exact atomic PPGF functionality.
- Loading branch information
Showing
10 changed files
with
246 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# [`QInchworm.exact_atomic_ppgf`](@id QInchworm.exact_atomic_ppgf) | ||
|
||
```@autodocs | ||
Modules = [QInchworm.exact_atomic_ppgf] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# QInchworm.jl | ||
# | ||
# Copyright (C) 2021-2024 I. Krivenko, H. U. R. Strand and J. Kleinhenz | ||
# | ||
# QInchworm.jl is free software: you can redistribute it and/or modify it under the | ||
# terms of the GNU General Public License as published by the Free Software | ||
# Foundation, either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# QInchworm.jl is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# QInchworm.jl. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Authors: Hugo U. R. Strand, Igor Krivenko | ||
|
||
""" | ||
Exact atomic pseudo-particle Green's function module enabling exact evaluation of the atomic | ||
propagator ``P_0(z)`` by evaluating the exponential ``P_0(z) = -i e^{-iz \\hat H_{loc}}``. | ||
# Exports | ||
$(EXPORTS) | ||
""" | ||
module exact_atomic_ppgf | ||
|
||
using DocStringExtensions | ||
|
||
using LinearAlgebra: Diagonal, tr | ||
|
||
using Keldysh: BranchPoint, AbstractTimeGF | ||
using KeldyshED; ked = KeldyshED; | ||
|
||
import Keldysh: interpolate! | ||
import QInchworm.ppgf: partition_function, atomic_ppgf, density_matrix | ||
|
||
export ExactAtomicPPGF, partition_function, atomic_ppgf, density_matrix, interpolate! | ||
|
||
""" | ||
$(TYPEDEF) | ||
Exact atomic pseudo-particle Green's function type. | ||
# Fields | ||
$(TYPEDFIELDS) | ||
""" | ||
struct ExactAtomicPPGF <: AbstractTimeGF{ComplexF64, false} | ||
"Inverse temperature" | ||
β::Float64 | ||
"Eigenvalues of the atomic Hamiltonian" | ||
E::Array{Float64, 1} | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Evaluate atomic propagator at complex contour time `z`. | ||
# Parameters | ||
- `z`: scalar time. | ||
# Returns | ||
- Value of atomic pseudo-particle propagator ``P_0(z)`` as a diagonal matrix | ||
`Diagonal`. | ||
""" | ||
function (P::ExactAtomicPPGF)(z::Number) | ||
return -im * Diagonal(exp.(-im * z * P.E)) | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Evaluate atomic propagator at the difference between imaginary time branch points. | ||
# Parameters | ||
- `z1`: first branch point. | ||
- `z2`: second branch point. | ||
# Returns | ||
- Value of atomic pseudo-particle propagator ``P_0(z_1 - z_2)`` as a diagonal matrix | ||
`Diagonal`. | ||
""" | ||
function (P::ExactAtomicPPGF)(z1::BranchPoint, z2::BranchPoint) | ||
Δz = z1.val - z2.val | ||
return P(Δz) | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
In-place evaluation of the atomic propagator at the difference between imaginary time branch | ||
points. | ||
# Parameters | ||
- `x`: Matrix to store the value of the atomic pseudo-particle propagator in. | ||
- `P_0`: Atomic pseudo-particle propagator. | ||
- `z1`: first branch point. | ||
- `z2`: second branch point. | ||
# Returns | ||
- Value of atomic pseudo-particle propagator ``P_0(z_1 - z_2)`` as a diagonal matrix | ||
`Diagonal`. | ||
""" | ||
function interpolate!(x::Matrix{ComplexF64}, | ||
P_0::ExactAtomicPPGF, | ||
z1::BranchPoint, | ||
z2::BranchPoint) | ||
Δz = z1.val - z2.val | ||
x[:] = P_0(Δz) | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Construct the exact atomic pseudo-particle Green's function. | ||
# Parameters | ||
- `β`: Inverse temperature. | ||
- `ed`: Exact diagonalization structure describing the atomic problem. | ||
""" | ||
function atomic_ppgf(β::Float64, ed::ked.EDCore)::Vector{ExactAtomicPPGF} | ||
Z = ked.partition_function(ed, β) | ||
λ = log(Z) / β # Pseudo-particle chemical potential (enforcing Tr[i P(β)] = Tr[ρ] = 1) | ||
P = [ ExactAtomicPPGF(β, E .+ λ) for E in energies(ed) ] | ||
return P | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Extract the partition function ``Z = \\mathrm{Tr}[i P_0(-i\\beta, 0)]`` from a un-normalized | ||
pseudo-particle Green's function `P_0`. | ||
""" | ||
function partition_function(P_0::Vector{ExactAtomicPPGF})::ComplexF64 | ||
return sum(P_0, init=0im) do P_s | ||
im * tr(P_s(-im * P_s.β)) | ||
end | ||
end | ||
|
||
""" | ||
$(TYPEDSIGNATURES) | ||
Extract the equilibrium density matrix ``\\rho = i P(-i\\beta, 0)`` from a normalized | ||
pseudo-particle Green's function `P`. The density matrix is block-diagonal and is returned | ||
as a vector of blocks. | ||
""" | ||
function density_matrix(P::Vector{ExactAtomicPPGF})::Vector{Matrix{ComplexF64}} | ||
@assert !isempty(P) | ||
return [1im * P_s(-im * P_s.β) for P_s in P] | ||
end | ||
|
||
end # module exact_atomic_ppgf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# QInchworm.jl | ||
# | ||
# Copyright (C) 2021-2024 I. Krivenko, H. U. R. Strand and J. Kleinhenz | ||
# | ||
# QInchworm.jl is free software: you can redistribute it and/or modify it under the | ||
# terms of the GNU General Public License as published by the Free Software | ||
# Foundation, either version 3 of the License, or (at your option) any later | ||
# version. | ||
# | ||
# QInchworm.jl is distributed in the hope that it will be useful, but WITHOUT ANY | ||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
# details. | ||
# | ||
# You should have received a copy of the GNU General Public License along with | ||
# QInchworm.jl. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Authors: Hugo U. R. Strand, Igor Krivenko | ||
|
||
# Test exact atomic pseudo particle Green's function (exact_atomic_ppgf) module | ||
# by comparing with the standard equidistant constructor in the ppgf module. | ||
|
||
using Test | ||
|
||
using Keldysh; kd = Keldysh | ||
using KeldyshED; ked = KeldyshED; op = KeldyshED.Operators | ||
|
||
using QInchworm.ppgf: atomic_ppgf, partition_function | ||
using QInchworm.exact_atomic_ppgf: exact_atomic_ppgf, partition_function | ||
|
||
@testset "exact_atomic_ppgf" begin | ||
|
||
β = 5.0 | ||
nτ = 11 | ||
μ = 1.337 | ||
|
||
H = μ * op.n(1) | ||
soi = ked.Hilbert.SetOfIndices([[1]]) | ||
ed = ked.EDCore(H, soi) | ||
|
||
P = atomic_ppgf(β, ed) | ||
Z = partition_function(P) | ||
@test Z ≈ 1.0 | ||
|
||
contour = kd.ImaginaryContour(β=β) | ||
grid = kd.ImaginaryTimeGrid(contour, nτ) | ||
P0 = atomic_ppgf(grid, ed) | ||
Z0 = partition_function(P0) | ||
@test Z == Z0 | ||
|
||
t0 = grid.points[1].bpoint | ||
|
||
for t1 in grid.points | ||
t1 = t1.bpoint | ||
for (p, p0) in zip(P, P0) | ||
@test p(t1, t0) == p0(t1, t0) | ||
end | ||
end | ||
|
||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters