mlff_attack.relaxation module¶
This module provides utilities for structure loading, MACE calculator setup, and geometry optimization (relaxation) of atomic structures.
MACE relaxation functionality.
- mlff_attack.relaxation.get_optimizer_class(optimizer_name)[source]¶
Get the ASE optimizer class from name.
- mlff_attack.relaxation.load_structure(input_path)[source]¶
Load structure from input file.
- Parameters:
input_path (str or Path) – Path to input structure file (CIF, POSCAR, etc.)
- Returns:
ASE Atoms object, or None if loading fails
- Return type:
ase.Atoms or None
- mlff_attack.relaxation.run_relaxation(atoms, traj_path, fmax=0.01, max_steps=300, optimizer='LBFGS')[source]¶
Run structural relaxation.
- Parameters:
atoms (ase.Atoms) – ASE Atoms object with calculator attached
traj_path (str or Path) – Path to save trajectory file
fmax (float, optional) – Force convergence criterion (eV/Å), by default 0.01
max_steps (int, optional) – Maximum number of optimization steps, by default 300
optimizer (str, optional) – Name of optimizer to use (“BFGS” or “LBFGS”), by default “LBFGS”
- Returns:
True if relaxation completed successfully, False otherwise
- Return type:
- mlff_attack.relaxation.save_results(atoms, output_dir, base_name='relaxed')[source]¶
Save relaxed structure to output files.
- mlff_attack.relaxation.setup_calculator(atoms, model_path, device='cuda', dtype_str='float64')[source]¶
Initialize and attach MACE calculator to atoms object.
- Parameters:
atoms (ase.Atoms) – ASE Atoms object
model_path (str or Path or MACECalculator) – Path to MACE model file or existing MACECalculator instance
device (str, optional) – Device to use (cuda or cpu), by default “cuda”
dtype_str (str, optional) – Data type for calculations (“float32” or “float64”), by default “float64”
- Returns:
ASE Atoms object with calculator attached, or None if setup fails
- Return type:
ase.Atoms or None