本文整理汇总了Python中diffpy.pdffit2.PdfFit.set_scat方法的典型用法代码示例。如果您正苦于以下问题:Python PdfFit.set_scat方法的具体用法?Python PdfFit.set_scat怎么用?Python PdfFit.set_scat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.pdffit2.PdfFit
的用法示例。
在下文中一共展示了PdfFit.set_scat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPdfFit
# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import set_scat [as 别名]
#.........这里部分代码省略.........
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'))
self.P.setphase(1)
self.assertEqual(142, self.P.get_scat('X', 'Pb'))
self.P.setphase(2)
self.assertEqual(fPb, self.P.get_scat('X', 'Pb'))
# check exception for invalid inputs
self.assertRaises(ValueError, self.P.set_scat, 'Z', 'C', 123)
self.assertRaises(ValueError, self.P.set_scat, 'X', 'ZZ', 123)
return
def test_reset_scat(self):
"""check PdfFit.reset_scat()
"""
# raises exception when no phase exists
self.assertRaises(pdffit2.unassignedError, self.P.reset_scat, 'Ti')
# 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.P.read_struct(datafile('PbScW25TiO3.stru'))
self.P.set_scat('N', 'Pb', -17)
self.P.setphase(1)
self.assertNotEqual(fPb, self.P.get_scat('X', 'Pb'))
self.P.reset_scat('Pb')
self.assertEqual(fPb, self.P.get_scat('X', 'Pb'))
self.P.setphase(2)
self.assertNotEqual(bPb, self.P.get_scat('N', 'Pb'))
self.P.reset_scat('Pb')
self.assertEqual(bPb, self.P.get_scat('N', 'Pb'))
# check exception for invalid inputs
self.assertRaises(ValueError, self.P.reset_scat, 'Zz')
return
def test_num_atoms(self):
"""check PdfFit.num_atoms()
"""
self.P.read_struct(datafile('Ni.stru'))
self.assertEqual(4, self.P.num_atoms())
self.P.read_struct(datafile('PbScW25TiO3.stru'))
self.assertEqual(56, self.P.num_atoms())
self.P.setphase(1)
self.assertEqual(4, self.P.num_atoms())
self.P.setphase(2)
self.assertEqual(56, self.P.num_atoms())
return