Example #1
0
    def test_extend_not_hnf(self):
        fcc_latt = [0, 5, 5,
                    5, 0, 5,
                    5, 5, 0]
        fcc_pos = [(0, 0, 0),
                   (0.5, 0.5, 0.5)]
        fcc_atoms = [1, 2]
        fcc_pcell = Cell(fcc_latt, fcc_pos, fcc_atoms)
        op_ext = numpy.array([-1, 1, 1,
                              1, -1, 1,
                              1, 1, -1]).reshape((3, 3))
        ext_fcc = fcc_pcell.extend(op_ext)

        wanted_latt = numpy.array([10, 0, 0,
                                   0, 10, 0,
                                   0, 0, 10]).reshape((3, 3))
        wanted_pos = numpy.array([(0, 0, 0),
                                  (0.5, 0.5, 0),
                                  (0.5, 0, 0.5),
                                  (0, 0.5, 0.5),
                                  (0.5, 0.5, 0.5),
                                  (0, 0, 0.5),
                                  (0, 0.5, 0),
                                  (0.5, 0, 0)])
        wanted_atoms = numpy.array([1, 1, 1, 1, 2, 2, 2, 2])
        numpy.testing.assert_almost_equal(ext_fcc.lattice, wanted_latt)
        numpy.testing.assert_almost_equal(ext_fcc.positions, wanted_pos)
        numpy.testing.assert_almost_equal(ext_fcc.atoms, wanted_atoms)
Example #2
0
 def test_extend_bug(self):
     sc_latt = [4, 0, 0, 0, 4, 0, 0, 0, 4]
     sc_pos = [(0, 0, 0)]
     sc_atoms = [1]
     sc_pcell = Cell(sc_latt, sc_pos, sc_atoms)
     op_ext = numpy.array([1, 0, 0, 0, 1, 0, 0, 0, 5]).reshape((3, 3))
     ext_sc = sc_pcell.extend(op_ext)  # raise ValueError
     pass