# `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:

> - `ovito_to_ase()`

> - `ase_to_ovito()`

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 include the ASE package by default. You can install the ASE module by running `ovitos -m pip install ase` if you are using the embedded Python interpreter of OVITO Pro. Alternatively, if you installed the `ovito` module in your own Python interpreter, simply run `pip3 install ase` to make the ASE package available.

ovito.io.ase.ase_to_ovito(atoms, data_collection=None)

  Converts an ASE Atoms object to an OVITO `DataCollection`.

  Parameters

    - atoms – The ASE Atoms object to be converted.

    - data_collection – An existing `DataCollection` to fill in with the atoms model. New data collection will be created if not provided.

  Returns

    `DataCollection` containing the converted atoms 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(data = data))

ovito.io.ase.ovito_to_ase(data_collection)

  Constructs an ASE Atoms object from the particle data in an 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)