Note
Go to the end to download the full example code
Select structures
This example shows how to select structures from dataset

NEP 3 calculator with 1 symbols: C
------------------------------
zbl : False
radial_cutoff : 4.2
angular_cutoff : 3.7
n_max_radial : 10
n_max_angular : 8
basis_size_radial : 10
basis_size_angular : 8
l_max_3body : 4
num_node : 65
num_para : 6903
element_list : ['C']
------------------------------
from pynep.calculate import NEP
from pynep.select import FarthestPointSample
from ase.io import read, write
import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
a = read('data.traj', ':')
calc = NEP("C_2022_NEP3.txt")
print(calc)
des = np.array([np.mean(calc.get_property('descriptor', i), axis=0) for i in a])
sampler = FarthestPointSample(min_distance=0.05)
selected_i = sampler.select(des, [])
write('selected.traj', [a[i] for i in selected_i])
reducer = PCA(n_components=2)
reducer.fit(des)
proj = reducer.transform(des)
plt.scatter(proj[:,0], proj[:,1], label='all data')
selected_proj = reducer.transform(np.array([des[i] for i in selected_i]))
plt.scatter(selected_proj[:,0], selected_proj[:,1], label='selected data')
plt.legend()
plt.axis('off')
plt.savefig('select.png')
Total running time of the script: ( 0 minutes 15.623 seconds)