⬡ Hub
Skip to content

4_VQE_on_a_Molecule

Variational Quantum Eigensolver (VQE) for H2 Molecule

Description

This project implements the Variational Quantum Eigensolver (VQE), a hybrid quantum-classical algorithm, to find the ground state energy of a hydrogen (H2) molecule. VQE is a promising algorithm for near-term quantum computers and has applications in quantum chemistry and materials science.

This implementation uses Qiskit Nature to define the molecule, construct the Hamiltonian, and run the VQE algorithm.

Setup

  1. Install Python: Make sure you have Python 3.6 or later installed.

  2. Install Qiskit and Qiskit Nature: Open your terminal or command prompt and install the necessary libraries:

    bash pip install qiskit pip install qiskit-nature[pyscf] Note: pyscf is a classical chemistry library used to generate the molecular integrals. Depending on your system, you might need to install it separately if the above command fails.

How to Run

  1. Navigate to this directory in your terminal.

  2. Run the vqe_h2.py script:

    bash python vqe_h2.py

    The script will define the H2 molecule, set up the VQE algorithm with a chosen ansatz and optimizer, run the simulation, and print the calculated ground state energy.

Files and Subdirectories