예제 #1
0
    def testEntry(self):
        entries = []
        for i, f in enumerate(self.iter_path):
            vi = VaspInput.from_directory(f)
            ls = LabeledSystem(os.path.join(f, 'OUTCAR'))
            attrib = loadfn(os.path.join(f, 'job.json'))
            comp = vi['POSCAR'].structure.composition
            entry = Entry(comp,
                          'vasp',
                          vi.as_dict(),
                          ls.as_dict(),
                          entry_id='pku-' + str(i),
                          attribute=attrib)
            entries.append(entry)
        self.assertEqual(len(entries), len(self.ref_entries))
        ret0 = entries[0]
        r0 = self.ref_entries[0]
        self.assertEqual(Incar.from_dict(ret0.inputs['INCAR']),
                         Incar.from_dict(r0.inputs['INCAR']))
        self.assertEqual(str(r0.inputs['KPOINTS']),
                         str(Kpoints.from_dict(ret0.inputs['KPOINTS'])))

        self.assertEqual(ret0.inputs['POTCAR'], r0.inputs['POTCAR'].as_dict())
        self.assertEqual(
            Poscar.from_dict(ret0.inputs['POSCAR']).structure,
            r0.inputs['POSCAR'].structure)
        self.assertEqual(ret0.entry_id, 'pku-0')
예제 #2
0
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")
예제 #3
0
        dict_INCAR = get_VASP_inputs(structure)

        # Reading the inputs for INCAR file
        for var_key, var_value in wano_file["TABS"]["INCAR"].items():
            if var_key in dict_INCAR.keys():
                dict_INCAR[var_key] = var_value
                print(var_key, var_value)
            else:
                dict_INCAR[var_key] = var_value

        dict_Analysis = {}

        for var_key, var_value in wano_file["TABS"]["Analysis"].items():
            if var_key == 'ENCUT':
                var_value = float(var_value)

            dict_Analysis[var_key] = var_value

        dict_INCAR = check_vdw_functional(dict_INCAR)
        dict_INCAR = check_hybrid_functionals(dict_INCAR)
        dict_INCAR = check_SOC(dict_INCAR)
        dict_INCAR = check_MD(dict_INCAR)

        # Analysis in INCAR file
        dict_INCAR = check_Bader(dict_Analysis, dict_INCAR)
        dict_INCAR = check_DOS(dict_Analysis, dict_INCAR)
        dict_INCAR = check_Band_structure(dict_Analysis, dict_INCAR)
        incar = Incar.from_dict(dict_INCAR)

        incar.write_file('INCAR')
        print("INCAR successfully created")
예제 #4
0
 def get_pymatgen(self):
     return Incar.from_dict(
         {k.upper(): v
          for k, v in self.incar_dict.items()})
예제 #5
0
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""")
예제 #6
0
def vasp_ncl_files(single_defect_dict, input_dir=None, incar_settings=None):
    """
    Generates INCAR for vasp_ncl single-shot SOC energy calculation on
    vasp_std-relaxed defect structure.
    For POSCAR, POTCAR, KPOINTS, use on command-line (to continue on from vasp_std run):
    'cp vasp_std/CONTCAR vasp_ncl/POSCAR; cp vasp_std/{POTCAR,CHGCAR} vasp_ncl/'
    and 'cp vasp_std/IBZKPT vasp_ncl/KPOINTS' because you need to use non-symmetrised k-points
    (single-weighted) for accurate SOC calculations.
    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_ncl 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)
    """
    NELECT = single_defect_dict['NELECT']
    # Variable parameters first
    vaspnclincardict = {
        '# May need to change NELECT, NCORE, KPAR, AEXX, ENCUT, NUPDOWN':
        'variable parameters',
        'NELECT': NELECT,
        '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': 2,
        'AEXX': 0.25,
        'ENCUT': 450,
        'ICORELEVEL':
        '0 # Get core potentials in OUTCAR for Kumagai corrections',
        'NSW': 0,
        'LSORBIT': True,
        'EDIFF': 1e-06,
        'EDIFFG': -0.01,
        'ALGO': 'All',
        'ADDGRID': True,
        'HFSCREEN': 0.2,
        'IBRION': -1,
        'ICHARG': 1,
        'ISIF': 2,
        'ISYM': 0,
        'ISMEAR': 0,
        'LASPH': True,
        'LHFCALC': True,
        'LORBIT': 11,
        'LREAL': False,
        'LVHAR': True,
        'LWAVE': True,
        'NEDOS': 2000,
        'NELM': 100,
        'PREC': 'Accurate',
        'PRECFOCK': 'Fast',
        'SIGMA': 0.05
    }
    if incar_settings:
        vaspnclincardict.update(incar_settings)

    # Directory
    vaspnclinputdir = input_dir + "/vasp_ncl/" if input_dir else 'VASP_Files/vasp_ncl/'
    if not os.path.exists(vaspnclinputdir):
        os.makedirs(vaspnclinputdir)

    # defect_supercell = supercell ## Add structure if re-generating POSCAR/POTCAR or some shit

    vaspnclincar = Incar.from_dict(vaspnclincardict)
    # vaspnclinput = DictSet(defect_supercell, config_dict=vasppotcardict)
    # vaspnclinput.potcar.write_file(vaspnclinputdir+'POTCAR') ## No POTCAR, use POTCAR from vasp_std run
    # vaspnclinput.poscar.write_file(vaspnclinputdir+'POSCAR') ## No POSCAR, use CONTCAR from vasp_std run

    with zopen(vaspnclinputdir + 'INCAR', "wt") as f:
        f.write(vaspnclincar.get_string())
예제 #7
0
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')