How would I create a cylindrical source

Hi all, I’m trying to replicate a neutron generator for my project. The generator is a cylindrical tube generating total 1e13 neutrons/s in all directions. Is there a way to do this in openmc?

This is what I’m doing currently:

@srichr221 When you assign source.space, it needs to be a “spatial distribution” (list of valid classes here). To get a cylindrical shape, you can either:

  1. Use the CylindricalIndependent class. An example close to this is described here.
  2. If your cylinder corresponds to the shape of a Cell, you can use a source with any spatial distribution that completely covers the cylinder and then use cell rejection (i.e., only positions sampled within the cell are accepted) with:
    my_source = openmc.Source(space=..., domains=[cell_to_reject_on])
    

Thanks very much. sorry I didn’t reply sooner.
Got it working (I think) with:

#initialises a new source object
source = openmc.Source()
radius=1.0
pi=3.14159265359

r = openmc.stats.PowerLaw(0.0, radius, 1.0)
phi = openmc.stats.Uniform(0.0, 2*pi)
z = openmc.stats.Uniform(a=0.0, b=5.0)
spatial_dist = openmc.stats.CylindricalIndependent(r, phi, z)

source.angle = openmc.stats.Isotropic()
source.energy = openmc.stats.Discrete([14.08e6], [1.0])
source.space=spatial_dist

I adapted this from the example you gave.

Hello, I have a question for your code, z = openmc.stats.Uniform(a=0.0, b=5.0) why here is [0,5] instead of [-0.5,0.5] ?