def gen_exchange_gpaw(gpw_fname, magnetic_elements=[], kmesh=[3, 3, 3], emin=-12.0, emax=0.0, nz=50, exclude_orbs=[], Rcut=None, description=''): print("Reading from GPAW data and calculate electronic structure.") model = GPAWWrapper(gpw_fname=gpw_fname) efermi = model.calc.get_fermi_level() print(f"Fermi Energy: {efermi}") poses = np.vstack([model.positions, model.positions]) basis, _ = auto_assign_basis_name(poses, model.atoms) if model.calc.get_spin_polarized(): print("Starting to calculate exchange.") exchange = ExchangeNCL(tbmodels=model, atoms=model.atoms, efermi=efermi, basis=basis, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, exclude_orbs=exclude_orbs, Rcut=Rcut, description=description) exchange.run() print("\n") print( "All calculation finsihed. The results are in TB2J_results directory." )
def gen_exchange_siesta(fdf_fname, magnetic_elements=[], kmesh=[5, 5, 5], emin=-12.0, emax=0.0, nz=100, exclude_orbs=[], Rcut=None, ne=None, np=1, use_cache=False, output_path='TB2J_results', description=''): try: import sisl except: raise ImportError( "sisl cannot be imported. Please install sisl first.") from packaging import version if version.parse(sisl.__version__) <= version.parse("0.10.0"): raise ImportError( f"sisl version is {sisl.__version__}, but should be larger than 0.10.0." ) fdf = sisl.get_sile(fdf_fname) H = fdf.read_hamiltonian() if H.spin.is_colinear: print("Reading Siesta hamiltonian: colinear spin.") tbmodel_up = SislWrapper(H, spin=0) tbmodel_dn = SislWrapper(H, spin=1) basis = dict(zip(tbmodel_up.orbs, list(range(tbmodel_up.norb)))) print("Starting to calculate exchange.") description = f""" Input from collinear Siesta data. working directory: {os.getcwd()} fdf_fname: {fdf_fname}. \n""" exchange = ExchangeCL2( tbmodels=(tbmodel_up, tbmodel_dn), atoms=tbmodel_up.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, #height=height, #nz1=nz1, #nz2=nz2, #nz3=nz3, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, np=np, use_cache=use_cache, description=description) exchange.run(path=output_path) print("\n") print( f"All calculation finsihed. The results are in {output_path} directory." ) elif H.spin.is_colinear: print( "Reading Siesta hamiltonian: colinear spin. Treat as non-colinear") tbmodel = SislWrapper(H, spin='merge') basis = dict(zip(tbmodel.orbs, list(range(tbmodel.nbasis)))) print("Starting to calculate exchange.") description = f""" Input from collinear Siesta data. working directory: {os.getcwd()} fdf_fname: {fdf_fname}. \n""" exchange = ExchangeNCL(tbmodels=tbmodel, atoms=tbmodel.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, np=np, use_cache=use_cache, description=description) exchange.run(path=output_path) print("\n") print( f"All calculation finsihed. The results are in {output_path} directory." ) elif H.spin.is_spinorbit: print("Reading Siesta hamiltonian: non-colinear spin.") tbmodel = SislWrapper(H, spin=None) basis = dict(zip(tbmodel.orbs, list(range(tbmodel.nbasis)))) print("Starting to calculate exchange.") description = f""" Input from non-collinear Siesta data. working directory: {os.getcwd()} fdf_fname: {fdf_fname}. Warning: The DMI component parallel to the spin orientation, the Jani which has the component of that orientation should be disregarded e.g. if the spins are along z, the xz, yz, zz, zx, zy components and the z component of DMI. If you need these component, try to do three calculations with spin along x, y, z, or use structure with z rotated to x, y and z. And then use TB2J_merge.py to get the full set of parameters. \n""" exchange = ExchangeNCL(tbmodels=tbmodel, atoms=tbmodel.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, np=np, use_cache=use_cache, description=description) exchange.run(path=output_path) print("\n") print( f"All calculation finsihed. The results are in {output_path} directory." )
def gen_exchange_siesta( fdf_fname, magnetic_elements=[], kmesh=[4, 4, 4], emin=-12.0, emax=0.0, nz=50, #height=0.2, #nz1=50, #nz2=200, #nz3=50, exclude_orbs=[], Rcut=None, ne=None, description=''): try: import sisl except: raise ImportError( "sisl cannot be imported. Please install sisl first.") fdf = sisl.get_sile(fdf_fname) H = fdf.read_hamiltonian() if H.spin.is_colinear: print("Reading Siesta hamiltonian: colinear spin.") tbmodel_up = SislWrapper(H, spin=0) tbmodel_dn = SislWrapper(H, spin=1) basis = dict(zip(tbmodel_up.orbs, list(range(tbmodel_up.norb)))) print("Starting to calculate exchange.") exchange = ExchangeCL2( tbmodels=(tbmodel_up, tbmodel_dn), atoms=tbmodel_up.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, #height=height, #nz1=nz1, #nz2=nz2, #nz3=nz3, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, description=description) exchange.run() print("\n") print( "All calculation finsihed. The results are in TB2J_results directory." ) elif H.spin.is_colinear: print( "Reading Siesta hamiltonian: colinear spin. Treat as non-colinear") tbmodel = SislWrapper(H, spin='merge') basis = dict(zip(tbmodel.orbs, list(range(tbmodel.nbasis)))) print("Starting to calculate exchange.") exchange = ExchangeNCL( tbmodels=tbmodel, atoms=tbmodel.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, #height=height, #nz1=nz1, #nz2=nz2, #nz3=nz3, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, description=description) exchange.run() print("\n") print( "All calculation finsihed. The results are in TB2J_results directory." ) elif H.spin.is_spinorbit: print("Reading Siesta hamiltonian: non-colinear spin.") tbmodel = SislWrapper(H, spin=None) basis = dict(zip(tbmodel.orbs, list(range(tbmodel.nbasis)))) print("Starting to calculate exchange.") exchange = ExchangeNCL(tbmodels=tbmodel, atoms=tbmodel.atoms, basis=basis, efermi=0.0, magnetic_elements=magnetic_elements, kmesh=kmesh, emin=emin, emax=emax, nz=nz, exclude_orbs=exclude_orbs, Rcut=Rcut, ne=ne, description=description) exchange.run() print("\n") print( "All calculation finsihed. The results are in TB2J_results directory." )