openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
769 stars 496 forks source link

openmc.plot_xs() should support NCrystal materials #2422

Closed marquezj closed 1 year ago

marquezj commented 1 year ago

This is something we (@tkittel , @paulromano) forgot in PR #2222, but @zoeprieto brought to my attention. This function is really handy to plot the XS of whole materials, but as it is right now it ignores the contribution from NCrystal.

I will look into it, but I think it should be something easy to fix.

shimwell commented 1 year ago

I would be keen to see this feature and in general any attention the plot_xs function gets is good.

I've been tinkering with the plotter.py recently with #2413 and I think there is further scope to improve the functions in that file.

Looking forward to seeing NCrystal make it into the plotting function, would that allow us to plot things like parahydrogen at low temperatures?

marquezj commented 1 year ago

Hi @shimwell. Yes! NCrystal supports mixtures of scattering kernels, and each one is associated with the right nuclide, without need for pseudo isotopes. For instance, with the PR from @zoeprieto, it works like this:

cfg = """phases<0.95*para-H_T20.0K_ENDF8_massconvert_inelasticonly_dummydensity.ncmat&
                0.05*ortho-H_T20.0K_ENDF8_massconvert_inelasticonly_dummydensity.ncmat>"""
m1 = openmc.Material.from_ncrystal(cfg)
E1, xs1 = openmc.calculate_cexs(m1, 'material', ('total',))
plt.loglog(E1, xs1[0], label='95% para')

cfg = "para-H_T20.0K_ENDF8_massconvert_inelasticonly_dummydensity.ncmat"
m2 = openmc.Material.from_ncrystal(cfg)
E2, xs2 = openmc.calculate_cexs(m2, 'material', ('total',))
plt.loglog(E2, xs2[0], label='100% para')

plt.legend()
plt.ylim(0.2,100)
plt.xlabel('Energy [eV]')
plt.ylabel('Total Macro XS [cm^-1]')

(this is a typical example for cold neutron sources: check the effect of a given amount of liquid ortho-hydrogen in the emission of the source )

Edit: the ncmat files for these scattering kernels are in NCrystal-extra.

image

marquezj commented 1 year ago

Fixed by PR #2435. Thanks