09-Nature Tutorial- Properties-or-OperatorFactories
[ ]:
#This code is at:
#https://qiskit-community.github.io/qiskit-nature/tutorials/09_properties.html
[1]:
from qiskit_nature.second_q.problems import BaseProblem
dummy_hamiltonian = None
base_problem = BaseProblem(dummy_hamiltonian)
print(base_problem.properties)
<qiskit_nature.second_q.problems.properties_container.PropertiesContainer object at 0x73421fae5450>
[2]:
from qiskit_nature.second_q.properties import AngularMomentum
print("AngularMomentum is in problem.properties:", AngularMomentum in base_problem.properties)
print("Adding AngularMomentum to problem.properties...")
base_problem.properties.add(AngularMomentum(2))
print("AngularMomentum is in problem.properties:", AngularMomentum in base_problem.properties)
print("Discarding AngularMomentum from problem.properties...")
base_problem.properties.discard(AngularMomentum)
print("AngularMomentum is in problem.properties:", AngularMomentum in base_problem.properties)
AngularMomentum is in problem.properties: False
Adding AngularMomentum to problem.properties...
AngularMomentum is in problem.properties: True
Discarding AngularMomentum from problem.properties...
AngularMomentum is in problem.properties: False
[3]:
from qiskit_nature.second_q.drivers import PySCFDriver
es_problem = PySCFDriver().run()
print(es_problem.properties.particle_number)
print(es_problem.properties.angular_momentum)
print(es_problem.properties.magnetization)
print(es_problem.properties.electronic_dipole_moment)
print(es_problem.properties.electronic_density)
<qiskit_nature.second_q.properties.particle_number.ParticleNumber object at 0x73421fadda50>
<qiskit_nature.second_q.properties.angular_momentum.AngularMomentum object at 0x73421b16f0d0>
<qiskit_nature.second_q.properties.magnetization.Magnetization object at 0x73421ab68fd0>
<qiskit_nature.second_q.properties.dipole_moment.ElectronicDipoleMoment object at 0x734234b47550>
None
[4]:
from qiskit_nature.second_q.properties import ElectronicDensity
density = ElectronicDensity.from_orbital_occupation(
es_problem.orbital_occupations,
es_problem.orbital_occupations_b,
)
es_problem.properties.electronic_density = density
[ ]: