Fixed source transport simulation error

Hello, Im trying to build a Low Energy Germanium detector to study gamma rays, which I defined as a series of concentric cylinders and some planes to cut them. My problem is that when I try to run the simulation, I get the following error:

ERROR: More than 95% of external source sites sampled were rejected. Please check your external source definition”.

This is my source definition:

source = openmc.Source()
source.particle = "photon"
source.space = openmc.stats.Point((0,0,6.071))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([1000e3],[1.0])
settings = openmc.Settings()
settings.run_mode = "fixed source"
settings.source = source
settings.batches = 100
settings.inactive = 5
settings.particles = 1000

In another post about this, I found out that maybe the problem was that the source was defined right on top of a plane, so I tried to change the position of the source to be a little bit higher than the plane (6.07 -----> 6.071) but it didn’t work.

Thanks in advance for your help

I would try plotting your model to confirm that the point in question is actually within a cell. You can also try using the Geometry.find method from Python to see what it returns – if it gives you an empty list, that probably means your geometry is not defined correctly.

Thank you for your answer.

I did not know the source had to be inside of a cell. I tried to create a cell with a sphere and a vacuum boundary that contained the detector and the source but it didn’t seem to work. In the end, I wanted to check if that was the actual problem, so I placed the source inside one of my cells and it worked but now I get a different error. It says:

After particle 670 crossed surface 56 it could not be located in any cell and it did not leak.
ERROR: Maximum number of lost particles have been reached

Is it necessary to have reflective boundary conditions to make the detector work?

Thanks again

The first thing you should do is look at your geometry.xml file to figure out which surface has id=“56” and see if you expect that surface to be an outer boundary for the problem. The error you’re getting indicates that a particle reached that surface and it couldn’t find a cell on the other side of it, nor was any boundary condition applied to the surface. If you applied a vacuum boundary condition, it must have been to a different surface.

Thanks again for your answer,

I checked the geometry.xml file and changed the surface boundary condition to vacuum to see if that solved the problem. It did for that surface but now it is another surface that is giving me the same error. I have been trying to understand what is wrong with my code but I cant seem to get it. Do I need to change every surface boundary condition to vacuum? does that allow the transport of photons through the surfaces and their respective interactions? or, most probable, Im doing something wrong.

Maybe this is too much to ask but could you check my code and help me figure out what is wrong?

import openmc
%matplotlib inline

mat = openmc.Material()
mat.add_element('Ge',1.0)
mat.set_density('g/cm3',5.3)

mat2 = openmc.Material()
mat2.add_element('Al',1.0)
mat2.set_density('g/cm3',2.698)

mat3 = openmc.Material()
mat3.add_element('Be',1.0)
mat3.set_density('g/cm3',1.848)

materials = openmc.Materials([mat,mat2,mat3])
materials.cross_sections = "/Users/user196949/Documents/antonio/mcnp_endfb71/cross_sections.xml"
materials.export_to_xml()

cil1 = openmc.ZCylinder(r = 2.52)
cil2 = openmc.ZCylinder(r = 3)
cil3 = openmc.ZCylinder(r = 3.81,boundary_type = 'vacuum')
plano1 = openmc.ZPlane(z0 = +3,boundary_type = 'transmission')
plano2 = openmc.ZPlane(z0 = +5.52,boundary_type = 'transmission')
plano3 = openmc.ZPlane(z0 = 0,boundary_type = 'vacuum')
plano4 = openmc.ZPlane(z0 = +6.02,boundary_type = 'transmission')
plano5 = openmc.ZPlane(z0 = +6.07,boundary_type = 'vacuum')
#left = openmc.XPlane(x0 = -4, boundary_type = 'vacuum')
#right = openmc.XPlane(x0 = +4, boundary_type = 'vacuum')
#bot = openmc.YPlane(y0 = -1, boundary_type = 'vacuum')
#top = openmc.YPlane(y0 = +7, boundary_type = 'vacuum')
#box = openmc.rectngular_prism(width = 15,height = 15, boundary_type = 'vacuum')
univ = openmc.Sphere(r = 7, boundary_type = 'vacuum')

ge_detector = -cil1 & +plano1 & -plano2
espacio_vacio = +cil1 & -plano1 & +plano2 & -cil2 & -plano4 & +plano3
capa_aluminio = +cil2 & -cil3 & -plano4 & +plano3
pantalla = +plano4 & -cil3 & -plano5
#box = +left & -right & +bot & -top & +cil3 & +plano5 & -plano3
#box1 = box 
univ1 = -univ & +cil3 & +plano5 & -plano3

cell_box = openmc.Cell()
cell_box.region = univ1

cell_detector = openmc.Cell()
cell_detector.region = ge_detector
cell_detector.fill = mat

cell_vacio = openmc.Cell()
cell_vacio.region = espacio_vacio

cell_al = openmc.Cell()
cell_al.region = capa_aluminio
cell_al.fill = mat2

cell_pantalla = openmc.Cell()
cell_pantalla.region = pantalla
cell_pantalla.fill = mat3

universe = openmc.Universe(cells = [cell_box,cell_detector,cell_vacio,cell_al,cell_pantalla])
universe.plot(width = (15.0,15.0),basis='xz',colors = {cell_box: 'fuchsia'})
geometry = openmc.Geometry(universe)
geometry.export_to_xml()

source = openmc.Source()
source.particle = 'photon'
source.space = openmc.stats.Point((0,0,6.05))
source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([1000e3],[1.0])
settings = openmc.Settings()
settings.run_mode = 'fixed source'
settings.source = source
settings.batches = 100
settings.inactive = 5
settings.particles = 1000
settings.export_to_xml()

tally_flujo = openmc.Tally(name = "espectro")
tally_flujo.scores = ['flux']
filtro_celda = openmc.filter.CellFilter(cell_detector.id)
tally_flujo.filters = [filtro_celda]
tallies = openmc.Tallies([tally_flujo])
tallies.export_to_xml()

The source is supposed to be on top of the screen cell (cell_pantalla) but I put it in the middle to avoid getting the first error I mentioned in this post.

@Tonyjcf This is what your model looks like currently:


All of the white space is not defined. If you imagine particles traveling through the geometry, anytime they encounter one of these cells, they will be lost unless the boundary they crossed had a defined boundary condition. It looks like you have the boundary conditions on the outer boundaries correctly defined, so the problem is that you need to define cells in the interior of the model to fill that space. Note that you don’t have to assign a material to these cells — by default they will be void.

That was the problem, I did not know the white space was not defined. I fixed it and now it works.

Thank you for your help