ovito.io.ase

This module provides functions for interfacing with the ASE (Atomistic Simulation Environment). It contains two high-level functions for converting atomistic data back and forth between OVITO and ASE:

Note

Using the functions of this module will raise an ImportError if the ASE package is not installed in the current Python interpreter. Note that the built-in Python interpreter of OVITO does not contain the ASE package by default. It is therefore recommended to build OVITO from source (as explained in the user manual), allowing you to import all packages available to the system Python interpreter.

ovito.io.ase.ovito_to_ase(data_collection)

Constructs an ASE Atoms object from the particle data in an existing OVITO DataCollection.

Param:data_collection: The OVITO DataCollection to convert.
Returns:An ASE Atoms object containing the converted particle data from the source DataCollection.

Usage example:

from ovito.io import import_file
from ovito.io.ase import ovito_to_ase

# Create an OVITO data pipeline from an external file:
pipeline = import_file('input/simulation.dump')

# Evaluate pipeline to obtain a DataCollection:
data = pipeline.compute()

# Convert it to an ASE Atoms object:
ase_atoms = ovito_to_ase(data)
ovito.io.ase.ase_to_ovito(atoms)

Converts an ASE Atoms object to an OVITO DataCollection.

Parameters:atoms – The ASE Atoms object to be converted.
Returns:A new DataCollection containing the converted data.

Usage example:

from ovito.pipeline import StaticSource, Pipeline
from ovito.io.ase import ase_to_ovito
from ase.atoms import Atoms

# The ASE Atoms object to convert:
ase_atoms = Atoms('CO', positions=[(0, 0, 0), (0, 0, 1.1)])

# Convert the ASE object to an OVITO DataCollection:
data = ase_to_ovito(ase_atoms)

# We may now create a Pipeline object with a StaticSource and use the 
# converted dataset as input for a data pipeline:
pipeline = Pipeline(source = StaticSource())
pipeline.source.assign(data)