コード例 #1
0
ファイル: helping_functions.py プロジェクト: mehese/scripts
def get_similar(at, str_x, verbose=False):
    """ Find equivalent atoms in structures
    (atom, AtomStruct) -> int, Atom

    Given an atom at an index i = index + 1, the routine looks for the closest
    match in str_out.

    WARNING -- DOESN'T CHECK NEAR BOX EDGES, SO IT MIGHT POSE PROBLEMS FOR
    ATOMS NEAR THE BOX BOUNDARIES
    """
    d_min, i_x, at_x = 1e+10, None, None
    for i in range(len(str_x)):
        d_ = distance(at, str_x.atoms[i])
        if (d_ < d_min) and (str_x.atoms[i].species == at.species):
            d_min = d_
            at_x = str_x.atoms[i]
            i_x = i
    if verbose:
        print 'd({}, {}) = {}'.format(at, at_x, d_min)
    return i_x, at_x
コード例 #2
0
ファイル: plot_ud_diff.py プロジェクト: mehese/scripts
for c in ['c'+ i for i in map(str, range(2, 7))]:
    print c,
    for eprime in eprime_dict[c]:
        print eprime,
        x, y_u, y_d = get_at_pdos(c, eprime)
        x = [o(p) for p in x]
        plt.plot(x, y_u, 'k-', linewidth=2)
        nps, = plt.plot(x, y_d, 'k-', label='Unpassivated', linewidth=2)
        # Get the Atom object of the eprime
        at_e = ReadStruct('../../crystal_files/INPUT_'+c,
                          'crystal').atoms[eprime-1]
        p_str= ReadStruct('../../crystal_files/INPUT_'+c+'p', 'crystal')
        # get equivalent atom from passified structure
        i_x, at_p = get_similar(at_e, p_str)
        print '{:5.3f}'.format(distance(at_e, at_p)), 
        x, y_u, y_d = get_at_pdos(c+'p', i_x)
        x = [o(p) for p in x]
        plt.plot(x, y_u, 'r-', linewidth=2.5)
        ps,= plt.plot(x, y_d, 'r-', label='H passivated', linewidth=2.5)
    print

minor_locator = MultipleLocator(0.10)
plt.gca().xaxis.set_minor_locator(minor_locator)
plt.gca().tick_params(which='minor', length=5, width=2)
plt.gca().tick_params(which='major', length=10, width=2, labelsize=15)

plt.legend(handles=[nps, ps], ncol=2, fontsize=20)
plt.axvspan(o(-5),o(-3.313), facecolor='0.85', linewidth=0)
plt.axvspan(o(-2.27),o(0.0), facecolor='0.85', linewidth=0)
plt.xlim([o(-5), o(0)])
コード例 #3
0
ファイル: plot_OSiO.py プロジェクト: mehese/scripts
}

for c in ["c" + i for i in map(str, range(2, 7))]:
    print c,
    for eprime in dimer_dict[c]:
        print eprime,
        x, y_u, y_d = get_at_pdos(c, eprime)
        x = [o(p) for p in x]
        plt.plot(x, y_u, "k-", linewidth=2)
        nps, = plt.plot(x, y_d, "k-", label="Unpassivated", linewidth=2)
        # Get the Atom object of the eprime
        at_e = ReadStruct("../../crystal_files/INPUT_" + c, "crystal").atoms[eprime - 1]
        p_str = ReadStruct("../../crystal_files/INPUT_" + c + "p", "crystal")
        # get equivalent atom from passified structure
        i_x, at_p = get_similar(at_e, p_str)
        print "{:5.3f}".format(distance(at_e, at_p)),
        x, y_u, y_d = get_at_pdos(c + "p", i_x)
        x = [o(p) for p in x]
        plt.plot(x, y_u, "r-", linewidth=2.5)
        ps, = plt.plot(x, y_d, "r-", label="H passivated", linewidth=2.5)
    print

minor_locator = MultipleLocator(0.10)
plt.gca().xaxis.set_minor_locator(minor_locator)
plt.gca().tick_params(which="minor", length=5, width=2)
plt.gca().tick_params(which="major", length=10, width=2, labelsize=15)

plt.legend(handles=[nps, ps], ncol=2, fontsize=20)
plt.axvspan(o(-5), o(-3.313), facecolor="0.85", linewidth=0)
plt.axvspan(o(-2.27), o(0.0), facecolor="0.85", linewidth=0)
plt.xlim([o(-5), o(0)])