Example #1
0
def main():

    atoms_ref = vf.my_read_vasp('../y_full_relax/CONTCAR')  # for strain
    natoms = atoms_ref.get_positions().shape[0]

    dirlist = [
        'y_convergence_encut',
        'y_convergence_kp',
        'y_convergence_sigma',
    ]

    ljobn = []  # list of data
    lEtot = []
    lEent = []

    for i in np.arange(len(dirlist)):
        dirn = dirlist[i]
        print(dirn)

        os.chdir(dirn)
        jobn, Etot, Eent, pres = vf.vasp_read_post_data()
        os.chdir('..')

        x = np.array([])
        for j in np.arange(len(jobn)):
            temp = float(jobn[j])
            x = np.append(x, temp)

        ljobn.append(x)
        lEtot.append(Etot / natoms)
        lEent.append(Eent / natoms)

    plot_convergence(ljobn, lEtot, lEent)
def vasp_create_hcp_prism1(a, ca, ncell, bp=33):
    print('==> create hcp prism plane: ')
    print(a, ca, ncell, bp)

    ncell2 = ncell.copy()
    for i in np.arange(3):
        ncell2[i] = ncell[np.mod(i + 2, 3)]

    vasp_create_hcp_basal(a, ca, ncell2, bp=0)

    atoms = vf.my_read_vasp('POSCAR')
    atoms = vf.make_SFP_xy(atoms, i1=1)
    atoms = vf.make_a3_ortho(atoms)

    if bp == 33:
        print('==> create prism1-W')
        atoms.positions = atoms.positions + np.array([0, 0, 0.1]) * a
        atoms.wrap()

    elif bp == -33:
        print('==> create prism1-N')
        atoms.positions = atoms.positions + np.array([0, 0, -0.1]) * a
        atoms.wrap()

    atoms.pos_a0 = a
    vf.my_write_vasp(atoms, filename='POSCAR', vasp5=True)
def run_MC_case(nstep=1000, T_list=[300.0, 1500.0], \
    EPI_filename='y_post_EPI.beta_4.txt', \
    pos_filename='CONTCAR'):

    EPI_beta = np.loadtxt(EPI_filename)
    atoms = vf.my_read_vasp(pos_filename)
    for T in np.array(T_list):
        print('==> MC starts, with T:', T)
        MC_swap_with_EPI(atoms, EPI_beta, T, nstep)
def shift_to_complete_layers():

    atoms = vf.my_read_vasp(filename='CONTCAR')

    nlayers, nmiss = check_layers(atoms)

    if nmiss > 0.1:
        print('==> shift to POSCAR_layer, nmiss:', nmiss)
        shift_to_poscar_layer(nmiss)
    else:
        print('==> no shift needed. ')
def shift_to_poscar_layer(nmiss):
    atoms = vf.my_read_vasp(filename='CONTCAR')

    z = atoms.get_positions()[:, -1]
    z.sort()
    natoms = len(z)

    latt33 = atoms.get_cell()[2, 2]

    temp1 = latt33 - z[int(-1 * nmiss)]
    temp2 = z[int(-1 * nmiss)] - z[int(-1 * nmiss - 1)]

    zshift = temp1 + 0.5 * temp2

    pos = atoms.get_positions()
    pos[:, 2] = pos[:, 2] + zshift
    atoms.set_positions(pos)
    atoms.wrap()

    vf.my_write_vasp(atoms, filename='POSCAR_layer', vasp5=True)

    # check
    atoms2 = vf.my_read_vasp('POSCAR_layer')
    atoms3 = vf.my_read_vasp('CONTCAR')

    latt = atoms2.get_cell()[:]
    vf.confirm_0(latt - atoms3.get_cell()[:])

    dpos = atoms2.get_positions() - atoms3.get_positions()

    dposD = dpos @ np.linalg.inv(latt)
    dposD = dposD - np.around(dposD)
    dpos = dposD @ latt

    for i in np.arange(3):
        dpos[:, i] = dpos[:, i] - dpos[:, i].mean()

    vf.confirm_0(dpos)
def main():

    atoms_ref = vf.my_read_vasp('../y_full_relax/CONTCAR')  # for strain

    dirlist = [
        'y_cij_energy_c11',
        'y_cij_energy_c12',
        'y_cij_energy_c13',
        'y_cij_energy_c33',
        'y_cij_energy_c44',
    ]

    ldata = []  # list of data

    for i in np.arange(len(dirlist)):
        dirn = dirlist[i]
        print(dirn)
        data = read_deform_data(dirn, atoms_ref)
        ldata.append(data)

    check_ldata(ldata)

    plot_cij_energy(ldata)
