Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_feature_index_mapping does not support global_species #386

Open
Luthaf opened this issue Oct 11, 2021 · 1 comment
Open

get_feature_index_mapping does not support global_species #386

Luthaf opened this issue Oct 11, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@Luthaf
Copy link
Contributor

Luthaf commented Oct 11, 2021

Here is a script demonstrating the issue:

import ase

from rascal.representations import SphericalInvariants

HYPERS = {
    "soap_type": "PowerSpectrum",
    "interaction_cutoff": 4.5,
    "max_radial": 6,
    "max_angular": 6,
    "gaussian_sigma_constant": 0.3,
    "gaussian_sigma_type": "Constant",
    "cutoff_smooth_width": 0.5,
    "radial_basis": "GTO",
    "compute_gradients": False,
    "normalize": True,
    "expansion_by_species_method": "user defined",
    "global_species": [1, 6, 7, 8],
}

soap = SphericalInvariants(**HYPERS)

frame = ase.Atoms(
    symbols="CO2",
    positions=[
        (5, 5, 5),
        (5, 5, 5 - 2),
        (5, 5, 5 + 2),
    ],
    cell=[10, 10, 10],
)

X = soap.transform([frame]).get_features(soap)

mapping = soap.get_feature_index_mapping([frame])

print(len(mapping))
print(X.shape)

assert len(mapping) == X.shape[1]

This will print 756 2520 and then fail the assertion.


I understand why get_feature_index_mapping need to take the managers as parameter, since the features could change depending on which species are present in the structures. But get_feature_index_mapping should deal with all possible expansion_by_species_method.


A temporary workaround is to call get_feature_index_mapping with a specially constructed frame:

mapping = soap.get_feature_index_mapping([ase.Atoms("CHNO")])
@Luthaf Luthaf added the bug Something isn't working label Oct 11, 2021
@rosecers
Copy link
Contributor

rosecers commented Aug 5, 2022

Hi! Adding a note to this issue. When masking several species, I still want them to come up in the mapping, e.g. if I only get the soap vectors for oxygen centers but there are hydrogens present, I want to see the mapping including all 1-1, 1-8, and 8-8, not just 8-8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants