Skip to content

Commit 8135c88

Browse files
committed
Minor updates tutorial H2
1 parent 2d94bb5 commit 8135c88

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

documentation/source/general/tutorial/H2.rst

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.. _H2:
22

33
Simulating the dynamics of the $H_2$ molecule
4-
===========================================
4+
=============================================
55

66
Quantum computing offers a promising avenue for simulating complex molecular systems, potentially revolutionizing fields like drug discovery, materials science, and chemical engineering. At the heart of this capability lies Hamiltonian simulation, a powerful technique that allows us to model the quantum behavior of molecules with exponentially less resources compared to classical computers.
7-
In this tutorial, we'll explore how to simulate molecules using Hamiltonian simulation techniques implemented in Qrisp. Since version 0.5 Qrisp provides a user-friendly interface for simulating quantum many body systems, making it a suitable tool for tackling complex quantum chemistry problems.
7+
In this tutorial, we'll explore how to simulate molecules using Hamiltonian simulation techniques implemented in Qrisp. Since version 0.5, Qrisp provides a user-friendly interface for simulating quantum many body systems, making it a suitable tool for tackling complex quantum chemistry problems.
88
We'll cover the following key aspects:
99

1010
* :ref:`The fundamentals of Hamiltonian simulation and the second quantization <ham_sim_fundamentals>`
@@ -15,36 +15,37 @@ By the end of this tutorial, you'll have a solid understanding of how to leverag
1515
Let's dive in and discover how Qrisp can help us unlock the quantum secrets of molecules!
1616

1717
.. _ham_sim_fundamentals:
18+
1819
The fundamentals of Hamiltonian simulation and the second quantization
1920
----------------------------------------------------------------------
2021

2122

22-
To understand what "second quantization" means it might be helpful to start with the **first quantization**. The idea behind this is that physical systems containing only a single particale are described by a Hilbert space $\mathcal{H}$, which consits of a set of basis-vectors:
23+
To understand what "second quantization" means it might be helpful to start with the **first quantization**. The idea behind this is that physical systems containing only a single particale are described by a Hilbert space $\mathcal{H}$, which consits of a set of basis vectors:
2324

2425
.. math::
25-
\mathcal{H} = \text{span}(\ket{\psi_i} | i \in \mathcal{N})
26+
\mathcal{H} = \text{span}(\ket{\psi_i} \mid i \in \mathcal{N})
2627
2728
An arbitrary state $\ket{\phi}$ can therefore be represented by a linear combination of these basis vectors:
2829

2930
.. math::
30-
\ket{\phi} = \sum_{i = 0}^\infty a_i \ket{\psi_i}, a_i \in \mathbb{C}
31+
\ket{\phi} = \sum_{i = 0}^\infty a_i \ket{\psi_i},\quad a_i \in \mathbb{C}
3132
3233
3334
34-
What these particular $\ket{\psi_i}$ represent depends on the system. For instance for the hydrogen atom these basis vectors represent the `atomic orbitals <https://en.wikipedia.org/wiki/Atomic_orbital>`_. If you participated in a course for atomic physics before, you might have seen pictures like this:
35+
What these particular $\ket{\psi_i}$ represent depends on the system. For instance for the Hydrogen atom these basis vectors represent the `atomic orbitals <https://en.wikipedia.org/wiki/Atomic_orbital>`_. If you participated in a course for atomic physics before, you might have seen pictures like this:
3536

3637
.. image:: ./hydrogen_with_axes.png
3738
:width: 400px
3839
:align: center
3940

4041
This plot represents the real part of the amplitude of one of the basis vectors (the one with $n = 4, k = 3, l = 1$ to be precise).
4142

42-
The **second quantization** now describes how systems including *multiple particles* are treated. For this the so called ladder-operators are introduced, that is for each basis state $\ket{\psi_i}$ there is an operator $a_i^\dagger$, which creates a particle in state $\ket{\psi_i}$. A creative notation for this might be:
43+
The **second quantization** now describes how systems including *multiple particles* are treated. For this the so called ladder operators are introduced, that is, for each basis state $\ket{\psi_i}$ there is an operator $a_i^\dagger$, which creates a particle in state $\ket{\psi_i}$. A creative notation for this might be:
4344

