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

Identical geometry but similarity < 1 #96

Closed
lundnguy opened this issue Oct 21, 2022 · 4 comments
Closed

Identical geometry but similarity < 1 #96

lundnguy opened this issue Oct 21, 2022 · 4 comments

Comments

@lundnguy
Copy link

lundnguy commented Oct 21, 2022

Hi everyone,

I tried to use SOAP/AverageKernel to determine the similarity between a H2O and a H2S molecule (exactly the same geometry, the difference is "O" and "S") I got the off-diagonal components < 1 (0.777). Probably I missed something but I think they should be 1.
Am I wrong?

The input and geometry files are provided below.

Thanks,

Lund

input file

from dscribe.descriptors import SOAP
from dscribe.kernels import AverageKernel
from ase import io 

a=io.read('H2O.xyz', index=':')
b=io.read('H2S.xyz', index=':')

desc=SOAP(species=["H","O","S"], rcut=6.0, nmax=15, lmax=12, sigma=0.01, periodic=False, crossover=True, sparse=False)

a_features = desc.create(a)
b_features = desc.create(b)

re_ave = AverageKernel(metric="linear")
print(re_ave.create([a_features[0], b_features[0]])[0,1])

H2O.xyz file
3

O 0.00000 0.00000 0.11779
H 0.00000 0.75545 -0.47116
H 0.00000 -0.75545 -0.47116


H2S.xyz file
3

S 0.00000 0.00000 0.11779
H 0.00000 0.75545 -0.47116
H 0.00000 -0.75545 -0.47116

@lauri-codes
Copy link
Contributor

Hi @lundnguy,

Typically the descriptors also take the chemical species into account. In the case of SOAP, the geometrical features for each species are written into different "channels" in the output. This is why there is a difference between your structures. If you want to only compare the geometry and ignore the species, just set all of your species e.g. to 'H' in the original structures that you feed into soap.create.

Hope this helps

@lundnguy
Copy link
Author

Hi @lauri-codes

Thank you.

I further calculated the similarities between H2O and H2Pb, between H2S and H2Pb. It appeared that they are the same as that between H2O and H2S (0.777). (Again, all molecules have exactly the same geometry, the difference is the chemical species O, S, Pb). Is there any reason why this happened?

The input file is provided below.

Thanks,
Lund

from dscribe.descriptors import SOAP
from dscribe.kernels import AverageKernel
from ase import io 

a=io.read('H2O.xyz', index=':')
b=io.read('H2S.xyz', index=':')
c=io.read('H2Pb.xyz', index=':')

desc=SOAP(species=["H","O","S","Pb"], rcut=6.0, nmax=15, lmax=12, sigma=0.01, periodic=False, crossover=True, sparse=False)

a_features = desc.create(a)
b_features = desc.create(b)
c_features = desc.create(c)



re_ave = AverageKernel(metric="linear")
print('O & S:', re_ave.create([a_features[0], b_features[0]])[0,1])
print('O & Pb:', re_ave.create([a_features[0],c_features[0]])[0,1])
print('S & Pb:', re_ave.create([b_features[0],c_features[0]])[0,1])


@lauri-codes
Copy link
Contributor

Hi @lundnguy,

The distance measure you are using (metric="linear" is essentially the dot product between two vectors) does not have a special notion of chemical distances between elements. It is simply a linear metric in a space where all species live in different dimensions (= different parts of the output).

There is no "universal distance" between chemical elements as any useful distance is application specific. This is typically where some form of machine learning comes into play, e.g. a neural network may have a latent space that can be seen as an application-specific distance metric between inputs that is trained during the training. Alternatively, you can hand-craft your own chemical distance metric by providing a custom function in the metric argument.

@lundnguy
Copy link
Author

lundnguy commented Nov 7, 2022

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants