# How to define a source in the shape of a spherical shell?

**URL:** <https://openmc.discourse.group/t/how-to-define-a-source-in-the-shape-of-a-spherical-shell/1014>\
**Category:** User Support\
**Created:** [February 15, 2021, 1:07pm UTC](https://openmc.discourse.group/t/how-to-define-a-source-in-the-shape-of-a-spherical-shell/1014 "2021-02-15T13:07:37Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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 24, 2021, 1:46pm UTC](https://openmc.discourse.group/t/how-to-define-a-source-in-the-shape-of-a-spherical-shell/1014/6 "2021-02-24T13:46:57Z")

</div>

@SophiaVT To have a shell source, you’ll also need to sample the radius in between a minimum and maximum radius. The appropriate PDF for the radius is uniform in r², as explained in arguments [here](https://stats.stackexchange.com/questions/481543/generating-random-points-uniformly-on-a-disk). Thus, your sampling scheme will look something like:

```auto
double r_min = ...;
double r_max = ...;
double angle = 2 * M_PI * openmc::prn(seed);
double radius_sq = r_min*r_min + openmc::prn(seed)*(r_max*r_max - r_min*r_min);
double radius = std::sqrt(radius_sq);
particle.r.x = radius * std::cos(angle);
particle.r.y = radius * std::sin(angle);
particle.r.z = 0.0;

```

---

_[View the full topic](https://openmc.discourse.group/t/how-to-define-a-source-in-the-shape-of-a-spherical-shell/1014)._
