def average_coordination_number(structures, freq=10):
    """
    Calculates the ensemble averaged Voronoi coordination numbers
    of a list of Structures using VoronoiNN.
    Typically used for analyzing the output of a Molecular Dynamics run.
    Args:
        structures (list): list of Structures.
        freq (int): sampling frequency of coordination number [every freq steps].
    Returns:
        Dictionary of elements as keys and average coordination numbers as values.
    """
    coordination_numbers = {}
    for spec in structures[0].composition.as_dict().keys():
        coordination_numbers[spec] = 0.0
    count = 0
    for t in range(len(structures)):
        if t % freq != 0:
            continue
        count += 1
        vnn = VoronoiNN()
        for atom in range(len(structures[0])):
            cn = vnn.get_cn(structures[t], atom, use_weights=True)
            coordination_numbers[structures[t][atom].species_string] += cn
    elements = structures[0].composition.as_dict()
    for el in coordination_numbers:
        coordination_numbers[el] = coordination_numbers[el] / elements[
            el] / count
    return coordination_numbers
def average_coordination_number ( structures , freq = 10 ) : coordination_numbers = { } for spec in structures [ 0 ] . composition . as_dict ( ) . keys ( ) : coordination_numbers [ spec ] = 0.0 count = 0 for t in range ( len ( structures ) ) : if t % freq != 0 : continue count += 1 vnn = VoronoiNN ( ) for atom in range ( len ( structures [ 0 ] ) ) : cn = vnn . get_cn ( structures [ t ] , atom , use_weights = True ) coordination_numbers [ structures [ t ] [ atom ] . species_string ] += cn elements = structures [ 0 ] . composition . as_dict ( ) for el in coordination_numbers : coordination_numbers [ el ] = coordination_numbers [ el ] / elements [ el ] / count return coordination_numbers
Calculates the ensemble averaged Voronoi coordination numbers
    of a list of Structures using VoronoiNN.
    Typically used for analyzing the output of a Molecular Dynamics run.
    Args:
        structures (list): list of Structures.
        freq (int): sampling frequency of coordination number [every freq steps].
    Returns:
        Dictionary of elements as keys and average coordination numbers as values.