Пример #1
0
def band_path(line_density):
    """
    for band calculation
    """
    poscar = Poscar.from_file('POSCAR', check_for_POTCAR=False)
    highsymmkp = MyHighSymmKpath(poscar.structure)
    kpts = highsymmkp.get_kpoints(line_density)
    args = {'comment': "Kpoints for band calc",
            'kpts': kpts[0],
            'num_kpts': len(kpts[0]),
            'labels': kpts[1],
            'style': 'Reciprocal',
            'kpts_weights': [1]*len(kpts[0])}
    kpoints = Kpoints(**args)
    kpoints.write_file('KPOINTS_band')
Пример #2
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""")
Пример #3
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')