This project is implemented as a part of the PHY F311 - Quantum Mechanics 2 at BITS Pilani K.K. Birla Goa Campus, and intends to simulate the XY Hamiltonian time evolution and demonstrates the iSWAP gate implementation using Qiskit.
- Python 3.8 or higher
- pip (Python package installer)
git clone https://github.com/atharvap2505/iSWAP_gate_simulation.git
cd iSWAP_gate_simulationCreate a virtual environment to isolate project dependencies:
python -m venv venvOn Linux/Mac:
source venv/bin/activateOn Windows:
venv\Scripts\activateYou should see (venv) prefix in your terminal prompt, indicating the virtual environment is active.
Install all required packages using the requirements file:
pip install -r requirements.txtOpen VS Code and navigate to the project folder:
code .Or use File → Open Folder in VS Code.
Install the following VS Code extensions:
- Python (by Microsoft)
- Jupyter (by Microsoft)
You can install them by:
- Opening the Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon Mac) - Searching for "Python" and "Jupyter"
- Clicking Install
Open iSWAP_simulation.ipynb in VS Code. It should open in the notebook editor.
- Click on the kernel picker in the top-right corner of the notebook (it may say "Select Kernel")
- Choose Python Environments
- Select the virtual environment you created (
venv)- It should be listed as
./venv/bin/pythonor similar
- It should be listed as
Execute cells by:
- Clicking the ▶ Run button next to each cell
- Pressing
Shift + Enterto run the current cell and move to the next - Using Run All from the top toolbar to execute all cells
The first cell will automatically install required packages if they're missing.
If you prefer the classic Jupyter interface:
jupyter notebookThis will open a browser window. Click on iSWAP_simulation.ipynb to open the notebook.
Execute the cells in order by pressing Shift + Enter or using the "Run All" option from the Cell menu.
When you're done working on the project, deactivate the virtual environment:
deactivateiSWAP_simulation.ipynb- Main Jupyter notebook containing the simulation coderequirements.txt- Python package dependenciesREADME.md- This filedocumentation.pdf- Compiled PDF documentation of the code and theoryconcurrence_plot.png- Generated plot of entanglement dynamicscircuit_diagram.txt- Text representation of the quantum circuit
- numpy: Numerical computing library
- matplotlib: Plotting and visualization
- qiskit: Quantum computing framework
- qiskit-aer: High-performance simulator for Qiskit
If you encounter import errors, ensure:
- The virtual environment is activated
- All packages are installed:
pip listshould show qiskit, numpy, matplotlib, and qiskit-aer - Try reinstalling:
pip install --force-reinstall -r requirements.txt
If the notebook can't find the packages in VS Code:
- Make sure you've selected the correct Python interpreter (the one in your
venvfolder) - Try reloading the window:
Ctrl+Shift+P(orCmd+Shift+Pon Mac) → "Developer: Reload Window" - Restart VS Code completely
If using Jupyter Notebook and it can't find the packages:
- Install ipykernel:
pip install ipykernel - Add the virtual environment to Jupyter:
python -m ipykernel install --user --name=venv - In Jupyter, select Kernel → Change Kernel → venv
- Qiskit Documentation
- Qiskit Tutorials
- See
documentation.pdffor detailed explanation of the physics and code