Beispiel #1
0
 def post_process(self, task_list):
     cwd = os.getcwd()
     poscar_start = os.path.abspath(
         os.path.join(task_list[0], '..', 'POSCAR'))
     os.chdir(os.path.join(task_list[0], '..'))
     if os.path.isfile(os.path.join(task_list[0], 'INCAR')):
         incar = incar_upper(
             Incar.from_file(os.path.join(task_list[0], 'INCAR')))
         kspacing = incar.get('KSPACING')
         kgamma = incar.get('KGAMMA', False)
         ret = vasp.make_kspacing_kpoints(poscar_start, kspacing, kgamma)
         kp = Kpoints.from_string(ret)
         if os.path.isfile('KPOINTS'):
             os.remove('KPOINTS')
         kp.write_file("KPOINTS")
         os.chdir(cwd)
         kpoints_universal = os.path.abspath(
             os.path.join(task_list[0], '..', 'KPOINTS'))
         for ii in task_list:
             if os.path.isfile(os.path.join(ii, 'KPOINTS')):
                 os.remove(os.path.join(ii, 'KPOINTS'))
             if os.path.islink(os.path.join(ii, 'KPOINTS')):
                 os.remove(os.path.join(ii, 'KPOINTS'))
             os.chdir(ii)
             os.symlink(os.path.relpath(kpoints_universal), 'KPOINTS')
     os.chdir(cwd)
Beispiel #2
0
def make_vasp_kpoints_from_incar(work_dir, jdata):
    cwd = os.getcwd()
    fp_aniso_kspacing = jdata.get('fp_aniso_kspacing')
    os.chdir(work_dir)
    # get kspacing and kgamma from incar
    assert (os.path.exists('INCAR'))
    with open('INCAR') as fp:
        incar = fp.read()
    standard_incar = incar_upper(Incar.from_string(incar))
    if fp_aniso_kspacing is None:
        try:
            kspacing = standard_incar['KSPACING']
        except KeyError:
            raise RuntimeError("KSPACING must be given in INCAR")
    else:
        kspacing = fp_aniso_kspacing
    try:
        gamma = standard_incar['KGAMMA']
        if isinstance(gamma, bool):
            pass
        else:
            if gamma[0].upper() == "T":
                gamma = True
            else:
                gamma = False
    except KeyError:
        raise RuntimeError("KGAMMA must be given in INCAR")
    # check poscar
    assert (os.path.exists('POSCAR'))
    # make kpoints
    ret = make_kspacing_kpoints('POSCAR', kspacing, gamma)
    kp = Kpoints.from_string(ret)
    kp.write_file("KPOINTS")
    os.chdir(cwd)
Beispiel #3
0
def _check_kpoints(testCase, idx) :
    fp_path = os.path.join('iter.%06d' % idx, '02.fp')
    tasks = glob.glob(os.path.join(fp_path, 'task.*'))
    for ii in tasks :
        kpoints=Kpoints.from_file(os.path.join(os.path.join(ii, 'KPOINTS')))
        incar=Incar.from_file(os.path.join(os.path.join(ii, 'INCAR')))
        kspacing = incar['KSPACING']
        gamma = incar['KGAMMA']
        if isinstance(gamma,bool):
           pass
        else:
           if gamma[0].upper()=="T":
              gamma=True
           else:
              gamma=False
        ret=make_kspacing_kpoints(os.path.join(os.path.join(ii, 'POSCAR')), kspacing, gamma)
        kpoints_ref=Kpoints.from_string(ret)
        testCase.assertEqual(repr(kpoints), repr(kpoints_ref))
