Skip to content

Migrating from pymatgen ​

Structure.from_pymatgen accepts both pymatgen.core.Structure and pymatgen.core.Molecule; to_pymatgen returns the matching type.

Taskpymatgenxtalforge
ReadStructure.from_file("x.cif")xtalforge.read("x.cif")
Read a moleculeMolecule.from_file("x.xyz")xtalforge.read("x.xyz")
Cellstructure.lattice.matrixstructure.lattice.matrix
Cartesian positionsstructure.cart_coordsstructure.positions
Fractional positionsstructure.frac_coordsstructure.frac_positions
Speciesstructure.speciesstructure.sites
Partial occupancysite.speciessite occupancy
SymmetrySpacegroupAnalyzer(structure)xtalforge.detect_symmetry(structure)
Supercellstructure.make_supercell([2, 2, 1])structure.supercell(2, 2, 1)
Exportstructure.to(filename="x.cif")structure.write("x.cif")
python
import xtalforge
from pymatgen.core import Structure as PmgStructure

pmg = PmgStructure.from_file("POSCAR")
structure = xtalforge.Structure.from_pymatgen(pmg)
print(structure.formula)
pmg_back = structure.to_pymatgen()

Disordered sites keep one core site per occupied species with its occupancy; the adapter is lossless for the common single-species case and records the pymatgen species composition when a site carries more than one species.