當前位置: 首頁>>代碼示例>>Python>>正文


Python PDFCalculator.setPairMask方法代碼示例

本文整理匯總了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()
開發者ID:XiaohaoYang,項目名稱:diffpy.srreal,代碼行數:70,代碼來源:testpdfcalculator.py


注:本文中的diffpy.srreal.pdfcalculator.PDFCalculator.setPairMask方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。