RuntimeError: No cross_sections.xml file was specified

Hello,

I’m new in OpenMC and need some help.

I successfully downloaded openmc and set up OPENMC_CROSS_SECTION environment variable
However, when I runed the “Modeling Hexagonal Lattices” example on Jupyter Notebook, an error occured

input

plot = openmc.Plot.from_geometry(geometry)
plot.color_by = 'material'
plot.colors = colors = {
    water: 'blue',
    fuel: 'olive',
    fuel2: 'yellow'
}
plot.to_ipython_image()

error message

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-53-856b8d0e4c5c> in <module>
      6     fuel2: 'yellow'
      7 }
----> 8 plot.to_ipython_image()

~/.local/lib/python3.6/site-packages/openmc/plots.py in to_ipython_image(self, openmc_exec, cwd, convert_exec)
    703 
    704         # Run OpenMC in geometry plotting mode
--> 705         openmc.plot_geometry(False, openmc_exec, cwd)
    706 
    707         # Convert to .png

~/.local/lib/python3.6/site-packages/openmc/executor.py in plot_geometry(output, openmc_exec, cwd)
     57 
     58     """
---> 59     _run([openmc_exec, '-p'], output, cwd)
     60 
     61 

~/.local/lib/python3.6/site-packages/openmc/executor.py in _run(args, output, cwd)
     36         error_msg = ' '.join(error_msg.split())
     37 
---> 38         raise RuntimeError(error_msg)
     39 
     40 

RuntimeError: No cross_sections.xml file was specified in materials.xml or in the OPENMC_CROSS_SECTIONS environment variable. OpenMC needs such a file to identify where to find data libraries. Please consult the user's guide at https://docs.openmc.org/ for information on how to set up data libraries.

I tried to write the address directly, but it didn’t work

materials = openmc.Materials([mat1, mat2, …])
materials.cross_sections = ‘/path/to/nucleardata/cross_sections.xml’
materials.export_to_xml()

Thanks in advance for your help.

Edit your ~/.bashrc file and write OPENMC_CROSS_SECTIONS instead of OPENMC_CROSS_SECTION. Save it and close your terminal. Your problem should be solved.

I’m getting the same error, but can’t find the ~/.bashrc file you’ve mentioned… Could you elaborate a bit more?

@soha On macOS, you will likely need to put it in ~/.bash_profile instead of ~/.bashrc. You can read more about this here.

Also note that you don’t necessarily have to use the OPENMC_CROSS_SECTIONS environment variable. You can alternatively set openmc.config['cross_sections'] from your Python script.

1 Like

Worked! Thank you! :smile: