def _setStructureFromMatterStructure(self, structure, massList = [], psList = [], ibrav = 0):
     """
     structure - matter.Structure object
     ibrav - Lattice index
     psList - list of strings with potential names
     matterStructure object will be modified with reduced atomic positions
     """      
     matterLattice = structure.lattice
     qeLattice = QELattice(ibrav = 0, base = matterLattice.base)
     qeLattice.a = 1.889725989*qeLattice.a
     qeLattice._qeInput = self._qeInput
     self.lattice = qeLattice
     self.lattice.type = 'generic cubic'
     atomNames = []        
     for a in structure:
         if a.symbol not in atomNames:
             atomNames.append(a.symbol)
     atomicSpecies = {}
     for i, elem in enumerate(atomNames):
         if len(massList) - 1 < i:
             mass = 0
         else:
             mass = massList[i]
         if len(psList) - 1 < i:
             ps = ''
         else:
             ps = psList[i]               
         atomicSpecies[elem] =  (mass, ps)   
     self[:] = []
     for atom in structure:
         self.addNewAtom(atype = atom.symbol, xyz = atom.xyz, \
                         mass = atomicSpecies[atom.symbol][0], \
                         potential = atomicSpecies[atom.symbol][1],\
                         lattice = self.lattice, optConstraint = [])  
 def reduce(self, ibrav = None): 
     """
     Reduces a structure instance with nonprimitive lattice ( i.e. solves
     for equivalent atomic positions) according to specified  lattice type (ibrav). 
     Each ibrav number corresponds to a specific primitive lattice 
     (see QE documentation).         
     """
     ib = self.lattice.ibrav
     if ibrav != None:
         ib = ibrav            
     a = self.lattice.matter().a
     b = self.lattice.matter().b
     c = self.lattice.matter().c
     cAB = cosd(self.lattice.matter().gamma)
     cBC = cosd(self.lattice.matter().alpha)
     cAC = cosd(self.lattice.matter().beta)
     if ib > 0:
         qeLattice = QELattice(ibrav = ib, a = a, b = b, c = c,  cBC =  cBC, \
                           cAC = cAC, cAB = cAB)
     else:
         qeLattice = QELattice(ibrav = ib, base = self.lattice.base)            
     qeLattice._qeInput = self._qeInput
     reducedStructure = QEStructure(self)
     reducedStructure.placeInLattice( qeLattice )
     # collect atoms that are at equivalent position to some previous atom
     duplicates = set([a1
         for i0, a0 in enumerate(reducedStructure) for a1 in reducedStructure[i0+1:]
             if  a0.symbol == a1.symbol and equalPositions(a0.xyz, a1.xyz, eps=1e-4)])
     # Filter out duplicate atoms.  Use slice assignment so that
     # reducedStructure is not replaced with a list.
     self.lattice = qeLattice
     self[:] = [a for a in reducedStructure if not a in duplicates]        
     self._qeInput.structure = self
     return
 def _setReducedStructureFromMatterStructure(self, structure, ibrav, massList = [], psList = []):
     """
     structure - matter.Structure object
     ibrav - Lattice index
     psList - list of strings with potential names
     matterStructure object will be modified with reduced atomic positions
     """
     import copy
     matterLattice = copy.deepcopy(structure.lattice)
     # there is a big problem with what Nikolay is doing because he is initializing QELattice with abcalbega which
     # leaves room for errors in how the basis vectors are chosen compared to the old lattice
     a = matterLattice.a
     b = matterLattice.b
     c = matterLattice.c
     cAB = cosd(matterLattice.gamma)
     cBC = cosd(matterLattice.alpha)
     cAC = cosd(matterLattice.beta)
     qeLattice = QELattice(ibrav = ibrav, a = a, b = b, c = c,  cBC =  cBC, \
                           cAC = cAC, cAB = cAB)
     #what he should do is initialize the vectors of QELattice with the vectors of matterLattice
     #
     qeLattice._qeInput = self._qeInput
     self.lattice = qeLattice
     # make a deep copy:
     reducedStructure = Structure(atoms = structure)
     reducedStructure.placeInLattice(Lattice(base=qeLattice.matter().base))
     # collect atoms that are at equivalent position to some previous atom
     duplicates = set([a1
         for i0, a0 in enumerate(reducedStructure) for a1 in reducedStructure[i0+1:]
             if a0.symbol==a1.symbol and equalPositions(a0.xyz, a1.xyz, eps=1e-4)])
     # Filter out duplicate atoms.  Use slice assignment so that
     # reducedStructure is not replaced with a list.
     reducedStructure[:] = [a for a in reducedStructure if not a in duplicates]
     atomNames = []
     for a in reducedStructure:
         if a.symbol not in atomNames:
             atomNames.append(a.symbol)
     atomicSpecies = {}
     for i, elem in enumerate(atomNames):
         if len(massList) - 1 < i:
             mass = 0
         else:
             mass = massList[i]
         if len(psList) - 1 < i:
             ps = ''
         else:
             ps = psList[i]
         atomicSpecies[elem] =  (mass, ps)
     self[:] = []
     # convert to bohr units
     self.lattice.setLattice(ibrav, self.lattice.a*1.889725989, \
                              self.lattice.b*1.889725989,
                              self.lattice.c*1.889725989)
     for atom in reducedStructure:
         self.addNewAtom(atype = atom.symbol, xyz = atom.xyz, \
                         mass = atomicSpecies[atom.symbol][0], \
                         potential = atomicSpecies[atom.symbol][1],\
                         lattice = self.lattice, optConstraint = [])
