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

Nested sums do not handle KroneckerDelta correctly #71

Open
goerz opened this issue May 22, 2018 · 0 comments
Open

Nested sums do not handle KroneckerDelta correctly #71

goerz opened this issue May 22, 2018 · 0 comments
Labels
Milestone

Comments

@goerz
Copy link
Member

goerz commented May 22, 2018

When indexed sum are nested through Sum involve a KroneckerDelta the scalar_indexed_sum_over_kronecker does not know how to handle it.

>>> i = IdxSym('i'); j = IdxSym('j')
>>> ket_i = BasisKet(FockIndex(i), hs=0)
>>> ket_j = BasisKet(FockIndex(j), hs=0)
>>> Sum(i)(Sum(j)(ket_i.dag() * ket_j))
Traceback (most recent call last):
  File "<ipython-input-6-11142b06b2d0>", line 1, in <module>
    Sum(i)(Sum(j)(ket_i.dag() * ket_j))
  File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/abstract_quantum_algebra.py", line 776, in sum
    return term._indexed_sum_cls.create(term, idx_range)
  File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/scalar_algebra.py", line 861, in create
    return super().create(term, *ranges)
  File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/abstract_algebra.py", line 115, in create
    simplified = simplification(cls, args, kwargs)
  File "/Users/goerz/Documents/Programming/github/QNET/src/qnet/algebra/core/algebraic_properties.py", line 558, in scalar_indexed_sum_over_kronecker
    assert i in bound_symbols and j in bound_symbols
AssertionError

The solution is to handle the case where only one of i, j is an index of the sum (the sum can still be executed, so this is an easy fix). Once this is done, test_sum_instantiator can be updated to test this case.

@goerz goerz added the bug label May 22, 2018
@goerz goerz added this to the v2.0 milestone May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant