xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
132 stars 63 forks source link

Generating FEFF input from CIF Files #523

Open Senjou123 opened 1 month ago

Senjou123 commented 1 month ago

Hello, I am trying to generate a FEFF file from a CIF file, ICSD database code 64918, which is for metallic Pd. I tried with both Larix 0.9.78 and 0.9.8 and in both cases the following error appears : Elements: ['Pd'] Sites: [0. 0. 0.] Pd0+ Traceback (most recent calls last): File "C:\Users\nrw23216\AppData\Local\xraylarch\Lib\site-packages\larch\wxlib\structure2feff_browser.py", line 415, in onImportStructure sites = ['%d' % (i+1) for i in range(len(sites))] ^^^^^^^^^^ TypeError: object of type 'PeriodicSite' has no len()

Is there a way to fix this problem?

Kind regards

Donato Decarolis

newville commented 1 month ago

@Senjou123 Sorry for the trouble. In general, CIF is a poorly defined format. The tools we use for parsing them can parse many things called "CIF", but they sometimes fail. We know that many from the COD do work. I don't know about ICSD.

The CIF database provided with Larix does have several structures for Pd.

But: for a problem reading some other CIF file, you would have to provide an example.

maurov commented 1 month ago

@Senjou123 I have tested with the following CIF file (ICSD 64918) and it works nicely with Larix 0.9.80

Pd_fcc_ICSD_CollCode64918.zip

Senjou123 commented 1 month ago

Hi,

Thank you both for your reply. I used that CIF file as an example. I have the same issue when trying to run other CIF files using the "Generate FEFF input from general structures, Run FEFF". I tried for example to run PdCl2 (ICSD 421215), Au3Pd, (ICSD 180873), PdO2 (ICSD 647283), and they all show up with the same error as the one I posted before " File "C:\Users\nrw23216\AppData\Local\xraylarch\Lib\site-packages\larch\wxlib\structure2feff_browser.py", line 415, in onImportStructure sites = ['%d' % (i+1) for i in range(len(sites))] ^^^^^^^^^^ TypeError: object of type 'PeriodicSite' has no len()"

Oddly enough I redownloaded the files and now it works. Could there be a problem with importing the files from OneDrive?

newville commented 1 month ago

@Senjou123 I doubt that the file's location is the issue -- your report shows that the file's content was read, and the problem occurs when it is being parsed.

But (again) for a problem reading some external CIF file, you will have to provide an example file.

Senjou123 commented 1 month ago

Hi Matt,

Sorry here are the CIF Files I was talking about.

Kind regards

Donato CIFS.zip

maurov commented 1 month ago

@Senjou123 it took me a while to correctly understand your issue, but I have found it now! Unfortunately, we currently have two pieces of code in Larch which are able to generate a FEFF input from CIF, all wrapping Pymatgen, but in a slightly different way. The first version was implemented by @newville, the second by @Ameyanagi (structure2feff). Actually, there is also a third one (struct2xas), but this is not available in the GUI, only as a Jupyter notebook.

To quickly fix your problem, simply use the first version by @newville, as shown in the screenshot here:

image