4445
.. math::
4546
a_i^\dagger \ket{\phi} = \ket{\phi \text{ + a particle in state i}}
4647
47-
For this reason this operator is called "creator". Similarly there is also the "annihilator" $a_i$, which destroys the particle.
48+
For this reason, this operator is called the "creator". Similarly there is also the "annihilator" $a_i$, which destroys the particle.
4849

4950
The ladder operators therefore determine the intrinsic interaction behavior of the particles. Observations from experiments show that there are two types of particles whose ladder operators follow different sets of laws.
5051

@@ -89,7 +90,7 @@ To apply the Pauli exclusion principle but also other anti-commutation laws for
8990
The Jordan-Wigner embedding
9091
^^^^^^^^^^^^^^^^^^^^^^^^^^^
9192

92-
A natural question that comes up is how to represent the ladder operators and the corresponding states on the quantum computer. The most established way to do this is to use the `Jordan-Wigner embedding <https://en.wikipedia.org/wiki/Jordan%E2%80%93Wigner_transformation>`_ (even though there are several `interesting alternatives <https://arxiv.org/abs/2212.09731>`_). The Jordan-Wigner embedding identifies each ladder term with an operator that acts on a qubit space:
93+
A natural question that comes up is how to represent the ladder operators and the corresponding states on a quantum computer. The most established way to do this is to use the `Jordan-Wigner embedding <https://en.wikipedia.org/wiki/Jordan%E2%80%93Wigner_transformation>`_ (even though there are several `interesting alternatives <https://arxiv.org/abs/2212.09731>`_). The Jordan-Wigner embedding identifies each ladder term with an operator that acts on a qubit space:
9394

9495
.. math::
9596
a_k = A_k \prod_{i = 0}^{k-1} Z_i
@@ -103,7 +104,7 @@ Where $A_k = \ket{0}\bra{1}$ and $Z_i$ are the Pauli-Z Operators. Feel free to v
103104
print(O_qubit)
104105
# Yields: Z_0*Z_1*Z_2*Z_3*A_4
105106

106-
This gives us an instance of the :ref:`QubitOperator` class. What is the difference to a :ref:`FermionicOperator`? While FermionicOperators model the more abstract fermion space, qubit operators represent operators on the qubit space $(\mathbb{C}^2)^{\otimes n}$ and can be simulated and evaluated efficiently using a quantum computer. In particular, QubitOperators can represent tensor products of the following operators $X,Y,Z,A,C,P^0,P^1,I$. Make sure to read the :ref:`docstring <QubitOperator>` to learn about their definition!
107+
This gives us an instance of the :ref:`QubitOperator` class. What is the difference to a :ref:`FermionicOperator`? While FermionicOperators model the more abstract fermion space, qubit operators represent operators on the qubit space $(\mathbb{C}^2)^{\otimes n}$ and can be simulated and evaluated efficiently using a quantum computer. In particular, QubitOperators can represent tensor products of the following operators $X,Y,Z,A,C,P^0,P^1,I$. Make sure to read the :ref:`documentation <QubitOperator>` to learn about their definition!
107108

108109
Dynamics
109110
^^^^^^^^
@@ -129,6 +130,7 @@ The particular values of the coefficients (like $h_{01}$ and $h_{00}$) are deter
129130

130131

131132
.. _molecular_data_tut:
133+
132134
Loading molecular data into Qrisp
133135
=================================
134136

@@ -171,6 +173,7 @@ Or if preferred, the Jordan-Wigner embedding:
171173
+ 0.697651504490463*P^0_2*P^0_3 - 0.475068848772178*P^0_3
172174
173175
.. _ham_sim_tut:
176+
174177
Performing Hamiltonian simulation
175178
=================================
176179

