Exemplo n.º 1
0
def get_catlearn_fp(A, Name=False):

    if not Name:
        A = autogen_info([A])
    gen = FeatureGenerator()
    if isinstance(A, list):
        gen._get_atom_types(A)
    else:
        gen._get_atom_types([A])

    train_fpv = [gen.mean_chemisorbed_atoms,
                 gen.bulk,
                 gen.term,
                 gen.strain,
                 gen.mean_surf_ligands,
                 gen.mean_site,
                 gen.median_site,
                 gen.max_site,
                 gen.min_site,
                 gen.sum_site,
                 #gen.generalized_cn,
                 #gen.bag_cn,
                 #gen.en_difference_ads,
                 #gen.en_difference_chemi,
                 #gen.en_difference_active,
                 #gen.bag_atoms_ads,
                 #gen.bag_connections_ads,
                 gen.count_chemisorbed_fragment]
    
    if not Name:
        gen.normalize_features(A)
        return gen.return_vec(A, train_fpv)
    else:
        return gen.return_names(train_fpv)
Exemplo n.º 2
0
 def test_recontruction(self):
     images = database_to_list('data/ads_example.db')
     slabs = []
     for atoms in images:
         slab = atoms.copy()
         slab.pop(-1)
         slabs.append(slab)
     images = autogen_info(images)
     slabs = images_connectivity(slabs)
     image_pairs = zip(images, slabs)
     r_index = check_reconstructions(image_pairs)
     for i in range(len(images)):
         species = images[i].info['key_value_pairs']['species']
         connectivity2ads_index(images[i], species)
     self.assertTrue(len(r_index) == 0)
Exemplo n.º 3
0
 def test_tags(self):
     """Test the feature generation."""
     images = self.setup_metals()
     images = autogen_info(images)
     print(str(len(images)) + ' training examples.')
     gen = FeatureGenerator(nprocs=1)
     train_fpv = default_fingerprinters(gen, 'adsorbates')
     train_fpv += [
         gen.formal_charges, gen.bag_edges_ads, gen.ads_av, gen.ads_sum
     ]
     matrix = gen.return_vec(images, train_fpv)
     labels = gen.return_names(train_fpv)
     print(np.shape(matrix), type(matrix))
     if __name__ == '__main__':
         for i, l in enumerate(labels):
             print(i, l)
     self.assertTrue(len(labels) == np.shape(matrix)[1])
Exemplo n.º 4
0
 def test_constrained_ads(self):
     """Test the feature generation."""
     images = self.setup_metals()
     [atoms.set_tags(np.zeros(len(atoms))) for atoms in images]
     for atoms in images:
         c_atoms = [a.index for a in atoms if
                    a.z < atoms.cell[2, 2] / 2. + 0.1]
         atoms.set_constraint(FixAtoms(c_atoms))
     images = autogen_info(images)
     print(str(len(images)) + ' training examples.')
     gen = FeatureGenerator(nprocs=1)
     train_fpv = default_fingerprinters(gen, 'adsorbates')
     matrix = gen.return_vec(images, train_fpv)
     labels = gen.return_names(train_fpv)
     print(np.shape(matrix), type(matrix))
     if __name__ == '__main__':
         for i, l in enumerate(labels):
             print(i, l)
     self.assertTrue(len(labels) == np.shape(matrix)[1])
Exemplo n.º 5
0
 def test_db_ads(self):
     """Test the feature generation."""
     images = database_to_list('data/ads_example.db')
     [atoms.set_tags(np.zeros(len(atoms))) for atoms in images]
     images = autogen_info(images)
     layers2ads_index(images[0],
                      images[0].info['key_value_pairs']['species'])
     print(str(len(images)) + ' training examples.')
     gen = FeatureGenerator(nprocs=1)
     train_fpv = default_fingerprinters(gen, 'adsorbates')
     # Test db specific functions.
     train_fpv += [gen.db_size, gen.ctime, gen.dbid, gen.delta_energy]
     # Old CatApp AxBy fingerprints.
     train_fpv += [gen.catapp_AB]
     matrix = gen.return_vec(images, train_fpv)
     labels = gen.return_names(train_fpv)
     print(np.shape(matrix), type(matrix))
     if __name__ == '__main__':
         for i, l in enumerate(labels):
             print(i, l)
     self.assertTrue(len(labels) == np.shape(matrix)[1])