예제 #1
0
    def addNewAtom(self, *args, **kwargs):
        """Add new Atom instance to the end of this Structure.

        All arguments are forwarded to Atom constructor.

        No return value.
        """
        kwargs['lattice'] = self.lattice
        a = QEAtom(*args, **kwargs)
        list.append(self, a)
        self._uncache('labels')
예제 #2
0
 def append(self, a, copy=True):
     """Append atom to a structure and update its lattice attribute.
     a    -- instance of QEAtom
     copy -- flag for appending a copy of a.
             When False, append a and update a.owner.
     No return value.
     """
     self._uncache('labels')
     adup = copy and QEAtom(a) or a
     adup.lattice = self.lattice
     list.append(self, adup)
     if hasattr(self, '_qeInput') and self._qeInput != None:
         self._qeInput.update()
     return
예제 #3
0
 def __setitem__(self, idx, a, copy=True):
     """Set idx-th atom to a.
     idx  -- index of atom in this Structure
     a    -- instance of QEAtom
     copy -- flag for setting to a copy of a.
             When False, set to a and update a.lattice.
     No return value.
     """
     self._uncache('labels')
     adup = copy and QEAtom(a) or a
     adup.lattice = self.lattice
     list.__setitem__(self, idx, adup)
     if hasattr(self, '_qeInput') and self._qeInput != None:
         self._qeInput.update()
     return
예제 #4
0
 def insert(self, idx, a, copy=True):
     """Insert atom a before position idx in this Structure.
     idx  -- position in atom list
     a    -- instance of QEAtom
     copy -- flag for inserting a copy of a.
             When False, append a and update a.lattice.
     No return value.
     """
     self._uncache('labels')
     adup = copy and QEAtom(a) or a
     adup.lattice = self.lattice
     list.insert(self, idx, adup)
     if hasattr(self, '_qeInput') and self._qeInput != None:
         self._qeInput.update()
     return
예제 #5
0
 def extend(self, atoms, copy=True):
     """Extend Structure by appending copies from a list of atoms.
     atoms -- list of QEAtom instances
     copy  -- flag for extending with copies of QEAtom instances.
              When False extend with atoms and update their lattice
              attributes.
     No return value.
     """
     self._uncache('labels')
     if copy: adups = [QEAtom(a) for a in atoms]
     else: adups = atoms
     for a in adups:
         a.lattice = self.lattice
     list.extend(self, adups)
     if hasattr(self, '_qeInput') and self._qeInput != None:
         self._qeInput.update()
     return
예제 #6
0
    def __setslice__(self, lo, hi, atoms, copy=True):
        """Set Structure slice from lo to hi-1 to the sequence of atoms.

        lo    -- low index for the slice
        hi    -- high index of the slice
        atoms -- sequence of Atom instances
        copy  -- flag for using copies of Atom instances.  When False, set
                 to existing instances and update their lattice attributes.

        No return value.
        """
        self._uncache('labels')
        if copy: adups = [QEAtom(a) for a in atoms]
        else: adups = atoms
        for a in adups:
            a.lattice = self.lattice
        list.__setslice__(self, lo, hi, adups)
        if hasattr(self, '_qeInput') and self._qeInput != None:
            self._qeInput.update()
        return