From 9c80612a38ff0badfed39ce62a030a90c6c52b60 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 3 Jul 2024 10:16:56 -0400 Subject: [PATCH 1/3] add comput_u func --- moha/rauk/PariserParr.py | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/moha/rauk/PariserParr.py b/moha/rauk/PariserParr.py index e157b5a..effb15a 100644 --- a/moha/rauk/PariserParr.py +++ b/moha/rauk/PariserParr.py @@ -291,3 +291,56 @@ def calculate_gamma(Uxy_bar, Rxy): # This is just a placeholder formula gamma = Uxy_bar / (Uxy_bar * Rxy + np.exp(-1 / 2 * Uxy_bar**2 * Rxy ** 2)) return gamma + +def compute_u(connectivity, atom_dictionary, affinity_dictionary): + r""" + Calculate the onsite potential energy (U) for each site. + + Parameters + ---------- + connectivity (list of tuples): Each tuple contains indices of two sites + (atom1, atom2) and the distance between them. + atom_dictionary (dict): Dictionary mapping atom types to their + ionization energies. + affinity_dictionary (dict): Dictionary mapping atom types to their + electron affinities. + + Returns + ---------- + tuple: Contains two elements: + 1. List of float: Onsite potential energies calculated + for each site based on their ionization energy + and electron affinity. + 2. List of float: Distances corresponding to each + connectivity tuple. + """ + if atom_dictionary is None: + atom_dictionary = {} + hx_dictionary_path = Path(__file__).parent / "hx_dictionary.json" + hx_dictionary = json.load(open(hx_dictionary_path, "rb")) + alpha_c = -0.414 # Value for sp2 orbital of Carbon atom. + beta_c = -0.0533 # Value for sp2 orbitals of Carbon atom. + for key, value in hx_dictionary.items(): + hx_value = value * abs(beta_c) + atom_dictionary[key] = alpha_c + hx_value + + if affinity_dictionary is None: + affinity_path = Path(__file__).parent / "affinity.json" + affinity_dictionary = json.load(open(affinity_path, "rb")) + + u_onsite = [] + Rxy_list = [] + + for tpl in connectivity: + atom1, atom2, dist = tpl[0], tpl[1], tpl[2] + atom1_name, _ = get_atom_type(atom1) + atom2_name, _ = get_atom_type(atom2) + + ionization = atom_dictionary[atom1_name] + affinity = affinity_dictionary[atom1_name] + U_x = ionization - affinity + + u_onsite.append(U_x) + Rxy_list.append(dist) + + return u_onsite, Rxy_list From 1aeaf3098f255711f2bcbe77f16dae0bd90b0a62 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 3 Jul 2024 10:20:35 -0400 Subject: [PATCH 2/3] fix imports --- moha/hamiltonians.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moha/hamiltonians.py b/moha/hamiltonians.py index f29fa28..24f447e 100644 --- a/moha/hamiltonians.py +++ b/moha/hamiltonians.py @@ -12,7 +12,7 @@ from typing import Union from moha.rauk.rauk import assign_rauk_parameters -from moha.rauk.PariserParr import compute_overlap +from moha.rauk.PariserParr import compute_overlap, compute_u, compute_gamma import warnings warnings.simplefilter('ignore', From f6123cfd1a87cf53485249af46bdb25427f52635 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 3 Jul 2024 10:25:27 -0400 Subject: [PATCH 3/3] change function name --- moha/rauk/PariserParr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moha/rauk/PariserParr.py b/moha/rauk/PariserParr.py index effb15a..373bdd0 100644 --- a/moha/rauk/PariserParr.py +++ b/moha/rauk/PariserParr.py @@ -274,7 +274,7 @@ def compute_overlap( return one_body -def calculate_gamma(Uxy_bar, Rxy): +def compute_gamma(Uxy_bar, Rxy): """ Calculate the gamma value based on Uxy and Rxy.