예제 #1
0
make_amp2_log_default(dir_band,src_path,'Band calculation with '+pot_type+' potential.',node,code_data)

# check relax calculation
no_rlx = 0
if not os.path.isdir(dir+'/relax_'+pot_type):
    make_amp2_log(dir_band,'Directory of relaxation does not exist.')
    no_rlx = 1
else:
    if not os.path.isfile(dir+'/relax_'+pot_type+'/CONTCAR'):
        make_amp2_log(dir_band,'CONTCAR file in relaxation does not exist.')
        no_rlx = 1
    elif count_line(dir+'/relax_'+pot_type+'/CONTCAR') < 9:
        make_amp2_log(dir_band,'CONTCAR file in relaxation is invalid.')
        no_rlx = 1

if no_rlx == 1 and set_on_off(inp_band['relax_check']) == 1:
    print(0)
    sys.exit()
# potential type is HSE
if pot_type == 'HSE':
    if no_rlx == 1:
        copy_input(dir+'/INPUT0',dir_band,POT)
    else:
        copy_input_cont(dir+'/relax_'+pot_type,dir_band)
    shutil.copy(dir+'/INPUT0/sym',dir_band+'/.')

    # make INCAR for CHGCAR
    incar_from_yaml(dir_band,inp_band['incar'])
    if no_rlx == 1:
        mag_on = 2
    else:
예제 #2
0
파일: dielectric.py 프로젝트: wangvei/AMP2
                      node, code_data)

no_rlx = 0
# check relax calculation
if not os.path.isdir(dir + '/relax_' + POT):
    make_amp2_log(dir_diel, 'Relax directory does not exist.')
    no_rlx = 1
else:
    if not os.path.isfile(dir + '/relax_' + POT + '/CONTCAR'):
        make_amp2_log(dir_diel, 'CONTCAR file in relaxation does not exist.')
        no_rlx = 1
    elif count_line(dir + '/relax_' + POT + '/CONTCAR') < 9:
        make_amp2_log(dir_diel, 'CONTCAR file in relaxation is invalid.')
        no_rlx = 1

if no_rlx == 1 and set_on_off(inp_diel['relax_check']) == 1:
    print(0)
    sys.exit()

# check band gap calculation
if set_on_off(inp_diel['metal_check']) == 1:
    if os.path.isfile(dir + '/band_' + POT + '/Band_gap.log'):
        with open(dir + '/band_' + POT + '/Band_gap.log', 'r') as inp:
            gap_log = inp.readline()
    elif os.path.isfile(dir + '/band_GGA/Band_gap.log'):
        with open(dir + '/band_GGA/Band_gap.log', 'r') as inp:
            gap_log = inp.readline()
    else:
        make_amp2_log(dir_diel, 'Band gap calculation should be performed.')
        print(0)
        sys.exit()
예제 #3
0
if not os.path.isdir(dir + '/magnetic_ordering'):
    os.mkdir(dir + '/magnetic_ordering', 0755)
    make_amp2_log_default(dir + '/magnetic_ordering', src_path,
                          'Magnetic ordering', node, code_data)
    make_amp2_log(dir + '/magnetic_ordering', 'New calculation.')
else:
    make_amp2_log_default(dir + '/magnetic_ordering', src_path,
                          'Magnetic ordering', node, code_data)
    make_amp2_log(dir + '/magnetic_ordering', 'Calculation continue.')

os.chdir(dir + '/magnetic_ordering')
target = dir + '/magnetic_ordering'

### Check magnetic elements
# define path for OUTCAR and POSCAR (atom type should be including (! xx1))
if set_on_off(inp_af['from_relax']) == 1:
    if os.path.isfile(dir + '/INPUT0/POSCAR_rlx_' + pot_type):
        make_amp2_log(
            target, 'Magnetic elements are determined by OUTCAR in relax_' +
            pot_type + '.')
        ref_dir = dir + '/relax_' + pot_type
        inp_pos = dir + '/INPUT0/POSCAR_rlx_' + pot_type
    else:
        make_amp2_log(target, 'Cannot find relaxed POSCAR.')
        print 0
        sys.exit()
else:
    ref_dir = ''
    inp_pos = dir + '/INPUT0/POSCAR'
    if os.path.isdir(dir + '/cutoff') and os.path.isfile(dir +
                                                         '/cutoff/cutoff.log'):
예제 #4
0
make_amp2_log(target,
              'It is metallic system. We rerun the calculation without U.')
# Modify U_note
with open(target + '/INPUT0/U_note', 'w') as out:
    out.write(' ')
# Modify INCAR
make_incar(target + '/INPUT0/POSCAR', target, src_path,
           inp_yaml['cif2vasp']['max_nelm'])

if os.path.isfile(target + '/INPUT0/CHGCAR_conv'
                  ):  #Calculation with U would not have convergence problem
    os.remove(target + '/INPUT0/CHGCAR_conv')

calc_out = 0

if set_on_off(cal_dic['kp_test']) == 1:
    try:
        notice = subprocess.check_output(
            [pypath, src_path + '/kpoint.py', target, inp_file, node, nproc],
            universal_newlines=True)
    except:
        notice = '0'
    if not notice.splitlines()[-1][0] == '1':
        shutil.move(target, ERROR_path + '/' + target.split('/')[-1])
        sys.exit()

# check existance of follow calculation and K-pts file
if 1 in list(
        cal_dic.values()) and not os.path.isfile(target + '/INPUT0/KPOINTS'):
    make_amp2_log(target,
                  'Warning!!! KPOINTS file should be located in INPUT0.')
예제 #5
0
    ncl = pygrep('NONCOL', dir_hse + '/OUTCAR', 0, 0).split()[2]
    [KPT, Band, nelect] = EIGEN_to_array(dir_hse + '/EIGENVAL', spin)
    fermi = get_fermi_level(Band, nelect, ncl)

    # Band gap calculation
    gap = gap_estimation(dir_hse, fermi, spin, ncl, KPT, Band, nelect)
    if gap == 'metal':
        make_amp2_log(dir_hse,
                      'HSE band gap calculation is done but it is metallic.')
        gap = '0.0'
    else:
        make_amp2_log(dir_hse,
                      'HSE band gap calculation is done.\nBand gap is ' + gap)

    # Small gap correction
    if set_on_off(
            inp_hse['band_structure_correction']) == 1 and float(gap) > 0.01:
        dir_band = dir + '/band_' + pot_point
        # Insulator in GGA. Band reodering is not required.
        if not 'etal' in gap_log:
            ncl = pygrep('NONCOL', dir_band + '/OUTCAR', 0, 0).split()[2]
            spin = pygrep('ISPIN', dir_band + '/OUTCAR', 0, 0).split()[2]
            [KPT, Band, nelect] = EIGEN_to_array(dir_band + '/EIGENVAL', spin)
            fermi = get_fermi_level(Band, nelect, ncl)
            [vb_idx, cb_idx, eVBM, eCBM] = find_cb_gap(Band, fermi, dir_band)
            E_shift = float(gap) + eVBM - eCBM
            for i in range(len(Band[0][0])):
                for n in cb_idx[i]:
                    for k in range(len(KPT)):
                        Band[n][k][i] = Band[n][k][i] + E_shift
            plot_band_corrected_structure(
                spin, Band, eVBM, dir_band + '/xtic.dat',