Missing thermal scattering data after installing OpenMC

Hello,
Thank you for your time reading this post. I am new to openmc and new to Linux.

My problem is during the ‘Modelling a Pin-Cell’ tutorial I get an error saying ‘RuntimeError: Could not find thermal scattering data c_H_in_H2O in cross_sections.xml file.’

How can I fix this?

I can also see that I don’t have the same amount of isotopes in my cross_sections.xml file.

To further expand on the problem, I think the reason this may be happening is because I followed an unusual installation video meant for fusion modelling. I followed a fusion installation example here openmc workshop ubuntu - YouTube with openmc being downloaded with bundle from a github page.

I theorize I need to overwrite my cross_sections.xml file with a new library. How do I run the JEFF 3.3 library here data/convert_jeff33.py at master · openmc-dev/data · GitHub which I will assume has thermal scattering?

I am new to Linux and installing anaconda was the peak of my abilities.

Download the LANL ENDF/B-VIII.0 cross-section file from here. Your problem should be solved.

Thanks fsabab for the solution.
I am new to this. I clicked the [Download .tar.xz] link and clicked ‘save’.
Once it has downloaded do I need to do anything more, like extract the file into a specific folder somewhere?

You mentioned that you don’t know how to set up the new cross-section which I missed in my previous reply. Follow the steps below.

  1. Download the cross-section from the previous link and extract it.
  2. Go to the extracted folder. Find the cross_sections.xml file. Go to its properties and copy the parent directory for it.
  3. Open the cross_sections.xml file using any text editor and go to the 2nd line of the script and write

<directory>paste_the_path_you_copied</directory>

and save that

  1. Now if you want to use the same cross-section data every time, you can set up an environment variable. To do that follow this

    • Go to HOME in FILES and unhide the hidden files. You will find a file called .bashrc
    • Open that file using a text editor. Go to the last line and write the following

export OPENMC_CROSS_SECTIONS=‘the_path_you_copied/cross_sections.xml’

    Do not change anything else on the `.bashrc` file. Save that. 
  1. Now if you don’t wanna do this i.e., setting up the environment variable, you can simply omit the previous step. Just copy the cross_sections.xml file and paste it to your working directory.

I hope that it helps.

1 Like

I searched for the cross_sections.xml file but couldn’t find it. I searched the whole of my Home folder. Where do I find it?

You will find that after extracting the downloaded cross-section file.

Ok, thanks. I am extracting it now. :slight_smile:

Hi fsabab,
I followed steps 1 to 4, and reran the code in Jupyter Notebooks but unfortunately it did not work. My exact input, with the error message at the end is this:
%matplotlib inline

#ln 30 has a comment for N13

import openmc

uo2 = openmc.Material(1, “uo2”)

print(uo2)

Material
ID = 1
Name = uo2
Temperature = None
Density = None [sum]
S(a,b) Tables
Nuclides

mat = openmc.Material()

print(mat)

Material
ID = 2
Name =
Temperature = None
Density = None [sum]
S(a,b) Tables
Nuclides

help(uo2.add_nuclide)

Help on method add_nuclide in module openmc.material:

add_nuclide(nuclide, percent, percent_type=‘ao’) method of openmc.material.Material instance
Add a nuclide to the material

Parameters
----------
nuclide : str
    Nuclide to add, e.g., 'Mo95'
percent : float
    Atom or weight percent
percent_type : {'ao', 'wo'}
    'ao' for atom percent and 'wo' for weight percent

#Add nuclides to uo2

uo2.add_nuclide(‘U235’, 0.03)

uo2.add_nuclide(‘U238’, 0.97)

uo2.add_nuclide(‘O16’, 2.0)

uo2.set_density(‘g/cm3’, 10.0)

zirconium = openmc.Material(name=“zirconium”)

zirconium.add_element(‘Zr’, 1.0)

zirconium.set_density(‘g/cm3’, 6.6)

water = openmc.Material(name=“h2o”)

water.add_nuclide(‘H1’, 2.0)

water.add_nuclide(‘O16’, 1.0)

water.set_density(‘g/cm3’, 1.0)

water.add_s_alpha_beta(‘c_H_in_H2O’)

materials = openmc.Materials([uo2, zirconium, water])

materials = openmc.Materials()

materials.append(uo2)

materials += [zirconium, water]

isinstance(materials, list)

True

materials.export_to_xml()

!cat materials.xml

<?xml version='1.0' encoding='utf-8'?>

water.remove_nuclide(‘O16’)

water.add_element(‘O’, 1.0)

materials.export_to_xml()

!cat materials.xml

<?xml version='1.0' encoding='utf-8'?>

!cat $OPENMC_CROSS_SECTIONS | head -n 10

