Exemplo n.º 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)
Exemplo n.º 2
0
def main():
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    njobs = len(jobn)

    if njobs < 0.5:
        sys.exit('ABORT. no jobs found. ')

    atoms = vf.get_list_of_atoms()

    E0 = np.array([])
    V = np.array([])
    V0 = np.array([])
    p = np.array([])

    for i in np.arange(njobs):
        natoms = len(atoms[i].get_positions())

        E0 = np.append(E0, Etot[i] / natoms)

        temp = atoms[i].get_volume()
        V = np.append(V, temp)
        V0 = np.append(V0, temp / natoms)

        p = np.append(p, np.mean(pres[i, 0:3]))

    write_output(jobn, E0, V, V0, p)
Exemplo n.º 3
0
def main():
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    latoms2 = vf.get_list_of_outcar()

    try: 
        latoms2[0].get_magnetic_moments()
        plot_output(latoms2, jobn)
    except:
        print('==> no mag info.')
Exemplo n.º 4
0
def get_list_of_outcar():
    from ase.io.vasp import read_vasp_out

    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    latoms2 = []  # list of ASE_Atoms from OUTCAR
    for i in jobn:
        filename = './y_dir/%s/OUTCAR' % (i)
        atoms2 = read_vasp_out(filename)
        latoms2.append(atoms2)
    return latoms2
Exemplo n.º 5
0
def get_list_of_atoms():
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    latoms = []  # list of ASE_Atoms from CONTCAR

    os.chdir('y_dir')
    for i in np.arange(len(jobn)):
        os.chdir(jobn[i])
        atoms = my_read_vasp('CONTCAR')
        latoms.append(atoms)
        os.chdir('..')
    os.chdir('..')

    return latoms
def main():
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()

    ASE_Atoms = read_vasp('../y_full_relax/CONTCAR')
    atoms_pos = ASE_Atoms.get_positions()
    natoms = atoms_pos.shape[0]

    V0 = np.linalg.det(ASE_Atoms.cell) / natoms
    Etot = Etot / natoms

    latoms = vf.get_list_of_atoms()
    latoms2 = vf.get_list_of_outcar()

    V = np.array([])
    magtot = np.array([])
    for i in np.arange(len(latoms)):
        temp = latoms[i].get_volume() / natoms
        V = np.append(V, temp)

        if np.abs(temp - V0) < 1e-10:
            E0 = Etot[i]

        try:
            temp = latoms2[i].get_magnetic_moment() / natoms
        except:
            temp = 0
        magtot = np.append(magtot, temp)

    magtot = np.abs(magtot)

    # scale
    k = np.array([])
    for i in np.arange(len(jobn)):
        k = np.append(k, float(jobn[i]))

    if np.linalg.norm(k - (V / V0)**(1 / 3)) > 1e-10:
        sys.exit('==> ABORT. wrong scaling. ')

    # check
    if Etot.min() != E0:
        sys.exit('E0 is wrong. Abort!')

    if Etot[-5:].std() > 5e-4:
        print('WARNING: Eatom might be wrong!')

    Eatom = Etot[-1]
    Ecoh = E0 - Eatom

    Vp, p, VB, B, p0, B0 = calc_p_B(V, Etot, V0)
    write_output(E0, Eatom, Ecoh, V0, p0, B0)
    plot_output(E0, Eatom, Ecoh, V0, k, Etot, Vp, p, VB, B, p0, B0, magtot)
def main():
    qe = vf.phy_const('qe')
    
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    njobs = len(jobn)  # number of jobs

    if njobs < 1.5:
        sys.exit('==> ABORT! more structures needed. ')

    if jobn[0] != '0.00':
        sys.exit('==> ABORT! no reference state. ')
        
    latoms = vf.get_list_of_atoms()
    
    Asf = np.linalg.norm( \
        np.cross(latoms[0].cell[0, :], latoms[0].cell[1, :] ) )

    a11 = latoms[0].cell[0, 0]
    a22 = latoms[0].cell[1, 1]
    
    natoms = latoms[0].get_positions().shape[0]    
    E0bulk = Etot[0] / natoms


    dE, da33 = check_constraints(Etot, latoms)
   
    # check jobname
    k = np.array([])
    for i in np.arange(len(jobn)):
        k = np.append(k, float(jobn[i]) )
     
    if np.linalg.norm( k - da33 ) > 1e-10:
        sys.exit('==> ABORT. wrong jobname. ')


    gamma = dE/Asf *qe*1e23   #[mJ/m^2]
   
    from ase.formula import Formula
    str2 = latoms[0].get_chemical_formula()
    str2 = Formula(str2).format('latex')
    str_all = '%s\n$A =$%.4f $\\mathrm{\\AA}^2$' %(str2, Asf)

 
    #=========================
    write_output(Asf, a11, a22, E0bulk, jobn, dE, gamma, da33)
    plot_output(gamma, da33, str_all)
