-
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 #29 from numericalEFT/xc-from-houpc
Xc from houpc
- Loading branch information
Showing
11 changed files
with
289 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
mass2 = np.array([1e-2,1e-4,1e-6,1e-8]) | ||
val = np.array([1.179, 1.379, 1.422, 1.422]) | ||
err = np.array([0.003,0.005,0.007,0.008]) | ||
|
||
plt.figure() | ||
plt.xscale("log") | ||
plt.errorbar(mass2, val, yerr=err, fmt="o-", markersize=4) | ||
plt.savefig("testPP.pdf") |
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,63 @@ | ||
using Test | ||
using ElectronLiquid | ||
using FeynmanDiagram | ||
using FiniteDifferences | ||
using Lehmann | ||
using Measurements | ||
using ElectronLiquid | ||
using ElectronLiquid.CompositeGrids | ||
using ElectronLiquid.UEG | ||
|
||
|
||
function compare(data, expect, ratio=5) | ||
# println(data, ", ", expect) | ||
@test isapprox(data.val, expect, atol=ratio * data.err) | ||
end | ||
|
||
function PP_interaction_dynamic(n, para::ParaMC, kamp=para.kF, kamp2=para.kF; kawargs...) | ||
kF = para.kF | ||
xgrid = CompositeGrid.LogDensedGrid(:gauss, [-1.0, 1.0], [-1.0, 1.0], 16, 0.001, 16) | ||
qs = [sqrt(kamp^2 + kamp2^2 - 2 * x * kamp * kamp2) for x in xgrid] | ||
|
||
Wp = zeros(Float64, length(qs)) | ||
for (qi, q) in enumerate(qs) | ||
Wp[qi] = UEG.KO_W(q, n, para) | ||
end | ||
Wp *= para.NFstar # additional minus sign because the interaction is exchanged | ||
return Interp.integrate1D(Wp, xgrid) | ||
end | ||
|
||
@testset "PP" begin | ||
seed = 1234 | ||
# p = (1, 0, 0) | ||
p = (2, 0, 0) | ||
rs = 2.0 | ||
beta = 25 | ||
mass2 = 1e-8 | ||
neval = 1e7 | ||
para = ElectronLiquid.ParaMC(rs=rs, beta=beta, Fs=0.0, order=2, mass2=mass2, isDynamic=true) | ||
UEG.MCinitialize!(para) | ||
println(para) | ||
# diagram = Ver4.diagram(para, [p,]; channel=[], filter=[]) | ||
# diagram = Ver4.diagram(para, [p, (2, 0, 0)]; channel=[PPr,], filter=[NoFock, NoBubble]) | ||
diagram = Ver4.diagram(para, [p,]; channel=[PPr,], filter=[NoFock, NoBubble]) | ||
|
||
############################ generic PH one-angle average ########################### | ||
nlist = [0, 1, 2] | ||
paras = [Ver4.OneAngleAveraged(para, [para.kF, para.kF], [[0, nlist[1], -1], [0, nlist[2], -1], [0, nlist[3], -1]], :PP, 0),] | ||
data, result = Ver4.one_angle_averaged(paras, diagram; neval=neval, print=-1, seed=seed) | ||
# obs = data[p] | ||
obs2 = data[(2, 0, 0)] | ||
println(obs2) | ||
# println("obs 1:", obs[:, 1, 1]) | ||
# println("obs 2:", obs[:, 2, 1]) | ||
# println("obs 3:", obs[:, 3, 1]) | ||
|
||
# println(PP_interaction_dynamic(nlist[1], para) / 2) | ||
# println(PP_interaction_dynamic(nlist[2], para) / 2) | ||
# println(PP_interaction_dynamic(nlist[3], para) / 2) | ||
# for i in 1:length(nlist) | ||
# println(real(obs[:, i, 1][2]), ", ", -PP_interaction_dynamic(nlist[i], para) / 2) | ||
# # compare(real(obs[:, i, 1][2]), -PP_interaction_dynamic(nlist[i], para) / 2) | ||
# end | ||
end |
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
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,119 @@ | ||
function integrandAA(idx, var, config) | ||
para, diag, root, extT, kamp, kamp2, nkin, nqout = config.userdata | ||
|
||
kF, β = para.kF, para.β | ||
varK, varT, varX = var[1], var[2], var[7] | ||
loopNum = config.dof[idx][1] | ||
# error(loopNum) | ||
_kin, _kout = kamp[var[3][1]], kamp2[var[4][1]] | ||
_nkin, _nqout = nkin[var[5][1]], nqout[var[6][1]] | ||
|
||
# println(kinL, ", ", koutL, ", ", kinR) | ||
x = varX[1][1] | ||
varK.data[1, 1] = _kout * x - _kin | ||
varK.data[2, 1] = _kout * sqrt(1 - x^2) | ||
varK.data[1, 2] = _kin | ||
|
||
diagram = diag[idx] | ||
weight = diagram.node.current | ||
rootuu, rootud = root[1][idx], root[2][idx] | ||
extTuu, extTud = extT[1][idx], extT[2][idx] | ||
|
||
# varK.data[:, 2] = [kF * x, kF * sqrt(1 - x^2), 0.0] | ||
|
||
ExprTree.evalKT!(diagram, varK.data, varT.data, para) | ||
if !isempty(rootuu) | ||
wuu = sum(weight[root] * phaseC(varT, extTuu[ri], _nkin, _nqout, β) for (ri, root) in enumerate(rootuu)) | ||
else | ||
wuu = zero(ComplexF64) | ||
end | ||
if !isempty(rootud) | ||
wud = sum(weight[root] * phaseC(varT, extTud[ri], _nkin, _nqout, β) for (ri, root) in enumerate(rootud)) | ||
else | ||
wud = zero(ComplexF64) | ||
end | ||
# factor = para.NF / (2π)^(para.dim * loopNum) | ||
factor = 1.0 / (2π)^(para.dim * loopNum) | ||
|
||
# if isdefined(Main, :Infiltrator) | ||
# Main.infiltrate(@__MODULE__, Base.@locals, @__FILE__, @__LINE__) | ||
# end | ||
|
||
return Weight(wuu * factor, wud * factor) | ||
# return Weight(zero(ComplexF64), wud * para.NF) | ||
end | ||
|
||
function measureAA(idx, var, obs, weight, config) | ||
kin, kout = var[3][1], var[4][1] | ||
nkin, nqout = var[5][1], var[6][1] | ||
obs[idx][1, kin, kout, nkin, nqout] += weight.d | ||
obs[idx][2, kin, kout, nkin, nqout] += weight.e | ||
end | ||
|
||
function AA(para::ParaMC, diagram; | ||
kamp=[para.kF,], kamp1=[kamp[1],], | ||
nkin=[0,], | ||
nqout=[0,], | ||
neval=1e6, #number of evaluations | ||
print=0, | ||
alpha=3.0, #learning ratio | ||
config=nothing, | ||
kwargs... | ||
) | ||
UEG.MCinitialize!(para) | ||
|
||
dim, β, kF, NF = para.dim, para.β, para.kF, para.NF | ||
|
||
partition, diagpara, diag, root, extT = diagram | ||
@assert length(diagpara) == length(diag) == length(root[1]) == length(extT[1]) | ||
@assert length(root[1]) == length(root[2]) | ||
@assert length(extT[1]) == length(extT[2]) | ||
|
||
K = MCIntegration.FermiK(para.dim, kF, 0.2 * kF, 10.0 * kF, offset=2) | ||
T = MCIntegration.Continuous(0.0, β, offset=1, alpha=alpha) | ||
T.data[1] = 0.0 | ||
X = MCIntegration.Continuous(-1.0, 1.0) #x=cos(θ) | ||
|
||
Nkin, Nkout = length(kamp), length(kamp1) | ||
Nwin, Nwqout = length(nkin), length(nqout) | ||
|
||
vKin = MCIntegration.Discrete(1, Nkin, alpha=alpha) | ||
vKout = MCIntegration.Discrete(1, Nkout, alpha=alpha) | ||
|
||
vWin = MCIntegration.Discrete(1, Nwin, alpha=alpha) | ||
vWqout = MCIntegration.Discrete(1, Nwqout, alpha=alpha) | ||
|
||
dof = [[p.innerLoopNum, p.totalTauNum - 1, 1, 1, 1, 1, 1] for p in diagpara] # K, T, ExtKidx | ||
obs = [zeros(ComplexF64, 2, Nkin, Nkout, Nwin, Nwqout) for p in diagpara] # observable for the Fock diagram | ||
|
||
if isnothing(config) | ||
config = MCIntegration.Configuration(; var=(K, T, vKin, vKout, vWin, vWqout, X), | ||
dof=dof, | ||
obs=obs, | ||
type=Weight, | ||
userdata=(para, diag, root, extT, kamp, kamp1, nkin, nqout), | ||
kwargs...) | ||
end | ||
result = integrate(integrandAA; config=config, measure=measureAA, solver=:mcmc, neval=neval, print=print, kwargs...) | ||
|
||
if isnothing(result) == false | ||
# if print >= 0 | ||
# report(result.config) | ||
# report(result; pick=o -> (real(o[1, 1, 1, 1, 1])), name="uu") | ||
# report(result; pick=o -> (real(o[2, 1, 1, 1, 1])), name="ud") | ||
# end | ||
|
||
datadict = Dict{eltype(partition),Any}() | ||
for k in 1:length(dof) | ||
avg, std = result.mean[k], result.stdev[k] | ||
r = measurement.(real(avg), real(std)) | ||
i = measurement.(imag(avg), imag(std)) | ||
data = Complex.(r, i) | ||
datadict[partition[k]] = data | ||
end | ||
return datadict, result | ||
else | ||
return nothing, nothing | ||
end | ||
|
||
end |
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 |
---|---|---|
|
@@ -109,5 +109,6 @@ end | |
# end | ||
|
||
include("ver3KW.jl") | ||
include("ver3angleavg.jl") | ||
|
||
end |
Oops, something went wrong.