Beispiel #1
0
 def atomAtPosition(self,position):
     """Returns the atom at the position if one exists, None otherwise"""
     if self.positionIsInCell(position):
         positionList = []
         for atom in self.Atoms:
             positionList.append(atom.getPosition())
         closest = self.Atoms[SymmetryUtilities.nearestSiteIndex(positionList,position)]
         if SymmetryUtilities.equalPositions(closest.getPosition(), position):
             return closest
     return None
Beispiel #2
0
 def atomAtPosition(self, position):
     """Returns the atom at the position if one exists, None otherwise"""
     if self.positionIsInCell(position):
         positionList = []
         tmpAtoms = []
         for num, atom in self.atoms.items():
             tmpAtoms.append(atom)
             positionList.append(atom.getPosition())
         closest = tmpAtoms[SymmetryUtilities.nearestSiteIndex(
             positionList, position)]
         if SymmetryUtilities.equalPositions(closest.getPosition(),
                                             position):
             return closest
     return None
Beispiel #3
0
    def generateAtoms(self, symbol, position, massNum = None, **kwds):
        """Given the information of one atom and the space group associated with
        this Cell object, this method creates all the symmetry equivalent atoms
        and adds them to the model (cutoff cell).
        
        -symbol is the element symbol (H, He, Li...)
	-massNum is the atomic Mass Number for the element
	If the symbol and mass number do not correspond to a real element, an
	ElementNotFound Exception will be raised.  massNum can, however, be None.
	
        -position is the fractional coordinates in the unit cell (a,b,c)
        
        Optional keyword arguments are:
        (spin, spinMagnitude, valence, anisotropy, rgb, radius, and description)
        
        -spin is a tuple(Sx, Sy, Sz). It is optional.
        -spinMagnitude is the total magnitude of the spin =sqrt(Sx^2+Sy^2+Sz^2)
        -anisotropy is the single ion anisotropy of the atom (Dx, Dy, Dz)
        -rgb is a 3 element tuple or list describing the color of the atom.  If
        this is notsupplied, the default color for that element is used.
        -radius is the radius of the atom in angstroms.  If it is None, it will
        be given the default value for the given element.
        -description is a string describing the atom such as a name/label and is
        optional.
        -Valence is a string describing the charge of the atom.
        """
        locations = SymmetryUtilities.expandPosition(self.Space_Group, numpy.array([position[0],position[1], position[2]]))[0]

        for coord in locations:
            #atom = Atom(self, coord[0], coord[1], coord[2], massNumber, description, valence, radius, r,g,b, anisotropy = anisotropy, spinMagnitude = spinMagnitude, elementObj = elementObj)
            #atom = Atom(elementObj, self, coord, valence, anisotropy, spinMagnitude, spin, description, rgb, radius)
            Atom(self, coord, symbol, massNum, **kwds)
Beispiel #4
0
    def generateAtoms(self, symbol, position, massNum=None, **kwds):
        """Given the information of one atom and the space group associated with
        this Cell object, this method creates all the symmetry equivalent atoms
        and adds them to the model (cutoff cell).
        
        -symbol is the element symbol (H, He, Li...)
	-massNum is the atomic Mass Number for the element
	If the symbol and mass number do not correspond to a real element, an
	ElementNotFound Exception will be raised.  massNum can, however, be None.
	
        -position is the fractional coordinates in the unit cell (a,b,c)
        
        Optional keyword arguments are:
        (spin, spinMagnitude, valence, anisotropy, rgb, radius, and description)
        
        -spin is a tuple(Sx, Sy, Sz). It is optional.
        -spinMagnitude is the total magnitude of the spin =sqrt(Sx^2+Sy^2+Sz^2)
        -anisotropy is the single ion anisotropy of the atom (Dx, Dy, Dz)
        -rgb is a 3 element tuple or list describing the color of the atom.  If
        this is notsupplied, the default color for that element is used.
        -radius is the radius of the atom in angstroms.  If it is None, it will
        be given the default value for the given element.
        -description is a string describing the atom such as a name/label and is
        optional.
        -Valence is a string describing the charge of the atom.
        """
        locations = SymmetryUtilities.expandPosition(
            self.Space_Group,
            numpy.array([position[0], position[1], position[2]]))[0]

        for coord in locations:
            #atom = Atom(self, coord[0], coord[1], coord[2], massNumber, description, valence, radius, r,g,b, anisotropy = anisotropy, spinMagnitude = spinMagnitude, elementObj = elementObj)
            #atom = Atom(elementObj, self, coord, valence, anisotropy, spinMagnitude, spin, description, rgb, radius)
            Atom(self, coord, symbol, massNum, **kwds)
Beispiel #5
0
    def generateAtoms(
        self, position, description, atomicNumber, valence, anisotropy=(0, 0, 0), spinMagnitude=1, radius=0.05
    ):
        """Given the information of one atom and the space group associated with
        this Cell object, this method creates all the symmetry equivalent atoms
        and adds them to the list."""

        locations = SymmetryUtilities.expandPosition(
            self.Space_Group, numpy.array([position[0], position[1], position[2]])
        )[0]

        # Create a random color for the atoms; In the future the color will be chosen
        # from a list based on hte atomic number along with the radius
        randGen = random.Random()
        r = random.uniform(0, 1)
        g = random.uniform(0, 1)
        b = random.uniform(0, 1)
        for coord in locations:
            # ===============================================================================
            #            print 'unit_cell:', self
            #            print 'x,y,z:', coord
            #            print 'atomicNum:', atomicNumber
            #            print 'description:', description
            #            print 'radius:', radius
            # ===============================================================================
            print "here"
            atom = Atom(
                self,
                coord[0],
                coord[1],
                coord[2],
                atomicNumber,
                description,
                valence,
                radius,
                r,
                g,
                b,
                anisotropy=anisotropy,
                spinMagnitude=spinMagnitude,
            )
            self.addAtom(atom)