Ejemplo n.º 1
0
def test_reduce1():
    atom = Atoms(['C', 'Au'])
    atom = atom.sub(0)
    atom1 = atom.reduce()
    assert atom[0] == Atom[6]
    assert len(atom) == 1
    assert len(atom.atom) == 2
    assert atom1[0] == Atom[6]
    assert atom1[0] != Atom[8]
    assert len(atom1) == 1
    assert len(atom1.atom) == 1
    atom.reduce(True)
    assert atom[0] == Atom[6]
    assert len(atom) == 1
    assert len(atom.atom) == 1
Ejemplo n.º 2
0
def test_remove1():
    atom = Atoms(['C', 'Au'])
    atom = atom.remove(1)
    atom = atom.reduce()
    assert atom[0] == Atom[6]
    assert len(atom) == 1
    assert len(atom.atom) == 1
Ejemplo n.º 3
0
 def test_reduce1(self):
     atom = Atoms(['C', 'Au'])
     atom = atom.sub(0)
     atom = atom.reduce()
     assert_true(atom[0] == Atom[6])
     assert_true(len(atom) == 1)
     assert_true(len(atom.atom) == 1)
Ejemplo n.º 4
0
Archivo: xv.py Proyecto: sofiasanz/sisl
    def read_geometry(self, velocity=False, species_Z=False):
        """ Returns a `Geometry` object from the XV file

        Parameters
        ----------
        species_Z : bool, optional
           if ``True`` the atomic numbers are the species indices (useful when
           reading the ChemicalSpeciesLabel block simultaneously).
        velocity : bool, optional
           also return the velocities in the file

        Returns
        -------
        Geometry
        velocity : only if `velocity` is true.
        """
        sc = self.read_supercell()

        # Read number of atoms
        na = int(self.readline())
        xyz = np.empty([na, 3], np.float64)
        vel = np.empty([na, 3], np.float64)
        atms = [None] * na
        sp = np.empty([na], np.int32)
        for ia in range(na):
            line = list(map(float, self.readline().split()[:8]))
            sp[ia] = int(line[0])
            if species_Z:
                atms[ia] = Atom(sp[ia])
            else:
                atms[ia] = Atom(int(line[1]))
            xyz[ia, :] = line[2:5]
            vel[ia, :] = line[5:8]

        xyz *= Bohr2Ang
        vel *= Bohr2Ang

        # Ensure correct sorting
        max_s = sp.max()
        sp -= 1
        # Ensure we can remove the atom after having aligned them
        atms2 = Atoms(AtomUnknown(1000), na=na)
        for i in range(max_s):
            idx = (sp[:] == i).nonzero()[0]
            if len(idx) == 0:
                # Always ensure we have "something" for the unoccupied places
                atms2[idx] = AtomUnknown(1000 + i)
            else:
                atms2[idx] = atms[idx[0]]

        geom = Geometry(xyz, atms2.reduce(), sc=sc)
        if velocity:
            return geom, vel
        return geom