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.

BKSF mapper fails to map H2 operator from driver

See original GitHub issue

Environment

  • Qiskit Nature version: main branch (did not try release)
  • Python version: 3.6
  • Operating system: Linux

What is happening?

In #432 I was asked had I tried with BKSF as I had added Parity and BK mappers into the test_excited_states_solvers.py test case when fixing the referenced issue and observing issues around two qubit reduction and symmetries. I did not try BKSF, you can see my comment in the referenced PR, but in trying it fails in the ground state computation. Now the bksf test file includes an pre-defined operator that is commented as H2 - in this case its built from the driver and here it fails with the following exception.

<snip>
line 480, in _add_edges_for_term
    _type = _interaction_type(n_number, n_raise, n_lower)
  File "...qiskit_nature/mappers/second_quantization/bksf.py", line 421, in _interaction_type
    raise ValueError("unexpected number of number operators: ", n_number)
ValueError: ('unexpected number of number operators: ', 0)

How can we reproduce the issue?

Based on the

from qiskit import BasicAer
from qiskit.utils import algorithm_globals, QuantumInstance
from qiskit_nature.drivers import UnitsType
from qiskit_nature.drivers.second_quantization import PySCFDriver
from qiskit_nature.mappers.second_quantization import BravyiKitaevSuperFastMapper, BravyiKitaevMapper
from qiskit_nature.converters.second_quantization import QubitConverter
from qiskit_nature.problems.second_quantization import ElectronicStructureProblem
from qiskit_nature.algorithms import  GroundStateEigensolver, VQEUCCFactory
 


algorithm_globals.random_seed = 8
driver = PySCFDriver(
    atom="H .0 .0 .0; H .0 .0 0.75",
    unit=UnitsType.ANGSTROM,
    charge=0,
    spin=0,
    basis="sto3g",
)
es_problem = ElectronicStructureProblem(driver)
quantum_instance = QuantumInstance(
    BasicAer.get_backend("statevector_simulator"),
    seed_transpiler=90,
    seed_simulator=12,
)


#converter = QubitConverter(BravyiKitaevMapper())
converter = QubitConverter(BravyiKitaevSuperFastMapper())
solver = VQEUCCFactory(quantum_instance)
gsc = GroundStateEigensolver(converter, solver)

result = gsc.solve(es_problem)
print(result)

What should happen?

If the code above is switched to say the BravyiKitaevMapper (not the super fast one) then it works and prints the result as below. I would expect the same with BKSF

=== GROUND STATE ENERGY ===
 
* Electronic ground state energy (Hartree): -1.842686681847
  - computed part:      -1.842686681847
~ Nuclear repulsion energy (Hartree): 0.70556961456
> Total ground state energy (Hartree): -1.137117067287
 
=== MEASURED OBSERVABLES ===
 
  0:  # Particles: 2.000 S: 0.000 S^2: 0.000 M: 0.000
 
=== DIPOLE MOMENTS ===
 
~ Nuclear dipole moment (a.u.): [0.0  0.0  1.41729459]
 
  0: 
  * Electronic dipole moment (a.u.): [0.0  0.0  1.41729468]
    - computed part:      [0.0  0.0  1.41729468]
  > Dipole moment (a.u.): [0.0  0.0  -0.00000009]  Total: 0.00000009
                 (debye): [0.0  0.0  -0.00000024]  Total: 0.00000024

Any suggestions?

No response

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mrossinekcommented, Nov 23, 2021

This appears to boil down to the fact that the BKSFMapper is unable to handle all-identity operators like IIII. @jlapeyre could you take a look at this one?

0reactions
jlapeyrecommented, Jan 12, 2022

@jlapeyre is that something you can add as part of #451?

Yes, I pushed a commit to #451 doing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to map a JSON column with H2, JPA, and Hibernate
I just came across this problem working with the JSONB column type - the binary version of the JSON type, which doesn't map...
Read more >
Spatial Mapping of VOC and NOx Limitation of Ozone ...
To summarize the results, maps of the results were prepared using the five highest ozone days at each site during each year. In...
Read more >
nIU - River Thames Conditions - Environment Agency - GOV.UK
Lusotopie 2001, Liverpool on the map of england, Folgejahr, ... Katolsk messe drammen, Durandus of st pourcain, Carbonite mobile sign in error, Ahorramas?...
Read more >
Vesting Tentative Tract Map No. 6195 - Fresno.GOV
Vesting Tentative Tract Map No. 6195. Draft Environmental Impact Report. State Clearinghouse No. 2021060089. City of Fresno, California.
Read more >
Draft Initial Study and Mitigated Negative Declaration - Lodi.gov
driving range and agricultural land. The entire 30-acre Project site is designated as. “Prime Farmland” by the Farmland Mapping and Monitoring Program ...
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