Skip to content

Commit

Permalink
Add PrimNeighborList.weight_matrix accessor
Browse files Browse the repository at this point in the history
  • Loading branch information
bpuchala committed Apr 22, 2024
1 parent 22b59d2 commit 6ba7280
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to `libcasm-clexulator` 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]

### Added

- Added `libcasm.clexulator.PrimNeighborList.weight_matrix()` to access the weight matrix


## [2.0a4] - 2024-03-14

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions python/src/clexulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,25 @@ PYBIND11_MODULE(_clexulator, m) {
(DoF) or 1 or more continuous DoF.
)pbdoc",
py::arg("xtal_prim"))
.def(
"weight_matrix",
[](clexulator::PrimNeighborListWrapper const &x) {
return x.prim_neighbor_list->weight_matrix();
},
R"pbdoc(
Get the weight matrix that defines the shape of neighborhood and \
orders neighbors.
Returns
-------
weight_matrix: np.ndarray, shape=(3,3), dtype=int
Weight matrix, :math:`W`, that defines the shape of neighborhood
that orders neighbors. In the
:class:`~libcasm.clexulator.PrimNeighborList`,
unit cells are ordered by the integer distance,
:math:`r = x^{\mathsf{T}} W x`, where :math:`x` is the integer
unit cell coordinates.
)pbdoc")
.def(
"sublattice_indices",
[](clexulator::PrimNeighborListWrapper const &x) {
Expand Down
1 change: 1 addition & 0 deletions python/tests/clexulator/test_neighbor_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_prim_neighbor_list_2():
W = PrimNeighborList.make_weight_matrix(lattice.column_vector_matrix())
prim_neighbor_list = PrimNeighborList(W, [0], 1)
assert isinstance(prim_neighbor_list, PrimNeighborList)
assert (prim_neighbor_list.weight_matrix() == W).all()


def test_prim_neighbor_list_3():
Expand Down

0 comments on commit 6ba7280

Please sign in to comment.