This page was generated from docs/tutorials/09_properties.ipynb.

Properties - or - Operator Factories#

Qiskit Nature has various built-in “properties”. These objects are effectively operator factories, since they allow the programming of operator blueprints based on a minimal set of required information. Some commonly used examples are the ParticleNumber, AngularMomentum and Magnetization properties, all of which take only the system size as their only input, and generate a SparseLabelOp of the required size.

These properties can be registered in a problem instance which will cause them to be evaluated once a ground state and/or excited states of that problem have been found. In the following, we will explain the general concept of how this works.

The BaseProblem base class dictates the existence of the .properties attribute on any problem instance. This attribute is of type PropertiesContainer which is an object that can hold at most one instance of any SparseLabelOpsFactory (or property class, as we commonly refer to them).

from qiskit_nature.second_q.problems import BaseProblem

dummy_hamiltonian = None

base_problem = BaseProblem(dummy_hamiltonian)
<qiskit_nature.second_q.problems.properties_container.PropertiesContainer object at 0x7f92ccb76640>

You can now modify the contents of the PropertiesContainer to your desire:

from import AngularMomentum

print("AngularMomentum is in", AngularMomentum in

print("Adding AngularMomentum to")

print("AngularMomentum is in", AngularMomentum in

print("Discarding AngularMomentum from")

print("AngularMomentum is in", AngularMomentum in
AngularMomentum is in False
Adding AngularMomentum to
AngularMomentum is in True
Discarding AngularMomentum from
AngularMomentum is in False

The specific subclasses of BaseProblem for the various stacks such as electronic structure, vibrational structure or lattice models make things even simpler for you, because they provide direct attributes for the built-in properties of Qiskit Nature:

from qiskit_nature.second_q.drivers import PySCFDriver

es_problem = PySCFDriver().run()

< object at 0x7f92791cb190>
< object at 0x7f92791cb340>
< object at 0x7f92791cb1f0>
< object at 0x7f92791cb070>

Note that the ElectronicDipoleMoment is populated by default. To exclude it, you can use the drivers to_problem() method and provide the include_dipole=False keyword argument. Refer to the drivers documentation for more details.

You can see, that all properties come pre-populated except for the ElectronicDensity. But this is easy to add:

from import ElectronicDensity

density = ElectronicDensity.from_orbital_occupation(
) = density

The same concepts apply to the VibrationalStructureProblem and the LatticeModelProblem.

import tutorial_magics


Version Information

System information
Python version3.8.18
Fri Feb 23 10:25:33 2024 UTC

This code is a part of a Qiskit project

© Copyright IBM 2017, 2024.

This code is licensed under the Apache License, Version 2.0. You may
obtain a copy of this license in the LICENSE.txt file in the root directory
of this source tree or at

Any modifications or derivative works of this code must retain this
copyright notice, and modified files need to carry a notice indicating
that they have been altered from the originals.