@@ -198,7 +201,7 @@ This snippets simulates the Dihydrogen molecule for $t = 100$ Angstrom seconds,
198201
&= \text{exp}(100iH)\ket{\phi, t =0}
199202
\end{align}
200203
201-
Finally we want to extract some physical quantity from our simulation. Our quantity of choice is the number operator:
204+
Finally, we want to extract some physical quantity from our simulation. Our quantity of choice is the particle number operator:
202205

203206
.. math::
204207
@@ -226,7 +229,7 @@ The value is not exact because of statistical noise - we can increase the precis
226229
print(N.get_measurement(electron_state, precision = 0.0001))
227230
# Yields: 1.4999799028124874
228231
229-
This concludes our little tutorial on Hamiltonian simulation. We hope you could learn something and possibly feel motivated to explore more systems and techniques! Make sure to also check out the :ref:`MolecularPotentialEnergyCurve` example to learn how to compute the ground state for both types of operators!
232+
This concludes our little tutorial on Hamiltonian simulation. We hope you could learn something and feel motivated to explore more systems and techniques! Make sure to also check out the :ref:`MolecularPotentialEnergyCurve` example to learn how to compute the ground state for both types of operators!
230233

231234
For your reference, we give the full code below:
232235

documentation/source/reference/Algorithms/index.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ This algorithms submodule of Qrisp provides a collection of commonly used quantu
99

1010
* - ALGORITHM
1111
- USED FOR
12+
* - :ref:`VQE <VQE>`
13+
- finding the ground state energy of a Hamiltonian
1214
* - :ref:`QAOA <QAOA>`
1315
- solving combinatorial optimization problems
1416
* - :ref:`QIRO <QIRO>`
1517
- solving combinatorial optimization problems, with quantum informed update rules
16-
* - :ref:`VQE <VQE>`
17-
- finding the ground state energy of a Hamiltonian
1818
* - :ref:`Shor's Algorithm <Shor>`
1919
- efficiently factoring large numbers
2020
* - :ref:`Grover's Algorithm <grovers_alg>`
@@ -33,8 +33,7 @@ We encourage you to explore these algorithms, delve into their documentation, an
3333
:maxdepth: 2
3434
:hidden:
3535

36-
QIRO
37-
VQE
36+
vqe/VQE
3837
qaoa/QAOA
3938
qiro/QIRO
4039
Shor

documentation/source/reference/Algorithms/VQE.rst renamed to documentation/source/reference/Algorithms/vqe/VQE.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Variational Quantum Eigensolver
88
.. toctree::
99
:hidden:
1010

11-
vqe/VQEProblem
12-
vqe/VQEBenchmark
13-
vqe/VQEImplementations
11+
VQEProblem
12+
VQEBenchmark
13+
VQEImplementations
1414

1515
This modules implements the `Variational Quantum Eigensolver (VQE) <https://arxiv.org/pdf/2111.05176>`_.
1616

documentation/source/reference/Examples/MolecularPotentialEnergyCurve.rst

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,17 @@ The potential energy is defined as
1010

1111
$$E_{\\text{pot}}(\\{R_A\\})=E_{\\text{elec}}(\\{R_A\\})+E_{\\text{nuc}}(\\{R_A\\})$$
1212

13-
where $E_{\text{elec}}(\{R_A\})$ is the electronic energy and $E_{\text{nuc}}(\{R_A\})$ is the nuclear repulsion energy depending on the coordinates of the atoms $\{R_A\}$.
13+
where $E_{\text{elec}}(\{R_A\})$ is the electronic energy and $E_{\text{nuc}}(\{R_A\})$ is the nuclear repulsion energy depending on the coordinates of the nuclei $\{R_A\}$.
1414

1515

1616
Example Hydrogen
1717
================
1818

19-
We caluclate the potential energy curve for the Hydrogen molecule for varying interatomic distance of the atoms.
20-
19+
We caluclate the potential energy curve for the Hydrogen molecule for varying interatomic distance.
2120

