qzhu2017 / XRD

X-ray diffraction calculations
MIT License
7 stars 6 forks source link

FWHM #15

Closed qzhu2017 closed 4 years ago

qzhu2017 commented 4 years ago

@sayred1 Please implement the angle dependent FWHM to XRD calculation. Also please quickly compare the results with VESTA/Mercury for a few structures. See if you can get the good fit.

sayred1 commented 4 years ago

@qzhu2017 I've implemented the angle dependent FWHM to the XRD profiling calculation, I will upload my code tomorrow morning, however I'd like to show you some of the comparisons.

As a recap of what we've discussed earlier, the profiling function that VESTA claims to use is the Pseudo Voigt profile, Screen Shot 2020-01-23 at 12 00 25 AM. Where gamma (the FWHM) is a function of the gamma_g and gamma_l, Screen Shot 2020-01-22 at 11 59 40 PM. Screen Shot 2020-01-22 at 11 55 54 PM, and eta a function of gamma and gamma_l:

Screen Shot 2020-01-23 at 12 06 29 AM

Users are left to vary V and X.

I've played around w/ NaCl, trying to match it with the pattern from vesta. In my first try I varied V and X until the maximum peak (peak 2) was identical (by eye):

Screen Shot 2020-01-23 at 12 14 11 AM

I also tried to match all peaks by varying parameters, but this was about the best I could do!

Screen Shot 2020-01-23 at 12 22 09 AM

Again, if you zoom into peak 2, you could see why the residuals aren't the best

Screen Shot 2020-01-23 at 12 23 54 AM

I've noticed that the wider the 2theta space considered, it is much harder to make a "perfect" match. For the structure from A2-m for example, assigning X = 0.01978, V = 0.045 gives

Screen Shot 2020-01-23 at 12 33 45 AM

while X= 0.03678, V = 0.09 gives

Screen Shot 2020-01-23 at 12 43 04 AM

It is very difficult to adjust the parameters such that the residuals look more like a random pattern about 0.

sayred1 commented 4 years ago

The code is up. I've also uploaded a test script if you wanted to play around with the FWHM parameters.

qzhu2017 commented 4 years ago

@sayred1 I just went through the VESTA manual

image
qzhu2017 commented 4 years ago

Here is the output from RIETAN NaCl-RIETAN.txt

sayred1 commented 4 years ago

After setting all asymmetry parameters to zero here are the results:

Screen Shot 2020-01-23 at 6 05 35 PM

Using the same U, V, W, X, and Y with PXRD we have:

2theta I     fwhm
27.466 0.081 0.04
31.819 1.0   0.042
45.619 0.655 0.048
54.076 0.019 0.052
56.692 0.212 0.053
66.493 0.093 0.059
73.373 0.009 0.063
75.607 0.247 0.064
84.359 0.182 0.071
90.826 0.011 0.077
101.67 0.066 0.088
108.36 0.02  0.097
110.644 0.158 0.1

I then take the 2theta and I values from the Rietan-FP simulation, and plug them into the FWHM formula from the RR paper..

2theta I     fwhm
27.466 0.0849 0.0405
31.82 1.0 0.0421
45.62 0.7192 0.0477
54.077 0.0265 0.0517
56.693 0.2506 0.0531
66.495 0.1166 0.0585
73.374 0.0147 0.0629
75.609 0.3206 0.0645
84.361 0.2364 0.0711
90.829 0.004 0.0768
90.829 0.012 0.0768
101.673 0.0747 0.0883
108.364 0.0218 0.097
110.648 0.1267 0.1003
110.648 0.0317 0.1003
120.193 0.1126 0.117

So despite the slightly varying I values, the FWHM formula still doesn't match RIETAN.

sayred1 commented 4 years ago

@qzhu2017 they did end up using the modified split-profile function .

Rietan simulations:

Screen Shot 2020-01-24 at 2 15 12 PM

and PXRD:

2theta  I     fwhm
27.4658 0.0806 0.074865
31.8193 1.0 0.075239
45.6187 0.6553 0.077372
54.0756 0.0194 0.079493
56.6916 0.2118 0.080293
66.493 0.0929 0.083987
73.3725 0.0091 0.087338
75.6067 0.247 0.088581
84.3592 0.1822 0.094311
90.8263 0.0111 0.09958
101.6702 0.0656 0.110994
108.3602 0.0199 0.12016
110.6441 0.158 0.123762
120.1885 0.1318 0.142197

I will upload the code after my drive home.

qzhu2017 commented 4 years ago

Excellent! Please also try some other structures!

On Fri, Jan 24, 2020 at 2:19 PM Dean Lewis Sayre Jr. < notifications@github.com> wrote:

@qzhu2017 https://github.com/qzhu2017 they did end up using the modified split-profile function .

Rietan simulations: [image: Screen Shot 2020-01-24 at 2 15 12 PM] https://user-images.githubusercontent.com/35546511/73107953-f3e28c00-3eb3-11ea-9278-903ccaf05efb.png

and PXRD:

2theta I fwhm 27.4658 0.0806 0.074865 31.8193 1.0 0.075239 45.6187 0.6553 0.077372 54.0756 0.0194 0.079493 56.6916 0.2118 0.080293 66.493 0.0929 0.083987 73.3725 0.0091 0.087338 75.6067 0.247 0.088581 84.3592 0.1822 0.094311 90.8263 0.0111 0.09958 101.6702 0.0656 0.110994 108.3602 0.0199 0.12016 110.6441 0.158 0.123762 120.1885 0.1318 0.142197

