# Multiple source using directives

**URL:** <https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850>\
**Category:** Source Definition\
**Created:** [15 June 2023 22:27 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850 "2023-06-15T22:27:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![corrado.tine](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/corrado.tine/32/10379_2.png) [@corrado.tine](https://fluka-forum.web.cern.ch/u/corrado.tine)\
**Post date:** [15 June 2023 22:27 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/1 "2023-06-15T22:27:49Z")

</div>

Dear Experts,  
as you suggested in the discussion [Multiple isotope source in a single input](https://fluka-forum.web.cern.ch/t/multiple-isotope-source-in-a-single-input/1420), I created a multiple source as in the picture:

 ![foto1](https://fluka-forum.web.cern.ch/uploads/default/original/2X/7/7b4784304e8d74583424bbc9cb26bee5dc3c021c.png)

I have two question:

1. How can I run such an input using command line in linux/unix? I use FLUKA/FLAIR in a shared cluster for scientific computing and I need to submit the run only with command line instead of using FLAIR Run tab. For exampe, I would like to run 1 cycle for each isotope, obtaining five different fort.17 files which I need to sum at the end. Usually, I use this script to submit the run:

> submit\_shared\_fluka\_kalculus -e $HOME/work/GMX/source\_volume (exe file name) -n 1 -s 1 GMX\_HPGe (input file name)

1. To combine the different fort.17 files, I use FLAIR (detsuw) to create tab.lis file.  
Is the tab.lis file the sum of each the single isotope contribution?

Thank You.  
Regards  
Corrado

---

<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:** [16 June 2023 06:44 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/2 "2023-06-16T06:44:29Z")

</div>

Dear Corrado,

To run simulations with preprocessors from the command line, you need to create separate input files, with only the relevant isotope enabled.

The _detsuw_ program calculates the average of the different fort.17 files, so it would give you meaningful results if the activities of the different isotopes are the same.

Since you are already using a source routine, you may want to implement the isotope switching in there. This would give you the ability to use different activities with only one simulation. (Unless you want to change the ratio of activities after the run.)

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![corrado.tine](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/corrado.tine/32/10379_2.png) [@corrado.tine](https://fluka-forum.web.cern.ch/u/corrado.tine)\
**Post date:** [16 June 2023 09:58 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/3 "2023-06-16T09:58:00Z")

</div>

Dear David,  
thank you for your answer.

Yes, my sources have different activities, so it would be useful to implement isotope switching and their activities in the source routine. The important thing form me is to obtain an unique final spectrum which is the sum of each isotope contribution.

I am using the modified source routine  
[source\_volume.f](https://fluka-forum.web.cern.ch/uploads/short-url/pAhFa4TC9xmQDXO9qZuQP7j6rq8.f) (9.8 KB)  
which you suggested in the following discussion  
[Volumetric source of complex geometry](https://fluka-forum.web.cern.ch/t/volumetric-source-of-complex-geometry/940)  
to simulate a volume source in marinelli beaker.

Could you tell me how to modify routine source to obtain what you said?

Cheers

Corrado

---

<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:** [16 June 2023 10:47 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/4 "2023-06-16T10:47:42Z")

</div>

Dear Corrado,

you need to use **if** statements  
you need to change the variables `IARES`, `IZRES` and `IISRES` on lines 99-101 to the mass, atomic, and isomer numbers of the individual isotopes using code similar to [Multiple complex source in Fluka - #2 by horvathd](https://fluka-forum.web.cern.ch/t/multiple-complex-source-in-fluka/1241/2)

`IPROA`, `IPROZ` and `IPROM` variables store the values set on the **HI-PROPE** card in the FLUKA input.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![corrado.tine](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/corrado.tine/32/10379_2.png) [@corrado.tine](https://fluka-forum.web.cern.ch/u/corrado.tine)\
**Post date:** [19 June 2023 09:04 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/5 "2023-06-19T09:04:02Z")

</div>

Dear David,

thank you very much for your suggestion.

If I well understood, I have to add an IF statement like the follow:

```auto
(Radioactive) isotope:
      IF ( IJBEAM .EQ. -2 .AND. LRDBEA ) THEN
        random = FLRNDM(XDUMMY)
         IF (random .lt. A_(1)/A_(tot)) THEN
         IARES = 241
         IZRES = 95
         IISRES = 0
         else if (random .lt. A_(2)/A_(tot) + A_(1)/A_(tot)) THEN
         IARES = 109
         IZRES = 48
         IISRES = 0
         else if (random .lt. ...) THEN
         .....
         .....
        end if 

```

Where A\_(i) and A\_(tot) are the activity of each radionuclide and total activity respectively.  
In this way I will be obtain an unique spectrum normalized per A\_(tot), right?

I hope I understood correctly.

Cheers,  
Corrado

---

<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:** [20 June 2023 06:42 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/6 "2023-06-20T06:42:35Z")

</div>

Dear Corrado,

Yes, this is the idea. (You may optimize a code a bit, by precalculating the cumulative probabilities for each isotope.)

The FLUKA results will be still normalized per decay in you case, so you need to multiply them with the total activity.

One more thing to keep in mind. FLUKA simulates the whole decay chain of the isopoes, as all daughters are in equilibrium.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![corrado.tine](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/corrado.tine/32/10379_2.png) [@corrado.tine](https://fluka-forum.web.cern.ch/u/corrado.tine)\
**Post date:** [20 June 2023 08:47 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/7 "2023-06-20T08:47:07Z")

</div>

Dear David,

thank you!

Yes, as you suggest, I will pre calculate the probabilities A\_(i)/A\_(tot) and I will insert their cumulative values directly into the subroutine.

Last question: Can I exclude from the simulation the alpha particle coming from Am-241 to save CPU time? Using PART-THR card?

Cheers,

Corrado

---

<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:** [20 June 2023 14:24 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/8 "2023-06-20T14:24:27Z")

</div>

Dear Corrado,

yes, you can use the **PART-THR** card, to stop the transport of alpha particles.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![corrado.tine](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/corrado.tine/32/10379_2.png) [@corrado.tine](https://fluka-forum.web.cern.ch/u/corrado.tine)\
**Post date:** [20 June 2023 14:52 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/9 "2023-06-20T14:52:36Z")

</div>

Great!

Thank you again.

Cheers

Corrado

---

<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:** [21 June 2023 06:07 UTC](https://fluka-forum.web.cern.ch/t/multiple-source-using-directives/4850/10 "2023-06-21T06:07:38Z")

</div>