Beispiel #4
0
    def _setStructureFromDiffpyStructure(self,
                                         structure,
                                         massList=[],
                                         psList=[],
                                         ibrav=0):
        """
        structure - diffpy.Structure object
        ibrav - Lattice index
        psList - list of strings with potential names
        diffpyStructure object will be modified with reduced atomic positions
        """
        diffpyLattice = structure.lattice

        qeLattice = QELattice(ibrav=0, base=diffpyLattice.base)
        qeLattice.a = 1.889725989 * qeLattice.a
        qeLattice._qeInput = self._qeInput

        self.lattice = qeLattice
        self.lattice.type = 'generic cubic'

        atomNames = []
        for a in structure:
            if self._element(a) not in atomNames:
                atomNames.append(self._element(a))

        atomicSpecies = {}
        for i, elem in enumerate(atomNames):
            if len(massList) - 1 < i:
                mass = 0
            else:
                mass = massList[i]
            if len(psList) - 1 < i:
                ps = ''
            else:
                ps = psList[i]
            atomicSpecies[elem] = (mass, ps)

        self[:] = []
        for atom in structure:
            elem = self._element(atom)
            self.addNewAtom(atype = elem, xyz = atom.xyz, \
                            mass = atomicSpecies[elem][0], \
                            potential = atomicSpecies[elem][1],\
                            lattice = self.lattice, optConstraint = [])
Beispiel #5
0
    def reduce(self, ibrav=None):
        """
        Reduces a structure instance with nonprimitive lattice ( i.e. solves
        for equivalent atomic positions) according to specified  lattice type (ibrav). 
        Each ibrav number corresponds to a specific primitive lattice 
        (see QE documentation).         
        """

        ib = self.lattice.ibrav
        if ibrav != None:
            ib = ibrav

        a = self.lattice.diffpy().a
        b = self.lattice.diffpy().b
        c = self.lattice.diffpy().c
        cAB = cosd(self.lattice.diffpy().gamma)
        cBC = cosd(self.lattice.diffpy().alpha)
        cAC = cosd(self.lattice.diffpy().beta)
        if ib > 0:
            qeLattice = QELattice(ibrav = ib, a = a, b = b, c = c,  cBC =  cBC, \
                              cAC = cAC, cAB = cAB)
        else:
            qeLattice = QELattice(ibrav=ib, base=self.lattice.base)

        qeLattice._qeInput = self._qeInput

        reducedStructure = QEStructure(self)

        reducedStructure.placeInLattice(qeLattice)

        # collect atoms that are at equivalent position to some previous atom
        duplicates = set([
            a1 for i0, a0 in enumerate(reducedStructure)
            for a1 in reducedStructure[i0 + 1:] if a0.element == a1.element
            and equalPositions(a0.xyz, a1.xyz, eps=1e-4)
        ])

        # Filter out duplicate atoms.  Use slice assignment so that
        # reducedStructure is not replaced with a list.
        self.lattice = qeLattice
        self[:] = [a for a in reducedStructure if not a in duplicates]

        self._qeInput.structure = self
        return
