fusion-energy / neutronics-workshop

A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools
MIT License
125 stars 53 forks source link

Task 01 Part 4 Broken? #300

Open VadanKhan opened 1 week ago

VadanKhan commented 1 week ago

It seems that this section is out of date, certainly not agreeing with the youtube videos. The plots are not interactive as in the videos, which is a shame (and when I try to copy the code I get this error on imports:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[19], line 6
      3 from openmc.data import REACTION_MT
      4 import matplotlib.pyplot as plt
----> 6 import plotting_utils
      7 from plotting_utils import create_temperature_plot_for_isotope

ModuleNotFoundError: No module named 'plotting_utils'

)

I had to edit both snippets to add show the legends: plt.legend() And the first plot did not iterate over multiple temperatures, I added this.

Could this section be updated, as so far the package has been great at touring the features of the package.

Updated Tungsten Temperature Iterative Plot

energy = np.linspace(1, 2000, 50000)  # sets the energy range from 1 to 2000eV, this is were resonances are

mt_number = REACTION_MT["(n,total)"]  # looks up the MT number for the total reaction

h5_file = f"/WMP_Library/074186.h5"  # 074186 is W186

isotope_multipole = openmc.data.WindowedMultipole.from_hdf5(h5_file)  # loads up the WMP cross section file

temperatures = [100, 200, 300, 400, 500, 750, 1000, 1500, 2000] # temperature in kelvin to plot

fig, ax = plt.subplots()

for temperature in temperatures:
    ax.plot(
        energy,
        isotope_multipole(energy, temperature)[mt_number],
        label=f"Tungsten 186 at {temperature} Kelvin",
    )

ax.set_yscale('log')
ax.set_ylabel('Microscopic cross section [barns]')
ax.set_xlabel('Energy [eV]')

plt.legend()
plt.show()
shimwell commented 1 week ago

Hi @VadanKhan

In this case the youtube video is out of date. It is difficult to find the time to keep the youtube videos up to date.

It would be great if you are able to make a PR for adding the temperature iteration on the first example and the legends if you have time.

If not, no worries I can tidy this up next week. Thanks for bringing it up.

As for the interactive examples these are no longer included as we switched to using the inbuild openmc code for plotting and that uses matplotlib. If you are keen then these can be made with plotly package and the openmc calculate _cexs function