Tutorial on the Visualization of Results
Data visualization is a critical aspect of analyzing and interpreting simulation results. In this notebook, you’ll learn how to leverage QuantumDNA’s predefined plotting routines to effectively visualize the outcomes of your calculations.
Examples Covered:
Visualizing the Eigenspectrum Gain insights into the electronic structure by plotting the eigenspectrum of your system. This visualization highlights energy levels and their distributions, essential for analyzing the quantum states of your model.
Visualizing the Fourier Analysis Explore frequency-domain characteristics using Fourier analysis. This technique is particularly useful for identifying periodicities and resonances in quantum systems.
Visualizing Coherences and Populations Delve into the dynamics of quantum states by visualizing coherences and populations of the DNA bases or basepairs. These plots reveal how quantum superpositions evolve over time, providing a window into processes such as energy transfer, decoherence, and relaxation.
By the end of this notebook, you’ll have a grasp of how to utilize qDNA’s visualization capabilities to analyze and communicate your results effectively.
[1]:
%load_ext autoreload
%autoreload 2
# Save flag: Set to True to enable saving results (currently unused in this script)
save = False
# Verbose flag: Set to True to enable detailed logging
verbose = False
Setup
[2]:
import numpy as np
import matplotlib.pyplot as plt
# --------------------------
# Installation of QuantumDNA
# --------------------------
from importlib.util import find_spec
qDNA_installed = find_spec('qDNA') is not None
if not qDNA_installed:
%pip install qDNA
print("Successfully installed the 'qDNA' package.")
else:
print("Package 'qDNA' is already installed.")
if verbose:
%pip show qDNA
# ------------------------
# Directory Setup
# ------------------------
import os
# Use the current working directory as the root
ROOT_DIR = os.getcwd()
# Define directory to save figures
SAVE_DIR = os.path.join(ROOT_DIR, "my_figures")
os.makedirs(SAVE_DIR, exist_ok=True)
if verbose:
print(f"Save directory: '{SAVE_DIR}' is ready.")
Visualization of the Eigenspectrum
[4]:
from qDNA import get_me_solver, plot_eigv
kwargs=dict()
upper_strand, tb_model_name= 'GCG', 'ELM'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plt.subplots()
plot_eigv(ax, me_solver.tb_ham)
[5]:
from qDNA import get_me_solver, plot_eigs
kwargs=dict()
upper_strand, tb_model_name= 'GCG', 'ELM'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
num_rows, num_cols = 3, 3
fig, axes = plt.subplots(num_rows, num_cols, figsize=(5*num_cols, 5*num_rows) )
for i, ax in enumerate(axes.flatten()[:num_rows*num_cols]):
plot_eigs(ax, me_solver.tb_ham, i)
Fourier Analysis
[6]:
from qDNA import get_me_solver, plot_fourier
kwargs=dict(particles=['electron', 'hole'])
upper_strand, tb_model_name= 'GA', 'WM'
tb_site = '(0, 1)'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plt.subplots()
plot_fourier(ax, me_solver.tb_ham, me_solver.init_state, tb_site, 'Period')
[7]:
from qDNA import get_me_solver, plot_pop_fourier
kwargs=dict(particles=['electron', 'hole'], t_end=15, t_unit='fs')
upper_strand, tb_model_name= 'GA', 'WM'
tb_site = '(0, 1)'
# plotting
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plt.subplots()
plot_pop_fourier(ax, me_solver.tb_ham, me_solver.init_state, tb_site, me_solver.times, me_solver.t_unit)
[8]:
from qDNA import get_me_solver, plot_average_pop
kwargs=dict()
upper_strand, tb_model_name= 'GA', 'WM'
J_list, J_unit = np.linspace(0,10,100), 'meV'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plt.subplots(1,3, figsize=(15,5))
plot_average_pop(ax, me_solver.tb_ham, J_list, J_unit)
Visualization of Populations and Coherences
[1]:
from qDNA import get_me_solver, plot_pops_heatmap
kwargs=dict(source="Hawke2010", t_end=2)
upper_strand, tb_model_name= 'GCG', 'ELM'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plot_pops_heatmap(me_solver)
[9]:
from qDNA import get_me_solver, plot_pops
kwargs=dict(source="Hawke2010", t_end=2)
upper_strand, tb_model_name= 'GCG', 'ELM'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plot_pops(me_solver)
[10]:
from qDNA import get_me_solver, plot_coh
kwargs=dict(source="Hawke2010", t_end=2)
upper_strand, tb_model_name= 'GCG', 'ELM'
me_solver = get_me_solver(upper_strand, tb_model_name, **kwargs)
fig, ax = plt.subplots()
plot_coh(ax, me_solver)
