Is it possible to create a spherical shell source that does not interact with itself and only has source particles evenly distributed inward from the shell. Essentially, I am trying to make an infinitesimally thin shell that can generate a constant flux inside of it, and zero flux outside, without recording flux scattering, absorption, etc through the source itself. I am working in python as well.
Also, I am noticing that when I use spherical uniform for the source, I have interactions between the particles in the area that used to be a vacuum. I have my radii set as 200 and 199, but there is absorption and scattering measured between the shell and my test object.
I don’t see any way to do that using the standard source distributions in OpenMC. You would need to write your own compiled source to handle this situation.
@paulromano I found a way to add thousands of isotropic source points along a spherical surface using the code below:
** The code for the coordinate generation was sourced from python - Generate a random sample of points distributed on the surface of a unit sphere - Stack Overflow
Although this works great for creating a mostly even source distribution, I am still seeing absorption and scattering of photons through empty space, and this does not happen at all with neutrons; any idea what might be causing this problem? My research is much heavily dependent on photon simulation.
import numpy as np
def sample_spherical(npoints, ndim=3):
vec = np.random.randn(ndim, npoints)
vec /= np.linalg.norm(vec, axis=0)
return vec
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import axes3d
phi = np.linspace(0, np.pi, 20)
theta = np.linspace(0, 2 * np.pi, 40)
radius = 200
x = np.outer(np.sin(theta), np.cos(phi))*radius
y = np.outer(np.sin(theta), np.sin(phi))*radius
z = np.outer(np.cos(theta), np.ones_like(phi))*radius
xi, yi, zi = sample_spherical(500)*radius
src_locations = []
for i in range(len(xi)):
src_locations.append([xi[i], yi[i]+50,zi[i]])
fig, ax = plt.subplots(1, 1, subplot_kw={'projection':'3d', 'aspect':'auto'})
ax.plot_wireframe(x, y, z, color='k', rstride=1, cstride=1)
ax.scatter(xi, yi, zi, s=100, c='r', zorder=10)
# we'll use the same energy for each source
src_e = openmc.stats.Discrete([14e3],[1])
angle1 = openmc.stats.Isotropic()
# create source for each location
sources = []
for loc in src_locations:
src_pnt = openmc.stats.Point(xyz=loc)
src = openmc.Source(space=src_pnt,angle = angle1, energy=src_e, particle = 'neutron')
sources.append(src)
src_str = 1.0 / len(sources)
for source in sources:
source.strength = src_str
settings.source = sources
settings.export_to_xml()
Hello, I am also trying to construct a source with a constant flux inside using a spherical thin shell source. But this method is not successful. Have you solved this problem now?
Yes the method in the above code works well for this application. At a high number of source points, the above code essentially creates an isotropic sphere at a specified radius