diff --git a/CHANGELOG.md b/CHANGELOG.md index 84e3f05..e772e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to `casm-tools` will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Exclude species from `casm.tools.shared.ase_utils.make_ase_atoms`. + Vacancies are excluded by default. ## [2.0a2] - 2024-08-07 diff --git a/casm/tools/shared/ase_utils.py b/casm/tools/shared/ase_utils.py index a424625..c043f63 100644 --- a/casm/tools/shared/ase_utils.py +++ b/casm/tools/shared/ase_utils.py @@ -13,7 +13,9 @@ import libcasm.xtal as xtal -def make_ase_atoms(casm_structure: xtal.Structure) -> ase.Atoms: +def make_ase_atoms( + casm_structure: xtal.Structure, exclude: list[str] = ["VA", "Va", "va"] +) -> ase.Atoms: """Given a CASM Structure, convert it to an ASE Atoms .. attention:: @@ -33,6 +35,8 @@ def make_ase_atoms(casm_structure: xtal.Structure) -> ase.Atoms: Parameters ---------- casm_structure : libcasm.xtal.Structure + exclude : list[str] + Species to exclude from the ASE Atoms. Returns ------- @@ -45,8 +49,14 @@ def make_ase_atoms(casm_structure: xtal.Structure) -> ase.Atoms: "to_ase_atoms" ) - symbols = casm_structure.atom_type() - positions = casm_structure.atom_coordinate_cart().transpose() + initial_symbols = casm_structure.atom_type() + initial_positions = casm_structure.atom_coordinate_cart().transpose() + symbols = [] + positions = [] + for index, symbol in enumerate(initial_symbols): + if symbol not in exclude: + symbols.append(symbol) + positions.append(initial_positions[index]) cell = casm_structure.lattice().column_vector_matrix().transpose() return ase.Atoms( diff --git a/tests/shared/ase_utils/test_ase_utils.py b/tests/shared/ase_utils/test_ase_utils.py new file mode 100644 index 0000000..b464ed6 --- /dev/null +++ b/tests/shared/ase_utils/test_ase_utils.py @@ -0,0 +1,7 @@ +from libcasm.xtal import structures +from casm.tools.shared import ase_utils + + +def test_make_ase_atoms_va(): + test_structure = structures.BCC(r=1, atom_type="Va") + ase_utils.make_ase_atoms(test_structure)