Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 13 additions & 3 deletions casm/tools/shared/ase_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -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
-------
Expand All @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions tests/shared/ase_utils/test_ase_utils.py
Original file line number Diff line number Diff line change
@@ -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)