2221
We implement a function ``problem_data`` that sets up a molecule and
2322
utilizes the `PySCF <https://pyscf.org>`_ quantum chemistry library to compute the :meth:`electronic data <qrisp.vqe.problems.electronic_structure.electronic_structure_problem>` (one- and two-electron integrals, number of orbitals, number of electrons, nuclear repulsion energy, Hartree-Fock energy)
24-
for a given molecular geometry. In this example, we vary the **atomic distance** between the two Hydrogen atoms.
23+
for a given molecular geometry. In this example, we vary the **interatomic distance**, i.e., the distance between the two Hydrogen nuclei.
2524

2625
::
2726
@@ -35,7 +34,7 @@ for a given molecular geometry. In this example, we vary the **atomic distance**
3534
basis = 'sto-3g')
3635
return electronic_data(mol)
3736

38-
Next, we define an array of atomic ``distances``. For each distance ``r`` we compute the electronic ``data`` including the Hartree-Fock energy.
37+
Next, we define an array of interatomic ``distances``. For each distance ``r`` we compute the electronic ``data`` including the Hartree-Fock energy.
3938
Then we utilize the :meth:`electronic_structure_problem <qrisp.vqe.problems.electronic_structure.electronic_structure_problem>` method to create a :ref:`VQEProblem` for the given electronic ``data``. By default, the ``QCCSD`` ansatz is utilized.
4039

4140
VQE is a probabilistic algorithm and may not yield the optimal solution every time.
@@ -66,8 +65,8 @@ Finally, we visualize the results.
6665
import matplotlib.pyplot as plt
6766
plt.scatter(distances, y_hf, color='#7d7d7d',marker="o", linestyle='solid',s=10, label='HF energy')
6867
plt.scatter(distances, y_qccsd, color='#6929C4',marker="o", linestyle='solid',s=10, label='VQE (QCCSD) energy')
69-
plt.xlabel("Atomic distance", fontsize=15, color="#444444")
70-
plt.ylabel("Energy", fontsize=15, color="#444444")
68+
plt.xlabel("Interatomic distance (Angstrom)", fontsize=15, color="#444444")
69+
plt.ylabel("Energy (Hartree)", fontsize=15, color="#444444")
7170
plt.legend(fontsize=12, labelcolor="#444444")
7271
plt.tick_params(axis='both', labelsize=12)
7372
plt.grid()
@@ -82,10 +81,10 @@ Finally, we visualize the results.
8281
Example Beryllium hydride
8382
=========================
8483

85-
We caluclate the potential energy curve for the Beryllium hydride molecule for varying interatomic distance of the atoms.
84+
We caluclate the potential energy curve for the Beryllium hydride molecule for varying interatomic distance.
8685

8786
As in the previous example, we set up a function that computes the :meth:`electronic data <qrisp.vqe.problems.electronic_structure.electronic_structure_problem>` for
88-
the Beryllium hydride molecule for varying **atomic distance** between the Beryllium and Hydrogen atoms.
87+
the Beryllium hydride molecule for varying **interatomic distance**, i.e., the distance between the Beryllium and Hydrogen nuclei.
8988

9089
::
9190

@@ -148,8 +147,8 @@ Finally, we visualize the results.
148147
import matplotlib.pyplot as plt
149148
plt.scatter(distances[5:], y_hf[5:], color='#7d7d7d',marker="o", linestyle='solid',s=10, label='HF energy')
150149
plt.scatter(distances[5:], y_qccsd[5:], color='#6929C4',marker="o", linestyle='solid',s=10, label='VQE (QCCSD) energy')
151-
plt.xlabel("Atomic distance", fontsize=15, color="#444444")
152-
plt.ylabel("Energy", fontsize=15, color="#444444")
150+
plt.xlabel("Interatomic distance (Angstrom)", fontsize=15, color="#444444")
151+
plt.ylabel("Energy (Hartree)", fontsize=15, color="#444444")
153152
plt.legend(fontsize=12, labelcolor="#444444")
154153
plt.tick_params(axis='both', labelsize=12)
155154
plt.grid()

0 commit comments

Comments
 (0)