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

Array reshaping in matfreq2dlr prevents array resizing #44

Open
lxvm opened this issue Dec 19, 2024 · 0 comments
Open

Array reshaping in matfreq2dlr prevents array resizing #44

lxvm opened this issue Dec 19, 2024 · 0 comments

Comments

@lxvm
Copy link

lxvm commented Dec 19, 2024

Hello,
I have been using the matfreq2dlr routine as it has been very useful for my research. There is an issue with being able to resize the array containing the imaginary frequency Green's function data after calling matfreq2dlr because the routine internally reshapes the array, causing an error in Julia v1.10 and before.
This happens as a result of a Julia issue JuliaLang/julia#33143.
Here is how I reproduce the issue

using Lehmann
β = 100.0 # inverse temperature
Euv = 1.0 # ultraviolt energy cutoff of the Green's function
rtol = 1e-8 # accuracy of the representation
isFermi = false
symmetry = :none # :ph if particle-hole symmetric, :pha is antisymmetric, :none if there is no symmetry
dlr = DLRGrid(Euv, β, rtol, isFermi, symmetry) #initialize the DLR parameters and basis
Nωn = 10000
ngrid = collect(-Nωn:Nωn)  # create a set of Matsubara-frequency points
Gn = Sample.SemiCircle(dlr, :n, ngrid) # Use semicircle spectral density to generate the sample Green's function in ωn
spectral_from_Gω = matfreq2dlr(dlr, Gn, ngrid)
resize!(Gn, 2length(ngrid))

This is the error

ERROR: cannot resize array with shared data
Stacktrace:
 [1] _growend!
   @ ./array.jl:1072 [inlined]
 [2] push!(a::Vector{Float64}, item::Float64)
   @ Base ./array.jl:1119
 [3] top-level scope
   @ REPL[22]:1

Although for now this doesn't cause any issues in Julia v1.11, I will avoid resizing my arrays, and in the long term it would be handy if matfreq2dlr didn't reshape arrays internally so that their memory could be reused in Julia v1.10 (the lts).

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