def make_atom_mp_relax_set(): for element, potcar in PotcarSet.mp_relax_set.potcar_dict().items(): if potcar is None: continue if is_target_element(element) is False: continue structure = Structure(Lattice.cubic(10), coords=[[0.5] * 3], species=[element]) mp_set = MPRelaxSet(structure, user_kpoints_settings=Kpoints(kpts=((1, 1, 1), )), user_incar_settings={ "ALGO": "D", "ISIF": 2, "ISMEAR": 0, "MAGMOM": { "H": 1.0 }, "NELM": 300 }) Path(element).mkdir() mp_set.write_input(element)
def make_atom_mp_relax_set(): for element, potcar in PotcarSet.mp_relax_set.potcar_dict().items(): if potcar is None: continue Path(element).mkdir() structure = Structure(Lattice.cubic(10), coords=[[0.5] * 3], species=[element]) mp_set = MPRelaxSet(structure, user_kpoints_settings=Kpoints(kpts=((1, 1, 1), )), user_incar_settings={ "ISIF": 2, "ISMEAR": 0, "NUPDOWN": nupdown[element], "NELM": 300 }) mp_set.write_input(element)
def setUp(self): lattice = [[10, 0, 0], [-5, 8.660254, 0], [0, 0, 5]] self.hexagonal = Structure(lattice=lattice, species=["H"], coords=[[0, 0, 0]]) self.kpoints_g = Kpoints.gamma_automatic(kpts=(2, 2, 2)) lattice2 = [[1, 0, 0], [0, 2, 0], [0, 0, 3]] self.ortho = Structure(lattice=lattice2, species=["H"], coords=[[0, 0, 0]]) self.kpoints_mp = Kpoints.monkhorst_automatic(kpts=(2, 2, 2)) self.kpoints_reciprocal = \ Kpoints(style=Kpoints.supported_modes.Reciprocal, num_kpts=2, kpts=((0, 0, 0), (0.5, 0.5, 0.5)), kpts_weights=[1, 1])
def main(): parser = argparse.ArgumentParser() parser.add_argument('-d', '--directories', default='all', help='directories (containing INCARs) to edit') args = parser.parse_args() directories = args.directories parameters_to_update = { "GGA": "PE", "ISYM": 3, "PRECFOCK": "Fast", "LMAXFOCK": 4, "TIME": 0.30, "LHFCALC": True, "AEXX": 0.25, "HFSCREEN": 0.2 } if directories == 'all': directories = find_vasp_calculations() for directory in directories: incar = Incar.from_file(f"{directory}/INCAR").as_dict() incar = deepcopy(incar) to_del = [i for i in incar.keys() if "LDA" in i] for d in to_del: incar.pop(d) new_incar = Incar.from_dict(incar | parameters_to_update) os.mkdir(f"{directory}/hygam") new_incar.write_file(f"{directory}/hygam/INCAR") structure = Poscar.from_file(f"{directory}/CONTCAR").structure structure.to(filename=f"{directory}/hygam/POSCAR") os.system(f"cp {directory}/POTCAR {directory}/hygam/POTCAR") Kpoints().write_file(f"{directory}/hygam/KPOINTS")
print("The folder {} already exists".format(folder_name)) continue else: os.system("cp -r initial " + folder_name) os.chdir(folder_name) st = comp["structure"] s = Structure.from_dict(st) s.to(filename="POSCAR") ibz = HighSymmKpath(s) kpoints = list() labels = list() for path in ibz.kpath["path"]: for kpts in path: kpoints.append(ibz.kpath["kpoints"][kpts]) labels.append(kpts) Kpoints( comment="Line mode for {} {} {}".format( comp["formula_pretty"], "sg" + str(comp["spacegroup"]["number"]), comp["spacegroup"]["symbol"]), num_kpts=20, style=Kpoints.supported_modes.Line_mode, coord_type="Reciprocal", kpts=kpoints, labels=labels, ).write_file("KPOINTS_NSELF") os.system("qsub partita.sh") os.chdir("../")
def vasp_converge_files(structure, input_dir=None, incar_settings=None, config=None): """ Generates input files for single-shot GGA convergence test calculations. Automatically sets ISMEAR (in INCAR) to 2 (if metallic) or 0 if not. Recommended to use with vaspup2.0 Args: structure (Structure object): Structure to create input files for input_dir (str): Folder in which to create 'input' folder with VASP input files (default: None) incar_settings (dict): Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at output INCARs or DefectsWithTheBoys.vasp_input source code, to see what the default INCAR settings are. (default: None) config (str): CONFIG file string. If provided, will also write the CONFIG file to each 'input' directory (default: None) """ # Variable parameters first vaspconvergeincardict = { '# May need to change ISMEAR, NCORE, KPAR, AEXX, ENCUT, NUPDOWN, ISPIN': 'variable parameters', 'NUPDOWN': "0 # But could be 1 etc. if ya think we got a bit of magnetic shit going down", 'NCORE': 12, '#KPAR': 1, 'ENCUT': 450, 'ISMEAR': "0 # Change to 2 for Metals", 'ISPIN': 2, 'ICORELEVEL': 0, 'GGA': 'PS', 'ALGO': 'Normal', 'ADDGRID': True, 'EDIFF': 1e-07, 'EDIFFG': -0.01, 'IBRION': -1, 'ICHARG': 1, 'ISIF': 3, 'LASPH': True, 'LORBIT': 11, 'LREAL': False, 'LVHAR': True, 'LWAVE': True, 'NEDOS': 2000, 'NELM': 100, 'NSW': 0, 'PREC': 'Accurate', 'SIGMA': 0.2 } if all(is_metal(element) for element in structure.composition.elements): vaspconvergeincardict['ISMEAR'] = 2 # If metals only else: vaspconvergeincardict['ISMEAR'] = 0 # Gaussian smearing otherwise if incar_settings: vaspconvergeincardict.update(incar_settings) # Directory vaspconvergeinputdir = input_dir + "/input/" if input_dir else 'VASP_Files/input/' if not os.path.exists(vaspconvergeinputdir): os.makedirs(vaspconvergeinputdir) vasppotcardict = { 'POTCAR': { 'Ac': 'Ac', 'Ag': 'Ag', 'Al': 'Al', 'Ar': 'Ar', 'As': 'As', 'Au': 'Au', 'B': 'B', 'Ba': 'Ba_sv', 'Be': 'Be_sv', 'Bi': 'Bi', 'Br': 'Br', 'C': 'C', 'Ca': 'Ca_sv', 'Cd': 'Cd', 'Ce': 'Ce', 'Cl': 'Cl', 'Co': 'Co', 'Cr': 'Cr_pv', 'Cs': 'Cs_sv', 'Cu': 'Cu_pv', 'Dy': 'Dy_3', 'Er': 'Er_3', 'Eu': 'Eu', 'F': 'F', 'Fe': 'Fe_pv', 'Ga': 'Ga_d', 'Gd': 'Gd', 'Ge': 'Ge_d', 'H': 'H', 'He': 'He', 'Hf': 'Hf_pv', 'Hg': 'Hg', 'Ho': 'Ho_3', 'I': 'I', 'In': 'In_d', 'Ir': 'Ir', 'K': 'K_sv', 'Kr': 'Kr', 'La': 'La', 'Li': 'Li_sv', 'Lu': 'Lu_3', 'Mg': 'Mg_pv', 'Mn': 'Mn_pv', 'Mo': 'Mo_pv', 'N': 'N', 'Na': 'Na_pv', 'Nb': 'Nb_pv', 'Nd': 'Nd_3', 'Ne': 'Ne', 'Ni': 'Ni_pv', 'Np': 'Np', 'O': 'O', 'Os': 'Os_pv', 'P': 'P', 'Pa': 'Pa', 'Pb': 'Pb_d', 'Pd': 'Pd', 'Pm': 'Pm_3', 'Pr': 'Pr_3', 'Pt': 'Pt', 'Pu': 'Pu', 'Rb': 'Rb_sv', 'Re': 'Re_pv', 'Rh': 'Rh_pv', 'Ru': 'Ru_pv', 'S': 'S', 'Sb': 'Sb', 'Sc': 'Sc_sv', 'Se': 'Se', 'Si': 'Si', 'Sm': 'Sm_3', 'Sn': 'Sn_d', 'Sr': 'Sr_sv', 'Ta': 'Ta_pv', 'Tb': 'Tb_3', 'Tc': 'Tc_pv', 'Te': 'Te', 'Th': 'Th', 'Ti': 'Ti_pv', 'Tl': 'Tl_d', 'Tm': 'Tm_3', 'U': 'U', 'V': 'V_pv', 'W': 'W_pv', 'Xe': 'Xe', 'Y': 'Y_sv', 'Yb': 'Yb_2', 'Zn': 'Zn', 'Zr': 'Zr_sv' } } vaspconvergekpts = Kpoints().from_dict({ 'comment': 'Kpoints from vasp_gam_files', 'generation_style': 'Gamma' }) vaspconvergeincar = Incar.from_dict(vaspconvergeincardict) vaspconvergeinput = DictSet(structure, config_dict=vasppotcardict) vaspconvergeinput.potcar.write_file(vaspconvergeinputdir + 'POTCAR') vaspconvergeposcar = Poscar(structure) vaspconvergeposcar.write_file(vaspconvergeinputdir + 'POSCAR') with zopen(vaspconvergeinputdir + 'INCAR', "wt") as f: f.write(vaspconvergeincar.get_string()) vaspconvergekpts.write_file(vaspconvergeinputdir + 'KPOINTS') # generate CONFIG file if config: with open(vaspconvergeinputdir + 'CONFIG', 'w+') as config_file: config_file.write(config) with open(vaspconvergeinputdir + 'CONFIG', 'a') as config_file: config_file.write(f"""\nname="{input_dir[13:]}" # input_dir""")
def vasp_gam_files(single_defect_dict, input_dir=None, incar_settings=None): """ Generates input files for VASP Gamma-point-only rough relaxation (before more expensive vasp_std relaxation) Args: single_defect_dict (dict): Single defect-dictionary from prepare_vasp_defect_inputs() output dictionary of defect calculations (see example notebook) input_dir (str): Folder in which to create vasp_gam calculation inputs folder (Recommended to set as the key of the prepare_vasp_defect_inputs() output directory) (default: None) incar_settings (dict): Dictionary of user INCAR settings (AEXX, NCORE etc.) to override default settings. Highly recommended to look at output INCARs or DefectsWithTheBoys.vasp_input source code, to see what the default INCAR settings are. (default: None) """ supercell = single_defect_dict['Defect Structure'] NELECT = single_defect_dict['NELECT'] POSCAR_Comment = single_defect_dict[ 'POSCAR Comment'] if single_defect_dict['POSCAR Comment'] else None # Variable parameters first vaspgamincardict = { '# May need to change NELECT, IBRION, NCORE, KPAR, AEXX, ENCUT, NUPDOWN, ISPIN, POTIM': 'variable parameters', 'NELECT': NELECT, 'IBRION': '2 # vasp_gam cheap enough, this is more reliable', 'NUPDOWN': f"{NELECT % 2:.0f} # But could be {NELECT % 2 + 2:.0f} if ya think we got a bit of crazy ferromagnetic shit going down", 'NCORE': 12, '#KPAR': 'One pal, only one k-point yeh', 'AEXX': 0.25, 'ENCUT': 450, 'POTIM': 0.2, 'ISPIN': 2, 'ICORELEVEL': 0, 'LSUBROT': True, 'ALGO': 'All', 'ADDGRID': True, 'EDIFF': 1e-06, 'EDIFFG': -0.005, 'HFSCREEN': 0.2, 'ICHARG': 1, 'ISIF': 2, 'ISYM': 0, 'ISMEAR': 0, 'LASPH': True, 'LHFCALC': True, 'LORBIT': 11, 'LREAL': False, 'LVHAR': True, 'LWAVE': True, 'NEDOS': 2000, 'NELM': 100, 'NSW': 300, 'PREC': 'Accurate', 'PRECFOCK': 'Fast', 'SIGMA': 0.05 } if incar_settings: vaspgamincardict.update(incar_settings) # Directory vaspgaminputdir = input_dir + "/vasp_gam/" if input_dir else 'VASP_Files/vasp_gam/' if not os.path.exists(vaspgaminputdir): os.makedirs(vaspgaminputdir) vasppotcardict = { 'POTCAR': { 'Ac': 'Ac', 'Ag': 'Ag', 'Al': 'Al', 'Ar': 'Ar', 'As': 'As', 'Au': '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Zr_sv' } } vaspgamkpts = Kpoints().from_dict({ 'comment': 'Kpoints from DefectsWithTheBoys.vasp_gam_files', 'generation_style': 'Gamma' }) vaspgamincar = Incar.from_dict(vaspgamincardict) vaspgaminput = DictSet(supercell, config_dict=vasppotcardict) vaspgamposcar = vaspgaminput.poscar vaspgaminput.potcar.write_file(vaspgaminputdir + 'POTCAR') if POSCAR_Comment: vaspgamposcar.comment = POSCAR_Comment vaspgamposcar.write_file(vaspgaminputdir + 'POSCAR') with zopen(vaspgaminputdir + 'INCAR', "wt") as f: f.write(vaspgamincar.get_string()) vaspgamkpts.write_file(vaspgaminputdir + 'KPOINTS')