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
Introduction of Property objects #220
Introduction of Property objects #220
Conversation
We really need to properly handle different bases...
I started working on the |
More WIP commits. Things I am not yet satisfied with/sure about which need to be addressed as part of this PR:
Things that will likely be addressed in the future:
|
All requested changes are implemented.
qiskit_nature/properties/second_quantization/electronic/electronic_energy.py
Outdated
Show resolved
Hide resolved
qiskit_nature/properties/second_quantization/electronic/integrals/electronic_integrals.py
Outdated
Show resolved
Hide resolved
if self._basis == ElectronicBasis.SO: | ||
return self._matrices # type: ignore | ||
|
||
matrix_a = self._matrices[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we introduce a special type to avoid accessing by an index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. This tuple of matrices gets stored in the base class ElectronicIntegrals
. It's length depends on which subclass we are dealing with (length is 2 in OneBodyElectronicIntegrals
but 4 in TwoBodyElectronicIntegrals
). Introducing a special type (e.g. a NamedTuple
) would require registering this type in the base class which would need to be updated when we decided to add e.g. ThreeBodyElectronicIntegrals
.
Given that the length and type of the matrices
is asserted at construction time (I extracted the validation methods as you suggested above) I think this is okay as is.
..._nature/properties/second_quantization/electronic/integrals/one_body_electronic_integrals.py
Outdated
Show resolved
Hide resolved
..._nature/properties/second_quantization/electronic/integrals/two_body_electronic_integrals.py
Outdated
Show resolved
Hide resolved
qiskit_nature/properties/second_quantization/vibrational/occupied_modals.py
Outdated
Show resolved
Hide resolved
test/properties/second_quantization/electronic/integrals/test_two_body_electronic_integrals.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Dariusz Lasecki <dal@zurich.ibm.com>
* [WIP] ElectronicEnergy Property object * Generalize to n-body integrals * Extract fermionic op builder for electronic energy * [WIP] ParticleNumber Property * Fix lint * Add remaining aux_op-based properties * Make tests slow again (as they used to be) * Fix some matrix dimensions We really need to properly handle different bases... * WIP: prepare proper Basis handling * Add simple BasisTransform * Remove register_length from Property base class * Do not use future annotations to support Python 3.6 * Fix lint * Fix _2BodyElectronicIntegrals.to_spin * Fix mypy in CI * Very, VERY (!!!) early PoC vibrational integrals * WIP: some improvements * Add OccupiedModals property * Some cleanup * Fix spell * Fix lint * Allow empty operator initialization * Revert "Allow empty operator initialization" This reverts commit 3692340. * Fix empty op case in VibrationalOp * Simplify some properties * Some naming updates * Fix DipoleMoment * Restructure properties submodule * Fix style * Fix mypy * Fix spell * Prepare property unittests * Prepare properties documentation * Address TODOs in properties.electronic * Fix spell * Address TODOs in properties.vibrational * Add TODOs in structure problem classes * Add unittests for ElectronicIntegrals * Add unittests for HarmonicBasis * Remove unused test directories - electronic bases are merely static files which cannot really be tested - vibrational integrals can basically only be tested as part of the vibrational basis tests * Add HarmonicBasis operator construction tests * Fix lint * Remove unused builder utilities Unfortunately, the UVCC and CHC unittests still rely on one of the removed, private methods. For now, I moved them to the unittest suite but we will properly migrate those tests in the future. * Fix auto-generated docs stubs * Add some TODO marks for the future * Fix spell * De-duplicate code * Use names for special ints/floats * Extract input type validation * Make naming consistent * Remove unused imports * Extract raw testing resources * Fix docstring titles * Fix Property valid type assertion * Add Property base class tests * Add vibrational property tests * Add electronic property tests * Fix linters * Update docstring * Remove interpret method stub from subclasses for now * Make ElectronicBasisTransform variables public * Extract common base class for ElectronicEnergy and DipoleMoment * Replace raw assert statements * Expose ERI_TRUNCATION_LEVEL overwrite option * Fix linters * Fix mypy * Remove unused import * Relocate qiskit_nature.properties to qiskit_nature.properties.second_quantization * Fix mypy in CI * Add missing docs * Extract validation methods * Extract integral threshold * Simplify OccupiedModals Co-authored-by: Dariusz Lasecki <dal@zurich.ibm.com> * Replace bare assert statements Co-authored-by: Dariusz Lasecki <dal@zurich.ibm.com>
Summary
This is a very early WIP for #167.
Details and comments
As proposed in the aforementioned issue as well as the Epic #148, we want to introduce some modular
Property
objects, in order to containerize theQMolecule
and make it fit better into the rest of the updated stack. This PR will make the first step into this direction. Below is a list of the changes:Property
objects for:ElectronicEnergy
ParticleNumber
AngularMomentum
Magnetization
DipoleMoment
WatsonHamiltonian
Basis(Enum)
)leverage @jlapeyre's 2-body integral symmetry utilities as part of(EDIT: postponed)_2BodyElectronicIntegrals
StructureProblem
s:The tying into the
Problem
classes will be improved in the future. The details of that implementation depend on steps outlined in #148. The same goes for theinterpret()
method stubs. I have them there right now because I think they could fit well, but they will only become useful if/once we reach the last implementation step.