Beispiel #1
0
 def setUp(self):
     g = GhostSpecie()
     b = Specie("B")
     self.sites = [[[b, b], [g, g]], [[b, g], [g, b]]]
     self.sg = SitesGrid(self.sites)
     self.allg0 = SitesGrid.sea(2, 2, 2, GhostSpecie())
     self.allg = SitesGrid.sea(4, 2, 2, GhostSpecie())
Beispiel #2
0
    def test_gen_nodup_cstru(self):
        c = Specie("Cu")
        t = Specie("Ti")
        m = [[-0.5, -0.5, -0.5],
             [-0.5,  0.5,  0.5],
             [ 0.5, -0.5,  0.5]]
        ele_sea = SitesGrid.sea(2, 2, 2, c)
        cell_mother_stru = CStru(m, ele_sea).get_cell()
        sym = get_symmetry(cell_mother_stru, symprec=1e-3)
        ops = [(r, t) for r, t in zip(sym['rotations'], sym['translations'])]

        sites_0 = [[[c, c],
                    [c, c]],

                   [[c, c],
                    [t, c]]]
        sg_0 = SitesGrid(sites_0)
        cstru01 = CStru(m, sg_0)

        gen_01 = sogen.gen_nodup_cstru(m, c, (2,2,2), t, 1)
        nodup_01 = [stru for stru in gen_01]
        self.assertEqual(len(nodup_01), 1)

        gen_02 = sogen.gen_nodup_cstru(m, c, (1,2,8), t, 4)
        nodup_02 = [stru for stru in gen_02]
        # eq_(len(nodup_02), 51)

        m_tri = [[0, 0, 20],
                        [1, 0, 0],
                        [0.5, 0.8660254, 0]]
        ele_sea = SitesGrid.sea(1, 3, 3, c)
        cell_mother_stru = CStru(m, ele_sea).get_cell()
        sym = get_symmetry(cell_mother_stru, symprec=1e-3)
        ops = [(r, t) for r, t in zip(sym['rotations'], sym['translations'])]

        sites_0 = [[[c, c, c],
                    [c, c, c],
                    [c, c, c]]]
        sg_0 = SitesGrid(sites_0)
        cstru01 = CStru(m, sg_0)

        gen_01 = sogen.gen_nodup_cstru(m_tri, c, (1,3,3), t, 2)
        nodup_01 = [stru for stru in gen_01]
        self.assertEqual(len(nodup_01), 2)

        gen_02 = sogen.gen_nodup_cstru(m_tri, c, (1,3,3), t, 3)
        nodup_02 = [stru for stru in gen_02]
        self.assertEqual(len(nodup_02), 4)

        gen_03 = sogen.gen_nodup_cstru(m_tri, c, (1,5,5), t, 2)
        nodup_03 = [stru for stru in gen_03]
        self.assertEqual(len(nodup_03), 4)
Beispiel #3
0
    def test_update_isoset(self):
        c = Specie("Cu")
        t = Specie("Ti")
        m = [[-0.5, -0.5, -0.5],
             [-0.5,  0.5,  0.5],
             [ 0.5, -0.5,  0.5]]
        ele_sea = SitesGrid.sea(2, 2, 2, c)
        cell_mother_stru = CStru(m, ele_sea).get_cell()
        sym = get_symmetry(cell_mother_stru, symprec=1e-5)
        ops = [(r, t) for r, t in zip(sym['rotations'], sym['translations'])]
        sym_perm = sogen.get_permutation_cell(cell_mother_stru)

        sites_0 = [[[c, c],
                    [c, c]],

                   [[c, c],
                    [t, c]]]
        sg_0 = SitesGrid(sites_0)
        cstru01 = CStru(m, sg_0)
        number01 = cstru01.get_cell()[2]

        isoset_init = set()
        isoset_init_copy = isoset_init.copy()
        isoset_a01 = sogen._update_isoset(isoset_init, number01, sym_perm)
        self.assertNotEqual(isoset_a01, isoset_init_copy)
        self.assertIsInstance(isoset_a01, set)

        isoset_a01_copy = isoset_a01.copy()
        isoset_a02 = sogen._update_isoset(isoset_a01, number01, sym_perm)
        self.assertEqual(isoset_a02, isoset_a01_copy)
        self.assertLessEqual(len(isoset_a01), len(ops))
Beispiel #4
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 #5
0
 def test_equal(self):
     other = SitesGrid.sea(4, 2, 2, Specie("Ti"))
     self.assertNotEqual(other, self.allg)
     self.assertNotEqual(None, self.allg)