def plot_magnon(): print_license() parser = argparse.ArgumentParser( description= "TB2J_magnon: Plot magnon band structure from the TB2J magnetic interaction parameters" ) parser.add_argument("--fname", default='exchange.xml', type=str, help='exchange xml file name. default: exchange.xml') parser.add_argument( "--qpath", default=None, type=str, help= 'The names of special q-points. If not given, the path will be automatically choosen. See https://wiki.fysik.dtu.dk/ase/ase/dft/kpoints.html for the table of special kpoints and the default path.' ) parser.add_argument( "--figfname", default=None, type=str, help= 'The file name of the figure. It should be e.g. png, pdf or other types of files which could be generated by matplotlib.' ) parser.add_argument( "--Jq", action="store_true", help="To plot the eigenvalues of -J(q) instead of the magnon band", default=False) parser.add_argument("--show", action="store_true", help="whether to show magnon band structure.", default=False) args = parser.parse_args() if args.Jq: print( "Plotting the eigenvalues of -J(q). The figure is written to %s" % (args.figfname)) if args.figfname is None: args.figfname = 'Eigen_Jq.pdf' else: print( "Plotting the magnon band structure. The figure is written to %s" % (args.figfname)) if args.figfname is None: args.figfname = 'magnon_band.pdf' plot_magnon_band(fname=args.fname, knames=args.qpath, npoints=300, Jq=args.Jq, show=args.show)
def run_wann2J(): print_license() parser = argparse.ArgumentParser( description= "wann2J: Using magnetic force theorem to calculate exchange parameter J from wannier functions" ) parser.add_argument('--path', help="path to the wannier files", default='./', type=str) parser.add_argument('--posfile', help="name of the position file", default='POSCAR', type=str) parser.add_argument('--prefix_spinor', help="prefix to the spinor wannier files", default='wannier90', type=str) parser.add_argument('--prefix_up', help="prefix to the spin up wannier files", default='wannier90.up', type=str) parser.add_argument('--prefix_down', help="prefix to the spin down wannier files", default='wannier90.dn', type=str) parser.add_argument('--elements', help="elements to be considered in Heisenberg model", default=None, type=str, nargs='*') parser.add_argument( '--groupby', help= "In the spinor case, the order of the orbitals have two conventions: 1: group by spin (orb1_up, orb2_up,... orb1_down, ...), 2,group by orbital (orb1_up, orb1_down, orb2_up, ...,). Use 'spin' in the former case and 'orbital' in the latter case. The default is spin.", default='spin', type=str, ) parser.add_argument( '--rcut', help= 'cutoff of spin pair distance. The default is to calculate all commensurate R point to the k mesh.', default=None, type=float) parser.add_argument('--efermi', help='Fermi energy in eV', default=None, type=float) parser.add_argument('--kmesh', help='kmesh in the format of kx ky kz', type=int, nargs='*', default=[5, 5, 5]) parser.add_argument('--emin', help='energy minimum below efermi, default -14 eV', type=float, default=-14.0) parser.add_argument('--emax', help='energy maximum above efermi, default 0.0 eV', type=float, default=0.0) parser.add_argument( '--nz', help='number of steps for semicircle contour, default: 100', default=100, type=int) # parser.add_argument( # '--height', # help= # 'energy contour, a small number (often between 0.1 to 0.5, default 0.1)', # type=float, # default=0.1) # parser.add_argument('--nz1', # help='number of steps 1, default: 50', # default=50, # type=int) # parser.add_argument('--nz2', # help='number of steps 2, default: 200', # default=200, # type=int) # parser.add_argument('--nz3', # help='number of steps 3, default: 50', # default=50, # type=int) parser.add_argument( '--cutoff', help="The minimum of J amplitude to write, (in eV), default is 1e-5 eV", default=1e-5, type=float) parser.add_argument( '--exclude_orbs', help= "the indices of wannier functions to be excluded from magnetic site. counting start from 0", default=[], type=int, nargs='+') parser.add_argument( '--np', help='number of cpu cores to use in parallel, default: 1', default=1, type=int) parser.add_argument( '--use_cache', help= "whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False", action='store_true', default=False) parser.add_argument( "--description", help= "add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.", type=str, default="Calculated with TB2J.") parser.add_argument("--spinor", action="store_true", help="Whether to use spinor wannier function.", default=False) parser.add_argument( "--orb_decomposition", default=False, action='store_true', help="whether to do orbital decomposition in the non-collinear mode.") parser.add_argument( "--output_path", help="The path of the output directory, default is TB2J_results", type=str, default="TB2J_results") parser.add_argument( "--wannier_type", help="The type of Wannier function, either Wannier90 or banddownfolder", type=str, default="Wannier90") # parser.add_argument("--qspace", # action="store_true", # help="Whether to calculate J in qspace first and transform to real space.", # default=False) args = parser.parse_args() if args.efermi is None: print("Please input fermi energy using --efermi ") sys.exit() if args.elements is None: print("Please input the magnetic elements, e.g. --elements Fe Ni") sys.exit() gen_exchange( path=args.path, colinear=(not args.spinor), groupby=args.groupby, posfile=args.posfile, efermi=args.efermi, kmesh=args.kmesh, magnetic_elements=args.elements, Rcut=args.rcut, prefix_SOC=args.prefix_spinor, prefix_up=args.prefix_up, prefix_dn=args.prefix_down, emin=args.emin, emax=args.emax, nz=args.nz, # height=args.height, # nz1=args.nz1, # nz2=args.nz2, # nz3=args.nz3, use_cache=args.use_cache, np=args.np, description=args.description, output_path=args.output_path, exclude_orbs=args.exclude_orbs, wannier_type=args.wannier_type, # qspace=args.qspace, orb_decomposition=args.orb_decomposition)
def run_wann2J(): print_license() parser = argparse.ArgumentParser( description= "wann2J: Using magnetic force theorem to calculate exchange parameter J from wannier functions" ) parser.add_argument('--path', help="path to the wannier files", default='./', type=str) parser.add_argument('--posfile', help="name of the position file", default='POSCAR', type=str) parser.add_argument('--prefix_spinor', help="prefix to the spinor wannier files", default='wannier90', type=str) parser.add_argument('--prefix_up', help="prefix to the spin up wannier files", default='wannier90.up', type=str) parser.add_argument('--prefix_down', help="prefix to the spin down wannier files", default='wannier90.dn', type=str) parser.add_argument('--elements', help="elements to be considered in Heisenberg model", default=None, type=str, nargs='*') parser.add_argument( '--orb_order', help= "In the spinor case, the order of the orbitals have two conventions: (orb1_up, orb2_up,... orb1_down, ...), (orb1_up, orb1_down, orb2_up, ...,). Use 1 in the former case and 2 in the latter case. The default is 1.", default=1, type=int, ) parser.add_argument( '--rcut', help= 'cutoff of spin pair distance. The default is to calculate all commensurate R point to the k mesh.', default=None, type=float) parser.add_argument('--efermi', help='Fermi energy in eV', default=None, type=float) parser.add_argument('--kmesh', help='kmesh in the format of kx ky kz', type=int, nargs='*', default=[5, 5, 5]) parser.add_argument('--emin', help='energy minimum below efermi, default -14 eV', type=float, default=-14.0) parser.add_argument('--emax', help='energy maximum above efermi, default 0.0 eV', type=float, default=0.0) parser.add_argument( '--nz', help='number of steps for semicircle contour, default: 100', default=100, type=int) parser.add_argument( '--height', help= 'energy contour, a small number (often between 0.1 to 0.5, default 0.1)', type=float, default=0.1) parser.add_argument('--nz1', help='number of steps 1, default: 50', default=50, type=int) parser.add_argument('--nz2', help='number of steps 2, default: 200', default=200, type=int) parser.add_argument('--nz3', help='number of steps 3, default: 50', default=50, type=int) parser.add_argument( '--cutoff', help="The minimum of J amplitude to write, (in eV), default is 1e-5 eV", default=1e-5, type=float) parser.add_argument( '--exclude_orbs', help= "the indices of wannier functions to be excluded from magnetic site. counting start from 0", default=[], type=int, nargs='+') parser.add_argument( "--description", help= "add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.", type=str, default="Calculated with TB2J.") parser.add_argument("--spinor", action="store_true", help="Whether to use spinor wannier function.", default=False) args = parser.parse_args() if args.efermi is None: print("Please input fermi energy using --efermi ") sys.exit() if args.elements is None: print("Please input the magnetic elements, e.g. --elements Fe Ni") sys.exit() if args.orb_order not in (1, 2): print("orb_order should be either 1 or 2.") sys.exit() gen_exchange(path=args.path, colinear=(not args.spinor), orb_order=args.orb_order, posfile=args.posfile, efermi=args.efermi, kmesh=args.kmesh, magnetic_elements=args.elements, Rcut=args.rcut, prefix_SOC=args.prefix_spinor, prefix_up=args.prefix_up, prefix_dn=args.prefix_down, emin=args.emin, emax=args.emax, nz=args.nz, height=args.height, nz1=args.nz1, nz2=args.nz2, nz3=args.nz3, description=args.description, exclude_orbs=args.exclude_orbs)
def run_siesta2J(): print_license() parser = argparse.ArgumentParser( description= "siesta2J: Using magnetic force theorem to calculate exchange parameter J from siesta Hamiltonian" ) parser.add_argument('--fdf_fname', help="path of the input fdf file", default='./', type=str) parser.add_argument('--elements', help="elements to be considered in Heisenberg model", default=None, type=str, nargs='*') parser.add_argument( '--rcut', help='range of R. The default is all the commesurate R to the kmesh', default=None, type=float) parser.add_argument('--efermi', help='Fermi energy in eV', default=None, type=float) parser.add_argument( '--kmesh', help= 'kmesh in the format of kx ky kz. Monkhorst pack. If all the numbers are odd, it is Gamma cenetered. (strongly recommended)', type=int, nargs='*', default=[5, 5, 5]) parser.add_argument('--emin', help='energy minimum below efermi, default -14 eV', type=float, default=-14.0) parser.add_argument('--emax', help='energy maximum above efermi, default 0.0 eV', type=float, default=0.05) #parser.add_argument( # '--height', # help= # 'energy contour, a small number (often between 0.1 to 0.5, default 0.2)', # type=float, # default=0.1) parser.add_argument('--nz', help='number of integration steps, default: 50', default=50, type=int) #parser.add_argument( # '--nz2', help='number of steps 2, default: 200', default=200, type=int) #parser.add_argument( # '--nz3', help='number of steps 3, default: 50', default=50, type=int) parser.add_argument( '--cutoff', help="The minimum of J amplitude to write, (in eV), default is 1e-5 eV", default=1e-5, type=float) parser.add_argument( '--exclude_orbs', help= "the indices of wannier functions to be excluded from magnetic site. counting start from 0", default=[], type=int, nargs='+') parser.add_argument( "--description", help= "add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.", type=str, default="Calculated with TB2J.") parser.add_argument("--fname", default='exchange.xml', type=str, help='exchange xml file name. default: exchange.xml') args = parser.parse_args() if args.elements is None: print("Please input the magnetic elements, e.g. --elements Fe Ni") exit() gen_exchange_siesta( fdf_fname=args.fdf_fname, kmesh=args.kmesh, magnetic_elements=args.elements, Rcut=args.rcut, emin=args.emin, emax=args.emax, nz=args.nz, #height=args.height, #nz1=args.nz1, #nz2=args.nz2, #nz3=args.nz3, description=args.description, exclude_orbs=args.exclude_orbs)
def run_siesta2J(): print_license() parser = argparse.ArgumentParser( description= "siesta2J: Using magnetic force theorem to calculate exchange parameter J from siesta Hamiltonian" ) parser.add_argument('--fdf_fname', help="path of the input fdf file", default='./', type=str) parser.add_argument( '--elements', help= "list of elements to be considered in Heisenberg model. For each element, a postfixes can be used to specify the orbitals(Only with Siesta backend), eg. Fe_3d, or Fe_3d_4s ", default=None, type=str, nargs='*') parser.add_argument( '--rcut', help='range of R. The default is all the commesurate R to the kmesh', default=None, type=float) parser.add_argument('--efermi', help='Fermi energy in eV. For test only. ', default=None, type=float) parser.add_argument( '--kmesh', help= 'kmesh in the format of kx ky kz. Monkhorst pack. If all the numbers are odd, it is Gamma cenetered. (strongly recommended), Default: 5 5 5', type=int, nargs='*', default=[5, 5, 5]) parser.add_argument('--emin', help='energy minimum below efermi, default -14 eV', type=float, default=-14.0) parser.add_argument('--emax', help='energy maximum above efermi. Default 0.0 eV', type=float, default=0.05) parser.add_argument( '--use_cache', help= "whether to use disk file for temporary storing wavefunctions and hamiltonian to reduce memory usage. Default: False", action='store_true', default=False) # parser.add_argument( # '--height', # help= # 'energy contour, a small number (often between 0.1 to 0.5, default 0.2)', # type=float, # default=0.1) parser.add_argument('--nz', help='number of integration steps. Default: 50', default=50, type=int) # parser.add_argument( # '--nz2', help='number of steps 2, default: 200', default=200, type=int) # parser.add_argument( # '--nz3', help='number of steps 3, default: 50', default=50, type=int) parser.add_argument( '--cutoff', help="The minimum of J amplitude to write, (in eV). Default: 1e-5 eV", default=1e-5, type=float) parser.add_argument( '--exclude_orbs', help= "the indices of wannier functions to be excluded from magnetic site. counting start from 0. Default is none.", default=[], type=int, nargs='+') parser.add_argument( '--np', help='number of cpu cores to use in parallel, default: 1', default=1, type=int) parser.add_argument( "--description", help= "add description of the calculatiion to the xml file. Essential information, like the xc functional, U values, magnetic state should be given.", type=str, default="Calculated with TB2J.") parser.add_argument( "--orb_decomposition", default=False, action='store_true', help= "whether to do orbital decomposition in the non-collinear mode. Default: False." ) parser.add_argument("--fname", default='exchange.xml', type=str, help='exchange xml file name. default: exchange.xml') parser.add_argument( "--output_path", help="The path of the output directory, default is TB2J_results", type=str, default="TB2J_results") args = parser.parse_args() if args.elements is None: print("Please input the magnetic elements, e.g. --elements Fe Ni") sys.exit() include_orbs = {} for element in args.elements: if "_" in element: elem = element.split("_")[0] orb = element.split("_")[1:] include_orbs[elem] = orb else: include_orbs[element] = None gen_exchange_siesta(fdf_fname=args.fdf_fname, kmesh=args.kmesh, magnetic_elements=list(include_orbs.keys()), include_orbs=include_orbs, Rcut=args.rcut, emin=args.emin, emax=args.emax, nz=args.nz, description=args.description, output_path=args.output_path, use_cache=args.use_cache, np=args.np, exclude_orbs=args.exclude_orbs, orb_decomposition=args.orb_decomposition)