print(’ …’)

!cat $OPENMC_CROSS_SECTIONS | tail -n 10

<?xml version='1.0' encoding='utf-8'?>

<cross_sections>


















</cross_sections>

uo2_three = openmc.Material()

uo2_three.add_element(‘U’, 1.0, enrichment=3.0)

uo2_three.add_element(‘O’, 2.0)

uo2_three.set_density(‘g/cc’, 10.0)

Create PuO2 material

puo2 = openmc.Material()

puo2.add_nuclide(‘Pu239’, 0.94)

puo2.add_nuclide(‘Pu240’, 0.06)

puo2.add_nuclide(‘O16’, 2.0)

puo2.set_density(‘g/cm3’, 11.5)

Create the mixture

mox = openmc.Material.mix_materials([uo2, puo2], [0.97, 0.03], ‘wo’)

sphere = openmc.Sphere(r=1.0)

inside_sphere = -sphere

outside_sphere = +sphere

print((0,0,0) in inside_sphere, (0,0,2) in inside_sphere)

print((0,0,0) in outside_sphere, (0,0,2) in outside_sphere)

True False
False True

z_plane = openmc.ZPlane(z0=0)

northern_hemisphere = -sphere & +z_plane

northern_hemisphere.bounding_box

(array([-1., -1., 0.]), array([1., 1., 1.]))

cell = openmc.Cell()

cell.region = northern_hemisphere

or…

cell = openmc.Cell(region=northern_hemisphere)

cell.fill = water

universe = openmc.Universe()

universe.add_cell(cell)

this also works

universe = openmc.Universe(cells=[cell])

universe.plot(width=(2.0, 2.0))

<matplotlib.image.AxesImage at 0x7f4fabb865d0>

universe.plot(width=(2.0, 2,0), basis=‘xz’)

<matplotlib.image.AxesImage at 0x7f4faba1b7d0>

#skipped color

fuel_outer_radius = openmc.ZCylinder(r=0.39)

clad_inner_radius = openmc.ZCylinder(r=0.40) #delete later

clad_outer_radius = openmc.ZCylinder(r=0.46) #delete later

fuel_region = -fuel_outer_radius

gap_region = +fuel_outer_radius & -clad_inner_radius

clad_region = +clad_inner_radius & -clad_outer_radius

fuel = openmc.Cell(name=‘fuel’)

fuel.fill = uo2

fuel.region = fuel_region

gap = openmc.Cell(name=‘clad’)

gap.region = gap_region

clad = openmc.Cell(name=‘clad’)

clad.fill = zirconium

clad.region = clad_region

pitch = 1.26

left = openmc.XPlane(x0=-pitch/2, boundary_type=‘reflective’)

right = openmc.XPlane(x0=pitch/2, boundary_type=‘reflective’)

bottom = openmc.YPlane(y0=-pitch/2, boundary_type=‘reflective’) #change to black body for N13

top = openmc.YPlane(y0=pitch/2, boundary_type=‘reflective’) #change to black body for N13

water_region = +left & -right & +bottom & -top & +clad_outer_radius

moderator = openmc.Cell(name=‘moderator’)

moderator.fill = water

moderator.region = water_region

box = openmc.rectangular_prism(width=pitch, height=pitch,

                           boundary_type='reflective')

type(box)

openmc.region.Intersection

water_region = box & +clad_outer_radius

root_universe = openmc.Universe(cells=(fuel, gap, clad, moderator))

geometry = openmc.Geometry()

geometry.root_universe = root_universe

or…

geometry = openmc.Geometry(root_universe)

geometry.export_to_xml()

!cat geometry.xml

<?xml version='1.0' encoding='utf-8'?>

Create a point source

point = openmc.stats.Point((0, 0, 0))

source = openmc.Source(space=point)

settings = openmc.Settings()

settings.source = source

settings.batches = 100

settings.inactive = 10

settings.particles = 1000

settings.export_to_xml()

!cat settings.xml

<?xml version='1.0' encoding='utf-8'?> eigenvalue 1000 100 10 0 0 0

cell_filter = openmc.CellFilter(fuel)

tally = openmc.Tally(1)

tally.filters = [cell_filter]

tally.nuclides = [‘U235’]

tally.scores = [‘total’, ‘fission’, ‘absorption’, ‘(n,gamma)’]

tallies = openmc.Tallies([tally])

tallies.export_to_xml()

!cat tallies.xml

<?xml version='1.0' encoding='utf-8'?> 3 1 U235 total fission absorption (n,gamma)

