本文整理汇总了Python中diffpy.srreal.pdfcalculator.PDFCalculator.setPairMask方法的典型用法代码示例。如果您正苦于以下问题:Python PDFCalculator.setPairMask方法的具体用法?Python PDFCalculator.setPairMask怎么用?Python PDFCalculator.setPairMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.srreal.pdfcalculator.PDFCalculator
的用法示例。
在下文中一共展示了PDFCalculator.setPairMask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPDFCalculator
# 需要导入模块: from diffpy.srreal.pdfcalculator import PDFCalculator [as 别名]
# 或者: from diffpy.srreal.pdfcalculator.PDFCalculator import setPairMask [as 别名]
#.........这里部分代码省略.........
# termination at rmin is poorly cut in PDFfit2
mxnd = _maxNormDiff(gpf2, gcalc)
self.failUnless(mxnd < 0.057)
# more accurate from 1.5
mxnd1 = _maxNormDiff(gpf2[:500], gcalc[:500])
mxnd2 = _maxNormDiff(gpf2[500:], gcalc[500:])
self.failUnless(mxnd1 < 0.056)
self.failUnless(mxnd2 < 0.020)
return
def test_partial_pdfs(self):
"""Check calculation of partial PDFs.
"""
pdfc = self.pdfcalc
pdfc.rstep = 0.1
rutile = self.tio2rutile
atomtypes = [a.element for a in rutile]
r0, g0 = pdfc(rutile)
rdf0 = pdfc.rdf
# Ti-Ti
pdfc.maskAllPairs(False)
pdfc.setTypeMask("Ti", "Ti", True)
r1, g1 = pdfc(rutile)
rdf1 = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r1))
pdfc.invertMask()
r1i, g1i = pdfc(rutile)
rdf1i = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r1i))
self.failUnless(numpy.allclose(g0, g1 + g1i))
self.failUnless(numpy.allclose(rdf0, rdf1 + rdf1i))
# Ti-O
pdfc.maskAllPairs(True)
pdfc.setPairMask(range(2), range(2), False)
pdfc.setPairMask(range(2, 6), range(2, 6), False)
r2, g2 = pdfc(rutile)
rdf2 = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r2))
pdfc.invertMask()
r2i, g2i = pdfc(rutile)
rdf2i = pdfc.rdf
self.failUnless(numpy.allclose(g0, g2 + g2i))
self.failUnless(numpy.allclose(rdf0, rdf2 + rdf2i))
# Ti-O using type mask
pdfc.maskAllPairs(True)
pdfc.setTypeMask("Ti", "Ti", False)
pdfc.setTypeMask("O", "O", False)
r2t, g2t = pdfc(rutile)
rdf2t = pdfc.rdf
self.failUnless(numpy.array_equal(r0, r2t))
self.failUnless(numpy.array_equal(g2, g2t))
self.failUnless(numpy.array_equal(rdf2, rdf2t))
pdfc.invertMask()
r2ti, g2ti = pdfc(rutile)
rdf2ti = pdfc.rdf
self.failUnless(numpy.array_equal(g2i, g2ti))
self.failUnless(numpy.array_equal(rdf2i, rdf2ti))
# O-O
pdfc.maskAllPairs(False)
for i, smbli in enumerate(atomtypes):
for j, smblj in enumerate(atomtypes):
if smbli == smblj == "O":
pdfc.setPairMask(i, j, True)
r3, g3 = pdfc(rutile)
rdf3 = pdfc.rdf
pdfc.invertMask()