# How would I create a cylindrical source

**URL:** https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713
**Category:** User Support
**Created:** [February 11, 2023, 3:33pm UTC](https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713 "2023-02-11T15:33:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![srichr221](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/srichr221/32/2360_2.png) [@srichr221](https://openmc.discourse.group/u/srichr221)
#### Post date: [February 11, 2023, 3:33pm UTC](https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713/1 "2023-02-11T15:33:40Z")

</div>

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:

 ![Screenshot 2023-02-11 at 15.32.56](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/c/c1f2401e2b69ce2fc1381cbb61f8e58dc2ac1b60.png)

---

<div class="post-metadata">

### Author: ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)
#### Post date: [February 13, 2023, 2:11am UTC](https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713/2 "2023-02-13T02:11:25Z")

</div>

@srichr221 When you assign `source.space`, it needs to be a “spatial distribution” (list of valid classes [here](https://docs.openmc.org/en/latest/pythonapi/stats.html#spatial-distributions)). To get a cylindrical shape, you can either:

1. Use the `CylindricalIndependent` class. An example close to this is described [here](https://openmc.discourse.group/t/how-to-define-the-source-strength-and-unit-circle-source-region-in-fixed-source-mode/1775/2).
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:

```plaintext
my_source = openmc.Source(space=..., domains=[cell_to_reject_on])

```

---

<div class="post-metadata">

### Author: ![srichr221](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/srichr221/32/2360_2.png) [@srichr221](https://openmc.discourse.group/u/srichr221)
#### Post date: [February 24, 2023, 5:38pm UTC](https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713/3 "2023-02-24T17:38:37Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Richard](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@Richard](https://openmc.discourse.group/u/Richard)
#### Post date: [May 31, 2024, 2:47am UTC](https://openmc.discourse.group/t/how-would-i-create-a-cylindrical-source/2713/4 "2024-05-31T02:47:10Z")

</div>

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] ?
