File conversion
File conversion from the CONQUEST coordinates file is handled by the writers module.
- class conquest2a.writers.conquest_writer(dest: str, coords: conquest_coordinates, encoding: str = 'utf-8', precision: int = 10)
Class to write a CONQUEST coordinates file given a
conquest_coordinatesinstance.- Parameters:
dest (
str) – Path to write the new coordinates file.coords (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”precision (
int, optional) – Float precision, defaults to 10
- Raises:
ValueError – If the float precision is not at least 1.
- class conquest2a.writers.extxyz_writer(dest: str, data: conquest_coordinates, encoding: str = 'utf-8', time: float = 0.0)
Class to write a
.extxyzfor a basic XYZ file given aconquest_coordinatesinstance.The main advantage of .extxyz is the ability to specify columns and the time, which is very useful for animations. I recommend just using CONQUEST’s ability to output
.extxyzfiles at different timesteps.- Parameters:
dest (
str) – Path to write the new coordinates file.data (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”.time (
float, optional) – The instance of time of the cell, defaults to 0.0.
- create_comment_line() str
Creates the
.extxyzcomment line: specifies columns, formats and time.- Returns:
The file’s comment line.
- Return type:
str
- class conquest2a.writers.file_writer(dest: str, mode: str = 'w', encoding: str = 'utf-8', is_angstrom: bool = False)
Generic parent class to define file operations and variables.
- Parameters:
dest (str) – _description_
mode (str, optional) – _description_, defaults to “w”
encoding (str, optional) – _description_, defaults to “utf-8”
is_angstrom (bool, optional) – _description_, defaults to False
- class conquest2a.writers.vasp_writer(dest: str, data: conquest_coordinates, encoding: str = 'utf-8', is_angstrom: bool = False)
Class to write a VASP file given a
conquest_coordinatesinstance.- Parameters:
dest (
str) – Path to write the new coordinates file.data (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”is_angstrom (
bool, optional) – Whether the data inconquest_coordinatesis already in angstroms instead of Bohrs, defaults toFalse.
- class conquest2a.writers.xsf_writer(dest: str, data: conquest_coordinates, write_extra: Literal['spin', 'force'] = 'spin', encoding: str = 'utf-8')
Class to write .xsf files given a
conquest_coordinatesinstance.XSF files support an extra 3 columns alongside the 3 columns used for position. These columns specify a vector associated with each atom. In CONQUEST, the relevant vectors are forces and spins. Note that CONQUEST only supports collinear spin (up and down), so the spin vector is visualised along the \(c\)-axis of the simulation cell.
- Parameters:
dest (
str) – Path to write the new coordinates file.data (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”.write_extra (Literal["spin", "force"], optional) – Whether to extract the force vector or spin vector of atoms, defaults to “spin”.
- class conquest2a.writers.xsf_writer_spins(dest: str, charges: atom_charge, xsf_file: str, encoding: str = 'utf-8')
XSF writer class that includes spin information from the AtomCharge.dat file, by editing an existing XSF file generated by PostProcessCQ.
- Parameters:
dest (
str) – Path to write the new coordinates file.data (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”.charges (
atom_charge:param xsf_file: XSF file to modify.) –atom_chargeinstance to read spin data from.
- process_xsf_file() None
Process an existing XSF file to include spin information.
- class conquest2a.writers.xyz_writer(dest: str, data: conquest_coordinates, encoding: str = 'utf-8', comment_line: str = 'comment line')
Class to write a
.xyzfor a basic XYZ file given aconquest_coordinatesinstance.- Parameters:
dest (
str) – Path to write the new coordinates file.data (
conquest_coordinates) –conquest_coordinatesinstance to write.encoding (
str, optional) – File encoding, defaults to “utf-8”comment_line (
str, optional) – What string to write as the comment line
- create_atoms_str() tuple[str, str]
Creates a line for an atom, for the XYZ file.
- Returns:
Components of the line to write: the element and the numbers
- Return type:
tuple[str, str]
- write() None
XYZ format expects cells in Cartesian coordinates. Since CONQUEST only deals with orthorhombic unit cells, we can just multiply the non-zero coordinates of the lattice vectors with the fractional coordinates