-
Notifications
You must be signed in to change notification settings - Fork 211
Demo: X-ray Absorption Spectroscopy #1390
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?
Conversation
Thank you for opening this pull request. You can find the built site at this link. Deployment Info:
Note: It may take several minutes for updates to this pull request to be reflected on the deployed site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to read this in more detail so suggest more story-telling improvements, but I think it's already in excellent shape. I don't think we need to add any more stuff, the
demonstrations/tutorial_xas.py
Outdated
###################################################################### | ||
# .. figure:: ../_static/demonstration_assets/xas/fingerprinting.gif | ||
# :alt: alt text | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this so much 😍
return qml.state() | ||
|
||
return qml.QNode(circuit, dev) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice pieces of code 🚀
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Implemented minor comments. Co-authored-by: Alvaro Ballon <91897656+alvaro-at-xanadu@users.noreply.github.com>
Title:
X-ray absorption spectroscopy simulation in the time domain
Summary:
This demo shows how to implement a time-domain XAS simulation algorithm for a small instance of an$H_2$ molecule. The algorithm is based on Fomichev et al. 2025, omitting some of the optimizations in that paper. XAS is introduced as well as why simulating XAS could be a promising use for early fault-tolerant quantum computers. The algorithm is described, and then implemented in PennyLane, with the time-domain and spectrum output plotted. Additional optimizations are discussed at the end.
Relevant references:
"Fast simulations of X-ray absorption spectroscopy for battery materials on a quantum computer" by Stepan Fomichev, Pablo A. M. Casares, Jay Soni, Utkarsh Azad, Alexander Kunitsa, Arne-Christian Voigt, Jonathan E. Mueller, Juan Miguel Arrazola, (2025) https://arxiv.org/abs/2506.15784
"Simulating X-ray absorption spectroscopy of battery materials on a quantum computer", by Stepan Fomichev, Kasra Hejazi, Ignacio Loaiza, Modjtaba Shokrian Zini, Alain Delgado, Arne-Christian Voigt, Jonathan E. Mueller, Juan Miguel Arrazola (2024) https://arxiv.org/abs/2405.11015
Possible Drawbacks:
Large knowledge overhead
The demo makes extensive reference to previous quantum chemistry demos: Using PennyLane with PySCF and OpenFermion, Initial state preparation for quantum chemistry, and How to build compressed double-factorized Hamiltonians. This increases the overhead for the reader to understand the demo (IMO).
Example too simple/not relevant
$H_2$ is not a battery material, but calculating the ground state for some small cluster of a relevant material would take a long time, and is infeasible for a demo. I tried to use an $N_2$ molecule, but $H_2$ .
factorize
seemed to produce different results on my local computer and on the website, so I changed back toPennyLane factorization requires fine-tuned parameters
$N_2$ active space, where I had to scan a large parameter space to find the number of factors that worked. The implementation in Stepan and Pablo's xas_simulation repo works much better than the PennyLane implementation. I'm not sure why the PennyLane factorization is so reliant on a very specific number of factors. It seems to be reliable for $H_2$ , which is why I switched back to it.
qml.qchem.factorize
does not seem to reliably produce a factorized Hamiltonian that works well in the algorithm unless the number of factors and number of steps of optimization are set very specifically. This was particularly an issue for anMolecular orbital coefficient sign flip-flop/inconsistency between implementations$N_2$ active space, I ended up changing the bond length to 1.0 Angstrom from 1.077 because that seemed to produce more stable results.
The molecular orbital coefficients (MO coeffs) that are calculated in PySCF, PennyLane and OpenFermion end up slightly different from each other. Because CASCI methods are used to find the ground state in the active space, I had to overwrite the PySCF MO coeffs with the PennyLane calculated MO coeffs to match the ones used in the Hamiltonian and the dipole operator. I believe the MO coeffs have to be the same in all calculations for the result to be correct. However,
qml.qchem.scf
does not consistently produce the same MO coeffs, and I believe the same is true for PySCF. But, the beyond Hartree-Fock calculation methods in PySCF pull from the initial Hartree Fock instance, so the MO coefficients remain the same. However in PennyLane, the MO coeffs are recalculated whendipole_moment
andelectron_integrals
are called, so I'm not sure if they will always give the same values. When trying anRelated GitHub Issues:
If you are writing a demonstration, please answer these questions to facilitate the marketing process.
To show off a recent Xanadu paper. This paper is of interest because it describes a quantum algorithm that could have near-term industrial utility (battery material simulation). The implementation of this algorithm in PennyLane is relatively simple, due to the functions in the quantum chemistry module of PennyLane. Showing off the utility of these functions is a main focus of the demo.
Chemistry researchers, anyone interested in Hamiltonian simulation algorithms.
X-ray absorption spectroscopy, Hamiltonian simulation, battery research, compressed double-factorized Hamiltonians, time-domain simulation, optimization, product formulas, commercial application
(more details here)