DanPorter / Dans_Diffraction

Reads crystallographic cif files and simulates diffraction
Apache License 2.0
45 stars 13 forks source link

voigt_profile #7

Closed yevgenyr closed 2 years ago

yevgenyr commented 2 years ago

Hi Dan, Great code - thanks!

I was wondering if you have plans to add a voigt peak shape (see here).

I remember that realistically, line profiles usually have this lineshape. Gaussians are usually rare.

it can be something like:

t = np.arange(-1000, 1000, 0.1) 
fwhmg = 2  
fwhml = 2 
v = sps.voigt_profile(t, fwhmg, fwhml) 
I = np.convolve(I, v, 'same') 

inside Scatter.generate_powder. (I is the pxrd profile with delta functions)

DanPorter commented 2 years ago

Hi yevgenyr,

Thanks for your message and glad to hear you like the code!

That's a great idea and something I had planned on adding at some point (when someone asked for it). Now you have asked, I'll find a way to add this feature :)

Best wishes,

Dan

yevgenyr commented 2 years ago

Thanks Dan, If you'de like I can also contribute in a way of Pull Requests as I go. I am working on integrating a different CIF reader (from diffpy - it is a bit more comprehansive) and map it over to your cif reader. (of course feel free to reject/modify my PRs :))

DanPorter commented 2 years ago

Hi yevgenyr, I've just committed a new version (V2.2.0) with some new features on the calculation of powder patterns:

twotheta, intensity, reflections = xtl.Scatter.powder('xray', units='twotheta', energy_kev=8, lorentz_fraction=0.5, custom_peak=None)

The are new inputs (all can also be set using xtl.Scatter.setup_scatter):

And there are new outputs:

I've added an example showing this functionality in the examples folder.

Please do have a go and see what you think! If you spot any problems let me know.

Out of interest - what features does the diffpy CIF reader have that aren't in my (admittedly pretty simple) one?