# Set all temperature factors isotropic and equal to @4 for idx in range(1, 5): pf.constrain(pf.u11(idx), '@4') pf.constrain(pf.u22(idx), '@4') pf.constrain(pf.u33(idx), '@4') pf.setpar(4, pf.u11(1)) # Refine --------------------------------------------------------------------- pf.pdfrange(1, 1.5, 19.99) pf.refine() # Save results --------------------------------------------------------------- pf.save_pdf(1, "Ni_refinement.fgr") pf.save_struct(1, "Ni_refinement.rstr") pf.save_res("Ni_refinement.res") # Plot results --------------------------------------------------------------- # pylab is matplotlib interface with MATLAB-like plotting commands import pylab # obtain data from PdfFit calculator object r = pf.getR() Gobs = pf.getpdf_obs() Gfit = pf.getpdf_fit() # calculate difference curve, with pylab arrays it can be done # without for loop
#!/usr/bin/env python '''Calculate PDF of FCC nickel. Save data to Ni_calculation.cgr. ''' from diffpy.pdffit2 import PdfFit # create new PDF calculator object P = PdfFit() # load structure file in PDFFIT or DISCUS format P.read_struct("Ni.stru") radiation_type = 'X' # x-rays qmax = 30.0 # Q-cutoff used in PDF calculation in 1/A qdamp = 0.01 # instrument Q-resolution factor, responsible for PDF decay rmin = 0.01 # minimum r-value rmax = 30.0 # maximum r-value npts = 3000 # number of points in the r-grid # allocate and configure PDF calculation P.alloc(radiation_type, qmax, qdamp, rmin, rmax, npts) P.calc() P.save_pdf(1, "Ni_calculation.cgr")