def __init__(self, path_x, path_y, path_z): self.dat_x = SpinIO.load_pickle(os.path.join(path_x, 'TB2J_results'), 'TB2J.pickle') self.dat_y = SpinIO.load_pickle(os.path.join(path_y, 'TB2J_results'), 'TB2J.pickle') self.dat_z = SpinIO.load_pickle(os.path.join(path_z, 'TB2J_results'), 'TB2J.pickle') self.dat = copy.copy(self.dat_z)
def __init__(self, path_x, path_y, path_z, method='structure'): assert (method in ['structure', 'spin']) self.dat_x = SpinIO.load_pickle(os.path.join(path_x, 'TB2J_results'), 'TB2J.pickle') self.dat_y = SpinIO.load_pickle(os.path.join(path_y, 'TB2J_results'), 'TB2J.pickle') self.dat_z = SpinIO.load_pickle(os.path.join(path_z, 'TB2J_results'), 'TB2J.pickle') self.dat = copy.copy(self.dat_z) self.paths = [path_x, path_y, path_z] self.method = method
def read_pickle(path): p1 = os.path.join(path, 'TB2J_results', 'TB2J.pickle') p2 = os.path.join(path, 'TB2J.pickle') if os.path.exists(p1) and os.path.exists(p2): print(f" WARNING!: Both file {p1} and {p2} exist. Use default {p1}.") if os.path.exists(p1): ret = SpinIO.load_pickle(os.path.join(path, 'TB2J_results')) elif os.path.exists(p2): ret = SpinIO.load_pickle(path) else: raise FileNotFoundError(f"Cannot find either file {p1} or {p2}") return ret
def write_output(self, path='TB2J_results'): self._prepare_index_spin() output = SpinIO( atoms=self.atoms, charges=self.charges, spinat=self.spinat, index_spin=self.index_spin, colinear=True, distance_dict=self.distance_dict, exchange_Jdict=self.exchange_Jdict, dmi_ddict=None, NJT_Jdict=None, NJT_ddict=None, biquadratic_Jdict=self.B, ) output.write_all(path=path)
def write_output(self, path='TB2J_results'): self._prepare_index_spin() output = SpinIO( atoms=self.atoms, charges=self.charges, spinat=self.spinat, index_spin=self.index_spin, colinear=False, distance_dict=self.distance_dict, exchange_Jdict=self.exchange_Jdict, dmi_ddict=self.DMI, NJT_Jdict=self.Jdict_NJT, NJT_ddict=self.Ddict_NJT, Jani_dict=self.Jani, biquadratic_Jdict=self.B, debug_dict=self.debug_dict, description=self.description, ) output.write_all(path=path)
def write_output(self, path='TB2J_results'): self._prepare_index_spin() output = SpinIO( atoms=self.atoms, charges=self.charges, spinat=self.spinat, index_spin=self.index_spin, colinear=True, orbital_names=self.orbital_names, distance_dict=self.distance_dict, exchange_Jdict=self.exchange_Jdict, Jiso_orb=self.Jiso_orb, dmi_ddict=None, NJT_Jdict=None, NJT_ddict=None, Jani_dict=None, biquadratic_Jdict=None, description=self.description, ) output.write_all(path=path)
def __init__(self, inpath, metals, ligands, outpath): fname = os.path.join(inpath, 'TB2J.pickle') with open(fname, 'rb') as myfile: self.obj = pickle.load(myfile) self.atoms = self.obj['atoms'] self.magnetic_elements = metals self.iM = [] self.iL = [] for i, sym in enumerate(self.atoms.get_chemical_symbols()): if sym in self.magnetic_elements: self.iM.append(i) elif sym in ligands: self.iL.append(i) self.ind_mag_atoms = self.iM self.nM = len(self.iM) self.nL = len(self.iL) self.nsite = self.nM + self.nL atoms = self.obj['atoms'] index_spin = self.obj['index_spin'] ind_atoms = self.obj['ind_atoms'] Jdict = self.obj['exchange_Jdict'] nspin = len(index_spin) JR = defaultdict(lambda: np.zeros((nspin, nspin), dtype=float)) for key, val in Jdict.items(): R, i, j = key JR[R][i, j] = val Rlist = list(JR.keys()) # build matrix form of JR nR = len(Rlist) JR2 = np.zeros((nR, nspin, nspin), dtype=float) for i, (key, val) in enumerate(JR.items()): JR2[i] = val # sum rule iR0 = np.argmin(np.linalg.norm(Rlist, axis=1)) for i in range(self.nsite): sum_JRi = np.sum(np.sum(JR2, axis=0)[i]) JR2[iR0][i, i] -= sum_JRi d = JDownfolder(JR2, Rlist, iM=self.iM, iL=self.iL, qmesh=[7, 7, 7]) Jd = d.get_JR() self.Rlist = Rlist self.Rcut = None self._prepare_distance() self._prepare_index_spin() self.Jdict = {} for iR, R in enumerate(d.Rlist): for i, ispin in enumerate(self.index_spin): for j, jspin in enumerate(self.index_spin): if ispin >= 0 and jspin >= 0: self.Jdict[(tuple(R), i, j)] = Jd[iR, i, j] io = SpinIO(atoms=atoms, spinat=self.obj['spinat'], charges=self.obj['charges'], index_spin=self.index_spin, colinear=True, distance_dict=self.distance_dict, exchange_Jdict=self.Jdict) io.write_all(outpath)