enclosed in main function and correcte d useful import

class-solution
Daniel Pozsar 3 months ago
parent 4b091373d9
commit bd3ec608c4

@ -7,17 +7,14 @@ import sisl
from mpi4py import MPI
from numpy.linalg import inv
from tqdm import tqdm
from useful import *
from src.grogu_magn.useful import *
def main():
start_time = timer() # runtime information
# runtime information
times = dict()
times["start_time"] = timer()
# this cell mimicks an input file
fdf = sisl.get_sile("./lat3_791/Fe3GeTe2.fdf")
fdf = sisl.get_sile("./Jij_for_Marci_6p45ang/CrBr.fdf") # ./lat3_791/Fe3GeTe2.fdf
# this information needs to be given at the input!!
scf_xcf_orientation = np.array([0, 0, 1]) # z
# list of reference directions for around which we calculate the derivatives
@ -30,7 +27,8 @@ def main():
dict(o=np.array([0, 0, 1]), vw=[np.array([1, 0, 0]), np.array([0, 1, 0])]),
]
# human readable definition of magnetic entities
"""
# human readable definition of magnetic entities ./lat3_791/Fe3GeTe2.fdf
magnetic_entities = [
dict(atom=3, l=2),
dict(atom=4, l=2),
@ -39,27 +37,47 @@ def main():
atom=[3, 4],
),
]
# pair information ./lat3_791/Fe3GeTe2.fdf
pairs = [
dict(ai=0, aj=1, Ruc=np.array([0, 0, 0])), # isotropic should be -82 meV
dict(
ai=0, aj=2, Ruc=np.array([0, 0, 0])
), # these should all be around -41.9 in the isotropic part
dict(ai=1, aj=2, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([-1, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([-1, 0, 0])),
] """
# pair information
# these should all be around -41.9 in the isotropic part
# isotropic should be -82 meV
# human readable definition of magnetic entities ./Jij_for_Marci_6p45ang/CrBr.fdf
magnetic_entities = [
dict(atom=0, l=2),
dict(atom=1, l=2),
dict(atom=2, l=2),
]
# pair information ./Jij_for_Marci_6p45ang/CrBr.fdf
pairs = [
dict(ai=0, aj=3, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=1, Ruc=np.array([0, 0, 0])),
dict(ai=1, aj=0, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([0, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([0, 0, 0])),
dict(ai=0, aj=1, Ruc=np.array([1, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([1, 0, 0])),
dict(ai=0, aj=1, Ruc=np.array([-1, 0, 0])),
dict(ai=0, aj=2, Ruc=np.array([-1, 0, 0])),
dict(ai=1, aj=2, Ruc=np.array([-1, 0, 0])),
dict(ai=0, aj=1, Ruc=np.array([0, 1, 0])),
dict(ai=0, aj=2, Ruc=np.array([0, 1, 0])),
dict(ai=0, aj=1, Ruc=np.array([0, 1, 0])),
dict(ai=0, aj=2, Ruc=np.array([0, 1, 0])),
]
# Brilloun zone sampling and Green function contour integral
kset = 20
kdirs = "xy"
ebot = -30
eset = 50
eset = 100
esetp = 10000
# MPI parameters
comm = MPI.COMM_WORLD
size = comm.Get_size()
@ -120,6 +138,7 @@ def main():
.astype("complex128")
)
# Reorganization of Hamiltonian and overlap matrix elements to SPIN BOX representation
U = np.vstack(
[np.kron(np.eye(NO, dtype=int), [1, 0]), np.kron(np.eye(NO, dtype=int), [0, 1])]
@ -132,22 +151,19 @@ def main():
# From now on everything is in SPIN BOX!!
hh, ss = np.array(
[
U.T
@ np.block([[h11[:, :, i], h12[:, :, i]], [h21[:, :, i], h22[:, :, i]]])
@ U
U.T @ np.block([[h11[:, :, i], h12[:, :, i]], [h21[:, :, i], h22[:, :, i]]]) @ U
for i in range(dh.lattice.nsc.prod())
]
), np.array(
[
U.T
@ np.block(
[[sov[:, :, i], sov[:, :, i] * 0], [sov[:, :, i] * 0, sov[:, :, i]]]
)
@ np.block([[sov[:, :, i], sov[:, :, i] * 0], [sov[:, :, i] * 0, sov[:, :, i]]])
@ U
for i in range(dh.lattice.nsc.prod())
]
)
# symmetrizing Hamiltonian and overlap matrix to make them hermitian
for i in range(dh.lattice.sc_off.shape[0]):
j = dh.lattice.sc_index(-dh.lattice.sc_off[i])
@ -190,9 +206,7 @@ def main():
# calculate size for Greens function generation
spin_box_shape = len(mag_ent["spin_box_indeces"])
mag_ent["energies"] = (
[]
) # we will store the second order energy derivations here
mag_ent["energies"] = [] # we will store the second order energy derivations here
mag_ent["Gii"] = [] # Greens function
mag_ent["Gii_tmp"] = [] # Greens function for parallelization
@ -222,12 +236,13 @@ def main():
pair["Gij_tmp"] = [] # Greens function for parallelization
pair["Gji_tmp"] = []
for i in ref_xcf_orientations:
# Greens functions for every quantization axis
pair["Gij"].append(
np.zeros((eset, spin_box_shape_i, spin_box_shape_j), dtype="complex128")
)
pair["Gij_tmp"].append(
np.zeros((eset, spin_box_shape_i, spin_box_shape_j), dtype="complex128")
) # Greens functions for every quantization axis
)
pair["Gji"].append(
np.zeros((eset, spin_box_shape_j, spin_box_shape_i), dtype="complex128")
)
@ -274,9 +289,10 @@ def main():
Vu2 = 1 / 8 * commutator(commutator(Tu, rot_H_XCF_uc), Tu) # equation 100
for mag_ent in magnetic_entities:
# fill up the perturbed potentials (for now) based on the on-site projections
mag_ent["Vu1"][i].append(
Vu1[:, mag_ent["spin_box_indeces"]][mag_ent["spin_box_indeces"], :]
) # fill up the perturbed potentials (for now) based on the on-site projections
)
mag_ent["Vu2"][i].append(
Vu2[:, mag_ent["spin_box_indeces"]][mag_ent["spin_box_indeces"], :]
)
@ -309,6 +325,11 @@ def main():
HK, SK = hsk(H, ss, dh.sc_off, k)
Gk = inv(SK * eran.reshape(eset, 1, 1) - HK)
# solve Greens function sequentially for the energies, because of memory bound
# Gk = np.zeros(shape=(eset, HK.shape[0], HK.shape[1]), dtype="complex128")
# for j in range(eset):
# Gk[j] = inv(SK * eran[j] - HK)
# store the Greens function slice of the magnetic entities (for now) based on the on-site projections
for mag_ent in magnetic_entities:
mag_ent["Gii_tmp"][i] += (
@ -348,9 +369,7 @@ def main():
# iterate over the first and second order local perturbations
for Vu1, Vu2 in zip(mag_ent["Vu1"][i], mag_ent["Vu2"][i]):
# The Szunyogh-Lichtenstein formula
traced = np.trace(
(Vu2 @ Gii + 0.5 * Gii @ Vu1 @ Gii), axis1=1, axis2=2
)
traced = np.trace((Vu2 @ Gii + 0.5 * Gii @ Vu1 @ Gii), axis1=1, axis2=2)
# evaluation of the contour integral
storage.append(np.trapz(-1 / np.pi * np.imag(traced * cont.we)))
@ -377,7 +396,3 @@ def main():
times["end_time"] = timer()
print_output(simulation_parameters, magnetic_entities, pairs, dh, times)
if __name__ == "__main__":
main()

Loading…
Cancel
Save