ddpc.io.read package

Submodules

ddpc.io.read.dspaw_as module

Read DS-PAW specified .as format file to ASE atoms.

ddpc.io.read.dspaw_as.read(p: Path | str = 'structure.as') Atoms[source]

Read DS-PAW atomic structure format file and convert to ASE Atoms object.

This function reads DS-PAW’s custom .as format files which support advanced features like lattice constraints, atomic position constraints, and magnetic moments. The format is used by the DS-PAW DFT code for structure input.

Parameters:
p : pathlib.Path or str, default "structure.as"

Path to the DS-PAW .as format structure file.

Returns:

ASE Atoms object containing the crystal structure with:

  • Atomic positions (Cartesian or fractional coordinates)

  • Unit cell lattice vectors

  • Magnetic moments (if specified)

  • Constraint information stored in the info dictionary

Return type:

ase.atoms.Atoms

Notes

The DS-PAW .as format supports:

  • Lattice vector constraints (Fix_x, Fix_y, Fix_z per vector)

  • Atomic position constraints (Fix, Fix_x, Fix_y, Fix_z per atom)

  • Magnetic moments (collinear: Mag, non-collinear: Mag_x, Mag_y, Mag_z)

  • Both Cartesian and Direct (fractional) coordinate systems

Constraint information is preserved in the Atoms.info dictionary for later use in calculations or file writing.

Examples

>>> atoms = read("input.as")
>>> print(atoms.get_chemical_formula())
'Si2'
>>> atoms = read(Path("structures/crystal.as"))
>>> print(atoms.info.keys())  # Shows constraint information
dict_keys(['Fix_x', 'Fix_y', 'Fix_z'])

ddpc.io.read.rescu_xyz module

Read RESCU specified .xyz format file and its input to create an ASE atoms.

ddpc.io.read.rescu_xyz.read(p: str | Path) Atoms[source]

Read RESCU XYZ format file and convert to ASE Atoms object.

This function reads RESCU’s extended XYZ format files which support magnetic moments and atomic position constraints. RESCU is a DFT code that uses a specialized XYZ format for structure input.

Parameters:
p : str or pathlib.Path

Path to the RESCU XYZ format structure file.

Returns:

ASE Atoms object containing the crystal structure with:

  • Atomic positions in Cartesian coordinates

  • Magnetic moments (if specified)

  • Constraint information stored in the info dictionary

Return type:

ase.atoms.Atoms

Notes

The RESCU XYZ format supports various line formats:

  • basic: element x/y/z

  • collinear magnetism: element x/y/z mag

  • non-collinear magnetism: element x/y/z mag_x/y/z

  • constraints: element x/y/z mag moveable_x/y/z

  • non-collinear mag + constraints: element x/y/z mag_x/y/z moveable_x/y/z

Constraint information is preserved in the Atoms.info dictionary as ‘atom_fix’ with shape (n_atoms, 3) indicating moveable directions.

Examples

>>> atoms = read("structure.xyz")
>>> print(atoms.get_chemical_formula())
'H2O'
>>> atoms = read("magnetic_structure.xyz")
>>> print(atoms.get_initial_magnetic_moments())
[1.0, -1.0, 0.0]

Module contents

Read structure files for .as and .xyz format