def setUp(self): unittest.TestCase.setUp(self) self.atoms = atomsites.AtomSites() self.atom1 = atomsite.AtomSite(13, 0, 0, 0) self.atom2 = atomsite.AtomSite(13, 0, 0.5, 0.5) self.atom3 = atomsite.AtomSite(13, 0.5, 0, 0.5) self.atom4 = atomsite.AtomSite(13, 0, 0.5, 0.5)
def __call__(self, atom): """ Return the symmetry operation on an *atomsite*. :math:`= RV + T` :arg atom: atomsite to apply the symmetry operation :type atom: :class:`atomsite.AtomSite` """ position = atom.position atomicnumber = atom.atomicnumber newposition = self.r * position + self.t return atomsite.AtomSite(atomicnumber, newposition)
def get_atomsites(self): """ Return a :class:`list` of :class:`atomsite.AtomSite` from the cif. :rtype: : keyword:`list` """ atoms = atomsites.AtomSites() symmetry_equiv_pos_as_xyz = self.get(SYMMETRY_EQUIV_POS_AS_XYZ) atom_site_labels = self.get(ATOM_SITE_LABEL) atom_site_fract_xs = self.get(ATOM_SITE_FRACT_X) atom_site_fract_ys = self.get(ATOM_SITE_FRACT_Y) atom_site_fract_zs = self.get(ATOM_SITE_FRACT_Z) for i, atom_site_label in enumerate(atom_site_labels): # Remove digits after the chemical symbol if len(atom_site_label) > 1 and atom_site_label[1].isdigit(): symbol = atom_site_label[0] else: symbol = atom_site_label[:2] atomicnumber = ElementProperties.getAtomicNumberBySymbol(symbol) atom = atomsite.AtomSite(atomicnumber, atom_site_fract_xs[i][0], atom_site_fract_ys[i][0], atom_site_fract_zs[i][0]) atoms.append(atom) # Apply symmetry equivalent positions for atom in atoms: x, y, z = tuple(atom.position) atomicnumber = atom.atomicnumber for equiv_pos in symmetry_equiv_pos_as_xyz: equiv_x, equiv_y, equiv_z = equiv_pos # Allow float division equiv_x = equiv_x.replace('1/', '1.0/').replace( '2/', '2.0/').replace('3/', '3.0/').replace( '4/', '4.0/').replace('6/', '6.0/') equiv_y = equiv_y.replace('1/', '1.0/').replace( '2/', '2.0/').replace('3/', '3.0/').replace( '4/', '4.0/').replace('6/', '6.0/') equiv_z = equiv_z.replace('1/', '1.0/').replace( '2/', '2.0/').replace('3/', '3.0/').replace( '4/', '4.0/').replace('6/', '6.0/') # Replace x, y, z by the value newx = eval( equiv_x.replace('x', str(x)).replace('y', str(y)).replace( 'z', str(z))) newy = eval( equiv_y.replace('x', str(x)).replace('y', str(y)).replace( 'z', str(z))) newz = eval( equiv_z.replace('x', str(x)).replace('y', str(y)).replace( 'z', str(z))) # Add if new position newatom = atomsite.AtomSite(atomicnumber, newx, newy, newz) try: atoms.append(newatom) except atomsites.AtomSitePositionError: pass return atoms
def setUp(self): unittest.TestCase.setUp(self) self.atom1 = atomsite.AtomSite(13, 0, 0.5, 1.5) self.atom2 = atomsite.AtomSite(14, (0.3, -0.8, 0.1))
def setUp(self): unittest.TestCase.setUp(self) # Manual testing self.cubic = unitcell.create_cubic_unitcell(2) self.tetragonal = unitcell.create_tetragonal_unitcell(2, 3) self.orthorhombic = unitcell.create_orthorhombic_unitcell(1, 2, 3) self.trigonal = unitcell.create_trigonal_unitcell(2, 35.0 / 180 * pi) self.hexagonal = unitcell.create_hexagonal_unitcell(2, 3) self.monoclinic = unitcell.create_monoclinic_unitcell( 1, 2, 3, 55.0 / 180 * pi) self.triclinic = \ unitcell.create_triclinic_unitcell(1, 2, 3, 75.0 / 180 * pi, 55.0 / 180 * pi, 35.0 / 180 * pi) self.planes = [ plane.Plane(1, 0, 0), plane.Plane(1, 1, 0), plane.Plane(1, 1, 1), plane.Plane(2, 0, 2), plane.Plane(1, 2, 3), plane.Plane(4, 5, 6), plane.Plane(0, 9, 2) ] # Example 1.13 from Mathematical Crystallography (p.31-33) self.L1 = unitcell.create_hexagonal_unitcell(4.914, 5.409) self.atom1 = atomsite.AtomSite(8, (0.4141, 0.2681, 0.1188)) self.atom2 = atomsite.AtomSite(14, (0.4699, 0.0, 0.0)) self.atom3 = atomsite.AtomSite(14, (0.5301, 0.5301, 0.3333)) # Problem 1.13 from Mathematical Crystallography (p.34) alpha = 93.11 / 180.0 * pi beta = 115.91 / 180.0 * pi gamma = 91.26 / 180.0 * pi self.L2 = unitcell.create_triclinic_unitcell(8.173, 12.869, 14.165, alpha, beta, gamma) self.atom4 = atomsite.AtomSite(8, (0.3419, 0.3587, 0.1333)) self.atom5 = atomsite.AtomSite(14, (0.5041, 0.3204, 0.1099)) self.atom6 = atomsite.AtomSite(13, (0.1852, 0.3775, 0.1816)) # Example 2.16 and Problem 2.9 from Mathematical Crystallography (p.64-65) alpha = 114.27 / 180.0 * pi beta = 82.68 / 180.0 * pi gamma = 94.58 / 180.0 * pi self.L3 = unitcell.create_triclinic_unitcell(6.621, 7.551, 17.381, alpha, beta, gamma) # Problem 2.15 from Mathematical Crystallography (p.79) alpha = 113.97 / 180.0 * pi beta = 98.64 / 180.0 * pi gamma = 67.25 / 180.0 * pi self.L4 = unitcell.create_triclinic_unitcell(5.148, 7.251, 5.060, alpha, beta, gamma) # Scattering factors relativepath = os.path.join('..', 'testdata', 'goodconfiguration.cfg') configurationfilepath = Files.getCurrentModulePath( __file__, relativepath) self.scatter = scatteringfactors.XrayScatteringFactors( configurationfilepath) # Atom sites self.atomsfcc = atomsites.AtomSites([ atomsite.AtomSite(14, 0.5, 0.5, 0.0), atomsite.AtomSite(14, 0.5, 0.0, 0.5), atomsite.AtomSite(14, 0.0, 0.5, 0.5), atomsite.AtomSite(14, 0.0, 0.0, 0.0) ]) self.atomsbcc = atomsites.AtomSites([ atomsite.AtomSite(14, 0.5, 0.5, 0.5), atomsite.AtomSite(14, 0.0, 0.0, 0.0) ]) self.atomshcp = atomsites.AtomSites([ atomsite.AtomSite(14, 1 / 3.0, 2 / 3.0, 0.5), atomsite.AtomSite(14, 0.0, 0.0, 0.0) ])
def setUp(self): unittest.TestCase.setUp(self) self.sg = spacegroups.sg25 self.atom1 = atomsite.AtomSite(13, 1, 0, 0) self.atom2 = atomsite.AtomSite(13, 0.1, 0.1, 0.1)