Skip to content
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

Update forging how-to to Qiskit Nature 0.5 #449

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions docs/entanglement_forging/how-tos/specify-problem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,42 @@
How to specify the problem
##########################

To specify the problem, we follow the Qiskit Nature workflow. We set up the ``molecule`` object, specify the driver, and instantiate the ``ElectronicStructureProblem``.
To specify the problem, we follow the Qiskit Nature workflow. We set up the ``molecule`` object, specify the driver, and instantiate the :class:`.ElectronicStructureProblem`.

We first require the following modules:

.. jupyter-execute::

from qiskit_nature.drivers import Molecule
from qiskit_nature.drivers.second_quantization import PySCFDriver
from qiskit_nature.problems.second_quantization import ElectronicStructureProblem
from qiskit_nature.second_q.formats import MoleculeInfo
from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.problems import ElectronicBasis

To set up the ``molecule`` object, we specify the individual atoms and their positions:

.. jupyter-execute::

molecule = Molecule(
geometry=[
("H", [0.0, 0.0, 0.0]),
("H", [0.0, 0.0, 0.735]),
molecule = MoleculeInfo(
["H", "H"],
[
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.735),
],
charge=0,
multiplicity=1, # Multiplicity (2S+1) of the molecule, where S is the total spin angular momentum
)

We then specify the driver (see ``PySCFDriver``) and load the molecule into the driver:
We then specify the driver (see :class:`.PySCFDriver`) and load the molecule into the driver:

.. jupyter-execute::

driver = PySCFDriver.from_molecule(molecule=molecule, basis="sto6g")

Here, the driver is an algorithm class that knows how to calculate the second quantized operators.

Finally, we instantiate the ``ElectronicStructureProblem``, a class which wraps a number of different types of drivers:
Finally, we instantiate the :class:`.ElectronicStructureProblem`, a class which wraps a number of different types of drivers:

.. jupyter-execute::
:stderr:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cell really, really wants to spit something to stderr, and the only way I could figure out not to have it cause the sphinx build to fail was to put this line here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, what is it printing out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the warning:

UserWarning: Since PySCF-2.3, B3LYP (and B3P86) are changed to the VWN-RPA variant, corresponding to the original definition by Stephens et al. (issue 1480) and the same as the B3LYP functional in Gaussian. To restore the VWN5 definition, you can put the setting "B3LYP_WITH_VWN5 = True" in pyscf_conf.py

This is also showing up in some Qiskit Nature notebooks, such as at https://qiskit.org/ecosystem/nature/migration/0.5_c_electronic_structure.html.


problem = ElectronicStructureProblem(driver)
driver.run()
problem = driver.to_problem(basis=ElectronicBasis.AO)