lab-cosmo / librascal

A scalable and versatile library to generate representations for atomic-scale learning
https://lab-cosmo.github.io/librascal/
GNU Lesser General Public License v2.1
80 stars 17 forks source link

Is it possible to dump/display a SOAP-encoded atom as a vector of floats? [question] #408

Closed UnixJunkie closed 2 years ago

UnixJunkie commented 2 years ago

I gave it a try, but it prints me things like:

<rascal.lib._rascal._internal.Strict_CenterContribution_NeighbourList_Centers.Center object at 0x7feec24ba030>
[...]

I was expecting a vector of floats.

My trial can be seen here: https://github.com/UnixJunkie/librascal/blob/SOAP_test_01/soap_test.py

Luthaf commented 2 years ago

Yes, you need to do something like this:

molecules = ase_read(input_fn, "{}:{}".format(start, start + length))
soap_encoded_molecules = soap.transform(molecules)

soap_np_array = soap_encoded_molecules.get_features(soap)

This gives you a n_atoms x n_features numpy array.

Luthaf commented 2 years ago

There are a handful more function to get the gradients of the representation, or some metadata describing the rows of the returned array.

https://github.com/lab-cosmo/librascal/blob/fed28b910d9ba6f8549c935aaf67bdc14051d511/bindings/rascal/neighbourlist/structure_manager.py#L117-L204

The columns of the returned array are described by soap.get_feature_index_mapping()

UnixJunkie commented 2 years ago

Thanks a lot!