ddpc package

Subpackages

Submodules

ddpc.util module

Common utilities for DDPC.

ddpc.util.find_orth(p: str | Path, op: str | Path, fmt: str | None, mlen: float) None[source]

Create an orthogonalized supercell with perpendicular lattice vectors.

This function reads a crystal structure, finds an orthogonalized supercell where all lattice vectors are perpendicular (a ⊥ b ⊥ c), and writes the result to an output file.

Parameters:
p : str or pathlib.Path

Path to the input structure file.

op : str or pathlib.Path

Path to the output file for the orthogonalized structure.

fmt : str or None

Output file format. If None, format is determined from file extension.

mlen : float

Maximum allowed lattice vector length for the orthogonalized cell.

Raises:
  • ValueError – If the input structure has no cell information.

  • Exception – If the orthogonalization process fails or no suitable supercell can be found within the maximum length constraint.

ddpc.util.find_prim(p: str | Path, op: str | Path, fmt: str | None, symprec: float) None[source]

Find primitive cell of a crystal structure.

This function reads a crystal structure file, finds its primitive cell using spglib, and writes the result to an output file.

Parameters:
p : str or pathlib.Path

Path to the input structure file.

op : str or pathlib.Path

Path to the output file for the primitive structure.

fmt : str or None

Output file format. If None, format is determined from file extension.

symprec : float

Symmetry precision for spglib primitive cell finding.

Raises:

ValueError – If the input structure has no cell information or if spglib fails to find the primitive cell.

ddpc.util.orthogonalize_cell(atoms: Atoms, mlen: float) Atoms[source]

Search for an orthogonalized supercell of the input structure.

This function uses pymatgen’s CubicSupercellTransformation to find a supercell with orthogonal lattice vectors (a ⊥ b ⊥ c). The transformation searches for the minimal supercell that satisfies the orthogonality constraints within the specified maximum length.

Parameters:
atoms : ase.atoms.Atoms

Input crystal structure as an ASE Atoms object.

mlen : float

Maximum allowed lattice vector length for the orthogonalized cell. The search will fail if no orthogonal supercell can be found within this constraint.

Returns:

Orthogonalized supercell as an ASE Atoms object with perpendicular lattice vectors.

Return type:

ase.atoms.Atoms

Raises:

Exception – If pymatgen fails to find an orthogonal supercell within the maximum length constraint, or if the transformation fails for any other reason.

Notes

The function uses the following transformation parameters:

  • min_length: 3.0 Å (minimum lattice vector length)

  • max_length: mlen (user-specified maximum)

  • allow_orthorhombic: True (allows orthorhombic cells)

  • angle_tolerance: 1e-3 (tolerance for 90° angles)

  • step_size: 0.1 (search step size)

ddpc.util.scale_atom_pos(p: str | Path, op: str | Path) None[source]

Convert structure file to POSCAR format with scaled (fractional) positions.

This function reads a crystal structure from any supported format and writes it as a VASP POSCAR file with atomic positions expressed in fractional coordinates (Direct format).

Parameters:
p : str or pathlib.Path

Path to the input structure file.

op : str or pathlib.Path

Path to the output POSCAR file.

Raises:

ValueError – If the input structure has no cell information (lattice vectors).

Module contents

DDPC package initialization.