ddpc.io.write package

Submodules

ddpc.io.write.dspaw_as module

Module to write structure to ds-paw as format file.

ddpc.io.write.dspaw_as.write(p: str, atoms: Atoms) str[source]

Write ASE Atoms object to DS-PAW .as format file.

This function converts an ASE Atoms object to DS-PAW’s custom .as format, preserving lattice constraints, atomic position constraints, and magnetic moments that are stored in the Atoms.info dictionary.

Parameters:
p : str

Output file path. Use “-” to return string without writing to file.

atoms : ase.atoms.Atoms

ASE Atoms object containing the crystal structure to write.

Returns:

String representation of the DS-PAW .as format file content.

Return type:

str

Notes

The function preserves constraint and magnetic information from the Atoms.info dictionary:

  • Lattice constraints: ‘lat’ key with 9 boolean values

  • Atomic constraints: ‘Fix’, ‘Fix_x’, ‘Fix_y’, ‘Fix_z’ keys

  • Magnetic moments: Retrieved from atoms.get_initial_magnetic_moments()

The output format supports both collinear and non-collinear magnetism, and various constraint types as supported by DS-PAW.

Examples

>>> content = write("output.as", atoms)
>>> print(content[:50])  # First 50 characters
'Total number of atoms\\n8\\nLattice\\n...'
>>> # Write to file
>>> write("structure.as", atoms)

ddpc.io.write.rescu_xyz module

Module to write structure to RESCU xyz format.

ddpc.io.write.rescu_xyz.write(f: str, atoms: Atoms) str[source]

Write RESCU xyz format file with formatted strings.

Parameters:
f : str

Output file path. Use “-” to return string without writing to file.

atoms : ase.atoms.Atoms

ASE Atoms object containing the crystal structure to write.

Returns:

String representation of the RESCU xyz format file content.

Return type:

str

Notes

The function preserves constraint and magnetic information from the Atoms.info dictionary:

  • Atomic constraints: ‘atom_fix’ key with shape (n_atoms, 3)

  • Magnetic moments: Retrieved from atoms.get_initial_magnetic_moments()

The output format supports both collinear and non-collinear magnetism, and various constraint types as supported by RESCU.

Module contents

Write structure files for .as and .xyz format