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 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 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 testNullData(self): """Make sure we get an error when trying to add or remove Null.""" from pyobjcryst.crystal import Crystal c = Crystal() self.assertRaises(ValueError, c.AddScatterer, None) self.assertRaises(ValueError, c.RemoveScatterer, None) self.assertRaises(ValueError, c.AddScatteringPower, None) self.assertRaises(ValueError, c.RemoveScatteringPower, None) return
def write_crystal(stru: Crystal, stru_file: str, fmt: str) -> None: """Write out the Crystal object in files.""" if fmt == "cif": with Path(stru_file).open("w") as f: stru.CIFOutput(f) elif fmt == "xyz": writexyz(stru, stru_file) else: raise ValueError("Unknown format: {}. Allow: 'cif', 'xyz'.".format(fmt)) return
def makeCrystal(sp, atom): c = Crystal(3.52, 3.52, 3.52, "225") c.AddScatterer(atom) c.AddScatteringPower(sp) return c
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 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
"""Plot C60 PDFs calculated with PDFCalculator and DebyePDFCalculator. The C60 molecule are stored in a pyobjcryst object. """ 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, }