Beispiel #4
0
    def make_input_file(self, output_dir, task_type, task_param):
        sepline(ch=output_dir)
        dumpfn(task_param, os.path.join(output_dir, 'task.json'), indent=4)

        assert (os.path.exists(self.incar)), 'no INCAR file for relaxation'
        relax_incar_path = os.path.abspath(self.incar)
        incar_relax = incar_upper(Incar.from_file(relax_incar_path))

        # deal with relaxation

        cal_type = task_param['cal_type']
        cal_setting = task_param['cal_setting']

        # user input INCAR for property calculation
        if 'input_prop' in cal_setting and os.path.isfile(
                cal_setting['input_prop']):
            incar_prop = os.path.abspath(cal_setting['input_prop'])
            incar = incar_upper(Incar.from_file(incar_prop))

        # revise INCAR based on the INCAR provided in the "interaction"
        else:
            incar = incar_relax
            if cal_type == 'relaxation':
                relax_pos = cal_setting['relax_pos']
                relax_shape = cal_setting['relax_shape']
                relax_vol = cal_setting['relax_vol']
                if [relax_pos, relax_shape, relax_vol] == [True, False, False]:
                    isif = 2
                elif [relax_pos, relax_shape, relax_vol] == [True, True, True]:
                    isif = 3
                elif [relax_pos, relax_shape,
                      relax_vol] == [True, True, False]:
                    isif = 4
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, True, False]:
                    isif = 5
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, True, True]:
                    isif = 6
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, False, True]:
                    isif = 7
                elif [relax_pos, relax_shape,
                      relax_vol] == [False, False, False]:
                    nsw = 0
                    isif = 2
                    if not ('NSW' in incar and incar.get('NSW') == nsw):
                        dlog.info("%s setting NSW to %d" %
                                  (self.make_input_file.__name__, nsw))
                        incar['NSW'] = nsw
                else:
                    raise RuntimeError(
                        "not supported calculation setting for VASP")

                if not ('ISIF' in incar and incar.get('ISIF') == isif):
                    dlog.info("%s setting ISIF to %d" %
                              (self.make_input_file.__name__, isif))
                    incar['ISIF'] = isif

            elif cal_type == 'static':
                nsw = 0
                if not ('NSW' in incar and incar.get('NSW') == nsw):
                    dlog.info("%s setting NSW to %d" %
                              (self.make_input_file.__name__, nsw))
                    incar['NSW'] = nsw

            else:
                raise RuntimeError("not supported calculation type for VASP")

            if 'ediff' in cal_setting:
                dlog.info(
                    "%s setting EDIFF to %s" %
                    (self.make_input_file.__name__, cal_setting['ediff']))
                incar['EDIFF'] = cal_setting['ediff']

            if 'ediffg' in cal_setting:
                dlog.info(
                    "%s setting EDIFFG to %s" %
                    (self.make_input_file.__name__, cal_setting['ediffg']))
                incar['EDIFFG'] = cal_setting['ediffg']

            if 'encut' in cal_setting:
                dlog.info(
                    "%s setting ENCUT to %s" %
                    (self.make_input_file.__name__, cal_setting['encut']))
                incar['ENCUT'] = cal_setting['encut']

            if 'kspacing' in cal_setting:
                dlog.info(
                    "%s setting KSAPCING to %s" %
                    (self.make_input_file.__name__, cal_setting['kspacing']))
                incar['KSAPCING'] = cal_setting['kspacing']

            if 'kgamma' in cal_setting:
                dlog.info(
                    "%s setting KGAMMA to %s" %
                    (self.make_input_file.__name__, cal_setting['kgamma']))
                incar['KGAMMA'] = cal_setting['kgamma']

        try:
            kspacing = incar.get('KSPACING')
        except KeyError:
            raise RuntimeError("KSPACING must be given in INCAR")

        if 'KGAMMA' in incar:
            kgamma = incar.get('KGAMMA')
        else:
            kgamma = False

        incar.write_file(os.path.join(output_dir, '../INCAR'))
        cwd = os.getcwd()
        os.chdir(output_dir)
        if not os.path.islink('INCAR'):
            os.symlink('../INCAR', 'INCAR')
        elif not '../INCAR' == os.readlink('INCAR'):
            os.remove('INCAR')
            os.symlink('../INCAR', 'INCAR')
        os.chdir(cwd)
        ret = vasp.make_kspacing_kpoints(self.path_to_poscar, kspacing, kgamma)
        kp = Kpoints.from_string(ret)
        kp.write_file(os.path.join(output_dir, "KPOINTS"))