def read_deform_data(dirn, atoms_ref):

    x = np.array([])  # applied strain, with respect to the ref state
    e_ss_V = np.zeros(6)  # strain components

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

    iref = -1  # id of the ref state

    for i in np.arange(len(jobn)):
        temp = float(jobn[i]) - 1
        x = np.append(x, temp)

        if np.abs(temp) < 1e-10:
            iref = i

        temp = vf.calc_strain(atoms_ref.get_cell()[:], latoms[i].get_cell()[:])
        e_ss_V = np.vstack([e_ss_V, temp])

    if iref < 0:
        os.exit('ABORT: no ref state. ')

    e_ss_V = np.delete(e_ss_V, 0, 0)
    np.savetxt('y_post_calc_strain_all.txt', e_ss_V)
    os.chdir('..')

    # energy density
    Etot = Etot - Etot[iref]
    ed = Etot / latoms[iref].get_volume() * vf.phy_const('qe') * 1e21

    # stress
    s = pres * (-0.1)  # GPa

    temp = s.copy()
    s[:, 3] = temp[:, 4]
    s[:, 4] = temp[:, 5]
    s[:, 5] = temp[:, 3]

    data = {}
    data['e'] = x
    data['ed'] = ed
    data['s'] = s
    data['iref'] = iref
    return data
Exemplo n.º 9
0
def main():
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()

    if Etot.shape[0] < 5.9:
        import sys
        sys.exit("\n==> ABORT: insufficient data \n")

    pres0 = vf.read_pressure('../y_full_relax/OUTCAR')
    temp = np.vstack((pres, pres0))

    s = temp.copy()
    s[:, 3] = temp[:, 4]
    s[:, 4] = temp[:, 5]
    s[:, 5] = temp[:, 3]

    s = s.T * (-0.1)  # stress data, 6*7, [GPa]

    s_d, Cij_d = calc_direct_Cij(s)
    fitres, C14, Cij_cubic, Cij_hcp = calc_fitting_Cij(s)
    write_output(s, s_d, Cij_d, fitres, C14, Cij_cubic, Cij_hcp)
Exemplo n.º 10
0
def post_E_in(deform_type='E_in_2', struc_type='bulk'):

    latoms = vf.get_list_of_atoms()

    nlayers, nmiss = vs.check_layers(latoms[0])
    print(nlayers, nmiss)

    jobn, Etot, Eent, pres = vf.vasp_read_post_data()

    #==========================

    natoms, a, t, tv = calc_a_t(latoms)

    a0, t0 = calc_a0_t0(a, Etot, t)

    A0 = calc_A0(latoms, el=a / a0, deform_type=deform_type)
    V0 = A0 * t0 * nlayers / (nlayers - 1)

    if deform_type == 'E_in_2':
        check_latt12_E_in_2(latoms, jobn)

    elif deform_type == 'E_in_1':
        check_latt12_E_in_1(latoms, jobn)

    sys_name = get_sys_name(latoms[0])

    if struc_type == 'bulk':
        check_latt3_bulk(latoms, t / (nlayers - 1) * nlayers)
        sys_name = '%s, bulk' % (sys_name)

    elif struc_type == 'slab':
        check_latt3_slab(latoms)
        sys_name = '%s, $t_v \\geqslant %.2f~\\mathrm{\AA}$' % (sys_name,
                                                                tv.min())

        d0 = calc_d0(latoms, elt=t / t0)
        plot_E_in_d0(sys_name, d0)

    plot_E_in(natoms, sys_name, Etot, V0, a, a0, t, t0, deform_type)
    write_E_in(natoms, nlayers, sys_name, jobn, Etot, a, t, tv, a0, t0, A0, V0)
