本文整理汇总了Python中diffpy.pdffit2.PdfFit.get_scat方法的典型用法代码示例。如果您正苦于以下问题:Python PdfFit.get_scat方法的具体用法?Python PdfFit.get_scat怎么用?Python PdfFit.get_scat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.pdffit2.PdfFit
的用法示例。
在下文中一共展示了PdfFit.get_scat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPdfFit
# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import get_scat [as 别名]
#.........这里部分代码省略.........
# 4 Ni atoms with coordination 12
self.assertEqual(4*12, len(dfcc['dij']))
# invalid element
self.assertRaises(ValueError, self.P.bond_length_types, 'Ni', 'Nix', 0.1, 5.0)
# check indices ij0
allij0 = sum(dfcc['ij0'], tuple())
self.assertEqual(0, min(allij0))
self.assertEqual(3, max(allij0))
# check indices ij1
allij1 = sum(dfcc['ij1'], tuple())
self.assertEqual(1, min(allij1))
self.assertEqual(4, max(allij1))
# check index values
ij0check = [(i1 - 1, j1 - 1) for i1, j1 in dfcc['ij1']]
self.assertEqual(ij0check, dfcc['ij0'])
# test valid element which is not present in the structure
dnone = self.P.bond_length_types('Ni', 'Au', 0.1, 5.0)
self.assertEqual(0, len(dnone['dij']))
self.assertEqual(0, len(dnone['ddij']))
self.assertEqual(0, len(dnone['ij0']))
self.assertEqual(0, len(dnone['ij1']))
return
# def test_show_scat(self):
# """check PdfFit.show_scat()
# """
# return
#
# def test_get_scat_string(self):
# """check PdfFit.get_scat_string()
# """
# return
def test_get_scat(self):
"""check PdfFit.get_scat()
"""
# x-ray scattering factors
fPb = self.P.get_scat('X', 'Pb')
self.assertEqual(82.0, fPb)
fTi = self.P.get_scat('X', 'tI')
self.assertEqual(22.0, fTi)
# neutron scattering lengths
bPb = self.P.get_scat('N', 'PB')
self.assertAlmostEqual(9.401, bPb, 3)
bTi = self.P.get_scat('N', 'ti')
self.assertAlmostEqual(-3.370, bTi, 3)
# exceptions
self.assertRaises(ValueError, self.P.get_scat, 'N', 'zz')
self.assertRaises(ValueError, self.P.get_scat, 'Z', 'Ti')
return
def test_set_scat(self):
"""check PdfFit.set_scat()
"""
# raises exception when no phase exists
self.assertRaises(pdffit2.unassignedError,
self.P.set_scat, 'N', 'Ti', -11)
# check if it is local to phase
fPb = self.P.get_scat('X', 'Pb')
bPb = self.P.get_scat('N', 'Pb')
self.P.read_struct(datafile('PbScW25TiO3.stru'))
self.P.set_scat('X', 'Pb', 142)
self.assertEqual(142, self.P.get_scat('X', 'Pb'))
self.assertEqual(bPb, self.P.get_scat('N', 'Pb'))
self.P.read_struct(datafile('PbScW25TiO3.stru'))
self.assertEqual(fPb, self.P.get_scat('X', 'Pb'))