qzhu2017 / XRD

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

Scattering Factor #7

Closed sayred1 closed 4 years ago

sayred1 commented 4 years ago

@qzhu2017

I've finished rewriting our scattering factor term to match pymatgen's code. I haven't compared it with pymatgen yet because I ran into something dealing with the pre-loaded scattering terms for each element.

Choosing SrF as the structure, pymatgen's scattering terms for Sr and F are 

[[  5.848 104.972]
  [  4.003  19.367]
  [  2.342   3.737]
  [  0.88    0.414]] 

[[  0.387  20.239]
 [  0.811   6.609]
 [  0.475   1.931]
 [  0.146   0.279]]

respectively.

Ours are

[[ 17.566   9.818   5.422   2.669   1.556  14.099   0.166 132.376   2.506]

 [  3.539   2.641   1.517   1.024  10.283   4.294   0.262  26.148   0.278]]

respectively.

I'm able to reshape ours to match their array shape, then proceed to calculating the scatter factor, but I'm not sure which subset of terms to use.

For now, I will just use their terms and ensure that our scattering terms match.

sayred1 commented 4 years ago

https://github.com/materialsproject/pymatgen/blob/master/pymatgen/analysis/diffraction/atomic_scattering_params.json location of their .json file of scattering parameters.

qzhu2017 commented 4 years ago

@sayred1

I don't understand what you mean here. First, please upload some code to support your results. Second, the scattering term depends on theta. Is the output before you couple the theta?

sayred1 commented 4 years ago

https://github.com/qzhu2017/XRD/blob/d31190d8215947b0339097497f311d9c5d785ccb/XRD.py#L724-L729

In line 725 we obtain the scattering parameters from the precomputed list within the Element class, particularly lines https://github.com/qzhu2017/XRD/blob/d31190d8215947b0339097497f311d9c5d785ccb/XRD.py#L165 (Sr) and https://github.com/qzhu2017/XRD/blob/d31190d8215947b0339097497f311d9c5d785ccb/XRD.py#L136 (F)

These are loaded directly from the precomputed list, and then used to calculate the scattering factor in line 726.

Pymatgen obtains their scattering parameters from a .json file linked earlier, and is loaded in the following manner:

        for site in structure:
            for sp, occu in site.species.items():
                zs.append(sp.Z)
                try:
                    c = ATOMIC_SCATTERING_PARAMS[sp.symbol]
                except KeyError:
                    raise ValueError("Unable to calculate XRD pattern as "
                                     "there is no scattering coefficients for"
                                     " %s." % sp.symbol)

Where ATOMIC_SCATTERING_PARAMS is the json file and sp.symbol is the element.

This is the output immediately before calculating the scattering factor. The scattering factor is theta dependent, but the scattering parameters aren't. According to the textbook I have (https://www.amazon.com/Structure-Materials-Marc-Graef-ebook/dp/B009XBOUNA), pymatgen terms are correct.

qzhu2017 commented 4 years ago

As I told you some time ago, our precomputed values are also from some table, which is theta independent. We need to change them to the new scheme. This is something which I asked you to work on. I don't understand why just started to prove to me this is a correct scheme. Now you need to implement it.

sayred1 commented 4 years ago

@qzhu2017

The precomputed values weren't included in my discussion notes of the meeting, I'm not sure why I didn't note that the scattering parameters need to be changed along with the formula for the scattering factor, sorry about that. I have already started to implement this, I will continue to update you along the way.

sayred1 commented 4 years ago

@qzhu2017 finishing up scattering/structure factor changes. Will upload code on repo tonight. Going to start reading up on different correction factors and the paper you showed me tonight.