This repository was archived by the owner on Dec 7, 2021. It is now read-only.
Commit d028eec
Bosonic algorithms and support for Chemistry (#1356)
* fixes in ground state
* patch MES result to GSC result instead of returning a tuple
* files fixes for GSC interface
* rm utf8 headers
* fix spell, lint, mypy
* Remove `custom_excitation_pool` from AdaptVQE `compute_ground_state` function
Rather than ignoring the arguments given by the interface, we can remove
this additional argument in favor of enabling the user to set this
custom excitation pool through the `MESFactory`.
An example on how to achieve such a thing can be seen in the
corresponding unittest.
* fix mypy
* fix lint
* Re-enable DeprecationWarnings after VQEAdapt has been initialized
* Fixes several minor nit-picks
- copyright years
- faulty renames
- faulty merge side-effects
- missing setters
* make MESFactory an interface only
* make MESFactory an interface only
* fix copyright years
* derive from MESFactory and update docs
* update docstrings and add molecule_info
* consistent naming in ``ground(_)state``
* fix spell
* more spell, deprecate MGSE
* fix deprecation
* more style
* test fixes
* fixes
* [WIP] basic Result-interfaces
This adds the following interfaces:
- qiskit.chemistry.ChemistryResult(AlgorithmResult)
- qiskit.chemistry.ground_state_calculation.GroundStateResult(ChemistryResult)
- qiskit.chemistry.ground_state_calculation.FermionicGroundStateResult(GroundStateResult)
The logic is as follows:
ChemistryResult and GroundStateResult are empty interfaces which define
a hierarchy for the result classes. They provide a useful granularity
for type checking. Once more subclasses are added we can extract common
functionality up into the stack as needed.
The FermionicGroundStateResult currently is just a port of the old
MolecularChemistryResult and MolecularGroundStateResult. Both of these
classes are deprecated in this commit. Since this class is currently
specific to the GroundStateCalculation it is part of that module. This
is, however, subject to change.
* Remove BosonicTransformation from this PR
The BosonicTransformation will be added in a separate PR aiming to
refactor the respective modules.
* AdaptVQE actually supports aux_operators
* [wip] resolve cyclic import problems
Having a `Result` class in either the `ground_state_calculations` or
`qubit_operator_transformations` modules leads to a coupling of the two
modules that is too tight. I.e. we run into cyclic imports whenever we
try to run any code because the `QubitOpTransformation` class needs to
load the `Result` class while at the same time it needs to be available
in the `GroundStateCalculation` class. Thus, when an additional coupling
in between these two modules is created, we have cyclic import.
Thus, we drop one level of granularity and only provide a single
result-interface on the `qiskit.chemistry` level, here, called
`ChemistryResult` (open for discussion). I also moved the `DipoleTuple`
to this level to simplify its usage in the other classes.
* Make AdaptVQE use the FermionicGSResult
* Use FermionicGroundStateResult in MinimumEigensolverGroundStateCalculation
* molecule update
* molecule update
* test molecule added
* test commit
* new branch
* Fix mypy
* Filter DeprecationWarnings in unittests
This filters all of the DeprecationWarnigns introduced in this PR.
In 3 months from now we can remove these tests once the corresponding
code is also removed.
This commit also adds TODO labels to all of these unittest files which
will have to be migrated to work within the new framework.
* Add TODO in AdaptVQE unittest
* Add missing unittest imports
I noticed that in some test files the unittest module is not imported
and the `__main__` is not set accordingly. If we do not want to mix
these changes into this PR, we can simply revert this commit.
* mypy fix
* unused code
* Create qiskit.chemistry.results module
* Replace interpret() with add_context() in QubitOperatorTransformations
Instead of an interpret() function, the QubitOperatorTransformation
interface defines an add_context() function which is used to augment the
given StateResult object with information based on the transformation's
context.
* Fix GroundStateCalculation classes to work with the results interface
* Revert faulty change in github workflow
* combining bosonic_operator into bosonic_transformation
* HarmonicBasis class to transform a Watson Hamiltonian (vibronic Hamiltonian) in the harmonic basis
* Watson Hamiltonian class to store the results of the bosonic driver
* now returns a watson hamiltonian and does not take care of the transformation to the harmonic basis anymore
* Watson Hamiltonian class to store the results of the bosonic driver
* added watson hamiltonian to init
* harmonic transformation for watson hamiltonian
* added docstring, made compatible with the harmonic basis and watson hamiltonian, replaced the printing ground state functions by a filter function
* unitests WIP first commit
* remove deprecation suppressing from new tests
* support additional aux ops and conv to dict
* fix aux_ops=None
* lint, style
* more test
* fixes in test
* fix style
* fix mypy
* fix mypy
* fixes in fermionic trafo
* fixed bug in direct qubit mapping
* remove editor created redundant file
* resolved tests
* docstring fix
* fix error & specify type hint
* change typehint Any -> FermionicOp
* add missing imports
* spell
* suggestions from code review
* consistent use in .keys()
* type hints, minor improvements
* Rethink the qiskit.chemistry.results
After some discussion we decided to rethink parts of the
qiskit.chemistry.results interfaces. We want to minimize the
differentiation between grround and excited states and let only the
concrete `QubitOperatorTransformation` handle the fermionic and bosonic
differentiation.
Thus, I apply the following changes:
* provide a single `EigenstateResult` which can be either a ground or
excited state
* derive `ElectronicStructureResult` (prev. `FermionicResult`) from this
* use the `FermionicTransformation.interpret()` method to map a general
`EigenstateResult` to the type specific for the transformation
With the last change we also align the `qiskit.chemistry` module further
with the `qiskit.optimization` module where we also use `interpret()`
rather than `add_context()` methods (which was the name we intended to
use prior to this commit).
* Remove unneeded DeprecationWarning from AdaptVQEResult
* Update some docstrings
* fix lint
* revert back to lists of aux_ops
* Update qiskit/chemistry/ground_state_calculation/adapt_vqe.py
Co-authored-by: Max Rossmannek <max.rossmannek@uzh.ch>
* apply suggestions from code review
* change typehint to List[float]
* Update qiskit/chemistry/core/hamiltonian.py
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
* test fixes after code review
* put back functionalities from bosonic_tranformation to bosonic_operator + created a vibronic_structure_result
* excited state interface for matching the ground state interface and handling both electronic and vibrational states
* Rename aux_values to aux_operator_eigenvalues
This naming is consistent with the EigensolverResult and
MinimumEigensolverResult classes.
* Remove leftover from dict-style aux_operators
* Add an `evaluate_operators` method to the GroundStateCalculation
This method can be used to evaluate any additional auxiliary operators
after the GSC has finished. This will be necessary especially in the
excited state calculations and is in general a nice option for the user
to have.
The method is similar to how the `VQE` evaluates auxiliary operators
internally. However, it can also deal with `MinimumEigensolver`s which
do not use a `QuantumInstance`.
A curiousity arose because the `VQE` appears to wrap the auxiliary
operator results into lists multiple times. In order to ensure
interoperability the same is done here.
The `AdaptVQE` now derives off of the `MinimumEigensolverGSC` because
there was no obvious drawback to this and the benefit of reusing this
new method was welcome.
Unittests have been added to test the new functionality.
* fix lint
* Remove erronous TODO
* Enforce a FermionicTransformation in the VQEUCCSDFactory
* Do not enforce VQEUCCSDFactory type in AdaptVQE
Since we check for the VQE and UCCSD types anyways we shouldn't force
the user to subclass this factory.
* Reuse the VQE object during AdaptVQE
* Expose molecule_info and qubit_mapping publicly
* fix lint
* added interpret function
* changed transformation and mapping type names to specify fermionic or bnosonic
* added the filter to bosonic_operator and changed the test accordingly (also fixed the test according to the bug in the mapping fixed last week)
* auxiliary operator for getting the number of occupied modals per mode plus test for bosonic tranformation
* fixes in tests
* fixes in tests and revert to molecule_methods
* remove two duplicate tests
* Expose some VQE arguments in the VQEUCCSDFactory
As discussed, we now expose some of the VQE arguments through this
factory in order to allow greater flexibility for the user.
* test commit
* fix spell
* fix bugs qeom code and first version of test for numerical qeom
* added the build_hopping_operator capability in the transformation
* modified results to take excited states components
* reverted due to missing part of the test uccsd_HF
* remove test EOM todos
* lint
* more lint
* more lint
* Prepare EigenstateResult to handle ground and excited states
* Deprecate the Enums in the chemistry.core module
* Also populate eigenstates in ground state calculations
* Add factory for NumPyMinimumEigensolver
* Implement `_filter_criterion` in FermionicTransformation
* Extract default filter_criterion into interface
Rather than checking for a private method being implemented we can
obtain the default filter_criterion cleanly.
This makes sense because any transformation in theory could implement a
default filter. However, we return None in case it is not implemented.
* fixing qeom code
* Make use of default filter criterion configurable
* Check state's type before making at a StateFn
* Use `supports_aux_ops` in `returns_groundstate`
* Replace Any type-hint where not really necessary
The reason for making it a union of lists rather than a list of a union
is to ensure that no mixed lists are allowed.
* Do not use legacy Operator in new interface
The WeightedPauliOp is a legacy operator and should not be used in this
new interface. Instead, we now convert the operators to the OperatorFlow
before returning them to ensure we only use the new operator types.
* fix the eigenstate_result and electronic_structure_result to work with excited states and test eom with Numpy eigensolver for the ground state
* clean qeom code
* tests for numerical qeom
* change of the ExcitedStatesCalculation init so that it does not have a GSC
* Except (Minimum)EigensolverResults in interpret()
To provide more user-flexibility and better compatibility with the Aqua
result classes, the interpret() method is able to handle
(Minimum)EigensolverResult classes as well as the EigenstateResult.
* Fix tests to work with OperatorBase rather than WeightedPauliOperator
* fix es_factory and additional information in FermionicTransformation for Analytical qEOM
* Gaussian Forces bosonic driver
* commutation rule and hopping operators for bosonic_transformation
* rm WPO support in trafo, add test for aux_ops
* test bosonic_transformation and fix bugs in filter function
* fix bug with aux_ops in filtered numpy eigensolver
* test bosonic transformation
* Fix docstring
* Fix aux_op particle-hole conversion
* vqe uvccsd factory
* gaussian log driver test adapted to changes in code
* added reno
* fix bug number of modes in gaussian_log_result
* Extend ElectronicStructureResult to work with excited state calculations
Since an electronic structure can consist of multiple states and during
excited state calculations we obtain energies and auxiliary operator
evaluations for each investigated state we expose all finally
interpreted result properties as Lists where the first entry should
always reflect the ground state properties.
* untapered_op for bosonic_transformation
* Update unit tests
* Fix bosonic tests
* testing bosonic qeom
* fix bug hopping operators in bosonic_transformation
* finish bosonic operator merge with esc
* Fix style in bosonic and excited state files
* Fix lint
* fix small things
* fix auxiliary operators
* reformatting of electronic structure results print
* fix linting
* fix mypy
* Restructure excited states code
- moving modules
- renaming classes
- adapting tests
* more mypy fixes
* final mypy fixes
* add use_default_filter_criterion argument to NumPyEigensolverFactory
* fix naming
* fix tests
* fix lint and spell
* Make commutation rule a boolean
This makes sense because it can only ever be one of two things:
commuting or anti-commuting.
* fix lint
* fix mypy
* remove warning about only fermionic problems being supported
* fix lint
* fix unittests
* fix spell and style
* try fixing sphinx
* fix test
* fix Steve's comments
* Add BosonicBasis to init file
* Fix style, lint and test
* release note
* change error message in bosonic_basis
* Do not use the default_filter_criterion for excited states
Since we opted to make the default filter criterion of the fermionic
case filter non-singlet states this kind of misses the point in the
excirted states cases.
Thus we now provide a custom filter in the test.
For the backlog we should consider a better implementation of the
default filter which can handle this automatically.
* Rename bosonic_basis module to bosonic_bases
* Fix module name in docs
Co-authored-by: Panagiotis Barkoutsos <bpa@zurich.ibm.com>
Co-authored-by: Cryoris <jules.gacon@googlemail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Manoel Marques <manoel.marques@ibm.com>
Co-authored-by: Max Rossmannek <oss@zurich.ibm.com>
Co-authored-by: Anton Dekusar <adekusar@ie.ibm.com>
Co-authored-by: Anton Dekusar <62334182+adekusar-drl@users.noreply.github.com>
Co-authored-by: Max Rossmannek <max.rossmannek@uzh.ch>
Co-authored-by: Panagiotis Barkoutsos <pbarkoutsos@gmail.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: Mario Motta <mario@marios-mbp.almaden.ibm.com>
Co-authored-by: woodsp <woodsp@us.ibm.com>
Co-authored-by: Stefan Woerner <WOR@zurich.ibm.com>1 parent 41d9a15 commit d028eec
File tree
39 files changed
+1574
-780
lines changed- docs/apidocs
- qiskit
- aqua/operators/legacy
- chemistry
- algorithms
- excited_states_solvers
- eigensolver_factories
- ground_state_solvers
- minimum_eigensolver_factories
- components
- bosonic_bases
- drivers
- gaussiand
- results
- transformations
- releasenotes/notes
- test/chemistry
39 files changed
+1574
-780
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
61 | 62 | | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
| 222 | + | |
220 | 223 | | |
221 | 224 | | |
222 | | - | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| |||
376 | 378 | | |
377 | 379 | | |
378 | 380 | | |
| 381 | + | |
379 | 382 | | |
380 | 383 | | |
381 | 384 | | |
| |||
760 | 763 | | |
761 | 764 | | |
762 | 765 | | |
| 766 | + | |
763 | 767 | | |
764 | 768 | | |
765 | 769 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
| 404 | + | |
405 | 405 | | |
406 | 406 | | |
407 | 407 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
| 414 | + | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
417 | | - | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
426 | 428 | | |
427 | 429 | | |
428 | 430 | | |
429 | | - | |
| 431 | + | |
430 | 432 | | |
431 | | - | |
| 433 | + | |
432 | 434 | | |
433 | 435 | | |
434 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| 169 | + | |
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
| |||
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
51 | | - | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
24 | 25 | | |
25 | | - | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 87 | | |
93 | 88 | | |
94 | 89 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
0 commit comments