dscribe icon indicating copy to clipboard operation
dscribe copied to clipboard

MBTR

Open mansoure37 opened this issue 1 year ago • 2 comments

Hi Lauri I want to make MBTR , for all three modes atomic_number, distance and cosine at the same time. Before we used k1, k2 and k3. k1={"geometry": {"function":"atomic_number"}, "grid": {"min":1, "max":118, "sigma":0.01, "n":5}},

k2={"geometry": {"function":"distance"},
    "grid": {"min":-50, "max":50, "sigma":0.01, "n":5},
    "weighting": {"function": "exp", "scale":0.5, "cutoff":1e-4, "threshold": 1e-2}},

k3={"geometry": {"function":"cosine"},
    "grid": {"min":-1.0, "max":1.0, "sigma":0.01, "n":5},
    "weighting": {"function": "exp", "scale":0.5, "cutoff":1e-4, "threshold": 1e-3}}.

The error is: got an unexpected keyword argument 'k1'. for just one method I can do it, such as examples in Dscribe but I don't want to make it just for one method for example just for cosine.

thank you

mansoure37 avatar Mar 04 '24 14:03 mansoure37

Hi @mansoure37!

The interface was changed in v2.0. You can see the new call syntax here. If you wish to compute different terms (k1, k2, k3), and combine them into a single vector, you would do something like this:

import numpy as np
from dscribe.descriptors import MBTR
from ase.build import bulk
import matplotlib.pyplot as mpl

# Define system
system = bulk('NaCl', crystalstructure='rocksalt', a=5.64)

# Setup and create
mbtr = MBTR(
    species=["Na", "Cl"],
    geometry={"function": "atomic_number"},
    grid={"min": 11, "max": 17, "n": 100, "sigma": 0.5},
    periodic=True,
    normalization="l2",
)
k1 = mbtr.create(system)
mbtr.geometry = {"function": "inverse_distance"}
mbtr.grid = {"min": 0, "max": 1, "n": 100, "sigma": 0.1}
mbtr.weighting = {"function": "exp", "scale": 0.5, "threshold": 1e-3}
k2 = mbtr.create(system)
mbtr.geometry = {"function": "cosine"}
mbtr.grid = {"min": 0, "max": 1, "n": 100, "sigma": 0.1}
mbtr.weighting = {"function": "exp", "scale": 0.5, "threshold": 1e-3}
k3 = mbtr.create(system)

# Combine along last axis
full = np.concatenate((k1, k2, k3), axis=-1)

# Plot
mpl.plot(full)
mpl.show()

lauri-codes avatar Mar 06 '24 10:03 lauri-codes

thanks. Another question is: I want to compare the Fingerprint of 2 compounds with the same elements but different space group number.Is it correct to make mbtr in the way that you said above for 2 compounds and compare their plotting or do you have another suggestion for making a Fingerprint?

mansoure37 avatar Mar 06 '24 18:03 mansoure37

If you normalize the outputs to unit length (normalizer='l2' in the MBTR constructor), then you can in principle compare structures coming from different spacegroups and importantly also the same structure in different supercells sizes (read more here)

lauri-codes avatar Apr 16 '24 14:04 lauri-codes