Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def analyse_ovito_cna_adaptive(atoms, mode='total'):
"""
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")])
def pyiron_to_ovito(atoms):
"""
Args:
atoms:
Returns:
"""
try:
from ovito.data import DataCollection
return DataCollection.create_from_ase_atoms(atoms)
except ImportError:
raise ValueError('ovito package not yet installed')
def analyse_ovito_centro_symmetry(atoms, num_neighbors=12):
"""
Args:
atoms:
num_neighbors:
Returns:
"""
s.publication_add(publication())
data = DataCollection.create_from_ase_atoms(atoms.copy())
node = ObjectNode()
node.source = data
node.modifiers.append(CentroSymmetryModifier(num_neighbors = num_neighbors))
output = node.compute()
return output.particle_properties['Centrosymmetry'].array
def pyiron_to_ovito(atoms):
"""
Args:
atoms:
Returns:
"""
try:
from ovito.data import DataCollection
return DataCollection.create_from_ase_atoms(atoms)
except ImportError:
raise ValueError('ovito package not yet installed')
def atoms_to_data(atoms):
data = DataCollection()
cell_matrix = np.zeros((3,4))
cell_matrix[:, :3] = atoms.get_cell()
cell_matrix[:, 3] = atoms.info.get('cell_origin',
[0., 0., 0.])
cell = SimulationCell(matrix=cell_matrix,
pbc=atoms.get_pbc())
data.addObject(cell)
position = ParticleProperty(name='Position',
type=Particles.ParticleProperty.Type.Position,
array=atoms.get_positions())
data.addObject(position)
return data