You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 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.
@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
`
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
The text was updated successfully, but these errors were encountered: