How to use the ovito.modifiers.CommonNeighborAnalysisModifier.Mode.AdaptiveCutoff function in ovito

To help you get started, we’ve selected a few ovito examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyiron / pyiron / pyiron / atomistics / structure / ovito.py View on Github external
"""

    Args:
        atoms:
        mode:

    Returns:

    """
    s.publication_add(publication())
    if not mode in ['total', 'numeric', 'str']:
        raise ValueError('Unsupported mode')
    data = DataCollection.create_from_ase_atoms(atoms.copy())
    node = ObjectNode()
    node.source = data
    node.modifiers.append(CommonNeighborAnalysisModifier(mode=CommonNeighborAnalysisModifier.Mode.AdaptiveCutoff))
    output = node.compute()
    if mode == 'total':
        return output.attributes
    else:
        atoms_output = output.to_ase_atoms()
        if mode == 'numeric':
            return atoms_output.get_array("Structure Type")
        elif mode == 'str':
            cna_property = output.particle_properties.structure_type
            return np.array([cna_property.get_type_by_id(cnatype).name
                             for cnatype in atoms_output.get_array("Structure Type")])