def test_kpts(self,kw={}):
     start,end,step = kw.get('start'),kw.get('end'),kw.get('step')
     is_login_node,kw = run_vasp.clean_parse(kw,'is_login_node',False)
     kw.pop('start');kw.pop('end');kw.pop('step')
     kpts = Kpoints()
     kpts_list = set()
     kppa_list = []
     for kppa in range(start,end,step):
         kpts.automatic_density(structure=read_vasp(self.poscar),kppa=kppa)
         if tuple(kpts.kpts[0]) not in kpts_list:
             kpts_list.add(tuple(kpts.kpts[0]))
             kppa_list.append(kppa)
     idx = 0
     for kppa in kppa_list:
         _kw = kw.copy()
         if 'style' not in _kw:
             _kw.update({'kppa':kppa,'style':'auto','job_name':'test_kpts'+str(idx),'NSW':0})
         prep_vasp.prep_single_vasp(poscar=self.poscar,kw=_kw)
         idx += 1
     for i in range(idx):
         run_vasp.run_single_vasp(job_name='test_kpts'+str(i),is_login_node=is_login_node)
     kpts_res = []
     for ii in range(len(kppa_list)):
         EV = ExtractValue(data_folder='test_kpts'+str(ii))
         kpts_res.append([kppa_list[ii],EV.get_energy(),EV.get_cpu_time()])
     with open('test_kpts.txt','w') as f:
         f.writelines('KPTS\tEnergy\tcpu_time\n')
         for line in kpts_res:
             f.writelines(str(line[0])+'\t'+str(line[1])+'\t'+str(line[2])+'\n')
Beispiel #2
0
def write_kpoints(poscar='POSCAR', kw={}):
    if not path.isfile(poscar):
        raise FileNotFoundError('Not found POSCAR')
    stru = read_vasp(poscar)
    style, kw = clean_parse(kw, 'style', 'auto')
    if not path.isfile('KPOINTS'):
        _kpts = Kpoints()
        if 'auto' in style.lower():
            if 'kpts' not in kw:
                kppa, kw = clean_parse(kw, 'kppa', 3000)
                kppa = float(kppa)
                _kpts.automatic_density(structure=stru, kppa=kppa)
                _kpts.write_file('KPOINTS')
            else:
                kpts, kw = clean_parse(kw, 'kpts', (1, 1, 1))
                shift, kw = clean_parse(kw, 'shift', (0, 0, 0))
                _kpts.gamma_automatic(kpts=kpts, shift=shift)
                _kpts.write_file('KPOINTS')
        elif 'gamma' in style.lower() and 'kpts' not in kw:
            kppa, kw = clean_parse(kw, 'kppa', 3000)
            kppa = float(kppa)
            _kpts.automatic_gamma_density(structure=stru, kppa=kppa)
            _kpts.write_file('KPOINTS')
        elif 'gamma' in style.lower() and 'kpts' in kw:
            kpts, kw = clean_parse(kw, 'kpts', (1, 1, 1))
            shift, kw = clean_parse(kw, 'shift', (0, 0, 0))
            _kpts.gamma_automatic(kpts=kpts, shift=shift)
            _kpts.write_file('KPOINTS')
        elif 'monk' in style.lower() and 'kpts' in kw:
            kpts, kw = clean_parse(kw, 'kpts', (1, 1, 1))
            shift, kw = clean_parse(kw, 'shift', (0, 0, 0))
            _kpts.monkhorst_automatic(kpts=kpts, shift=shift)
            _kpts.write_file('KPOINTS')
        elif 'band' in style.lower() or 'line' in style.lower():
            num_kpts, kw = clean_parse(kw, 'num_kpts', 16)
            _kpts.automatic_linemode(structure=stru, num_kpts=num_kpts)
            _kpts.write_file('KPOINTS')
    return kw