brainandforce / Electrum.jl

A Julian toolkit for solid-state chemical theory.
MIT License
31 stars 0 forks source link

Returning `PlanewaveWavefunction` in other functions #160

Closed xamberl closed 1 year ago

xamberl commented 1 year ago

I'm having issues returning a PlanewaveWavefunction object as part of a tuple in another function. The particular error message I get is this:

ERROR: MethodError: no method matching reshape(::PlanewaveWavefunction{3, ComplexF32}, ::Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}, Base.OneTo{Int64}, UnitRange{Int64}, UnitRange{Int64}, UnitRange{Int64}})
Closest candidates are:
  reshape(::AbstractArray{T, N}, ::Val{N}) where {T, N} at reshapedarray.jl:140
  reshape(::AbstractArray, ::Val{N}) where N at reshapedarray.jl:141
  reshape(::AbstractArray, ::Int64...) at reshapedarray.jl:117
brainandforce commented 1 year ago

I assume this is a function you've written that's external to Electrum - can you provide the rest of that function?

xamberl commented 1 year ago

Here's the function:

function import_VASP(d::AbstractString="")
    fermi = get_fermi(string(d,"OUTCAR"))
    geo = readPOSCAR(string(d,"POSCAR"))
    wave = readWAVECAR(string(d,"WAVECAR"))
    kpt = parse.(Int, split(readlines(string(d,"KPOINTS"))[4]))
    super = supercell(geo,kpt) # Creates an AtomList{3} supercell from POSCAR and KPOINTS
    return (fermi, geo, super, wave)
end

If I return the tuple without the PlanewaveWavefunction object, it works just fine.

brainandforce commented 1 year ago

I discussed this in person, but leaving it here for reference: the bug is not with PlanewaveWavefunction, it's in how Julia handles the show(::IO, [::MIME"text/plain"], ::PlanewaveWavefunction) method. The return value is correct, but when it attempts to display a PlanewaveWavefunction tuple member it fails.