DanPorter / Dans_Diffraction

Reads crystallographic cif files and simulates diffraction
Apache License 2.0
41 stars 12 forks source link

Comparison of Intensities with other software #6

Closed DanPorter closed 2 years ago

DanPorter commented 3 years ago

Question from Sirius Han, Princeton Uni

I had some questions about how intensities are calculated using the "print_all_reflections" method. To be precise, if I load in a .cif card and use the above method to calculate intensities, they vary somewhat considerably from the same .cif card loaded into, say, CrystalDiffract, or literature data from MinDat (I am a geoscientist, so my primary use case involves mineralogy data.)

For example, using the attached .cif card for Rutile, CrystalDiffract predicts (hkl / I/Imax) 110 / 100 011 / 45.85 020 / 6.86 111 / 18.96

whereas using Dans-Diffraction, the following is calculated: (hkl / I/Imax) 110 / 95.07 011 / 39.35 020 / 14.13 111 / 21.87

Another example: using the attached .cif card for Spinel, CrystalDiffract predicts (hkl / I/Imax) 113 / 11.5

whereas Dans-Diffraction calculates: (hkl / I/Imax) 113 / 0.00015

thomasaarholt commented 3 years ago

Oddly enough, today I am wondering the same thing. We just had a master student come in and complain that various softwares are giving different relative intensities for peaks simulated with Vesta (here, the plot and table disagree as well) and PowderCell (20 year old software).

This raises the question of what is causing the difference, and is of particular import when trying to fit a pattern to a powder diffraction of an unknown structure.

If you attach the above Rutile Cif here, I can provide equivalent tables from the other softwares.

DanPorter commented 3 years ago

After investigating the rutile.cif structure:

My current hypothesis is that the difference arises from the definition of the x-ray scattering factor. My code uses the analytical approximation from the International Tables of Crystallography, though other methods of interpolation are possible. I will investigate this more closely later this week if I get some time.

DanPorter commented 3 years ago

Hi @thomasaarholt, thanks for commenting! This is indeed a strange issue.

I won't upload Sirius' cif without permission, but will ask. I've uploaded a very simple structure with no symmetry, only 1 element and I still see variations in the intensity: trial_structure.cif.txt

This evening I have had a close look through the differences in intensity calculation between my code, Vesta and CrystalDiffract. The documentation for Vesta is excellent and I can see there are a few differences. I'm still struggling to work out how CrystalDiffract works as I can't produce anything similar yet, although the documentation mentions something about normalising by the density.

One difference between x-ray scattering intensities in Dans_Diffraction is a slight difference in the analytical coefficients used to calculate the x-ray scattering factor -I use the values from the international tables of crystallography and Vesta uses values from the paper by Waasmaier and Kirfel (Acta Cryst 1995). On testing, this made very little difference however.

Another difference is in the method of calculating the Debye-Waller factor (accounting for the thermal motion of atoms). I haven't compared the calculation methods yet but if I set the Uiso value in the above CIF to 0 (or very very small), I suddenly calculate the same intensities.

So some progress... do let me know how you get on with other programs!

DanPorter commented 3 years ago

I've been very busy recently but I have now had a closer look through the differences in intensity calculation between my code, Vesta and CrystalDiffract. The documentation for Vesta is excellent and I can see there are a few differences. I'm still struggling to work out how CrystalDiffract works as I can't produce anything similar. The CrystalDiffract documentation mentions something about normalising by the density, but I still haven't reproduced their numbers.

One difference between x-ray scattering intensities in Dans_Diffraction is a slight difference in the analytical coefficients used to calculate the x-ray scattering factor. I use the values from the international tables of crystallography and Vesta uses values from the paper by Waasmaier and Kirfel (Acta Cryst 1995). On testing however, this made very little difference and does not account for the differences in intensity we see.

Another difference is in the method of calculating the Debye-Waller factor (accounting for the thermal motion of atoms). In the original CIFs supplied by Sirius (attached: Rutile.cif.txt, Spinel - Ono 08.cif.txt) there were no thermal parameters specified, and the default choosen is different between VESTA and Dans Diffraction, and probably CrystalDiffract. My code takes a value of u_iso=0.0 as default, VESTA takes B=1.0. If I set the same value, I got almost the exact match. Comparing the methods of calcualtion it turned out I had made a slight mistake in my calculation of the Debye-Waller factor.

I have now updated Dans_Diffraction with these corrections and version 1.9.9 is now available on GitHub. I have included an example script that compares the intensities: example_intensity_comparison.py

I have also comapred intensities across a wider range of software using the trial_structure above. The results are tabulated below: X-Ray Intensities - trail_strucuture.cif Energy = 8.0480 keV, wl = 1.5406 A (h,k,l) two-theta ITA Waasmaier Vesta CrystalDiffract CCTBX Mercury [1, 0, 0] 31.2487 411.85 412.09 412.09 34.21 412.09 411.85 [1, 1, 0] 44.7775 301.35 301.26 301.26 20.70 301.26 301.35 [1, 1, 1] 55.6136 231.05 230.89 230.89 13.75 230.89 231.05 [2, 0, 0] 65.1847 181.84 181.82 181.82 9.62 181.82 181.84 [2, 1, 0] 74.0607 146.03 146.11 146.11 7.01 146.11 146.03 [2, 1, 1] 82.5568 119.24 119.36 119.36 5.29 119.36 119.24

Here we can see that some codes by default use the ITA x-ray scattering analytical coefficients (Mercury) and others use the Waasmaier + Kirfel coefficients (Vesta, CCTBX).