write_structure#

casm.tools.shared.structure_io.write_structure(
path: Path,
casm_structure: Structure,
format: str | None = None,
force: bool = False,
quiet: bool = False,
) None[source]#

Write a structure to a file.

Notes

This method writes a structure to a file. For CASM and VASP files, ASE does not need to be installed, but for other formats, ASE is required. If ASE is not installed, or ASE does not recognize the file format, an error message will be printed and the program will exit.

Parameters:
  • path (Path) – The path to the structure file. If the file has no suffix, or the suffix is “.vasp”, it will be written as a VASP POSCAR file, using CASM. If the suffix is “.json” or “.casm”, it will be written as a CASM Structure JSON file, using CASM. Otherwise, if ASE is installed, then the ase.io.write method will be used to write the structure.

  • structure (Structure) – The CASM Structure to write.

  • format (Optional[str]=None) – If not None, ignore the path suffix and write the structure with specified format. If the format is “vasp” or “casm”, a VASP POSCAR or CASM Structure is written, using CASM. For any other value, use ase.io.write to write the structure with the specified format.

  • force (bool=False) – By default, if the file already exists, it will not be overwritten. If force is True, the file will be overwritten.

  • quiet (bool=False) – By default, messages about writing the file will be printed. If quiet is True, no messages will be printed.