def makeC60(): """Make the C60 molecule using pyobjcryst.""" from pyobjcryst.crystal import Crystal from pyobjcryst.molecule import Molecule from pyobjcryst.scatteringpower import ScatteringPowerAtom pi = numpy.pi # make a crystal box to put the molecule in c = Crystal(1, 1, 1, "P1") c.SetName("c60frame") # put a molecule inside the box m = Molecule(c, "c60") c.AddScatterer(m) # Create a dummy atom at the center. m.AddAtom(0, 0, 0, None, "center") # Create the scattering power object for the carbon atoms sp = ScatteringPowerAtom("C", "C") c.AddScatteringPower(sp) sp.SetBiso(0.25) # Add the other atoms. They will be named C1, C2, ..., C60. for i, l in enumerate(c60xyz.strip().splitlines()): x, y, z = map(float, l.split()) m.AddAtom(x, y, z, sp, "C%i"%(i+1)) return m
def makeScatterer(): sp = ScatteringPowerAtom("Ni", "Ni") sp.SetBiso(8*pi*pi*0.003) sp.B11 = 8*pi*pi*0.003 sp.SetBij(2, 2, 8*pi*pi*0.003) sp.SetBij(3, 3, 8*pi*pi*0.003) atom = Atom(0, 0, 0, "Ni", sp) print(sp.B11) return sp, atom
def makeC60(): c = Crystal(100, 100, 100, "P1") c.SetName("c60frame") m = Molecule(c, "c60") c.AddScatterer(m) sp = ScatteringPowerAtom("C", "C") sp.SetBiso(8*pi*pi*0.003) c.AddScatteringPower(sp) for i, l in enumerate(c60xyz.strip().splitlines()): x, y, z = map(float, l.split()) m.AddAtom(x, y, z, sp, "C%i"%i) return c
def makeC60(): """Make a crystal containing the C60 molecule using pyobjcryst.""" pi = numpy.pi c = Crystal(100, 100, 100, "P1") c.SetName("c60frame") m = Molecule(c, "c60") c.AddScatterer(m) sp = ScatteringPowerAtom("C", "C") sp.SetBiso(8*pi*pi*0.003) #c.AddScatteringPower(sp) for i, l in enumerate(c60xyz.strip().splitlines()): x, y, z = map(float, l.split()) m.AddAtom(x, y, z, sp, "C%i"%i) return c
def makeMnO6(): a = 5.6 crystal = Crystal(a, a, a, "P1") sp1 = ScatteringPowerAtom("Mn", "Mn") sp1.SetBiso(8*pi*pi*0.003) sp2 = ScatteringPowerAtom("O", "O") sp2.SetBiso(8*pi*pi*0.003) m = MakeOctahedron(crystal, "MnO6", sp1, sp2, 0.5*a) crystal.AddScatterer(m) return crystal
def convertObjcrystStru(self, mode='xyz_c'): ''' convert self.xxx to objcryst object only applied to non-periodic structure ''' if self.periodic: # raise TypeError('Cannot convert to periodic structure') if self.rawstype == 'diffpy': cif = self.rawstru.write('temp.cif', 'cif') objcryst = CreateCrystalFromCIF(file('temp.cif')) rv = objcryst os.remove('temp.cif') else: c = Crystal(1, 1, 1, "P1") c.SetName(self.name) m = Molecule(c, self.name) c.AddScatterer(m) for i in range(self.n): ele = self.element[i] sp = ScatteringPowerAtom(self.element[i], ele) if self.anisotropy[i]: uij = self.uij_c[i] sp.B11 = uij[0, 0] sp.B22 = uij[1, 1] sp.B33 = uij[2, 2] sp.B12 = uij[0, 1] sp.B13 = uij[0, 2] sp.B23 = uij[1, 2] else: biso = np.sum(self.uij_c[i].diagonal()) / 3 * (8 * np.pi ** 2) sp.SetBiso(biso) if mode == 'xyz': x, y, z = map(float, self.xyz[i]) else: x, y, z = map(float, self.xyz_c[i]) a = m.AddAtom(x, y, z, sp, "%s%i" % (ele, i + 1)) a.Occupancy = self.occ[i] rv = m return self.addProp(rv)
def makeLaMnO3(): from pyobjcryst.crystal import Crystal from pyobjcryst.atom import Atom from pyobjcryst.molecule import Molecule from pyobjcryst.scatteringpower import ScatteringPowerAtom pi = numpy.pi # It appears that ObjCryst only supports standard symbols crystal = Crystal(5.486341, 5.619215, 7.628206, "P b n m") crystal.SetName("LaMnO3") # La1 sp = ScatteringPowerAtom("La1", "La") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.996096, 0.0321494, 0.25, "La1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # Mn1 sp = ScatteringPowerAtom("Mn1", "Mn") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0, 0.5, 0, "Mn1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # O1 sp = ScatteringPowerAtom("O1", "O") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.0595746, 0.496164, 0.25, "O1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # O2 sp = ScatteringPowerAtom("O2", "O") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.720052, 0.289387, 0.0311126, "O2", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) return crystal
def makeScattererAnisotropic(): sp = ScatteringPowerAtom("Ni", "Ni") sp.B11 = sp.B22 = sp.B33 = 8*pi*pi*0.003 sp.B12 = sp.B13 = sp.B23 = 0 atom = Atom(0, 0, 0, "Ni", sp) return sp, atom
def makeScatterer(): sp = ScatteringPowerAtom("Ni", "Ni") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0, 0, 0, "Ni", sp) return sp, atom
def makeLaMnO3(): crystal = Crystal(5.486341, 5.619215, 7.628206, "P b n m") crystal.SetName("LaMnO3") # La1 sp = ScatteringPowerAtom("La1", "La") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.996096, 0.0321494, 0.25, "La1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # Mn1 sp = ScatteringPowerAtom("Mn1", "Mn") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0, 0.5, 0, "Mn1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # O1 sp = ScatteringPowerAtom("O1", "O") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.0595746, 0.496164, 0.25, "O1", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) # O2 sp = ScatteringPowerAtom("O2", "O") sp.SetBiso(8*pi*pi*0.003) atom = Atom(0.720052, 0.289387, 0.0311126, "O2", sp) crystal.AddScatteringPower(sp) crystal.AddScatterer(atom) return crystal
from matplotlib.pyplot import plot, show, clf, draw from diffpy.Structure import Structure from pyobjcryst.crystal import Crystal from pyobjcryst.molecule import Molecule from pyobjcryst.scatteringpower import ScatteringPowerAtom from diffpy.srreal.pdfcalculator import PDFCalculator, DebyePDFCalculator # load C60 molecule as a diffpy.Structure object bucky_diffpy = Structure(filename='datafiles/C60bucky.stru') # convert to an ObjCryst molecule c60 = Crystal(1, 1, 1, 'P1') mc60 = Molecule(c60, "C60") c60.AddScatterer(mc60) # Create the scattering power object for the carbon atoms sp = ScatteringPowerAtom("C", "C") sp.SetBiso(bucky_diffpy[0].Bisoequiv) for i, a in enumerate(bucky_diffpy): cname = "C%i" % (i + 1) mc60.AddAtom(a.xyz_cartn[0], a.xyz_cartn[1], a.xyz_cartn[2], sp, cname) # PDF configuration cfg = { 'qmax' : 25, 'rmin' : 0, 'rmax' : 10.001, 'rstep' : 0.05, } # calculate PDF by real-space summation pc0 = PDFCalculator(**cfg) r0, g0 = pc0(c60)