

def setup(self):
    '\n        Performs initial setup for VaspJob, including overriding any settings\n        and backing up.\n        '
    files = os.listdir('.')
    num_structures = 0
    if (not set(files).issuperset(VASP_INPUT_FILES)):
        for f in files:
            try:
                struct = read_structure(f)
                num_structures += 1
            except:
                pass
        if (num_structures != 1):
            raise RuntimeError('{} structures found. Unable to continue.'.format(num_structures))
        else:
            self.default_vis.write_input(struct, '.')
    if self.backup:
        for f in VASP_INPUT_FILES:
            shutil.copy(f, '{}.orig'.format(f))
    if self.auto_npar:
        try:
            incar = Incar.from_file('INCAR')
            if (not (incar.get('LHFCALC') or incar.get('LRPA') or incar.get('LEPSILON'))):
                if (incar.get('IBRION') in [5, 6, 7, 8]):
                    del incar['NPAR']
                else:
                    import multiprocessing
                    ncores = (os.environ.get('NSLOTS') or multiprocessing.cpu_count())
                    ncores = int(ncores)
                    for npar in range(int(math.sqrt(self)), ncores):
                        if ((ncores % npar) == 0):
                            incar['NPAR'] = npar
                            break
                incar.write_file('INCAR')
        except:
            pass
    if (self.settings_override is not None):
        VaspModder().apply_actions(self.settings_override)

dataset/ETHPy150Open materialsproject/custodian/custodian/vasp/jobs.py VaspJob.setup/VarMisuse@262/393 `ncores`->`self`