本文整理汇总了Python中diffpy.pdffit2.PdfFit.fixpar方法的典型用法代码示例。如果您正苦于以下问题:Python PdfFit.fixpar方法的具体用法?Python PdfFit.fixpar怎么用?Python PdfFit.fixpar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类diffpy.pdffit2.PdfFit
的用法示例。
在下文中一共展示了PdfFit.fixpar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calculate
# 需要导入模块: from diffpy.pdffit2 import PdfFit [as 别名]
# 或者: from diffpy.pdffit2.PdfFit import fixpar [as 别名]
def calculate(self):
"""do the real calculation
"""
# clean up old results
self.rcalc = []
self.Gcalc = []
# do the job
if len(self.owner.strucs) == 0:
raise ControlConfigError("No structure is given for calculation")
# make sure parameters are initialized
self.owner.updateParameters()
from diffpy.pdffit2 import PdfFit
server = PdfFit()
# structure needs to be read before dataset allocation
for struc in self.owner.strucs:
server.read_struct_string(struc.writeStr('pdffit'))
for key,var in struc.constraints.items():
server.constrain(key.encode('ascii'), var.formula.encode('ascii'))
# set up dataset
server.alloc(self.stype, self.qmax, self.qdamp,
self.rmin, self.rmax, self.rlen)
server.setvar('qbroad', self.qbroad)
server.setvar('dscale', self.dscale)
# phase related variables
# pair selection applies to current dataset,
# therefore it has to be done after alloc
nstrucs = len(self.owner.strucs)
for phaseidx0, struc in enumerate(self.owner.strucs):
phaseidx1 = phaseidx0 + 1
server.setphase(phaseidx1)
server.setvar('pscale', struc.getvar('pscale'))
server.setvar('spdiameter', struc.getvar('spdiameter'))
struc.applyPairSelection(server, phaseidx1)
# set up parameters
for index, par in self.owner.parameters.items():
server.setpar(index, par.initialValue()) # info[0] = init value
# fix if fixed. Note: all parameters are free after server.reset().
if par.fixed:
server.fixpar(index)
# all ready here
server.calc()
# get results
self.rcalc = server.getR()
self.Gcalc = server.getpdf_fit()