airsspy.tools.modcell#

Tools for modifying CASTEP cell files.

Provides functions to replace blocks in cell files and update lattice and position blocks using ASE Atoms objects.

Module Contents#

Functions#

replace_block

Replace a block in a list of cell file lines with new values.

modify_cell

Modify a cell file using the structure given by an ASE Atoms object.

API#

airsspy.tools.modcell.replace_block(lines: list[str], block_name: str, block_pattern: str, new_value: list[str], check: bool = True) list[str][source]#

Replace a block in a list of cell file lines with new values.

Args: lines: Original lines of the cell file. block_name: Name for the replacement block header. block_pattern: Regex pattern to match the block name in the file. new_value: Lines to insert as the block content. check: If True, raise RuntimeError when the block is not found.

Returns: A new list of lines with the block replaced.

airsspy.tools.modcell.modify_cell(base_cell: str, atoms: ase.Atoms) list[str][source]#

Modify a cell file using the structure given by an ASE Atoms object.

Replaces the LATTICE_CART and POSITIONS_ABS blocks in the base cell file with data from atoms, leaving all other content unchanged.

Args: base_cell: Path to the base .cell file. atoms: ASE Atoms object with the new structure.

Returns: A list of lines for the modified cell file.