Skip to content

ASE

mdapy.interop.to_ase and from_ase convert a System to an ase.Atoms and back, with velocities, charges, constraints and the results of a calculation.

from ase.build import bulk
from ase.constraints import FixAtoms
from mdapy.interop import from_ase, to_ase

atoms = bulk("Cu", "fcc", a=3.615, cubic=True).repeat(2)
atoms.set_constraint(FixAtoms(indices=[0, 1]))
system = from_ase(atoms)  # 32 atoms in a 7.23 Å box
system.table["movable"]  # False for the first two atoms
back = to_ase(system)
back.constraints  # [FixAtoms(indices=[0, 1])]

Both need ASE (pip install mdapy[ase]). Calculators go between ASE and MDAPY too; see ASE calculators.

Parameters

Function Argument Returns
to_ase(system) a System a new ase.Atoms
from_ase(atoms) an ase.Atoms a new System

The result shares no memory with its source.

Results

System ase.Atoms
positions positions
box.matrix, box.pbc cell, pbc
box.origin cell displacement (celldisp)
element chemical symbols; X without an element column
mass masses, when set on the atoms
velocities (Å/ps) momenta, in ASE's unit of time, Å·(amu/eV)1/2
charge initial charges
movable FixAtoms for atoms that cannot move, FixCartesian for atoms fixed along some axes
other numeric columns arrays of the same name
info info
info["energy"], forces, info["stress"] (GPa) or info["virial"] (eV) a single-point calculator with the energy, forces and stress (eV/ų)

Columns of strings, such as type_label, are not converted. ASE gives the stress in eV/ų in the order xx, yy, zz, yz, xz, xy; MDAPY keeps it as a (3, 3) array in GPa. Both are positive under tension.

Errors

from_ase raises InvalidParameter for constraints other than FixAtoms and FixCartesian.

See also