def main():
    qe = vf.phy_const('qe')
    
    jobn, Etot, Eent, pres = vf.vasp_read_post_data()
    njobs = len(jobn)  # number of jobs

    if njobs < 1.5:
        sys.exit('==> ABORT! more structures needed. ')

    ibulk=-1
    for i in np.arange(njobs):
        if jobn[i] == 'bulk':
            ibulk = i 
            break

    if ibulk == -1:
        sys.exit('==> ABORT! no reference bulk state. ')
        
    latoms = vf.get_list_of_atoms()
    
    Asf = np.linalg.norm( \
        np.cross(latoms[ibulk].cell[0, :], latoms[ibulk].cell[1, :] ) )
    a11 = latoms[ibulk].cell[0, 0]
    a22 = latoms[ibulk].cell[1, 1]
    
    natoms = latoms[ibulk].get_positions().shape[0]
    E0bulk = Etot[ibulk]/natoms
    V0bulk = latoms[ibulk].get_volume()/natoms

    if np.abs( Asf-a11*a22 ) > 1e-10:
        sys.exit('ABORT: wrong Asf. ')


    dE, da3, dpos_all = check_constraints(Etot, latoms, ibulk)
   
    gamma = dE/Asf *qe*1e23   #[mJ/m^2]
    
    #=========================
    write_output(Asf, a11, a22, E0bulk, V0bulk, jobn, dE, gamma, da3)
    plot_output(jobn, latoms, dpos_all, gamma, Asf, ibulk)
Exemplo n.º 12
0
def main():

    latoms = vf.get_list_of_atoms()
    latoms2 = vf.get_list_of_outcar()

    natoms = latoms[0].get_positions().shape[0]

    V = np.array([]) 
    ca = np.array([])
    magtot = np.array([])

    for i in np.arange(len(latoms)):
        temp = latoms[i].get_volume()/natoms
        V = np.append(V, temp) 
        
        temp = latoms[i].get_cell()[:]
        temp = np.linalg.norm( temp[2,:] ) / np.linalg.norm( temp[0,:] ) 
        ca = np.append(ca, temp) 


        try:
            temp = latoms2[i].get_magnetic_moment()/natoms
        except:
            temp = 0
        magtot = np.append(magtot, temp)
        
    magtot = np.abs(magtot)


    jobn, Etot, Eent, pres = vf.vasp_read_post_data()

    a_pos = np.array([])  # scale in POSCAR
    for i in jobn:
        filename = './y_dir/%s/CONTCAR' %(i)
        with open(filename,'r') as f:
            a_pos = np.append( a_pos, float( f.readlines()[1] ) )

 
    Etot = Etot / natoms
    fitres = myfitting(V, Etot)


    V1 = np.array([])
    a1_pos = np.array([])
    p_dft = np.array([])

    for i in np.arange(len(jobn)):
        p_dft = np.append( p_dft, pres[i,0:2].mean()*(0.1) )  # pressure [GPa]
        
        if jobn[i][0] == '0' or jobn[i][0] == '1' :   
            V1 = np.append( V1, V[i] / float(jobn[i]))
            a1_pos = np.append( a1_pos, a_pos[i] / (float(jobn[i]))**(1/3) )
     
    
    if (V1.std() > 1e-8) or (a1_pos.std() > 1e-8) :
        print('V1, V1.std(), a1_pos.std():')
        print( V1, V1.std(), a1_pos.std()  )
        sys.exit('V1 or a1_pos is wrong. Abort!')
    else:
        V1 = V1.mean()
        a1_pos = a1_pos.mean()

    write_output(V, Etot, fitres, V1, a1_pos, p_dft)
    plot_eos(V, Etot, fitres, p_dft, V1, ca, magtot)


    ASE_eos = EquationOfState(V, Etot, eos='birchmurnaghan')
    temp = np.array([ 
    ASE_eos.fit()[1] - fitres[0], 
    ASE_eos.fit()[0] - fitres[1],
    ASE_eos.fit()[2] - fitres[2] ])
    print('==> check with ASE fitting, diff: {0} \n'.format(temp) )