Skip to content

Commit

Permalink
Fixed explore model to work with mta 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ceriottm committed Nov 4, 2024
1 parent 7a2c21d commit c4d9eb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions python/examples/8-explore-with-metatensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def __init__(self, cutoff: float, max_k: int):
self.cutoff = cutoff
self.max_k = max_k

self._neighbors_options = NeighborListOptions(cutoff=cutoff, full_list=True)
self._neighbors_options = NeighborListOptions(
cutoff=cutoff, full_list=True, strict=True
)

def requested_neighbor_lists(self) -> List[NeighborListOptions]:
# our model requires a neighbor list, that will be computed and provided to it
Expand Down Expand Up @@ -198,12 +200,13 @@ def forward(
"features": ModelOutput(per_atom=True),
},
atomic_types=[6],
length_unit="angstrom",
interaction_range=0.0,
supported_devices=["cpu"],
dtype="float64",
)

model = MetatensorAtomisticModel(model.eval(), metadata, capabilities)
mta_model = MetatensorAtomisticModel(model.eval(), metadata, capabilities)

# %%
#
Expand All @@ -215,9 +218,17 @@ def forward(
# Once the model is fully defined, we can use it with
# :py:func:`chemiscope.metatensor_featurizer`:

featurizer = chemiscope.metatensor_featurizer(model, check_consistency=True)
featurizer = chemiscope.metatensor_featurizer(mta_model, check_consistency=True)
chemiscope.explore(
frames=frames,
featurize=featurizer,
environments=chemiscope.all_atomic_environments(frames),
)

# %%
# The metatensor model can also be easily exported,
# to be shared with collaborators for use in their
# visualization workflows

mta_model.save("model-exported.pt")
# %%
Binary file modified python/examples/model.pt
Binary file not shown.

0 comments on commit c4d9eb8

Please sign in to comment.