Beispiel #6
0
    def _setReducedStructureFromDiffpyStructure(self,
                                                structure,
                                                ibrav,
                                                massList=[],
                                                psList=[]):
        """
        structure - diffpy.Structure object
        ibrav - Lattice index
        psList - list of strings with potential names
        diffpyStructure object will be modified with reduced atomic positions
        """
        import copy

        diffpyLattice = copy.deepcopy(structure.lattice)

        a = diffpyLattice.a
        b = diffpyLattice.b
        c = diffpyLattice.c
        cAB = cosd(diffpyLattice.gamma)
        cBC = cosd(diffpyLattice.alpha)
        cAC = cosd(diffpyLattice.beta)

        qeLattice = QELattice(ibrav = ibrav, a = a, b = b, c = c,  cBC =  cBC, \
                              cAC = cAC, cAB = cAB)

        qeLattice._qeInput = self._qeInput
        self.lattice = qeLattice
        # make a deep copy:
        reducedStructure = Structure(atoms=structure)

        reducedStructure.placeInLattice(Lattice(base=qeLattice.diffpy().base))

        # collect atoms that are at equivalent position to some previous atom
        duplicates = set([
            a1 for i0, a0 in enumerate(reducedStructure)
            for a1 in reducedStructure[i0 + 1:]
            if self._element(a0) == self._element(a1)
            and equalPositions(a0.xyz, a1.xyz, eps=1e-4)
        ])

        # Filter out duplicate atoms.  Use slice assignment so that
        # reducedStructure is not replaced with a list.
        reducedStructure[:] = [
            a for a in reducedStructure if not a in duplicates
        ]

        atomNames = []
        for a in reducedStructure:
            if self._element(a) not in atomNames:
                atomNames.append(self._element(a))

        atomicSpecies = {}
        for i, elem in enumerate(atomNames):
            if len(massList) - 1 < i:
                mass = 0
            else:
                mass = massList[i]
            if len(psList) - 1 < i:
                ps = ''
            else:
                ps = psList[i]
            atomicSpecies[elem] = (mass, ps)

        self[:] = []

        # convert to bohr units
        self.lattice.setLattice(ibrav, self.lattice.a*1.889725989, \
                                 self.lattice.b*1.889725989,
                                 self.lattice.c*1.889725989)

        for atom in reducedStructure:
            elem = self._element(atom)
            self.addNewAtom(atype = elem, xyz = atom.xyz, \
                            mass = atomicSpecies[elem][0], \
                            potential = atomicSpecies[elem][1],\
                            lattice = self.lattice, optConstraint = [])
