# Multiple cylindrical source as shown in figure

**URL:** <https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806>\
**Category:** Source Definition\
**Created:** [18 February 2022 04:26 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806 "2022-02-18T04:26:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArghyaC](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/arghyac/32/46_2.png) [@ArghyaC](https://fluka-forum.web.cern.ch/u/ArghyaC)\
**Post date:** [18 February 2022 04:26 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/1 "2022-02-18T04:26:54Z")

</div>

Dear Experts,  
Is it possible to model multiple cylindrical sources (as shown in the attached figure) in FLUKA ? How to sample different orientation of the source cylinders in a single source.f ?

Can these cylindrical sources be activated in region-basis option of newgen\_source.f as shown below?  
call regionsource ( coordinate\_x, coordinate\_y, coordinate\_z, [region number], [xmin], [xmax], [ymin], [ymax], [zmin], [zmax] )  
Here how to put the [region number] of these many cylindrical source regions?

Waiting for your suggestions.  
Thanking you in advance.

[design\_Silver hybrid eye plaque I-125 capsule.pdf](https://fluka-forum.web.cern.ch/uploads/short-url/jeewhKXoxbHkzX7T4qR3tLbgXUL.pdf) (43.7 KB)

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [18 February 2022 09:52 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/2 "2022-02-18T09:52:34Z")

</div>

Dear @ArghyaC,

Similarly as it was discussed in [Multiple complex source in Fluka](https://fluka-forum.web.cern.ch/t/multiple-complex-source-in-fluka/1241), you can use a random number to select between regions.

Please note, the `regionsource()` subroutine is not part of the distributed version of the _source\_newgen.f_ user routine.

Also, since it is using a rejection method, the speed of the sampling is worse, than sampling directly from a cylinder and then roto-translating the coordinates to match the geometry.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![ArghyaC](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/arghyac/32/46_2.png) [@ArghyaC](https://fluka-forum.web.cern.ch/u/ArghyaC)\
**Post date:** [18 February 2022 10:55 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/3 "2022-02-18T10:55:26Z")

</div>

Thank you for quick reply.

Can I code like below:

* * *

random = FLRNDM(XDUMMY)

if (random .lt. beam1\_probablility) then  
call regionsource ( coordinate\_x, coordinate\_y, coordinate\_z, [region number\_1], [xmin], [xmax],[ymin], [ymax], [zmin], [zmax] )  
else if (random .lt. beam1\_probability + beam2\_probability) then  
call regionsource ( coordinate\_x, coordinate\_y, coordinate\_z, [region number\_2], [xmin], [xmax], [ymin], [ymax], [zmin], [zmax] )  
else if (random .lt. beam1\_probability + beam2\_probability + beam3\_probability) then  
call regionsource ( coordinate\_x, coordinate\_y, coordinate\_z, [region number\_3], [xmin], [xmax], [ymin], [ymax], [zmin], [zmax] )  
else  
call regionsource ( coordinate\_x, coordinate\_y, coordinate\_z, [region number\_4], [xmin], [xmax], [ymin], [ymax], [zmin], [zmax] )  
end if

* * *

Kindly correct me if the above code is wrong.

Whether you have some example source.f file using roto-translating the coordinates for such application?

Kindly give me some suggestions.

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [18 February 2022 11:03 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/4 "2022-02-18T11:03:30Z")

</div>

Dear @ArghyaC,

The code looks correct, but you need to optimize the x/y/z min/max values for each regions separately, to increase the success rate of the rejection sampling.

I’m not aware of an example for a roto-translation, but since it is only 2 dimensional matrix and vector operations are needed, it should be hard to program them. ([Rotation matrix - Wikipedia](https://en.wikipedia.org/wiki/Rotation_matrix))

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![ArghyaC](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/arghyac/32/46_2.png) [@ArghyaC](https://fluka-forum.web.cern.ch/u/ArghyaC)\
**Post date:** [18 February 2022 11:22 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/5 "2022-02-18T11:22:25Z")

</div>

Thank you for your reply and co-operations.

Since it is a cylindrical region, can I use ([Rmin], [Rmax], [Zmin], [Zmax]) instead of ([xmin], [xmax], [ymin], [ymax], [zmin], [zmax] ) for calling region source ?

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [18 February 2022 12:00 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/6 "2022-02-18T12:00:37Z")

</div>

Dear @ArghyaC,

no, you can’t change the arguments unless you alter the subroutine accordingly.

The x/y/z min/max values set up a bounding box around the desired region. A point is uniformly sampled in this box, and checked if it is inside the region. If not, a new point is sampled. So if you change it to a cylinder, you will encounter the problem of the rotated regions, as they won’t align with the bounding region.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![rversaci](https://fluka-forum.web.cern.ch/letter_avatar_proxy/v4/letter/r/cc9497/32.png) [@rversaci](https://fluka-forum.web.cern.ch/u/rversaci)\
**Post date:** [20 March 2022 13:26 UTC](https://fluka-forum.web.cern.ch/t/multiple-cylindrical-source-as-shown-in-figure/2806/7 "2022-03-20T13:26:26Z")

</div>