I will upload the code after my drive home.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qzhu2017/XRD/issues/15?email_source=notifications&email_token=AHAUZ5QF3AUKY4K656BIAZLQ7NSOHA5CNFSM4KKQVHIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ4IQ3A#issuecomment-578324588, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHAUZ5XYWWI3HOYH5J4LVNTQ7NSOHANCNFSM4KKQVHIA .

--

*Qiang Zhu, *Assistant Professor 4505 S. Maryland Parkway, Room 232, Department of Physics and Astronomy, University of Nevada Las Vegas NV 89154-4002

Phone: 702-895-1707 Fax: 702-895-0804

Webpage: http://www.physics.unlv.edu/~qzhu http://uspex.stonybrook.edu/qzhu.html

sayred1 commented 4 years ago

I just noticed that the intensity values are different, probably because of the 2theta step sizes. I’ll look into this further.

Thanks, On Jan 24, 2020, 14:19 -0800, Dean Lewis Sayre Jr. notifications@github.com, wrote:

@qzhu2017 they did end up using the modified split-profile function . Rietan simulations: and PXRD: 2theta I fwhm 27.4658 0.0806 0.074865 31.8193 1.0 0.075239 45.6187 0.6553 0.077372 54.0756 0.0194 0.079493 56.6916 0.2118 0.080293 66.493 0.0929 0.083987 73.3725 0.0091 0.087338 75.6067 0.247 0.088581 84.3592 0.1822 0.094311 90.8263 0.0111 0.09958 101.6702 0.0656 0.110994 108.3602 0.0199 0.12016 110.6441 0.158 0.123762 120.1885 0.1318 0.142197 I will upload the code after my drive home. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

sayred1 commented 4 years ago

@qzhu2017 earlier I got over-excited when I saw the print out of the FWHM values. Although the FWHM values agree, the profiling does not: Screen Shot 2020-01-24 at 7 49 56 PM.

Would you please double check that my code for f(x) is consistent with that mentioned in the paper (as a sanity check)? I've checked it several times. Also, in the code, if you are wondering why we have to loop through x values here is because of the conditions stated within the paper:

H = np.sqrt(U*np.tan(np.pi*theta2[i]/2/180)**2 + V*np.tan(np.pi*theta2[i]/2/180) + W)
x = g2thetas - theta2[i]
for k, deltax in enumerate(x):
    if deltax >=  0:
        A = 1/A
        eta_h = kwargs['eta_l']
        eta_l = kwargs['eta_h']
    tmp[k] = ((1+A)*(eta_h + np.sqrt(np.pi*np.log(2))*(1-eta_h))) /\
                    (eta_l + np.sqrt(np.pi*np.log(2)) * (1-eta_l) + \
                    A*(eta_h + np.sqrt(np.pi*np.log(2))*(1-eta_h))) *\
                    (eta_l*2/(np.pi*H) * (1+((1+A)/A)**2 * (deltax/H)**2)**(-1) +\
                    (1-eta_l)*np.sqrt(np.log(2)/np.pi)* 2/H *np.exp(-np.log(2) * ((1+A)/A)**2 * (deltax/H)**2))

The following parameters were chosen for this profile:

U = 5.776410E-03 # FWHM parameter, U
V = -1.673830E-03 # FWHM parameter, V
W = 5.668770E-03 # FWHM parameter, W
A = 1.03944 # Asymmetry parameter, a1
eta_h = 0.504656 # Mixing parameter, eta_H0
eta_l = 0.611844  # Mixing parameter, eta_L0
Screen Shot 2020-01-24 at 7 58 00 PM

I'm going to continue looking into this tonight, there's a possibility that I'm missing something.

sayred1 commented 4 years ago

@qzhu2017 I just noticed that in the formula for the profile, they do not multiply by the intensity I0.

I do this and we have

Screen Shot 2020-01-24 at 8 38 12 PM
sayred1 commented 4 years ago

A couple more structures (from space groups A-1 and Pcab):

Screen Shot 2020-01-24 at 9 11 52 PM Screen Shot 2020-01-24 at 9 13 35 PM
qzhu2017 commented 4 years ago

@sayred1 Excellent. Can you update the script and check some more structures? Seems that this issue is to be solved finally!

sayred1 commented 4 years ago

I've updated the profiling code in the repo. There still exists the option to choose theta dependent gaussian or lorentzian profiling functions. Should I upload any others, like pseudo-voigt?

I also uploaded FWHM-angle.ipynb that tests 9 more structures and shows relevant plots + prints the similarity. If you want me to upload the corresponding .gpd/.ins files required to run this test script, let me know.

qzhu2017 commented 4 years ago

@sayred1 I just checked your updates. It looks like that we have pretty good agreement with VESTA output now. Can you also check a few structures with Mercury. After that, we can close this issue and then move on to #11

sayred1 commented 4 years ago

I've added 5 more structures in FWHM-angle.ipynb to compare with mercury.

Along with the lorentzian or gaussian functions w/ constant FWHM, I'm not positive that Mercury uses the same profiling function that VESTA uses. My hunch is that they use the pseudo-voigt profiling function w/ constant FWHM. Is this worth further looking into?

qzhu2017 commented 4 years ago

@sayred1 Thanks, can we find some time to talk?

qzhu2017 commented 4 years ago

Yes, it seems that Mercury used a different equation. I suggest we just stick to VESTA from now on.

sayred1 commented 4 years ago

@qzhu2017 sure, let me know when you'd like to chat.