コード例 #1
0
def _check_incar_ele_temp(testCase, idx, ele_temp):
    fp_path = os.path.join('iter.%06d' % idx, '02.fp')
    tasks = glob.glob(os.path.join(fp_path, 'task.*'))
    cwd = os.getcwd()
    for ii in tasks:
        os.chdir(ii)
        bname = os.path.basename(ii)
        sidx = int(bname.split('.')[1])
        tidx = int(bname.split('.')[2])
        with open('INCAR') as fp:
            incar = fp.read()
            incar0 = Incar.from_string(incar)
            # make_fake_md: the frames in a system shares the same ele_temp
            incar1 = Incar.from_string(
                vasp_incar_ele_temp_ref %
                (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt))
            for ii in incar0.keys():
                # skip checking nbands...
                if ii == 'NBANDS':
                    continue
                testCase.assertAlmostEqual(incar0[ii],
                                           incar1[ii],
                                           msg='key %s differ' % (ii),
                                           places=5)
        os.chdir(cwd)
コード例 #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)
コード例 #3
0
def test_get_defect_charge_state(tmpdir):
    tmpdir.chdir()
    structure = Structure(Lattice.cubic(10), ["H", "He"],
                          [[0.0] * 3, [0.5] * 3])
    fake_potcar_str = """ PAW_PBE H 15Jun2001                    
   1.00000000000000     
 parameters from PSCTR are:
   VRHFIN =H: ultrasoft test
   LEXCH  = PE
   TITEL  = PAW_PBE H 15Jun2001
   POMASS =    1.000; ZVAL   =    1.000    mass and valenz
   ENMAX  =  250.000; ENMIN  =  200.000 eV

   END of PSCTR-controll parameters
 End of Dataset
      PAW_PBE He_pv 15Jun2001                    
   1.00000000000000     
 parameters from PSCTR are:
   VRHFIN =He: ultrasoft test
   LEXCH  = PE
   TITEL  = PAW_PBE He_pv 15Jun2001
   POMASS =    1.000; ZVAL   =    1.000    mass and valenz
   ENMAX  =  250.000; ENMIN  =  200.000 eV

   END of PSCTR-controll parameters
 End of Dataset
 """
    Path("POTCAR").write_text(fake_potcar_str)
    potcar = Potcar.from_file("POTCAR")
    incar = Incar.from_string("NELECT = 1")
    assert get_defect_charge_state(Poscar(structure), potcar, incar) == 2 - 1

    structure = Structure(Lattice.cubic(10), ["H", "He", "H", "H"],
                          [[0.0] * 3, [0.2] * 3, [0.4] * 3, [0.6] * 3])
    with pytest.raises(ValueError):
        get_defect_charge_state(Poscar(structure), potcar, incar)

    incar = Incar.from_string("")
    assert get_defect_charge_state(Poscar(structure), potcar, incar) == 0