Skip to content

Commit

Permalink
fix undefined var names
Browse files Browse the repository at this point in the history
  • Loading branch information
mailhexu committed Oct 22, 2023
1 parent de0a0cf commit 7936fd8
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
Expand Down
11 changes: 10 additions & 1 deletion TB2J/Oiju_epc.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,21 @@ def __init__(
# prepare dDelta
self.calc_dDelta()

self._kmap = None

def prepare_epc_wann(self):
"""
prepare EPC in electron wannier function representation
"""
self.EPCmat_wann_up = self.EPCmat_up.to_wann(self.Umat_up)
self.EPCmat_wann_dn = self.EPCmat_dn.to_wann(self.Umat_dn)

def get_iq(self, q):
if self._kmap is None:
self._kmap = {}
for i, q in enumerate(self.klist):
self._kmap[tuple(q)] = i

def calc_dDelta(self):
"""
calculate $\delta \Delta$.
Expand All @@ -77,7 +85,8 @@ def calc_dDelta(self):
"""
self.dDelta = np.zeros((self.nphon, self.nwann, self.nwann))
# iq, iv, iR
iq0 = iqlist[(0, 0, 0)]
# iq0 = self.iqlist[(0, 0, 0)]
iq0 = self.get_iq((0, 0, 0))

for iv in range(self.nphon):
for ik, k in enumerate(self.klist):
Expand Down
22 changes: 11 additions & 11 deletions TB2J/exchangeCL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ def get_A_ijR(self, Gup, Gdn, iatom, jatom):
"ij, ji-> ij", np.matmul(Deltai, Gij_up), np.matmul(Deltaj, Gji_dn)
)

if self.biquadratic:
A = np.einsum(
"ij, ji-> ij",
np.matmul(Deltai, Gij_up),
np.matmul(Deltaj, Gji_up),
)
C = np.einsum(
"ij, ji-> ij",
np.matmul(Deltai, Gij_down),
np.matmul(Deltaj, Gji_down),
)
# if self.biquadratic:
# A = np.einsum(
# "ij, ji-> ij",
# np.matmul(Deltai, Gij_up),
# np.matmul(Deltaj, Gji_up),
# )
# C = np.einsum(
# "ij, ji-> ij",
# np.matmul(Deltai, Gij_down),
# np.matmul(Deltaj, Gji_down),
# )
tmp = np.sum(t)
self.Jorb_list[(R, iatom, jatom)].append(t / (4.0 * np.pi))
self.JJ_list[(R, iatom, jatom)].append(tmp / (4.0 * np.pi))
Expand Down
26 changes: 13 additions & 13 deletions TB2J/exchange_pert.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ def calculate_all(self):
"""
print("Green's function Calculation started.")

widgets = [
" [",
progressbar.Timer(),
"] ",
progressbar.Bar(),
" (",
progressbar.ETA(),
") ",
]
bar = progressbar.ProgressBar(maxval=self.contour.npoints, widgets=widgets)
bar.start()
# widgets = [
# " [",
# progressbar.Timer(),
# "] ",
# progressbar.Bar(),
# " (",
# progressbar.ETA(),
# ") ",
# ]
# bar = progressbar.ProgressBar(maxval=self.contour.npoints, widgets=widgets)
# bar.start()
for ie in range(self.contour.npoints):
bar.update(ie)
# bar.update(ie)
e = self.contour.elist[ie]
de = self.contour.de[ie]
GR, dGdx = self.G.get_GR_and_dGRdx(self.Rlist, energy=e, dHdx=self.dHdx)
Expand All @@ -203,7 +203,7 @@ def calculate_all(self):
self.A_to_Jtensor()
if self.calc_NJt:
self.calculate_DMI_NJT()
bar.finish()
# bar.finish()

def write_output(self, path="TB2J_results"):
self._prepare_index_spin()
Expand Down
4 changes: 2 additions & 2 deletions TB2J/exchange_qspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def get_all_A(self):
# Kq= Gk_up[ik] @ self.Delta @ Gk_dn[ikq]
# for ik, ikq in enumerate(range(self.nkpts)):
Guk = Gk_up[ik, :, :]
# Gdk = Gk_dn[ik, :, :]
# Gukq = Gk_up[ikq, :, :]
Gdk = Gk_dn[ik, :, :]
Gukq = Gk_up[ikq, :, :]
Gdkq = Gk_dn[ikq, :, :]
for i, iatom in enumerate(self.ind_mag_atoms):
Deltai = self.get_Delta(iatom)
Expand Down
4 changes: 2 additions & 2 deletions TB2J/gpaw_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, atoms=None, calc=None, gpw_fname=None):
# return eigh(self.hamk(k), self.S(k))

def get_kpts(self):
return calc.get_ibz_k_points()
return self.calc.get_ibz_k_points()

def HS_and_eigen(self, kpts=None, convention=2):
if kpts is not None:
Expand Down Expand Up @@ -135,7 +135,7 @@ def __init__(self, calc=None, atoms=None, gpw_fname=None, pickle_fname=None):
self.H_NMM, self.S_NMM = tb.h_and_s()
self.Rlist = tb.R_cN.T
else:
with open(fname, "rb") as myfile:
with open(gpw_fname, "rb") as myfile:
self.H_NMM, self.S_NMM, self.Rlist = pickle.load(myfile)
self.nR, self.nbasis, _ = self.H_NMM.shape
self.positions = np.zeros((self.nbasis, 3))
Expand Down
12 changes: 12 additions & 0 deletions TB2J/mathutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
from scipy.linalg import inv, eigh


def Lowdin(S):
"""
Calculate S^(-1/2).
Which is used in lowind's symmetric orthonormalization.
psi_prime = S^(-1/2) psi
"""
eigval, eigvec = eigh(S)
return eigvec @ np.diag(np.sqrt(1.0 / eigval)) @ (eigvec.T.conj())
4 changes: 4 additions & 0 deletions TB2J/sisl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import defaultdict
from scipy.linalg import eigh
from TB2J.myTB import AbstractTB
from TB2J.mathutils import Lowdin


class SislWrapper(AbstractTB):
Expand Down Expand Up @@ -199,6 +200,9 @@ def HS_and_eigen(self, kpts, convention=2):
shape=(nkpts, self.nbasis, self.nbasis),
dtype=complex,
)
Hk = self.Hk(k, convention=convention)
Sk = self.Sk(k, convention=convention)
evalue, evec = eigh(Hk, Sk)
self.H[ik] = Hk
self.S[ik] = Sk
self.evals[ik] = evalue
Expand Down
2 changes: 1 addition & 1 deletion TB2J/spinham/supercell.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def map_to_primitive(atoms, primitive_atoms, offset=(0, 0, 0)):
def test():
sc_mat = np.diag([1, 1, 2])
# sc_mat[0, 1] = 2
spm = supercell_maker(sc_matrix=sc_mat)
spm = SupercellMaker(sc_matrix=sc_mat)
print(spm.sc_cell([1, 1, 1]))
print(spm.sc_pos([[0.5, 1, 1]]))
print(spm.sc_trans_invariant(["Fe"]))
Expand Down
1 change: 1 addition & 0 deletions TB2J/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import OrderedDict, defaultdict
import copy
import numpy as np
from pathlib import Path

Expand Down

0 comments on commit 7936fd8

Please sign in to comment.