This page was generated from docs/tutorials/08_qcschema.ipynb.


The QCSchema is a standard data format for quantum chemistry. The current version of it which has been adopted by multiple classical chemistry codes, only supports serialization via JSON, but their docs clearly indicate that HDF5 may also be used. Thus, in Qiskit Nature, we have opted for implementing support for both hierarchical data formats.

Now, why do we have a tutorial specifically about this format you may wonder? The reason is fairly simple: this is the data format which our drivers use internally to transfer data between the classical computation and Qiskit Nature. Thus, this tutorial will explain a few concepts, in case you want to get a bit more elaborate with your driver interaction.

Note: the support for electronic-repulsion integrals as part of the QCSchema is not yet part of the official specification and, thus, custom to Qiskit Nature. But we are working with the QCSchema authors to make this integration official!

For the purposes of this tutorial, we are using the PySCFDriver, but most discussion points should apply to the other electronic structure drivers, too.

First, let us construct a PySCFDriver and run it:

from qiskit_nature.second_q.drivers import PySCFDriver

driver = PySCFDriver()

problem =
<qiskit_nature.second_q.problems.electronic_structure_problem.ElectronicStructureProblem object at 0x7f6e2891a400>
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pyscf/dft/ 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
  warnings.warn('Since PySCF-2.3, B3LYP (and B3P86) are changed to the VWN-RPA variant, '

This is basically short for the following:

from qiskit_nature.second_q.problems import ElectronicBasis

problem = driver.to_problem(basis=ElectronicBasis.MO, include_dipole=True)

There are two things to note here: - the problem is specifically requested in the MO basis - dipole integrals are handled separately (because the current QCSchema standard does not support these coefficients)

What this means for you as an end-user, is that you can also request the problem in another basis like so:

ao_problem = driver.to_problem(basis=ElectronicBasis.AO)

If you now want to transform an AO problem into the MO basis, you need to use the BasisTransformer which is explained in a separate tutorial.

This is the point, where you need to understand that the to_problem method actually relies on the to_qcschema method internally:

from qiskit_nature.second_q.formats.qcschema_translator import qcschema_to_problem

qcschema = driver.to_qcschema()
ao_problem = qcschema_to_problem(qcschema, basis=ElectronicBasis.AO)

Specifically extracting the QCSchema object from the driver allows you to later extract a BasisTransformer from it, without having to manually dig out the AO-2-MO transformation coefficients from the depths of the driver object:

from qiskit_nature.second_q.formats.qcschema_translator import get_ao_to_mo_from_qcschema

basis_transformer = get_ao_to_mo_from_qcschema(qcschema)
mo_problem = basis_transformer.transform(ao_problem)


Version Information

System information
Python version3.8.18
Python compilerGCC 11.4.0
Python builddefault, Aug 28 2023 08:27:22
Memory (Gb)15.60689926147461
Wed Nov 29 13:17:41 2023 UTC

This code is a part of Qiskit

© Copyright IBM 2017, 2023.

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.