-
Notifications
You must be signed in to change notification settings - Fork 211
[WIP] How to build a vibrational Hamiltonian #1402
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
13ab25d
6456359
f99a2e9
d497621
2bb78e8
da1912e
05408be
1f15615
d846ef2
d50ef96
d24b3ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"title": "How to build spin Hamiltonians", | ||
"authors": [ | ||
{ | ||
"username": "ddhawan" | ||
}, | ||
{ | ||
"username": "soran" | ||
} | ||
], | ||
"dateOfPublication": "2024-12-05T00:00:00+00:00", | ||
"dateOfLastModification": "2024-12-06T00:00:00+00:00", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update to current date |
||
"categories": [ | ||
"Getting Started", | ||
"How-to" | ||
], | ||
"tags": [], | ||
"previewImages": [ | ||
{ | ||
"type": "thumbnail", | ||
"uri": "/_static/demo_thumbnails/regular_demo_thumbnails/thumbnail_how_to_build_spin_hamiltonians.png" | ||
}, | ||
{ | ||
"type": "large_thumbnail", | ||
"uri": "/_static/demo_thumbnails/large_demo_thumbnails/thumbnail_large_how_to_build_spin_hamiltonians.png" | ||
} | ||
Comment on lines
+21
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder to update this as well. |
||
], | ||
"seoDescription": "Learn how to build spin Hamiltonians with PennyLane.", | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"doi": "", | ||
"references": [ | ||
{ | ||
"id": "ashcroft", | ||
"type": "book", | ||
"title": "Solid State Physics", | ||
"authors": "N. W. Ashcroft, D. N. Mermin", | ||
"year": "1976", | ||
"publisher": "New York: Saunders College Publishing", | ||
"url": "https://en.wikipedia.org/wiki/Ashcroft_and_Mermin" | ||
}, | ||
{ | ||
"id": "jovanovic", | ||
"type": "article", | ||
"title": "Refraction and band isotropy in 2D square-like Archimedean photonic crystal lattices", | ||
"authors": "D. Jovanovic, R. Gajic, K. Hingerl", | ||
"journal": "Opt. Express", | ||
"volume": "16", | ||
"pages": "4048--4058", | ||
"year": "2008", | ||
"url": "https://opg.optica.org/oe/fulltext.cfm?uri=oe-16-6-4048&id=154856" | ||
} | ||
], | ||
"basedOnPapers": [], | ||
"referencedByPapers": [], | ||
"relatedContent": [ | ||
{ | ||
"type": "demonstration", | ||
"id": "tutorial_quantum_chemistry", | ||
"weight": 1.0 | ||
}, | ||
{ | ||
"type": "demonstration", | ||
"id": "tutorial_fermionic_operators", | ||
"weight": 1.0 | ||
}, | ||
{ | ||
"type": "demonstration", | ||
"id": "tutorial_isingmodel_PyTorch", | ||
"weight": 1.0 | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
r"""How to build vibrational Hamiltonians | ||
========================================= | ||
Vibrational motions are crucially important to describe the quantum properties of molecules and | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
materials. Molecular vibrations can significantly affect the outcome of chemical reactions. There | ||
are also several spectroscopy techniques that rely on the vibrational properties of molecules to | ||
provide valuable insight to understand chemical systems and design new materials. Classical quantum | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
austingmhuang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
computations have been routinely implemented to describe vibrational motions of molecules. However, | ||
efficient classical methods typically have fundamental theoretical limitations that prevent their | ||
practical implementation for describing challenging vibrational systems. This makes quantum | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
algorithms an ideal choice where classical methods are not efficient or accurate. | ||
|
||
Quantum algorithms require a precise description of the system Hamiltonian to compute vibrational | ||
properties. In this demo, we learn how to use PennyLane features to construct and manipulate | ||
different representations of vibrational Hamiltonians. We also briefly discuss the implementation of | ||
the Hamiltonian in an interesting quantum algorithm for computing the vibrational dynamics of a | ||
molecule. | ||
Comment on lines
+14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The demo simply constructs the Christiansen and Taylor hamiltonians, but doesn't actually use them in any quantum algorithm to compute the vibrational dynamics. |
||
|
||
.. figure:: ../_static/demo_thumbnails/opengraph_demo_thumbnails/OGthumbnail_how_to_build_spin_hamiltonians.png | ||
:align: center | ||
:width: 70% | ||
:target: javascript:void(0) | ||
""" | ||
|
||
###################################################################### | ||
# Vibrational Hamiltonian | ||
# ----------------------- | ||
# A molecular vibrational Hamiltonian can be defined in terms of the kinetic energy operator of the | ||
# nuclei, :math:`T`, and the potential energy operator, :math:`V`, that describes the interaction | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# between the nuclei as: | ||
# | ||
# .. math:: | ||
# | ||
# H = T + V. | ||
# | ||
# The kinetic and potential energy operators can be written in terms of momentum and position | ||
# operators, respectively. There are several ways to construct the potential energy operator which | ||
# lead to different representation of the vibrational Hamiltonian. Here we explain some of these | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I thought we always construct the PES the same way, just that the Christiansen form uses the PES as-is whereas the Taylor form uses the taylor expansion of the PES? |
||
# representations and provide PennyLane codes for constructing them. | ||
# | ||
# Christiansen representation | ||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
# The Christiansen representation of the vibrational Hamiltonian relies on the n-mode expansion of | ||
# the potential energy surface :math:`V` over vibrational normal coordinates :math:`Q`. | ||
# | ||
# .. math:: | ||
# | ||
# V({Q}) = \sum_i V_1(Q_i) + \sum_{ij} V_2(Q_i,Q_j) + .... | ||
# | ||
# This provides a general representation of the potential energy surface where the terms :math:`V_n` | ||
# depend on :math:`n` vibrational mode at most. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# The Christiansen Hamiltonian is then constructed in second-quantization based on this potential | ||
# energy surface and bosonic creation :math:`b^{\dagger}` and annihilation :math:`b` operations: | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# .. math:: | ||
# | ||
# H = \sum_{i}^M \sum_{k_i, l_i}^{N_i} C_{k_i, l_i}^{(i)} b_{k_i}^{\dagger} b_{l_i} + | ||
# \sum_{i<j}^{M} \sum_{k_i,l_i}^{N_i} \sum_{k_j,l_j}^{N_j} C_{k_i k_j, l_i l_j}^{(i,j)} | ||
# b_{k_i}^{\dagger} b_{k_j}^{\dagger} b_{l_i} b_{l_j}, | ||
# | ||
# where :math:`M` represents the number of normal modes and :math:`N` is the number of modals. The | ||
# coefficients :math:`C` represent n-mode integrals which depend on the :math:`n`-mode contribution | ||
# of the potential energy, :math:`V_n`, defined above. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we mention here that for Christiansen Hamiltonian, we truncate the number of bosonic excitations to 2? As for the normal bosonic representation, we can set the number of modals to be higher. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, feel free to add it here and I will merge it. |
||
# | ||
# PennyLane provides a set of functions to construct the Christiansen Hamiltonian, either directly | ||
# in one step or by building the Hamiltonian from its building blocks step by step. An important | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# step in both methods is to construct the potential energy operator which is done based on | ||
# single-point energy calculations along the normal modes of the molecule. The | ||
# :func:`~.pennylane.qchem.vibrational_pes` function in PennyLane provides a convenient way to | ||
# perform the potential energy calculations for a given molecule. The calculations are typically | ||
# done by performing single-point energy calculations at small distances along the | ||
# normal mode coordinates. Computing the energies for each mode separately provides the term | ||
# :math:`V_1` while displacing atoms along two different modes simultaneously gives the term | ||
# :math:`V_2` and so on. | ||
# | ||
# Let's look at an example for the HF molecule. | ||
|
||
import numpy as np | ||
import pennylane as qml | ||
|
||
symbols = ['H', 'F'] | ||
geometry = np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) | ||
mol = qml.qchem.Molecule(symbols, geometry) | ||
pes = qml.qchem.vibrational_pes(mol) | ||
|
||
###################################################################### | ||
# The :func:`~.pennylane.qchem.vibrational_pes` function creates a | ||
# :class:`~.pennylane.qchem.VibrationalPES` object that stores the potential energy surface | ||
# and vibrational information. This object is the input for several functions that we learn about | ||
# here. For instance, the :func:`~.pennylane.qchem.christiansen_integrals` function accepts this | ||
# object to compute the integrals needed to construct the bosonic form of the Christiansen | ||
# Hamiltonian defined above. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
integrals = qml.qchem.vibrational.christiansen_integrals(pes,n_states=4) | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
h_bosonic = qml.qchem.christiansen_bosonic(integrals[0]) | ||
print(h_bosonic) | ||
|
||
###################################################################### | ||
# The bosonic Hamiltonian constructed with :func:`~.pennylane.qchem.christiansen_bosonic` can be | ||
# mapped to its qubit form by using the proper mapping equations defined in the | ||
# :func:`~.pennylane.qchem.christiansen_mapping` function. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
h_qubit = qml.bose.christiansen_mapping(h_bosonic) | ||
h_qubit | ||
|
||
###################################################################### | ||
# This provides a vibrational Hamiltonian in the qubit basis that can be used in any desired quantum | ||
# algorithm in PennyLane. | ||
# | ||
# Note that PennyLane also provides the :func:`~.pennylane.qchem.christiansen_hamiltonian` function | ||
# that uses the :class:`~.pennylane.qchem.VibrationalPES` object directly and builds the qubit | ||
# Christiansen Hamiltonian. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
h_qubit2 = qml.qchem.vibrational.christiansen_hamiltonian(pes,n_states=4) | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
###################################################################### | ||
# You can verify that the two Hamiltonians are identical. | ||
austingmhuang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# Taylor representation | ||
# ^^^^^^^^^^^^^^^^^^^^^ | ||
# The Taylor representation of the vibrational Hamiltonian relies on a Taylor expansion of | ||
# the potential energy surface :math:`V` in terms of the vibrational mass-weighted normal | ||
# coordinate operators :math:`q`. | ||
# | ||
# .. math:: | ||
# | ||
# V = V_0 + \sum_i F_i q_i + \sum_{ij} F_{ij} q_i,q_j + .... | ||
# | ||
# Note that the force constants :math:`F` are derivatives of the potential energy surface. | ||
# | ||
# The Taylor Hamiltonian can then be constructed by defining the kinetic and potential energy | ||
# components in terms of the momentum and coordinate operators. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# .. math:: | ||
# | ||
# H = \sum_{i \ge j} K_{ij} p_i p_j + \sum_{i\ge j} \Phi_{ij}^{(2)} q_i q_j + | ||
# \sum_{i \ge j \ge k} \Phi_{ijk}^{(3)} q_i q_j q_k + ..., | ||
# | ||
# where the coefficients :math:`\Phi` are obtained from the force constants :math:`F` after | ||
# rearranging the terms in the potential energy operator according to the number of different modes. | ||
# | ||
# The :func:`~.pennylane.qchem.taylor_coeffs` function computes the coefficients :math:`\Phi` from | ||
# a :class:`~.pennylane.qchem.VibrationalPES` object. | ||
|
||
one, two = qml.qchem.taylor_coeffs(pes) | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
###################################################################### | ||
# We can then use these coefficients to construct a bosonic form of the Taylor Hamiltonian. | ||
|
||
h_bosonic = qml.qchem.taylor_bosonic(coeffs=[one, two], freqs=pes.freqs, uloc=pes.uloc) | ||
print(h_bosonic) | ||
|
||
###################################################################### | ||
# This bosonic Hamiltonian can be mapped to the qubit basis using mapping schemes of | ||
# :func:`~.pennylane.bose.binary_mapping` or :func:`~.pennylane.bose.unary_mapping` functions. | ||
|
||
h_qubit = qml.binary_mapping(h_bosonic, n_states=4) | ||
h_qubit | ||
|
||
###################################################################### | ||
# This Hamiltonian can be used in any desired quantum algorithm in PennyLane. | ||
# | ||
# Note that PennyLane also provides the :func:`~.pennylane.qchem.taylor_hamiltonian` function | ||
# that uses the :class:`~.pennylane.qchem.VibrationalPES` object directly and builds the qubit | ||
# Taylor Hamiltonian. | ||
|
||
h_qubit2 = qml.qchem.vibrational.taylor_hamiltonian(pes, n_states=4) | ||
|
||
###################################################################### | ||
# You can verify that the two Hamiltonians are identical. | ||
# | ||
# Conclusion | ||
# ---------- | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# The | ||
# | ||
# References | ||
# ---------- | ||
# | ||
# .. [#aaa] | ||
# | ||
# N. W. , | ||
# "". | ||
# | ||
# .. [#bbb] | ||
# | ||
# D. , | ||
# "", | ||
# 2008. | ||
soranjh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# | ||
# About the authors | ||
# ----------------- | ||
# |
Uh oh!
There was an error while loading. Please reload this page.