Skip to content

Commit

Permalink
Apply suggestions to get started page
Browse files Browse the repository at this point in the history
Co-authored-by: abbycross <[email protected]>
  • Loading branch information
kaelynj and abbycross authored Nov 5, 2024
1 parent f956f77 commit 9634725
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions docs/guides/qiskit-addons-sqd-get-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"source": [
"# Getting started with SQD\n",
"\n",
"In this page we will overview the `qiskit-addons-sqd` package and demonstrate a simple working example to get started. We will demonstrate this by using SQD to obtain an approximation of the ground state of the $N_2$ molecule at equilibrium.\n",
"This guide demonstrates a simple working example to get started with the `qiskit-addons-sqd` package. In this example, you can use SQD to obtain an approximation of the ground state of the $N_2$ molecule at equilibrium.\n",
"\n",
"To begin, recall that the generic interacting-electron Hamiltonian has the form:\n",
"\n",
Expand All @@ -22,7 +22,7 @@
"metadata": {},
"source": [
"<Admonition type = \"note\">\n",
"This example ingests pre-generated data in a file called `n2_fci.txt` which contains one and two-body electronic integrals. To run the code cells below on a local machine, simply copy and pasted the data into a file with the same name. This example also utilizes the `pyscf` package so be sure to install those in the environment used to execute it.\n",
"This example ingests pre-generated data in a file called `n2_fci.txt`, which contains one- and two-body electronic integrals. To run the code cells below on a local machine, simply copy and paste the data into a file with the same name. This example also utilizes the `pyscf` package, so be sure to install it in the environment used to execute it.\n",
"</Admonition>\n",
"\n",
"<details>\n",
Expand Down Expand Up @@ -1654,7 +1654,7 @@
"source": [
"## Prepare molecule information\n",
"\n",
"To begin, specify the molecule and its properties using `pyscf` and the electronic integrals stored in `n2_fci.txt`"
"To begin, specify the molecule and its properties using `pyscf` and the electronic integrals stored in `n2_fci.txt`."
]
},
{
Expand Down Expand Up @@ -1716,10 +1716,10 @@
"id": "0f6239eb-d7f5-40ff-9e7a-262cf4fbe613",
"metadata": {},
"source": [
"We'll next generate a random set of counts for the configuration recovery loop to post-process. This will simulate the measurement data of a 32-qubit circuit sampled with 10,000 shots. Once the count data has been generated, the `recover_configurations()` method requires that the count data be converted into a matrix of the bitstrings measured at each shot as well as an array of probabilities for each state that was measured.\n",
"Next, generate a random set of counts for the configuration recovery loop to post-process. This simulates the measurement data of a 32-qubit circuit sampled with 10,000 shots. Once the count data has been generated, the `recover_configurations()` method requires that you convert the count data into a matrix of the bitstrings measured at each shot, as well as an array of probabilities for each state that was measured.\n",
"\n",
"<Admonition type = \"note\">\n",
"The artificial generation of samples is only used as a means to demonstrate the tooling of `qiskit-addon-sqd`. The package is meant to be used as part of a larger workflow wherein an ansatz or other circuit is defined, optimized, and executed using the `Sampler` primitive. The code cell below contains commented out code demonstrating what a typical workflow might look like.\n",
"The artificial generation of samples is only used as a means to demonstrate the tooling of `qiskit-addon-sqd`. The package is meant to be used as part of a larger workflow wherein an ansatz or other circuit is defined, optimized, and executed using the `Sampler` primitive. The code cell below contains commented-out code demonstrating what a typical workflow might look like.\n",
"</Admonition>"
]
},
Expand Down Expand Up @@ -1758,7 +1758,7 @@
"\n",
"The measurement samples can then be refined by repeating the configuration recovery and diagonalizing sets of subsamples to approximate the ground state until convergence.\n",
"\n",
"There are first a few options which need to be specified:\n",
"First, specify the following options:\n",
"\n",
"- `ITERATIONS`: the number of self-consistent configuration recovery iterations\n",
"- `NUM_BATCHES`: the number of sets of subsamples to diagonalize\n",
Expand Down Expand Up @@ -1787,7 +1787,7 @@
"id": "d977f0e1-0e21-45d0-8971-92e1773f418b",
"metadata": {},
"source": [
"Next, in order to plot the convergence, define arrays to store the approximation of the ground state energy, expectation value of the $\\langle S \\rangle ^2$, and the orbital occupancy of the molecule"
"Next, in order to plot the convergence, define arrays to store the approximation of the ground state energy, expectation value of the $\\langle S \\rangle ^2$, and the orbital occupancy of the molecule."
]
},
{
Expand All @@ -1809,11 +1809,11 @@
"id": "05823f66-cf57-43e0-bd9a-a77c6b6f8786",
"metadata": {},
"source": [
"Then we'll run the configuration recovery loop. Each loop consists of three steps:\n",
"Now, run the configuration recovery loop. Each loop consists of three steps:\n",
"\n",
"1. Here we first use the `recover_configurations()` method to obtain a refined bitstring matrix and probability array based on the average orbital occupancy.\n",
"1. Use the `recover_configurations()` method to obtain a refined bitstring matrix and probability array based on the average orbital occupancy.\n",
"1. The `postselect_and_subsample()` function is used to collect batches of subsamples to diagonalize over.\n",
"1. The batches of subsamples are then used as arguments to the `solve_fermion()` method to obtain an approximation of the ground state"
"1. The batches of subsamples are then used as arguments to the `solve_fermion()` method to obtain an approximation of the ground state."
]
},
{
Expand Down Expand Up @@ -1909,7 +1909,7 @@
"source": [
"### Visualize the results\n",
"\n",
"Lastly, the results can be visualized by examining the approximated energy and average orbital occupancy at each iteration of the configuration recovery loop. The first plot shows that after a few iterations we estimate the ground state energy to within approximately `200 mH` (chemical accuracy is typically accepted to be `1 kcal/mol` $\\approx$ `1.6 mH`). Recall that this demo used pure noise and that the ability to approximate the energy so well comes from our prior knowledge about the molecule and its electronic structure.\n",
"Lastly, the results can be visualized by examining the approximated energy and average orbital occupancy at each iteration of the configuration recovery loop. The first plot shows that after a few iterations, the ground state energy is estimated to within approximately `200 mH` (chemical accuracy is typically accepted to be `1 kcal/mol` $\\approx$ `1.6 mH`). Recall that this demo used pure noise, and that the ability to approximate the energy to this degree comes from prior knowledge about the molecule and its electronic structure.\n",
"\n",
"The second plot shows the average occupancy of each spatial orbital after the final iteration. We can see that both the spin-up and spin-down electrons occupy the first five orbitals with high probability in our solutions."
]
Expand Down Expand Up @@ -1995,7 +1995,7 @@
"pygments_lexer": "ipython3",
"version": "3"
},
"title": "Getting started with SQD addon"
"title": "Getting started with SQD"
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down

0 comments on commit 9634725

Please sign in to comment.