How to specify boundary current

Hi all,

I want to know if the neutron current on the boundary (inward and outward) can be specified in openmc. In other words, the boundary current is given as the boundary condition. How to apply this boundary in openmc. Can you give me some advice? Thank you.

yahui

There’s no “easy” way to do this, but depending on the shape of your boundary, there may be several ways to achieve it. For starters, if your boundary is an x-, y- or z-plane, you can use openmc.stats.CartesianIndependent to specify a distribution over each of the directions. For example, to have a source on a plane at z=5 that extends from x=-10 to 10 and y=-10 to 10:

x_dist = openmc.stats.Uniform(-10, 10)
y_dist = openmc.stats.Uniform(-10, 10)
z_dist = openmc.stats.Discrete([5.0], [1.0])
spatial_dist = openmc.stats.CartesianIndependent(x_dist, y_dist, z_dist)

Then you would need an angular distribution. For example, if you wanted a monodirectional distribution facing in the negative z direction:

angle_dist = openmc.stats.Monodirectional((0.0, 0.0, -1.0))

Then put these together in a source object

settings = openmc.Settings()
settings.source = openmc.Source(space=spatial_dist, angle=angle_dist)

If this is not a viable approach, you could create a source file manually with source points distributed on the boundary

n_source = 10000
source_particles = []
for _ in range(n_source):
    # sample position/angle/energy of source site using Python
    p = openmc.SourceParticle(...)
    source_particles.append(p)
openmc.write_source_file(source_particles, "my_source.h5")

Then specify in the settings to use this file:

settings = openmc.Settings()
settings.source = openmc.Source(filename="my_source.h5")

Finally, your last option might be to write a C++ custom source routine.