Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dehe1011 committed Nov 22, 2024
1 parent a1661fa commit 4dedf6b
Show file tree
Hide file tree
Showing 36 changed files with 43,467 additions and 142 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
<img src="https://readthedocs.org/projects/quantumdna/badge/?version=latest"
alt="Documentation Status"></a>
<a href="https://github.com/dehe1011/QuantumDNA/releases">
<img src="https://img.shields.io/badge/version-0.1.8-blue"
alt="Release"></a>
<img src="https://img.shields.io/github/v/release/dehe1011/QuantumDNA"
alt="Latest Release"></a>
<a href="https://pypi.org/project/qDNA/">
<img src="https://img.shields.io/pypi/v/qDNA"
alt="PyPI Version"></a>
<a href='https://coveralls.io/github/dehe1011/QuantumDNA?branch=main'>
<img src='https://coveralls.io/repos/github/dehe1011/QuantumDNA/badge.svg?branch=main'
alt='Coverage Status' /></a>
Expand Down Expand Up @@ -66,7 +69,7 @@ For a quick installation, you can install the `qDNA` package via pip:
pip install qDNA
```

To ensure compatibility and avoid conflicts with other packages, we recommend using a virtual environment. For detailed installation instructions and alternative methods, please refer to the [Installation Guide](INSTALLATION.md).
To ensure compatibility and avoid conflicts with other packages, we recommend using a virtual environment. For detailed installation instructions and alternative methods, please refer to the [Installation Guide](installation.md).

### Example Program

Expand All @@ -92,7 +95,7 @@ print(f"Average charge separation {dipole} A")

## Documentation

The documentation for the [latest release](https://quantumdna.readthedocs.io/en/latest/) is available for reading on Read The Docs. Tutorials can be found in a separate GitHub repository [QuantumDNA-notebooks](https://github.com/dehe1011/QuantumDNA-notebooks)
The documentation for the latest release is available for reading on [Read The Docs](https://quantumdna.readthedocs.io/en/latest/). Tutorials can be found in a separate GitHub repository [QuantumDNA-notebooks](https://github.com/dehe1011/QuantumDNA-notebooks).

## Graphical User Interface

Expand Down
2 changes: 1 addition & 1 deletion qDNA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
from .environment import *
from .dynamics import *
from .evaluation import *
from .plotting import *
from .visualization import *
Binary file added qDNA/data/figures_tutorials/FMO_energy_level.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
43,135 changes: 43,135 additions & 0 deletions qDNA/data/logs/qDNA.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion qDNA/data/raw/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"data": {
"DNA_BASES": ["A", "T", "G", "C", "F"],
"TB_MODELS": ["WM", "LM", "ELM", "FWM", "FLM", "FELM", "FC"],
"SOURCES": ["Hawke2010", "Simserides2014", "Mantela2021", "Simserides2024", "Herb2024", "1BNA"],
"SOURCES": ["Hawke2010", "Simserides2014", "Mantela2021", "Simserides2024", "Herb2024", "uni_dimer_seq", "1BNA"],
"DESCRIPTIONS": ["1P", "2P"],
"PARTICLES": ["electron", "hole", "exciton"],
"UNITS": ["meV", "eV", "100meV", "rad/ps", "rad/fs", "1/cm", "K", "J", "1/fs", "1/ps"],
Expand Down
1 change: 0 additions & 1 deletion qDNA/data/raw/tb_params/1BNA_electron_LM.json

This file was deleted.

1 change: 0 additions & 1 deletion qDNA/data/raw/tb_params/1BNA_hole_LM.json

This file was deleted.

1 change: 1 addition & 0 deletions qDNA/data/raw/tb_params/uni_dimer_seq_electron_ELM.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data": {"t_01A02T": -23.11, "h_01A34T": 12.15, "h_02T33A": 12.12, "t_33A34T": -22.53, "E_01A": -4187.49, "E_02T": -4294.38, "E_33A": -4185.61, "E_34T": -4295.99, "r+_01A33A": -4.17, "r-_02T34T": -2.85, "t_02T03T": -7.92, "h_03T32A": -12.16, "t_32A33A": -43.27, "E_03T": -4294.09, "E_32A": -4187.82, "r+_02T32A": 0.73, "r-_03T33A": -5.56, "t_03T04A": 24.11, "h_04A31T": 12.19, "t_31T32A": -23.86, "E_04A": -4188.25, "E_31T": -4293.36, "r+_03T31T": -0.11, "r-_04A32A": 65.12, "t_04A05A": -44.41, "h_05A30T": -12.17, "t_30T31T": -7.15, "E_05A": -4186.87, "E_30T": -4292.1, "r+_04A30T": -0.73, "r-_05A31T": 5.54, "t_05A06G": 38.48, "h_06G29C": 1.27, "t_29C30T": 27.17, "E_06G": -4117.42, "E_29C": -4421.11, "r+_05A29C": -0.02, "r-_06G30T": 4.15, "t_06G07C": 47.55, "h_07C28G": -1.06, "t_28G29C": -31.28, "E_07C": -4419.92, "E_28G": -4115.03, "r+_06G28G": 2.46, "r-_07C29C": -0.91, "t_07C08C": -60.87, "h_08C27G": 1.24, "t_27G28G": 20.09, "E_08C": -4420.76, "E_27G": -4113.86, "r+_07C27G": -0.07, "r-_08C28G": -2.57, "t_08C09G": 29.01, "h_09G26C": -1.15, "t_26C27G": -31.42, "E_09G": -4114.58, "E_26C": -4423.24, "r+_08C26C": 0.03, "r-_09G27G": -30.76, "t_09G10G": 16.68, "h_10G25C": 1.15, "t_25C26C": -59.95, "E_10G": -4116.31, "E_25C": -4421.21, "r+_09G25C": 0.08, "r-_10G26C": 2.56, "t_10G11T": 26.27, "h_11T24A": 12.14, "t_24A25C": -5.01, "E_11T": -4294.27, "E_24A": -4188.18, "r+_10G24A": -3.42, "r-_11T25C": 1.17, "t_11T12C": -20.67, "h_12C23G": 1.29, "t_23G24A": -7.83, "E_12C": -4425.69, "E_23G": -4116.33, "r+_11T23G": -0.59, "r-_12C24A": 0.92, "t_12C13T": -27.39, "h_13T22A": 12.13, "t_22A23G": 39.81, "E_13T": -4295.18, "E_22A": -4185.78, "r+_12C22A": -0.02, "r-_13T23G": -4.45, "t_13T14G": -24.65, "h_14G21C": 1.19, "t_21C22A": -12.17, "E_14G": -4116.29, "E_21C": -4423.77, "r+_13T21C": 0.01, "r-_14G22A": 43.7, "t_14G15A": 6.87, "h_15A20T": 12.13, "t_20T21C": 21.45, "E_15A": -4187.0, "E_20T": -4294.34, "r+_14G20T": 0.64, "r-_15A21C": -0.99, "t_15A16C": -4.5, "h_16C19G": 1.12, "t_19G20T": 26.24, "E_16C": -4428.59, "E_19G": -4116.11, "r+_15A19G": -3.55, "r-_16C20T": 1.16, "t_16C17A": -11.88, "h_17A18T": -12.2, "t_18T19G": 24.46, "E_17A": -4187.71, "E_18T": -4294.32, "r+_16C18T": -0.01, "r-_17A19G": 49.98}, "metadata": {"source": "uni_dimer_seq", "particle": "electron", "tb_model_name": "ELM", "unit": "meV", "notes": "Geometries from Biovia"}}
1 change: 1 addition & 0 deletions qDNA/data/raw/tb_params/uni_dimer_seq_hole_ELM.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data": {"t_01A02T": 354.8, "h_01A34T": 28.62, "h_02T33A": 28.54, "t_33A34T": 351.84, "E_01A": -8507.82, "E_02T": -9139.1, "E_33A": -8507.05, "E_34T": -9142.61, "r+_01A33A": -20.43, "r-_02T34T": -3.75, "t_02T03T": -82.66, "h_03T32A": -28.6, "t_32A33A": -56.7, "E_03T": -9139.83, "E_32A": -8509.32, "r+_02T32A": 2.55, "r-_03T33A": -29.03, "t_03T04A": -27.37, "h_04A31T": -28.57, "t_31T32A": -26.99, "E_04A": -8509.79, "E_31T": -9140.17, "r+_03T31T": -0.31, "r-_04A32A": -222.88, "t_04A05A": 56.41, "h_05A30T": -28.53, "t_30T31T": -81.36, "E_05A": -8507.77, "E_30T": -9139.32, "r+_04A30T": 2.56, "r-_05A31T": 29.02, "t_05A06G": -12.95, "h_06G29C": 37.81, "t_29C30T": 13.36, "E_06G": -8296.84, "E_29C": -8691.99, "r+_05A29C": -4.89, "r-_06G30T": 7.36, "t_06G07C": 185.05, "h_07C28G": -37.74, "t_28G29C": -177.47, "E_07C": -8691.46, "E_28G": -8295.88, "r+_06G28G": 5.17, "r-_07C29C": -11.05, "t_07C08C": 57.86, "h_08C27G": 37.75, "t_27G28G": 47.75, "E_08C": -8690.26, "E_27G": -8296.48, "r+_07C27G": -2.14, "r-_08C28G": 22.33, "t_08C09G": -18.43, "h_09G26C": -37.84, "t_26C27G": 18.35, "E_09G": -8295.89, "E_26C": -8690.68, "r+_08C26C": -1.03, "r-_09G27G": 24.88, "t_09G10G": 47.59, "h_10G25C": 37.87, "t_25C26C": 58.06, "E_10G": -8297.33, "E_25C": -8692.35, "r+_09G25C": 2.14, "r-_10G26C": -22.18, "t_10G11T": -267.41, "h_11T24A": -28.57, "t_24A25C": 310.22, "E_11T": -9141.51, "E_24A": -8509.07, "r+_10G24A": -8.22, "r-_11T25C": 5.94, "t_11T12C": -26.39, "h_12C23G": 37.74, "t_23G24A": 14.75, "E_12C": -8692.17, "E_23G": -8296.84, "r+_11T23G": -1.13, "r-_12C24A": 62.66, "t_12C13T": -14.37, "h_13T22A": 28.51, "t_22A23G": -12.54, "E_13T": -9142.71, "E_22A": -8508.15, "r+_12C22A": -4.86, "r-_13T23G": -7.42, "t_13T14G": -18.5, "h_14G21C": -37.87, "t_21C22A": 39.16, "E_14G": -8296.31, "E_21C": -8690.4, "r+_13T21C": -0.56, "r-_14G22A": 90.02, "t_14G15A": -14.34, "h_15A20T": -28.57, "t_20T21C": -25.88, "E_15A": -8507.67, "E_20T": -9140.12, "r+_14G20T": 1.14, "r-_15A21C": 62.33, "t_15A16C": -314.15, "h_16C19G": -37.83, "t_19G20T": -266.95, "E_16C": -8691.53, "E_19G": -8296.86, "r+_15A19G": -8.25, "r-_16C20T": -5.95, "t_16C17A": -39.45, "h_17A18T": -28.59, "t_18T19G": -18.12, "E_17A": -8507.22, "E_18T": -9139.51, "r+_16C18T": -0.57, "r-_17A19G": -90.34}, "metadata": {"source": "uni_dimer_seq", "particle": "hole", "tb_model_name": "ELM", "unit": "meV", "notes": "Geometries from Biovia"}}
2 changes: 1 addition & 1 deletion qDNA/dynamics/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __init__(self, tb_ham, lindblad_diss, **me_kwargs):
self.init_matrix = self.get_init_matrix()

# set options for the solver
self.options = q.Options(method=self.me_kwargs.get("solver_method"))
self.options = None

# empty lists to store results
self.reset()
Expand Down
16 changes: 12 additions & 4 deletions qDNA/environment/lindblad.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import numpy as np
import qutip as q

from ..tools import DEFAULTS, UNITS, DNA_BASES, check_diss_kwargs
from ..tools import DEFAULTS, UNITS, check_diss_kwargs
from ..utils import get_conversion
from ..hamiltonian import TB_Ham, add_groundstate

Expand Down Expand Up @@ -132,11 +132,14 @@ def __init__(self, tb_ham, **diss_kwargs):
# Relaxation
self.uniform_relaxation = self.diss_kwargs.get("uniform_relaxation")
if self.uniform_relaxation:
DNA_SITES = DNA_BASES + ["B"]
relax_rate = self.diss_kwargs["relax_rate"]
self.relax_rates = dict(zip(DNA_SITES, [relax_rate] * len(DNA_SITES)))
tb_sites = tb_ham.tb_sites_flattened
self.relax_rates = dict(zip(tb_sites, [relax_rate] * len(tb_sites)))
else:
self.relax_rates = self.diss_kwargs.get("relax_rates")
assert set(self.relax_rates.keys()) == set(
tb_ham.tb_sites_flattened
), "relax_rates must have the same keys as the tight-binding sites"

# Relaxation operators
self.relax_ops = self._get_relax_ops()
Expand Down Expand Up @@ -229,8 +232,13 @@ def _get_relax_ops(self):
list
A list of relaxation operators, each scaled by the square root of the corresponding relaxation rate.
"""
if not self.tb_ham.relaxation:
return []

return get_relax_ops(self.relax_rates, self.tb_ham)
tb_basis = self.tb_ham.tb_basis
tb_basis_sites_dict = self.tb_ham.tb_basis_sites_dict

return get_relax_ops(tb_basis, tb_basis_sites_dict, self.relax_rates)

def _get_deph_ops(self):
"""
Expand Down
13 changes: 6 additions & 7 deletions qDNA/environment/relax_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_relax_op(tb_basis, tb_site):
return q.Qobj(relax_op)


def get_relax_ops(relax_rates, tb_ham):
def get_relax_ops(tb_basis, tb_basis_sites_dict, relax_rates):
"""
Generate relaxation operators based on the provided relaxation rates and tight-binding Hamiltonian.
Expand All @@ -45,10 +45,9 @@ def get_relax_ops(relax_rates, tb_ham):
"""

relax_ops = []
if tb_ham.relaxation:
for tb_site in tb_ham.tb_basis:
relax_rate = relax_rates[tb_ham.tb_basis_sites_dict[tb_site]]
if relax_rate != 0:
relax_op = get_relax_op(tb_ham.tb_basis, tb_site)
relax_ops.append(np.sqrt(relax_rate) * relax_op)
for tb_site in tb_basis:
relax_rate = relax_rates[tb_basis_sites_dict[tb_site]]
if relax_rate != 0:
relax_op = get_relax_op(tb_basis, tb_site)
relax_ops.append(np.sqrt(relax_rate) * relax_op)
return relax_ops
2 changes: 1 addition & 1 deletion qDNA/evaluation/dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def calc_dipole_moment_dict(tb_model_name, filename, directory, num_cpu=None):
save_json(
dipole_dict,
kwargs,
"dipole_" + filename,
"dipole_moment_" + filename,
directory,
)
return dipole_moment_dict
10 changes: 8 additions & 2 deletions qDNA/evaluation/eq_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ..utils import get_conversion
from ..model import global_to_local, local_to_global
from ..hamiltonian import delete_groundstate

__all__ = ["get_therm_eq_state", "get_deph_eq_state"]

Expand Down Expand Up @@ -78,11 +79,16 @@ def get_deph_eq_state(me_solver):
# Local dephasing
if me_solver.lindblad_diss.loc_deph_rate:
# maximally mixed state
return np.eye(me_solver.tb_ham.matrix_dim) / me_solver.tb_ham.matrix_dim
dim = me_solver.tb_ham.matrix_dim
if me_solver.tb_ham.relaxation:
dim -= 1
return np.eye(dim) / dim

# Global dephasing
if me_solver.lindblad_diss.glob_deph_rate:
loc_init_matrix = me_solver.init_matrix.full()
loc_init_matrix = me_solver.init_matrix.full().real
if me_solver.tb_ham.relaxation:
loc_init_matrix = delete_groundstate(loc_init_matrix)
_, eigs = me_solver.tb_ham.get_eigensystem()
glob_init_matrix = local_to_global(loc_init_matrix, eigs)

Expand Down
2 changes: 1 addition & 1 deletion qDNA/gui/plotting_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

from ..plotting import plot_pop, plot_pops, plot_coh, plot_fourier
from ..visualization import plot_pop, plot_pops, plot_coh, plot_fourier
from ..tools import save_figure

# -----------------------------------------------------------------------------------------------------
Expand Down
5 changes: 0 additions & 5 deletions qDNA/gui/qdna_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,3 @@ def enable_plotting_frame(self):
self.initial_frame.change_state("disabled")
self.options_frame.change_state("disabled")
self.plot_options_frame.change_state("normal")


if __name__ == "__main__":
app = qDNA_app()
app.mainloop()
1 change: 1 addition & 0 deletions qDNA/hamiltonian/tb_ham.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def __init__(self, dna_seq, **ham_kwargs):
self._relaxation = self.ham_kwargs.get("relaxation")
self.eh_basis = get_eh_basis(self.tb_model.tb_dims)
self._nn_cutoff = self.ham_kwargs.get("nn_cutoff")

self.matrix = self.get_matrix()
self.matrix_dim = self.matrix.shape[0]
self.backbone = True if self.tb_model.num_strands in (3, 4) else False
Expand Down
4 changes: 2 additions & 2 deletions qDNA/hamiltonian/tb_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def tb_ham_1P(
tb_str = f"E_{tb_basis_sites_dict[old_state]}"
else:
tb_str = f"{tb_str}_{tb_basis_sites_dict[old_state]}{tb_basis_sites_dict[new_state]}"
if tb_str[0] == "h" and tb_str not in tb_param_dict:
tb_str = f"{tb_str[0]}_{tb_basis_sites_dict[new_state]}{tb_basis_sites_dict[old_state]}"
if tb_str[0] in ["h", "r"] and tb_str not in tb_param_dict:
tb_str = f"{tb_str.split('_')[0]}_{tb_basis_sites_dict[new_state]}{tb_basis_sites_dict[old_state]}"

if tb_str not in tb_param_dict:
raise ValueError(
Expand Down
8 changes: 3 additions & 5 deletions qDNA/hamiltonian/tb_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ def save_tb_params(
Parameters
----------
tb_param_dict : dict
tb_params : dict
Dictionary containing the tight-binding parameters.
info_dict : dict
metadata : dict
Dictionary with metadata, e.g., `source`, `particle`, and `tb_model_name`.
directory : str, optional
Directory to save the file, by default `data/raw/tb_params`.
notes : str, optional
Additional notes to include in the info_dict, by default None.
Examples
--------
Expand All @@ -58,7 +56,7 @@ def load_tb_params(
Parameters
----------
info_dict : dict
metadata : dict
Dictionary with metadata, e.g., `source`, `particle`, and `tb_model_name`.
directory : str, optional
Directory to load the file from, by default `data/raw/tb_params`.
Expand Down
29 changes: 23 additions & 6 deletions qDNA/lcao/save_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def convert_pdb_to_xyz(filepath_pdb):
elements = []
coordinates = []
current_base = None
xyz_files = {}

current_chain = ""
current_base_number = 0

# Read the PDB file
with open(filepath_pdb, "r") as file:
Expand All @@ -90,11 +92,26 @@ def convert_pdb_to_xyz(filepath_pdb):
z = float(line[46:54].strip()) # Extract Z coordinate

# Parse base identifier
residue_name = line[17:20].strip()
residue_sequence_number = line[22:26].strip()
base_identifier = (
str(residue_sequence_number).zfill(2) + residue_name[1]
)
base_identifier = line[17:20].strip()
chain_identifier = line[21].strip()
base_number = int(line[22:26].strip())

chain_changes = current_chain != chain_identifier
base_changes = current_base_number != base_number

# checks if the base counter starts from one if the chain changes
if chain_changes:
lower_strand = True
num_bases_per_strand = current_base_number
start_from_one = bool(base_number == 1)

if base_changes and lower_strand and start_from_one:
base_number += num_bases_per_strand

current_chain = chain_identifier
current_base_number = base_number

base_identifier = str(base_number).zfill(2) + base_identifier[1]

# If base changes, write the previous base to a new .xyz file
if current_base is not None and base_identifier != current_base:
Expand Down
7 changes: 5 additions & 2 deletions qDNA/lcao/slater_koster.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ def calc_orbital_overlap(orbital1, orbital2, connection):

vector = np.array(orbital2.coordinates) - np.array(orbital1.coordinates)
distance = np.linalg.norm(vector)
if distance != 0:
vector_norm = vector / distance

if distance == 0:
return 0

vector_norm = vector / distance

orbital_types = [orbital1.orbital_type, orbital2.orbital_type]

Expand Down
7 changes: 0 additions & 7 deletions qDNA/tools/check_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,6 @@ def check_diss_kwargs(**diss_kwargs):
assert isinstance(kwargs["relax_rates"], dict), f"relax_rates must be of form dict"

# check values
DNA_SITES = CONFIG["DNA_BASES"] + ["B"]
assert all(
[
key in DNA_SITES and isinstance(value, (int, float))
for key, value in kwargs["relax_rates"].items()
]
)
assert (
kwargs["spectral_density"] in CONFIG["SPECTRAL_DENSITIES"]
), f"spectral_density must be in {CONFIG['SPECTRAL_DENSITIES']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"axes.grid": True, # Always show grid
"grid.linestyle": "--", # Grid line style
"grid.alpha": 0.7, # Grid transparency
"axes.titlesize": 18, # Font size for title
"axes.labelsize": 15, # Font size for axis labels
"legend.fontsize": 12, # Font size for legend
"xtick.labelsize": 12, # Font size for x-tick labels
Expand Down
File renamed without changes.
Loading

0 comments on commit 4dedf6b

Please sign in to comment.