Beispiel #1
0
def gen_nodup_cstru(lattice, sea_ele, size, speckle, num):
    d, w, l = size
    ele_sea = SitesGrid.sea(d, w, l, sea_ele)
    cell_mother_stru = CStru(lattice, ele_sea).get_cell()

    sym_perm = get_permutation_cell(cell_mother_stru)

    # For testing: Show that the first unit matrix convert to range(num) perm_operator
    # print(sym_perm[0])

    gen_dup_cstrus = CStru.gen_speckle(lattice, sea_ele, size, speckle, num)

    # Add the progress bar when looping
    from scipy.special import comb
    number_of_structures = comb((d * w * l), num)
    bar = ProgressBar(max_value=number_of_structures)

    isoset = set()
    for cstru in bar(gen_dup_cstrus):
        b, pos, atom_num = cstru.get_cell()
        #id_cstru = _get_id_seq(pos, atom_num)
        id_cstru = _get_atom_seq_identifier(atom_num)
        # print(id_cstru)
        if id_cstru not in isoset:
            # print(len(sym_perm))
            # print(len(isoset))
            # print(cstru.get_array())
            yield cstru
            _update_isoset(isoset, atom_num, sym_perm)
Beispiel #2
0
 def test_gen_speckle(self):
     c = Specie("Cu")
     t = Specie("Ti")
     sites = [[[c, c], [t, t]], [[c, t], [t, c]]]
     sg = SitesGrid(sites)
     gen = CStru.gen_speckle(self.m, Specie("Cu"), (2, 2, 2), Specie("Ti"),
                             4)
     from collections import Iterator
     self.assertIsInstance(gen, Iterator)
     self.assertIn(CStru(self.m, sg), gen)
     self.assertEqual(next(gen).get_array().sum(), 204)
     self.assertEqual(next(gen).get_array().sum(), 204)