Open dragonyanglong opened 6 years ago
Can I ask you questions for them in the future? I really appreciate your help and time!
Sure, I'd be glad to help.
How can I do similar thing like this part of code for CMI PDFcalculator load structure for PDFFIT engine?
You can directly pass FitStructure
instances from self.owner.strucs
to PDFCalculator call. No need to write any file. There are however several caveats:
unlike pdffit2, PDFCalculator has no utility for constraint equations, therefore you need to make sure any constraints have been applied to the structure before passing it to PDFCalculator. This can be done by calling FitStructure.applyParameters
method; this is effectively the same as the |Apply parameters|
button in the Parameters panel.
PDFCalculator works with one structure. To model multi-phase PDF, you need to sum up partial PDFs in the Calculation.
PDFCalculator currently applies some metadata from FitStructure.pdffit
dictionary to the calculation, but I am going to remove that functionality. To make sure your code will not break, I recommend to disable metadata using the nometa
function and set any calculator attributes as needed yourself. Example:
from matplotlib.pyplot import subplots, show
from diffpy.srreal.pdfcalculator import PDFCalculator
from diffpy.srreal.structureadapter import nometa
from diffpy.pdfgui.tui import LoadProject
prj = LoadProject('src/diffpy/pdfgui/tests/testdata/ni.ddp') nickel = prj.getPhases()[0]
nickel.pdffit['delta2'] = 4 nickel.pdffit['spdiameter'] = 20 pc1 = PDFCalculator() r, g1 = pc1(nickel)
pc2 = PDFCalculator() r, g2 = pc2(nometa(nickel))
pc3 = PDFCalculator() pc3.delta2 = 4 pc3.addEnvelope('sphericalshape') pc3.spdiameter = 20 r, g3 = pc3(nometa(nickel))
fig, ax = subplots() ax.plot(r, g1, label='implicit metadata') ax.plot(r, g2, label='no metadata') ax.plot(r, g3, label='explicit metadata') ax.legend()
show()
Hi @pavoljuhas, I am currently working on PDFgui2 project, replacing PDFFIT engine with your CMI engine. So in the future, one important functionality is that people can use magnetic PDF in PDFgui2 to analyze data from neutron PDF. I may sometimes have questions about the codes and functionalities, like in PDFgui and CMI, during my developing. Can I ask you questions for them in the future? I really appreciate your help and time!
Currently, I am working on calculation (no refinement yet) in the
pdfgui2
branch on my own forked repo. I meet a problem about loading structure information for CMI engine in the GUI. Could you help give any clues when you have time?In calculation.py , I would like to load structure information for CMI PDFcalculator. How can I do similar thing like this part of code for CMI PDFcalculator load structure for PDFFIT engine ? The original
self.owner.strucs
is in such format:[[Ni 0.000000 0.000000 0.000000 1.0000, Ni 0.000000 0.500000 0.500000 1.0000, Ni 0.500000 0.000000 0.500000 1.0000, Ni 0.500000 0.500000 0.000000 1.0000]]
I tried to use
diffpy.Structure.loadStructure
function to read the structure informationself.owner.strucs
, but failed. Any solutions?Or perhaps I even don't need to use
diffpy.Structure.loadStructure
for CMI PDFcalculator (although that's the only method I use when using CMI for refinements)? I could just keep such format and add structure information into CMI PDFcalculator load structure for PDFFIT engine ?Thank you very much, Pavol!