question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ElectronicStructureProblem` might generate a redundant operator

See original GitHub issue

What is the expected enhancement?

ElectronicStructureProblem of main branch generates a redundant operator than that by stable though they are identical from matrix perspective. Because the operator is larger, qubit mapping takes more time with main branch than stable. I think we need to apply reduce somewhere.

from qiskit_nature.drivers import Molecule
from qiskit_nature.drivers.second_quantization import ElectronicStructureDriverType, \
    ElectronicStructureMoleculeDriver
from qiskit_nature.problems.second_quantization import ElectronicStructureProblem

h2_geometry = [('H', [0, 0, 0]), ('H', [0, 0, 1])]

molecule = Molecule(geometry=h2_geometry, charge=0, multiplicity=1)
driver = ElectronicStructureMoleculeDriver(molecule, basis="sto3g",
                                           driver_type=ElectronicStructureDriverType.PYSCF)
es_problem = ElectronicStructureProblem(driver)
second_q_op = es_problem.second_q_ops()
lst = sorted(second_q_op[0].to_list(display_format="dense"), key=lambda e: e[0])
print(f'size {len(lst)}')
for op in lst:
    print(op)
print("\nmatrix")
print(second_q_op[0].to_matrix())

main

size 28
('+-+-', (0.09839529174273506+0j))
('+-+-', (0.09839529174273506+0j))
('+--+', (-0.0983952917427351+0j))
('+--+', (-0.09839529174273509+0j))
('-++-', (-0.09839529174273509+0j))
('-++-', (-0.0983952917427351+0j))
('-+-+', (0.09839529174273512-0j))
('-+-+', (0.09839529174273512-0j))
('IIIN', (-0.589121003706083+0j))
('IINI', (-1.1108441798837272+0j))
('IINN', (-0.0983952917427351+0j))
('IINN', (0.31085338155985665+0j))
('IINN', (0.31085338155985653+0j))
('IINN', (-0.09839529174273509+0j))
('INII', (-0.589121003706083+0j))
('ININ', (0.326535373471287+0j))
('ININ', (0.326535373471287+0j))
('INNI', (0.31085338155985653+0j))
('INNI', (0.31085338155985665+0j))
('NIII', (-1.1108441798837272+0j))
('NIIN', (0.31085338155985665+0j))
('NIIN', (0.31085338155985653+0j))
('NINI', (0.3132012497647589+0j))
('NINI', (0.3132012497647589+0j))
('NNII', (-0.0983952917427351+0j))
('NNII', (0.31085338155985665+0j))
('NNII', (0.31085338155985653+0j))
('NNII', (-0.09839529174273509+0j))

matrix
  (1, 1)	(-0.589121003706083+0j)
  (2, 2)	(-1.1108441798837272+0j)
  (3, 3)	(-1.275049003955567+0j)
  (4, 4)	(-0.589121003706083+0j)
  (5, 5)	(-0.525171260469592+0j)
  (10, 5)	(0.19679058348547013+0j)
  (6, 6)	(-1.078258420470097+0j)
  (9, 6)	(0.19679058348547018-0j)
  (7, 7)	(-0.5893924975993629+0j)
  (8, 8)	(-1.1108441798837272+0j)
  (6, 9)	(0.19679058348547018-0j)
  (9, 9)	(-1.078258420470097+0j)
  (5, 10)	(0.19679058348547024+0j)
  (10, 10)	(-1.5952858602379365+0j)
  (11, 11)	(-1.137783921190063+0j)
  (12, 12)	(-1.275049003955567+0j)
  (13, 13)	(-0.5893924975993629+0j)
  (14, 14)	(-1.137783921190063+0j)
  (15, 15)	(-0.02721123519961588+0j)

stable/0.3

size 14
('+-+-', (0.19679058348547013+0j))
('+--+', (-0.19679058348547018+0j))
('-++-', (-0.19679058348547018+0j))
('-+-+', (0.19679058348547024+0j))
('IIIN', (-0.589121003706083+0j))
('IINI', (-1.1108441798837272+0j))
('IINN', (0.424916179634243+0j))
('INII', (-0.589121003706083+0j))
('ININ', (0.653070746942574+0j))
('INNI', (0.6217067631197132+0j))
('NIII', (-1.1108441798837272+0j))
('NIIN', (0.6217067631197132+0j))
('NINI', (0.6264024995295178+0j))
('NNII', (0.424916179634243+0j))

matrix
  (1, 1)	(-0.589121003706083+0j)
  (2, 2)	(-1.1108441798837272+0j)
  (3, 3)	(-1.275049003955567+0j)
  (4, 4)	(-0.589121003706083+0j)
  (5, 5)	(-0.525171260469592+0j)
  (10, 5)	(0.19679058348547013+0j)
  (6, 6)	(-1.078258420470097+0j)
  (9, 6)	(0.19679058348547018-0j)
  (7, 7)	(-0.5893924975993629+0j)
  (8, 8)	(-1.1108441798837272+0j)
  (6, 9)	(0.19679058348547018-0j)
  (9, 9)	(-1.078258420470097+0j)
  (5, 10)	(0.19679058348547024+0j)
  (10, 10)	(-1.5952858602379365+0j)
  (11, 11)	(-1.137783921190063+0j)
  (12, 12)	(-1.275049003955567+0j)
  (13, 13)	(-0.5893924975993629+0j)
  (14, 14)	(-1.137783921190063+0j)
  (15, 15)	(-0.02721123519961588+0j)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrossinekcommented, May 31, 2022

@t-imamichi would you mind opening a PR for these two changes?

1reaction
t-imamichicommented, May 31, 2022

It sounds good. If we call _to_dense_label_data within simplify (for example, as follows), the number of operators is reduced from 28 to 14.

        for label, coeff in self._to_dense_label_data():
            data[label] += coeff

I’m fine to change the default display_format too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Qiskit - nuclear repulsion energy derivative
When using Qiskit Nature , to compute an ElectronicStructureProblem , you will find nuclear_repulsion_energy as a field in the ...
Read more >
arXiv:2210.15438v1 [quant-ph] 25 Oct 2022
When we create operators from scratch, we obviously have to start with Paulis strings, then we can use ether the PauliOp class [25],...
Read more >
MidasCpp Manual
overview including a small description of all files that can be generated by MidasCpp we refer ... Such an operator file is usually...
Read more >
PRX Quantum 3, 020351 - Physical Review Link Manager
We present a method for encoding second-quantized fermionic systems in qubits when the number of fermions is conserved, as in the electronic ......
Read more >
Application of fermionic marginal constraints to hybrid ...
qubits and leveraging the fact that the norm of the operator of interest, and thus Lipschitz constant will remain the same. If one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found