Skip to content

Commit

Permalink
implemented pmap in height fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
abhirup-m committed Jan 29, 2025
1 parent cd2682b commit 5f3590c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 38 deletions.
64 changes: 46 additions & 18 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.7"
julia_version = "1.11.2"
manifest_format = "2.0"
project_hash = "4a00b4d413e72ea2f6526377c008c7569b5a81f4"
project_hash = "c31ac22794d5e2d5b5b2c4d37e0aa18de7c370e9"

[[deps.ANSIColoredPrinters]]
git-tree-sha1 = "574baf8110975760d391c710b6341da1afa48d8c"
Expand All @@ -16,13 +16,15 @@ version = "0.4.5"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"
version = "1.1.2"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
version = "1.11.0"

[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
version = "1.11.0"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
Expand All @@ -43,10 +45,12 @@ version = "1.1.1+0"
[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
version = "1.11.0"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
version = "1.11.0"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
Expand All @@ -69,10 +73,11 @@ version = "1.6.0"
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "e51db81749b0777b2147fbe7b783ee79045b8e99"
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.6.4+1"
version = "2.6.4+3"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
version = "1.11.0"

[[deps.Git]]
deps = ["Git_jll"]
Expand All @@ -95,12 +100,13 @@ version = "0.2.5"
[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
version = "1.11.0"

[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
git-tree-sha1 = "be3dc50a92e5a386872a493a10050136d4703f9b"
git-tree-sha1 = "a007feb38b422fbdab534406aeca1b86823cb4d6"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.6.1"
version = "1.7.0"

[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
Expand All @@ -121,16 +127,17 @@ version = "0.6.4"
[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.4.0+0"
version = "8.6.0+0"

[[deps.LibGit2]]
deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
version = "1.11.0"

[[deps.LibGit2_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"]
uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
version = "1.6.4+0"
version = "1.7.2+0"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
Expand All @@ -139,23 +146,27 @@ version = "1.11.0+1"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
version = "1.11.0"

[[deps.Libiconv_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "61dfdba58e585066d8bce214c5a51eaa0539f269"
git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809"
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
version = "1.17.0+1"
version = "1.18.0+0"

[[deps.LinearAlgebra]]
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
version = "1.11.0"

[[deps.Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
version = "1.11.0"

[[deps.Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
version = "1.11.0"

[[deps.MarkdownAST]]
deps = ["AbstractTrees", "Markdown"]
Expand All @@ -166,14 +177,15 @@ version = "0.1.2"
[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+1"
version = "2.28.6+0"

[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
version = "1.11.0"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.1.10"
version = "2023.12.12"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
Expand All @@ -182,13 +194,13 @@ version = "1.2.0"
[[deps.OpenBLAS_jll]]
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
version = "0.3.23+4"
version = "0.3.27+1"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "7493f61f55a6cce7325f197443aa80d32554ba10"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.0.15+1"
version = "3.0.15+3"

[[deps.PCRE2_jll]]
deps = ["Artifacts", "Libdl"]
Expand All @@ -202,9 +214,13 @@ uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.8.1"

[[deps.Pkg]]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"]
deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
version = "1.10.0"
version = "1.11.0"
weakdeps = ["REPL"]

[deps.Pkg.extensions]
REPLExt = "REPL"

[[deps.PrecompileTools]]
deps = ["Preferences"]
Expand All @@ -221,6 +237,7 @@ version = "1.4.3"
[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
version = "1.11.0"

[[deps.ProgressMeter]]
deps = ["Distributed", "Printf"]
Expand All @@ -229,12 +246,14 @@ uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "1.10.2"

[[deps.REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
version = "1.11.0"

[[deps.Random]]
deps = ["SHA"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
version = "1.11.0"

[[deps.RegistryInstances]]
deps = ["LazilyInitializedFields", "Pkg", "TOML", "Tar"]
Expand All @@ -248,9 +267,15 @@ version = "0.7.0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
version = "1.11.0"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
version = "1.11.0"

[[deps.StyledStrings]]
uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
version = "1.11.0"

[[deps.TOML]]
deps = ["Dates"]
Expand All @@ -265,6 +290,7 @@ version = "1.10.0"
[[deps.Test]]
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
version = "1.11.0"

[[deps.TranscodingStreams]]
git-tree-sha1 = "0c45878dcfdcfa8480052b6ab162cdd138781742"
Expand All @@ -274,9 +300,11 @@ version = "0.11.3"
[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
version = "1.11.0"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
version = "1.11.0"

[[deps.Zlib_jll]]
deps = ["Libdl"]
Expand All @@ -291,7 +319,7 @@ version = "5.11.0+0"
[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.52.0+1"
version = "1.59.0+0"

[[deps.p7zip_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ version = "0.1.0"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Distributed = "1.11.0"
2 changes: 1 addition & 1 deletion src/Fermions.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fermions

using ProgressMeter, LinearAlgebra, Combinatorics
using ProgressMeter, LinearAlgebra, Combinatorics, Distributed

include("constants.jl")
include("base.jl")
Expand Down
37 changes: 18 additions & 19 deletions src/correlations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,36 +388,35 @@ function SpecFuncVariational(
allowedRelError::Float64;
standDevGuess::Float64=0.1,
degenTol::Float64=0.,
normalise::Bool=false,
silent::Bool=false,
broadFuncType::String="lorentz",
fixedContrib::Union{Nothing,Vector{Vector{Float64}}}=nothing,
maxIter::Int64=30,
)
totalFixedContrib = ifelse(isnothing(fixedContrib), nothing, sum(fixedContrib))
totalFixedContrib = ifelse(isnothing(fixedContrib), zeros(length(spectralCoefficients)), sum(fixedContrib))

function RootFunction(standDev)

specFunc = sum([SpecFunc(coeffs, freqValues, standDev;
normalise=normalise, silent=silent,
broadFuncType=broadFuncType
)
for coeffs in spectralCoefficients]
)
if !isnothing(totalFixedContrib)
specFunc .+= totalFixedContrib
end
specFunc = Normalise(specFunc, freqValues, true)
return specFunc
centerSpecFuncArr = pmap(coeffs -> SpecFunc(coeffs, freqValues, standDev;
normalise=false, silent=silent,
broadFuncType=broadFuncType
),
spectralCoefficients
)
#=if !isnothing(totalFixedContrib)=#
#= specFunc .+= totalFixedContrib=#
#=end=#
localSpecFunc = Normalise(sum(centerSpecFuncArr) .+ totalFixedContrib, freqValues, true)
return centerSpecFuncArr, localSpecFunc
end

specFunc = RootFunction(standDevGuess)
centerSpecFuncArr, localSpecFunc = RootFunction(standDevGuess)

if targetHeight == 0
return specFunc, standDevGuess
return centerSpecFuncArr, localSpecFunc, standDevGuess
end

error = specFunc[freqValues .≥ 0][1] / targetHeight - 1.
error = localSpecFunc[freqValues .≥ 0][1] / targetHeight - 1.
step = 0
while abs(error) allowedRelError && step maxIter
step += 1
Expand All @@ -426,16 +425,16 @@ function SpecFuncVariational(
else
standDevGuess /= (1 + abs(error))
end
specFunc = RootFunction(standDevGuess)
error = specFunc[freqValues .≥ 0][1] / targetHeight - 1.
centerSpecFuncArr, localSpecFunc = RootFunction(standDevGuess)
error = localSpecFunc[freqValues .≥ 0][1] / targetHeight - 1.
end

if abs(error) < allowedRelError
println("Converged in $(step) runs: η=$(standDevGuess)")
else
println("Failed to converge: error=$(abs(error))")
end
return (specFunc, standDevGuess)
return (centerSpecFuncArr, localSpecFunc, standDevGuess)
end
export SpecFuncVariational

Expand Down

0 comments on commit 5f3590c

Please sign in to comment.