Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'en' keyword not functioning in xu.simpack.PowderModel class #47

Closed
wholden opened this issue Nov 17, 2017 · 2 comments
Closed

'en' keyword not functioning in xu.simpack.PowderModel class #47

wholden opened this issue Nov 17, 2017 · 2 comments

Comments

@wholden
Copy link

wholden commented Nov 17, 2017

While trying to change the energy of x-rays for simulating xrd data, I noticed that the pattern wouldn't change by setting the en=(energy, eV) keyword when PowderModel is instantiated.

e.g., looking at the tutorial example
(https://xrayutilities.sourceforge.io/simulations.html#powder-diffraction-simulations)

pm = xu.simpack.PowderModel(Fe_powder, Co_powder, I0=100, en=10000)
The addition of the 'en' keyword does not affect the output. After the above line of code, I checked the energy of the PowderDiffraction class that was created:
in: pm.pdiff[0].energy out: 8047.8230999999987

After some digging, I noticed I could override this and set the energy manually by:
pm.pdiff[0].energy=10000

However it seemed to me that this keyword should have worked. I can see that the keyword get's passed down in the source code, but for whatever reason the PowderDiffraction class that comes out still has the Cu Kalpha1 energy.

I made a jupyter notebook showing the bug based on the example from the tutorial. I couldn't attach it here as a .ipynb so I changed the extension to txt. I've also attached a PDF of the notebook.
XrayUtilities_BugDemonstration.pdf
XrayUtilities_BugDemonstration.txt

@wholden
Copy link
Author

wholden commented Nov 17, 2017

I have since understood that perhaps the intended method of controlling this is by setting the [powder.emission] setting in the xrayutilities.conf file.

I can use it that way, but it seems like the 'en' kwarg was getting passed through and should have worked, and also having the ability to control it through kwargs permits easy comparison of patterns at different incident energies. I'm also slightly confused since now I see that manually changing the pm.pdiff[0].energy=10000 doesn't affect the pm.pdiff[0].settings attribute, which still contains the value from the conf file. Not sure what to make of that.

@dkriegner
Copy link
Owner

dkriegner commented Nov 17, 2017

@wholden: this is indeed a bug/inconvenience in the latest release which was since then fixed. Please look at issue #42 which shows how it can be done and should also work for PowderModel when you use the newest GIT version. I will make an release in the next weeks which will contain this and lots of more improvements

Using the latest GIT code the output for your example is:
`In [13]: import numpy
...: import xrayutilities as xu
...: tt = numpy.arange(5, 120, 0.01)
...: Fe_powder = xu.simpack.Powder(xu.materials.Fe, 1,
...: crystallite_size_gauss=100e-9)
...: Co_powder = xu.simpack.Powder(xu.materials.Co, 5, # 5 times more Co
...: crystallite_size_gauss=200e-9)
...: pm = xu.simpack.PowderModel(Fe_powder, Co_powder, I0=100)
...: inte = pm.simulate(tt)
...:

In [14]: pm = xu.simpack.PowderModel(Fe_powder, Co_powder, I0=100, en=10000)

In [15]: pm.pdiff[0].energy
Out[15]: 10000.000000000002
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants