Skip to content

Migrating from ASE ​

The conversion is explicit and keeps the ASE metadata that has a crystal meaning. Install ase separately.

TaskASExtalforge
Read a filease.io.read("x.cif")xtalforge.read("x.cif")
Periodic structureAtoms with pbc=TrueStructure with a lattice
Cellatoms.cellstructure.lattice
Cartesian positionsatoms.positionsstructure.positions
Fractional positionsatoms.get_scaled_positions()structure.frac_positions
Symbolsatoms.get_chemical_symbols()[site.element for site in structure.sites]
Preserve tags/chargesatoms.get_tags(), get_initial_charges()kept by from_ase / to_ase
Energy/forcescalculatorstructure.ff_energy() or UffAseCalculator
Symmetryspglib through ASExtalforge.detect_symmetry
Supercellatoms.repeat((2, 2, 1))structure.supercell(2, 2, 1)
Exportatoms.write("x.cif")structure.write("x.cif")
python
import xtalforge
from ase.io import read

ase_atoms = read("POSCAR")
structure = xtalforge.Structure.from_ase(ase_atoms)
print(structure.formula, structure.lattice.volume)
structure.supercell(2, 2, 1).write("supercell.cif")

Going back keeps tags, charges, magnetic moments and fixed atoms:

python
atoms = structure.to_ase()

The ASE calculator adapter uses the native UFF implementation; no xtalforge structure leaves the process.