def calc_gamma_s(EPI_beta, pos_filename, a_fcc, b_slip):

    atoms = vf.my_read_vasp( pos_filename )
    latt = atoms.get_cell()[:]
    natoms = atoms.get_positions().shape[0]

    b = atoms.pos_a0/np.sqrt(2)
    nx = np.around( latt[0,0]/b )
    vf.confirm_int(nx)
    nx = int(nx)
        
    nlayers, nmiss = vf_shift.check_layers(filename = pos_filename)
    vf.confirm_0(nmiss)
    nz = nlayers

    E_s = calc_E_s(atoms, nx, nz, EPI_beta, b_slip)
    
    vf.confirm_0( E_s.shape - np.array([nz/6, 2]) )

    qe = vf.phy_const('qe')
    gamma_s = E_s/(natoms/nz) / (np.sqrt(3)/2*a_fcc**2/2) *qe*1e23

    return gamma_s, nz
def calc_pairs_per_shell_from_CONTCAR(shellmax=4):

    atoms = vf.my_read_vasp('CONTCAR')
    calc_pairs_per_shell(atoms, shellmax=shellmax)
def analyze_dump(jobname):

    atoms = vf.my_read_vasp('../CONTCAR')
    nelem = atoms.get_nelem()

    EPI_beta = np.loadtxt('../y_post_EPI.beta_4.txt')

    # extend EPIs to 10 shells
    if nelem == 2:
        EPI_beta = np.append(EPI_beta, np.zeros(11 - len(EPI_beta)))

    else:
        shellmax = calc_shellmax(atoms, EPI_beta)

        temp = int((len(EPI_beta) - 1) / shellmax * (10 - shellmax))
        temp2 = np.zeros(temp)

        EPI_beta = np.append(EPI_beta, temp2)

    print('==> extended EPI_beta:')
    print(EPI_beta)

    os.system('ls POSCAR_step_* > tmp_filelist')
    f = open('tmp_filelist', 'r')

    dp_shell_tot = np.zeros(len(EPI_beta) - 1)
    WC_SRO_tot = np.zeros(len(EPI_beta) - 1)

    for line in f:
        filename = line.strip('\n')
        print(filename)
        atoms = vf.my_read_vasp(filename)

        dp_shell = plot_dp_shell(atoms, EPI_beta=EPI_beta)
        dp_shell_tot = np.vstack([dp_shell_tot, dp_shell])

        filename2 = 'y_post_dp_shell_%s.pdf' % (filename)
        os.rename('y_post_dp_shell.pdf', filename2)

        os.remove('y_post_dp_shell.txt')

        filename2 = 'y_post_WC_SRO_shell.txt'
        temp = np.loadtxt(filename2)
        WC_SRO_tot = np.vstack([WC_SRO_tot, temp])
        os.remove(filename2)

    os.remove('tmp_filelist')

    dp_shell_tot = np.delete(dp_shell_tot, 0, 0)
    print('==> dp_shell_tot.shape[0]:', dp_shell_tot.shape[0])

    dp_shell_avg = np.mean(dp_shell_tot, axis=0)
    filename2 = 'y_post_dp_shell_avg_%s.txt' % (jobname)
    np.savetxt(filename2, dp_shell_avg)

    plot_dp_shell(atoms, EPI_beta, dp_shell=dp_shell_avg)
    filename2 = 'fig_dp_shell_avg_%s.pdf' % (jobname)
    os.rename('y_post_dp_shell.pdf', filename2)

    WC_SRO_tot = np.delete(WC_SRO_tot, 0, 0)
    print('==> WC_SRO_tot.shape[0]:', WC_SRO_tot.shape[0])

    WC_SRO_avg = np.mean(WC_SRO_tot, axis=0)
    filename2 = 'y_post_WC_SRO_shell_avg_%s.txt' % (jobname)
    np.savetxt(filename2, WC_SRO_avg)

    plot_dp_shell(atoms, EPI_beta, dp_shell=WC_SRO_avg, dp_type='SRO')
    filename2 = 'fig_WC_SRO_shell_avg_%s.pdf' % (jobname)
    os.rename('y_post_WC_SRO_shell.pdf', filename2)