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

Creating NBodyMatrixElements for zero-body operators fails #8

Open
jagot opened this issue Apr 29, 2019 · 1 comment
Open

Creating NBodyMatrixElements for zero-body operators fails #8

jagot opened this issue Apr 29, 2019 · 1 comment

Comments

@jagot
Copy link
Member

jagot commented Apr 29, 2019

Trying to create an NBodyMatrixElement of a zero-body operator fails with the following error:

julia> using EnergyExpressions

julia> import EnergyExpressions: NBodyMatrixElement

julia> a=SlaterDeterminant([:a,:b])
a(1)b(2) - a(2)b(1)

julia> NBodyMatrixElement(a, IdentityOperator{0}(), a, overlap_matrix(a,a))
ERROR: UndefVarError: A not defined
Stacktrace:
 [1] EnergyExpressions.OrbitalMatrixElement(::Tuple{}, ::IdentityOperator{0}, ::Tuple{}) at /home/jagot/.julia/dev/EnergyExpressions/src/nbody_matrix_elements.jl:85
 [2] NBodyMatrixElement(::SlaterDeterminant{Symbol}, ::IdentityOperator{0}, ::SlaterDeterminant{Symbol}, ::SparseArrays.SparseMatrixCSC{EnergyExpressions.NBodyTerm,Int64}) at /home/jagot/.julia/dev/EnergyExpressions/src/nbody_matrix_elements.jl:442
 [3] top-level scope at none:0
 [4] run_backend(::REPL.REPLBackend) at /home/jagot/.julia/packages/Revise/gStbk/src/Revise.jl:771
 [5] (::getfield(Revise, Symbol("##58#60")){REPL.REPLBackend})() at ./task.jl:259

This is because the type cannot be inferred for the tuples of zero length. However, the OrbitalMatrixElement should not be necessary for zero-body operators, since the full energy expression consists solely of OrbitalOverlaps.

@jagot
Copy link
Member Author

jagot commented Jun 3, 2019

The same example above, now produces this non-sensical result:

julia> NBodyMatrixElement(a, IdentityOperator{0}(), a, overlap_matrix(a,a))
⟨𝐈₀⟩

julia> dump(NBodyMatrixElement(a, IdentityOperator{0}(), a, overlap_matrix(a,a)))
NBodyMatrixElement
  terms: Array{EnergyExpressions.NBodyTerm}((1,))
    1: EnergyExpressions.NBodyTerm
      factors: Array{EnergyExpressions.NBodyTermFactor}((1,))
        1: EnergyExpressions.OrbitalMatrixElement{0,Symbol,IdentityOperator{0},Symbol}
          a: Array{Symbol}((0,))
          o: IdentityOperator{0} 𝐈₀
          b: Array{Symbol}((0,))
      coeff: Int64 1

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