コード例 #1
0
ファイル: elastic.py プロジェクト: Baijianlu/AICON2
 def Get_ElasConst(self, filepath):
     outcar = Outcar(filepath + "OUTCAR")
     outcar.read_elastic_tensor()
     self.tensor = np.array(outcar.data["elastic_tensor"]) / 10       #unit in GPa
コード例 #2
0
ファイル: vaspout.py プロジェクト: wangvei/maptool
def elastic_analysis():

    filename = 'OUTCAR'
    step_count = 1
    check_file(filename)
    proc_str = "Reading Data From " + filename + " File ..."
    procs(proc_str, step_count, sp='-->>')
    outcar = Outcar(filename)
    outcar.read_elastic_tensor()
    cij_tensor = np.array(outcar.data['elastic_tensor'])

    filename = 'vasprun.xml'
    step_count += 1
    check_file(filename)
    proc_str = "Reading Data From " + filename + " File ..."
    procs(proc_str, step_count, sp='-->>')
    vsr = Vasprun(filename)
    struct0 = vsr.structures[0]
    natom = struct0.num_sites
    weight = struct0.composition.weight
    volume = struct0.lattice.volume

    ## converting the units
    volume *= 1.0e-30  ## from Angstrom to meters
    weight *= weight * 1.0e-3  ## from gram to kg
    density = weight / (volume * Avogadro)

    asa = analyzer.SpacegroupAnalyzer(struct0)
    #   lat_type=asa.get_crystal_system()

    crys_type = asa.get_lattice_type()

    ## Redefining the Cij matrix into the correct Voigt notation since VASP's OUTCAR has a different order
    ## In VASP: Columns and rows are listed as: 1, 2, 3, 6, 4, 5
    ## In this format OUTCAR's C44 values would be actually C66, C55 would be C44, and C66 would be C55.
    ## OUTCAR follows the below order:
    ## [C11 C12 C13 C16 C14 C15]
    ## [C21 C22 C23 C26 C24 C25]
    ## [C31 C32 C33 C36 C34 C35]
    ## [C61 C62 C63 C66 C64 C65]
    ## [C41 C42 C43 C46 C44 C45]
    ## [C51 C52 C53 C56 C54 C55]

    cnew = np.zeros((6, 6))
    snew = np.zeros((6, 6))
    cnew = np.copy(cij_tensor)

    for j in range(0, 6):
        cnew[3][j] = cij_tensor[4][j]
        cnew[4][j] = cij_tensor[5][j]
        cnew[5][j] = cij_tensor[3][j]

    ctemp = np.zeros((6, 6))
    ctemp = np.copy(cnew)

    for i in range(0, 6):
        cnew[i][3] = cnew[i][4]
        cnew[i][4] = cnew[i][5]
        cnew[i][5] = ctemp[i][3]

    # Change the units of Cij from kBar to GPa
    cnew = cnew / 10.0
    proc_str = "\n Modified elastic tensor in correct order (in GPa units)"
    print(proc_str)
    fmt = "%7.3f " * 6
    for i in range(6):
        print(fmt % tuple(cnew[i, :]))

    def check_symmetric(a, tol=1e-8):
        return np.allclose(a, a.T, atol=tol)

    print(
        '\n Checking if the elastic tensor is symmetric: i.e. Cij = Cji:  %5s'
        % check_symmetric(cnew))
    print("\n Eigen Values of the elastic tensor:")
    evals = LA.eigvals(cnew)
    print(fmt % tuple(evals))
    if np.all(evals) > 0.0:
        print("\n All eigen values are positive indicating elastic stability.")
    else:
        print(
            "\n ATTENTION: One or more eigen values are negative indicating elastic instability."
        )
    calc_elastic_prop(cnew, snew, crys_type, density, weight, natom)