def __init__(self, structure, spec, functional='PBE', sym_prec=0.01, **kwargs): """ Supports the same kwargs as :class:`JSONVaspInputSet`. """ with open(os.path.join(MODULE_DIR, "GWVaspInputSet.json")) as f: DictSet.__init__(self, "MP Static exact diagonalization", json.load(f), sort_structure=False, **kwargs) self.structure = structure self.tests = self.__class__.get_defaults_tests() self.convs = self.__class__.get_defaults_convs() self.functional = functional self.sym_prec = sym_prec self.user_kpoints_settings = {} self.set_dens(spec) npar = self.get_npar(self.structure) #single step exact diagonalization, output WAVEDER self.user_incar_settings.update({ "ALGO": "Exact", "NELM": 1, "LOPTICS": "TRUE" }) # for large systems exact diagonalization consumes too much memory self.set_gw_bands(15) self.user_incar_settings.update({"NPAR": npar})
def gen_mol_sp(self, pmgmol, charge, wdir): config = load_yaml_config('lateng_hse_d3bj_sp') boxs = boxstructure(pmgmol) boxs._charge = charge vasp_set = DictSet(boxs, config, use_structure_charge=True, user_kpoints_settings=onekpoints) vasp_set.write_input(wdir)
def __init__(self, name, incar, poscar, kpoints, potcar=None, qadapter=None, script_name='submit_script', vis_logger=None, reuse_path=None, test=False, **kwargs): """ default INCAR from config_dict """ self.name = name self.test = test #print (test) self.incar_init = Incar.from_dict(incar.as_dict()) self.poscar_init = Poscar.from_dict(poscar.as_dict()) if not self.test: self.potcar_init = Potcar.from_dict(potcar.as_dict()) if not isinstance(kpoints, str): self.kpoints_init = Kpoints.from_dict(kpoints.as_dict()) #print (kpoints) else: self.kpoints_init = kpoints self.reuse_path = reuse_path # complete reuse paths self.extra = kwargs if qadapter is not None: self.qadapter = qadapter.from_dict(qadapter.to_dict()) else: self.qadapter = None self.script_name = script_name config_dict = {} config_dict['INCAR'] = self.incar_init.as_dict() config_dict['POSCAR'] = self.poscar_init.as_dict() # caution the key and the value are not always the same if not self.test: config_dict['POTCAR'] = self.potcar_init.as_dict() # dict(zip(self.potcar.as_dict()['symbols'], # self.potcar.as_dict()['symbols'])) if not isinstance(kpoints, str): #print (self.kpoints_init) config_dict['KPOINTS'] = self.kpoints_init.as_dict() else: # need to find a way to dictify this kpoints string more # appropriately config_dict['KPOINTS'] = {'kpts_hse': self.kpoints_init} # self.user_incar_settings = self.incar.as_dict() DictSet.__init__(self, poscar.structure, config_dict) #**kwargs) if vis_logger: self.logger = vis_logger else: self.logger = logger
def __init__(self, name, incar, poscar, kpoints, potcar=None, qadapter=None, script_name='submit_script', vis_logger=None, reuse_path=None, test=False, **kwargs): """ default INCAR from config_dict """ self.name = name self.test = test self.incar_init = Incar.from_dict(incar.as_dict()) self.poscar_init = Poscar.from_dict(poscar.as_dict()) if not self.test: self.potcar_init = Potcar.from_dict(potcar.as_dict()) if not isinstance(kpoints, str): self.kpoints_init = Kpoints.from_dict(kpoints.as_dict()) else: self.kpoints_init = kpoints self.reuse_path = reuse_path # complete reuse paths self.extra = kwargs if qadapter is not None: self.qadapter = qadapter.from_dict(qadapter.to_dict()) else: self.qadapter = None self.script_name = script_name config_dict = {} config_dict['INCAR'] = self.incar_init.as_dict() config_dict['POSCAR'] = self.poscar_init.as_dict() # caution the key and the value are not always the same if not self.test: config_dict['POTCAR'] = self.potcar_init.as_dict() # dict(zip(self.potcar.as_dict()['symbols'], # self.potcar.as_dict()['symbols'])) if not isinstance(kpoints, str): config_dict['KPOINTS'] = self.kpoints_init.as_dict() else: # need to find a way to dictify this kpoints string more # appropriately config_dict['KPOINTS'] = {'kpts_hse':self.kpoints_init} # self.user_incar_settings = self.incar.as_dict() DictSet.__init__(self, poscar.structure, config_dict) #**kwargs) if vis_logger: self.logger = vis_logger else: self.logger = logger
def get_mol_nelect(self, pmgmol, charge): config = load_yaml_config('lateng_pbe_d3bj_relax') boxs = boxstructure(pmgmol) boxs._charge = charge vasp_set = DictSet(boxs, config, use_structure_charge=True, user_kpoints_settings=onekpoints) return vasp_set.nelect
def __init__(self, structure, spec, functional='PBE', sym_prec=0.01, **kwargs): """ Supports the same kwargs as :class:`JSONVaspInputSet`. """ with open(os.path.join(MODULE_DIR, "GWVaspInputSet.json")) as f: DictSet.__init__(self, "MP Static Self consistent run for GW", json.load(f), sort_structure=False, **kwargs) self.structure = structure self.tests = self.__class__.get_defaults_tests() self.convs = self.__class__.get_defaults_convs() self.user_kpoints_settings = {} self.functional = functional self.set_dens(spec) self.sym_prec = sym_prec
def __init__(self, structure, spec, functional='PBE', sym_prec=0.01, **kwargs): """ Supports the same kwargs as :class:`JSONVaspInputSet`. """ with open(os.path.join(MODULE_DIR, "GWVaspInputSet.json")) as f: DictSet.__init__(self, "MP Static G0W0", json.load(f), sort_structure=False, **kwargs) self.structure = structure self.tests = self.__class__.get_defaults_tests() self.convs = self.__class__.get_defaults_convs() self.functional = functional self.user_kpoints_settings = {} self.sym_prec = sym_prec npar = self.get_npar(structure) # G0W0 calculation with reduced cutoff for the response function self.user_incar_settings.update({ "ALGO": "GW0", "ENCUTGW": 250, "LWAVE": "FALSE", "NELM": 1 }) self.set_dens(spec) self.nomega_max = 2 * self.get_kpoints(structure).kpts[0][0]**3 nomega = npar * int(self.nomega_max / npar) self.set_gw_bands(15) self.user_incar_settings.update({"NPAR": npar}) self.user_incar_settings.update({"NOMEGA": nomega}) self.tests = self.__class__.get_defaults_tests()
def main(): df = pd.read_csv('calc_data.csv') converged = df['converged'] == True few_steps = df['ionic_steps'] < 10 to_run = list(df[converged & few_steps].iloc[:, 0]) converged_calculations = [] for converged_calculation in tqdm(to_run): if os.path.exists( f'mkdir {converged_calculation}/../run.final') == False: os.system(f'mkdir {converged_calculation}/../run.final') outcar = Outcar(f'{converged_calculation}/OUTCAR') mags = [i['tot'] for i in outcar.magnetization] structure = Poscar.from_file( f'{converged_calculation}/CONTCAR').structure structure.add_site_property('magmom', mags) incar = Incar.from_file(f'{converged_calculation}/INCAR') incar.update(static_params) try: del incar['MAGMOM'] except: None potcar = Potcar.from_file(f'{converged_calculation}/POTCAR') calculation = DictSet(structure, { 'INCAR': incar, 'POTCAR': potcar }) calculation.incar.write_file( f'{converged_calculation}/../run.final/INCAR') calculation.poscar.write_file( f'{converged_calculation}/../run.final/POSCAR') os.system( f'cp {converged_calculation}/POTCAR {converged_calculation}/../run.final ; cp {converged_calculation}/job.sh {converged_calculation}/../run.final' ) os.system( f'touch {converged_calculation}/../run.final/vasp_out ; touch {converged_calculation}/../run.final/vasprun.xml' )
def slabs_to_file(list_of_slabs, structure, make_fols, make_input_files, config_dict, fmt, name, **save_slabs_kwargs): """ Saves the slabs to file, optionally creates input files. The function can take any relevant keyword argument for DictSet. Args: list_of_slabs (`list`): a list of slab dictionaries made with either of surfaxe.generation get_slab functions structure (`str`): Filename of bulk structure file in any format supported by pymatgen. make_fols (`bool`): Makes folders for each termination and slab/vacuum thickness combinations containing structure files. * ``True``: A Miller index folder is created, in which folders named slab_vac_index are created to which the relevant structure files are saved. E.g. for a (0,0,1) slab of index 1 with a slab thickness of 20 Å and vacuum thickness of 30 Å the folder structure would be: ``001/20_30_1/POSCAR`` * ``False``: The indexed structure files are put in a folder named after the bulk formula. E.g. for a (0,0,1) MgO slab of index 1 with a slab thickness of 20 Å and vacuum thickness of 30 Å the folder structure would be: ``MgO/POSCAR_001_20_30_1.vasp`` make_input_files (`bool`): Makes INCAR, POTCAR and KPOINTS files in each folder. If ``make_input_files`` is ``True`` but ``make_files`` or ``save_slabs`` is ``False``, files will be saved to folders regardless. This only works with VASP input files, other formats are not yet supported. Defaults to ``False``. config_dict (`dict` or `str`): Specifies the dictionary used for the generation of the input files. fmt (`str`, optional): The format of the output files. Options include 'cif', 'poscar', 'cssr', 'json', not case sensitive. Defaults to 'poscar'. name (`str`, optional): The name of the surface slab structure file created. Case sensitive. Defaults to 'POSCAR' Returns: None, saves surface slabs to file """ bulk_name = structure.composition.reduced_formula if make_fols or make_input_files: for slab in list_of_slabs: os.makedirs(os.path.join( os.getcwd(), r'{}/{}/{}_{}_{}'.format(bulk_name, slab['hkl'], slab['slab_thickness'], slab['vac_thickness'], slab['slab_index'])), exist_ok=True) # Makes all input files (KPOINTS, POTCAR, INCAR) based on the config # dictionary if make_input_files: # soft check if potcar directory is set potcars = _check_psp_dir() if potcars: cd = _load_config_dict(config_dict) vis = DictSet(slab['slab'], cd, **save_slabs_kwargs) vis.write_input(r'{}/{}/{}_{}_{}'.format( bulk_name, slab['hkl'], slab['slab_thickness'], slab['vac_thickness'], slab['slab_index'])) # only make the folders with structure files in them else: slab['slab'].to(fmt=fmt, filename=r'{}/{}/{}_{}_{}/{}'.format( bulk_name, slab['hkl'], slab['slab_thickness'], slab['vac_thickness'], slab['slab_index'], name)) warnings.formatwarning = _custom_formatwarning warnings.warn( 'POTCAR directory not set up in pymatgen, only ' 'POSCARs were generated ') # Just makes the folders with structure files in them else: slab['slab'].to(fmt=fmt, filename=r'{}/{}/{}_{}_{}/{}'.format( bulk_name, slab['hkl'], slab['slab_thickness'], slab['vac_thickness'], slab['slab_index'], name)) # Makes name_hkl_slab_vac_index files in the bulk_name folder else: suffix = 'vasp' if fmt.lower() != 'poscar': suffix = fmt.lower() os.makedirs(os.path.join(os.getcwd(), r'{}'.format(bulk_name)), exist_ok=True) for slab in list_of_slabs: slab['slab'].to(fmt=fmt, filename=r'{}/{}_{}_{}_{}_{}.{}'.format( bulk_name, name, slab['hkl'], slab['slab_thickness'], slab['vac_thickness'], slab['slab_index'], suffix))
def get_all_slabs(structure=None, max_index=None, thicknesses=None, vacuums=None, make_fols=False, make_input_files=False, max_size=500, ox_states=None, is_symmetric=True, lll_reduce=True, center_slab=True, config_dict=PBEsol_slab_config, potcar_functional='PBE', update_incar=None, update_potcar=None, update_kpoints=None, **kwargs): """ Generates all unique slabs with specified maximum Miller index, minimum slab and vacuum thicknesses. It includes all combinations for multiple zero dipole symmetric terminations for the same Miller index. Note that using this method of slab generation will results in different slab index numbers as in the `get_one_hkl_slabs` - the slabs identified are the same, the index varies based on the position in the list of generated slabs. Args: structure: filename of structure file, takes all pymatgen-supported formats. max_index (int): maximum Miller index to be considered thicknesses (list): minimum size of the slab in angstroms. vacuums (list): minimum size of the vacuum in angstroms. make_fols (bool): makes folders containing POSCARs; default=False make_input_files (bool): makes INCAR, POTCAR and KPOINTS files in each of the folders; if True but make_fols is False it will make the folders regardless; default=False. max_size (int): the maximum number of atoms in the slab for the size warning; default=500. ox_states (list or dict): add oxidation states either by sites i.e. [3, 2, 2, 1, -2, -2, -2, -2] or by element i.e. {'Fe': 3, 'O':-2}; default=None which adds oxidation states by guess is_symmetric (bool): whether or not the slabs cleaved should have inversion symmetry. Needs to be False for slabs cleaved from a non-centrosymmetric bulk; default=True lll_reduce (bool): whether or not the slabs will be orthogonalized; default=True. center_slab (bool): position of the slab in the unit cell, if True the slab is centered with equal amounts of vacuum above and below; default=True config_dict (dict): specifies the dictionary used for generation of input files; default=PBEsol_slab_config potcar_functional (str): The functional used for POTCAR generation; default='PBE' update_incar (dict): overrides default INCAR settings; default=None update_kpoints (dict or kpoints object): overrides default kpoints settings, if supplied as dict should be as {'reciprocal_density': 100}; default=None update_potcar (dict): overrides default POTCAR settings; default=None Returns: POSCAR_hkl_slab_vac_index.vasp or hkl/slab_vac_index folders with POSCARs or hkl/slab_vac_index with all input files """ # Check all neccessary input parameters are present if not any([structure, max_index, thicknesses, vacuums]): raise ValueError('One or more of the required arguments (structure, ' 'max_index, thicknesses, vacuums) were not supplied.') # Import bulk relaxed structure, add oxidation states for slab dipole # calculations struc = Structure.from_file(structure) bulk_name = struc.formula.replace(" ", "") struc = oxidation_states(struc, ox_states=ox_states) # Iterate through vacuums and thicknessses provisional = [] for vacuum in vacuums: for thickness in thicknesses: all_slabs = generate_all_slabs(struc, max_index=max_index, min_slab_size=thickness, min_vacuum_size=vacuum, lll_reduce=lll_reduce, center_slab=center_slab, **kwargs) for i, slab in enumerate(all_slabs): # Get all the zero-dipole slabs with inversion symmetry if is_symmetric: if (slab.is_polar() == False) and (slab.is_symmetric() == True): provisional.append({ 'hkl': ''.join(map(str, slab.miller_index)), 'slab_t': thickness, 'vac_t': vacuum, 's_index': i, 'slab': slab }) # Get all the zero-dipole slabs wihtout inversion symmetry else: if not slab.is_polar(): provisional.append({ 'hkl': ''.join(map(str, slab.miller_index)), 'slab_t': thickness, 'vac_t': vacuum, 's_index': i, 'slab': slab }) # Iterate though provisional slabs to extract the unique slabs unique_list, unique_list_of_dicts, repeat, large = ([] for i in range(4)) for slab in provisional: if slab['slab'] not in unique_list: unique_list.append(slab['slab']) unique_list_of_dicts.append(slab) # For large slab size warning atoms = len(slab['slab'].atomic_numbers) if atoms > max_size: large.append('{}_{}_{}_{}'.format(slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index'])) # For repeat slabs warning else: repeat.append('{}_{}_{}_{}'.format(slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index'])) # Warnings for large and repeated slabs if repeat: warnings.formatwarning = custom_formatwarning warnings.warn( 'Not all combinations of hkl or slab/vac thicknesses ' 'were generated because of repeat structures. ' 'The repeat slabs are: ' + ', '.join(map(str, repeat))) if large: warnings.formatwarning = custom_formatwarning warnings.warn('Some generated slabs exceed the max size specified.' ' Slabs that exceed the max size are: ' + ', '.join(map(str, large))) # Makes folders hkl/slab_vac_index, if only make_input_files is true the # folders will also be made automatically. if make_fols or make_input_files: for slab in unique_list_of_dicts: os.makedirs(os.path.join( os.getcwd(), r'{}/{}_{}_{}'.format(slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index'])), exist_ok=True) # Makes all VASP input files (KPOINTS, POTCAR, INCAR) based on the # config dictionary if make_input_files: vis = DictSet(structure=slab['slab'], config_dict=config_dict, potcar_functional=potcar_functional, user_incar_settings=update_incar, user_potcar_settings=update_potcar, user_kpoints_settings=update_kpoints, **kwargs) vis.write_input( os.path.join( os.getcwd(), r'{}/{}_{}_{}'.format(slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index']))) # Makes the folders with POSCARs else: slab['slab'].to(fmt='poscar', filename=r'{}/{}_{}_{}/POSCAR'.format( slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index'])) # Omits folders, makes POSCAR_hkl_slab_vac_index files in folder bulk_name else: os.makedirs(os.path.join(os.getcwd(), r'{}'.format(bulk_name)), exist_ok=True) for slab in unique_list_of_dicts: slab['slab'].to(fmt='poscar', filename='{}/POSCAR_{}_{}_{}_{}.vasp'.format( bulk_name, slab['hkl'], slab['slab_t'], slab['vac_t'], slab['s_index']))
def gen_pbc_sp(self, wdir, nelect): config = load_yaml_config('lateng_hse_d3bj_sp') config['INCAR']['NELECT'] = nelect vasp_set = DictSet(self.structure, config) vasp_set.write_input(wdir)
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': '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' } } 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')