Beispiel #7
0
    def _setReducedStructureFromDiffpyStructure(self, structure, ibrav, massList = [], psList = []):
        """
        structure - diffpy.Structure object
        ibrav - Lattice index
        psList - list of strings with potential names
        diffpyStructure object will be modified with reduced atomic positions
        """
        import copy

        diffpyLattice = copy.deepcopy(structure.lattice)

        a = diffpyLattice.a
        b = diffpyLattice.b
        c = diffpyLattice.c
        cAB = cosd(diffpyLattice.gamma)
        cBC = cosd(diffpyLattice.alpha)
        cAC = cosd(diffpyLattice.beta)

        qeLattice = QELattice(ibrav = ibrav, a = a, b = b, c = c,  cBC =  cBC, \
                              cAC = cAC, cAB = cAB)

        qeLattice._qeInput = self._qeInput
        self.lattice = qeLattice
        # make a deep copy:
        reducedStructure = Structure(atoms = structure)

        reducedStructure.placeInLattice(Lattice(base=qeLattice.diffpy().base))

        # collect atoms that are at equivalent position to some previous atom
        duplicates = set([a1
            for i0, a0 in enumerate(reducedStructure) for a1 in reducedStructure[i0+1:]
                if   self._element(a0) == self._element(a1) and equalPositions(a0.xyz, a1.xyz, eps=1e-4)])

        
        # Filter out duplicate atoms.  Use slice assignment so that
        # reducedStructure is not replaced with a list.
        reducedStructure[:] = [a for a in reducedStructure if not a in duplicates]

        atomNames = []
        for a in reducedStructure:
            if self._element(a) not in atomNames:
                atomNames.append(self._element(a))
        
        atomicSpecies = {}
        for i, elem in enumerate(atomNames):
            if len(massList) - 1 < i:
                mass = 0
            else:
                mass = massList[i]
            if len(psList) - 1 < i:
                ps = ''
            else:
                ps = psList[i]
            atomicSpecies[elem] =  (mass, ps)
               
        self[:] = []
        
        # convert to bohr units
        self.lattice.setLattice(ibrav, self.lattice.a*1.889725989, \
                                 self.lattice.b*1.889725989,
                                 self.lattice.c*1.889725989)

        for atom in reducedStructure:
            elem = self._element(atom)
            self.addNewAtom(atype = elem, xyz = atom.xyz, \
                            mass = atomicSpecies[elem][0], \
                            potential = atomicSpecies[elem][1],\
                            lattice = self.lattice, optConstraint = [])
Beispiel #8
0
 def _setReducedStructureFromMatterStructure(self,
                                             structure,
                                             ibrav,
                                             massList=[],
                                             psList=[]):
     """
     structure - matter.Structure object
     ibrav - Lattice index
     psList - list of strings with potential names
     matterStructure object will be modified with reduced atomic positions
     """
     import copy
     matterLattice = copy.deepcopy(structure.lattice)
     # there is a big problem with what Nikolay is doing because he is initializing QELattice with abcalbega which
     # leaves room for errors in how the basis vectors are chosen compared to the old lattice
     a = matterLattice.a
     b = matterLattice.b
     c = matterLattice.c
     cAB = cosd(matterLattice.gamma)
     cBC = cosd(matterLattice.alpha)
     cAC = cosd(matterLattice.beta)
     qeLattice = QELattice(ibrav = ibrav, a = a, b = b, c = c,  cBC =  cBC, \
                           cAC = cAC, cAB = cAB)
     #what he should do is initialize the vectors of QELattice with the vectors of matterLattice
     #
     qeLattice._qeInput = self._qeInput
     self.lattice = qeLattice
     # make a deep copy:
     reducedStructure = Structure(atoms=structure)
     reducedStructure.placeInLattice(Lattice(base=qeLattice.matter().base))
     # collect atoms that are at equivalent position to some previous atom
     duplicates = set([
         a1 for i0, a0 in enumerate(reducedStructure)
         for a1 in reducedStructure[i0 + 1:] if a0.symbol == a1.symbol
         and equalPositions(a0.xyz, a1.xyz, eps=1e-4)
     ])
     # Filter out duplicate atoms.  Use slice assignment so that
     # reducedStructure is not replaced with a list.
     reducedStructure[:] = [
         a for a in reducedStructure if not a in duplicates
     ]
     atomNames = []
     for a in reducedStructure:
         if a.symbol not in atomNames:
             atomNames.append(a.symbol)
     atomicSpecies = {}
     for i, elem in enumerate(atomNames):
         if len(massList) - 1 < i:
             mass = 0
         else:
             mass = massList[i]
         if len(psList) - 1 < i:
             ps = ''
         else:
             ps = psList[i]
         atomicSpecies[elem] = (mass, ps)
     self[:] = []
     # convert to bohr units
     self.lattice.setLattice(ibrav, self.lattice.a*1.889725989, \
                              self.lattice.b*1.889725989,
                              self.lattice.c*1.889725989)
     for atom in reducedStructure:
         self.addNewAtom(atype = atom.symbol, xyz = atom.xyz, \
                         mass = atomicSpecies[atom.symbol][0], \
                         potential = atomicSpecies[atom.symbol][1],\
                         lattice = self.lattice, optConstraint = [])