Integer division or modulo by zero

Hello everyone, I’m trying to get the tritium production and I run to this error, here’s also the whole script:

import openmc
%matplotlib inline
from IPython.display import Image
import numpy as np
import matplotlib.pyplot as plt
!rm summary.h5
!rm statepoint.*.h5
settings = openmc.Settings()
settings.particles = 500
settings.batches = 10
settings.inactive = 0
energy_dist = openmc.stats.Discrete([14.5e6], [1.0])  # energies, probabilities
source = openmc.Source(energy=energy_dist)
source = openmc.Source()
source.space = openmc.stats.Point((0, 0, 0))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14.5e6], [1.0])
settings.source = source 
settings.source = source
settings.run_mode = 'fixed source'
settings.export_to_xml()
lithium = openmc.Material(1, "lithium")
lithium.add_element('Li', 6.0)
lithium.set_density('g/cm3', 0.534)
mats = openmc.Materials([lithium])
mats.export_to_xml()
sph = openmc.Sphere(r=16, boundary_type='reflective')
inside_sph = -sph
outside_sph = +sph
sph_2 = openmc.Sphere(r=15, boundary_type='reflective')
inside_sph_2 = -sph_2
outside_sph_2 = +sph_2
spherical_shell = -sph & +sph_2
cell = openmc.Cell(region=spherical_shell)
cell.fill = lithium
outside_sph = openmc.Sphere(r=17, boundary_type='vacuum')
empty_cell = openmc.Cell(region=-sph_2)
universe = openmc.Universe(cells=[cell, empty_cell])
universe.plot(width = (40.0, 40.0), colors={cell: 'green'})
geometry = openmc.Geometry(universe)
geometry.export_to_xml()
cell_filter = openmc.CellFilter([cell])
energy_filter = openmc.EnergyFilter([14.5e6])
tally = openmc.Tally(name='breeding')
tally.filters = [cell_filter, energy_filter]
tallies_file = openmc.Tallies()
tallies_file.append(tally)
tally.scores = ['H3-production']
tallies_file.export_to_xml()
model = openmc.model.Model(geometry, mats, settings, tallies_file)
!rm summary.h5
!rm statepoint.*.h5
sp_filename = model.run()
sp = openmc.StatePoint(sp_filename)
tbr_tally = sp.get_tally(name ='breeding')
df = tbr_tally.get_pandas_dataframe()
df
tbr_tally_result = (df['mean'].sum())
print('The tritium breeding by lithium 6 is ', tbr_tally_result)
with openmc.StatePoint("statepoint.10.h5") as sp:
 k_eff = sp.keff


Thank you so much for your help!

I believe the problem stems from this line:

Energy filters specify ranges of energies for which particles can be scored. If you want a single energy bin, you would have to specify a lower and an upper energy, e.g., openmc.EnergyFilter([0.0, 14.5e6])

1 Like