openmc.run()

                            %%%%%%%%%%%%%%%
                       %%%%%%%%%%%%%%%%%%%%%%%%
                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
               %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                                %%%%%%%%%%%%%%%%%%%%%%%%
                                 %%%%%%%%%%%%%%%%%%%%%%%%
             ###############      %%%%%%%%%%%%%%%%%%%%%%%%
            ##################     %%%%%%%%%%%%%%%%%%%%%%%
            ###################     %%%%%%%%%%%%%%%%%%%%%%%
            ####################     %%%%%%%%%%%%%%%%%%%%%%
            #####################     %%%%%%%%%%%%%%%%%%%%%
            ######################     %%%%%%%%%%%%%%%%%%%%
            #######################     %%%%%%%%%%%%%%%%%%
             #######################     %%%%%%%%%%%%%%%%%
             ######################     %%%%%%%%%%%%%%%%%
              ####################     %%%%%%%%%%%%%%%%%
                #################     %%%%%%%%%%%%%%%%%
                 ###############     %%%%%%%%%%%%%%%%
                   ############     %%%%%%%%%%%%%%%
                      ########     %%%%%%%%%%%%%%
                                  %%%%%%%%%%%

               | The OpenMC Monte Carlo Code
     Copyright | 2011-2021 MIT and OpenMC contributors
       License | https://docs.openmc.org/en/latest/license.html
       Version | 0.12.1
      Git SHA1 | 36913589c4f43b7f843332181645241f0f10ae9e
     Date/Time | 2021-07-28 15:07:40
OpenMP Threads | 8

Reading settings XML file…
Reading cross sections XML file…
Reading materials XML file…
ERROR: Could not find thermal scattering data c_H_in_H2O in cross_sections.xml
file.


RuntimeError Traceback (most recent call last)
in
----> 1 openmc.run()

/opt/conda/lib/python3.7/site-packages/openmc/executor.py in run(particles, threads, geometry_debug, restart_file, tracks, output, cwd, openmc_exec, mpi_args, event_based)
225 args = mpi_args + args
226
→ 227 _run(args, output, cwd)

/opt/conda/lib/python3.7/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: Could not find thermal scattering data c_H_in_H2O in cross_sections.xml file.

Did you restart your pc? If not, then restart that and run again.

I restarted my computer, but now when I run it in Jupyter Notebook it says ’
ModuleNotFoundError: No module named ‘openmc’’

I think you messed something up in your bashrc file.
Please check again. Do remember that you need to put the export OPENMC_CROSS_SECTION command in a new line.

I checked the .bashrc file and the export command is on a new line. I don’t know what is wrong. I am very new at this. It was a struggle to get anything running on it in the first place. I installed it via someones github and when that wasn’t working with the cross section reinstalled it with the conda command. It was still running the code but missing cross sections. It displaying that ‘no module named openmc’ error message when I run it now

When I type ‘openmc’ in terminal, nothing comes up. I was using Jupyter Notebooks before

I’m assuming this happened because of installing OpenMC from the source that mainly focused on fusion.
Please follow the link below and install OpenMC again.
https://docs.openmc.org/en/stable/usersguide/install.html#installation-and-configuration

1 Like

@fruitfly You’re using Docker and to fix this problem you can use either openmc-data-downloader or install full data library inside docker. I’d go with the second option

docker run -it ukaea/openmcworkshop /bin/bash
cd $HOME
wget -c https://anl.box.com/shared/static/uhbxlrx7hvxqw27psymfbhi7bx7s6u6a.xz -O endfb8
 tar -xvf endfb8 -C /opt
rm -rf endfb8
echo "export OPENMC_CROSS_SECTIONS= '/opt/endfb80_hdf5/cross_sections.xml'" >> ~/.bashrc

But I would recommend using anaconda/miniconda to install openmc. Open terminal and type the following command one by one

cd $HOME/Downloads
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh
bash Miniconda3-py39_4.10.3-Linux-x86_64.sh -b -p ~/miniconda3
conda config --set auto_activate_base false
conda config --add channels conda-forge
conda create -n openmc-env openmc jupyterlab vtk -y

Best
pranto

1 Like

I tried using anaconda/miniconda to install openmc but now when I type “impost openmc” in Jupyter Notebook it comes back with an error message saying “ModuleNotFoundError: No module named ‘openmc’” , and when I type “openmc” in terminal it says “Command ‘openmc’ not found”.

I’m going to try restarting my PC.

Restarting did nothing.

I am new to Linux and openmc so it could be that I am making some big beginner mistake.

To fix this, Can we talk in private? Email: ariful.prantestain55@yahoo.com

Ok, I sent you an email.

It turns out my problem was more than just downloading a new data library and couldn’t be solved in this thread. Therefor I have chosen fsabab’s answer for the solution as it worked to at least download the data library.