# Re: [fluka-discuss]: About multiple spherical source

From: Andrea Fontana <andrea.fontana_at_pv.infn.it>
Date: Sat, 16 Sep 2017 10:45:43 +0200 (CEST)

Hello Arghya,
the idea is to save the x coordinates of the five centers in the
array CENTERS and then to randomly generate the index in the interval
1:5 to select a random center among the five. The array looks like:

ARRAY(1) = -10.
ARRAY(2) = -5.
ARRAY(3) = 0.
ARRAY(4) = 5.
ARRAY(5) = 10.

Actually, if you check in the manual of FLUKA, FLRNDM returns a
uniform random number in the interval [0,1), i.e. with 1 excluded:
so it would be better to write 1+5*FLRNDM(XDUMMY) to have a random
index among 1,2,3,4,5.

In Fortran you can use the implicit type declaration (as in the FLUKA
user routines) and so you can skip both REAL*4 or REAL*8 instructions
and simply write a DIMENSION instruction. FLRNDM returns a 64-bit
number and the conversion is done automatically: in your case I think
this is not relevant since you round your numbers...

So a better version of the code is:

DIMENSION CENTERS(5)
DATA CENTERS/-10.,-5.,0.,5.,10./

INDEX = FLOOR(1+5*FLRNDM(XDUMMY))
X0 = CENTERS(INDEX)

CALL RACO(TXX, TYY, TZZ)

XFLK (NPFLKA) = X0 + RADIUS*TXX
YFLK (NPFLKA) = RADIUS*TYY
ZFLK (NPFLKA) = RADIUS*TZZ

I hope that now it is more clear. Please test it in your simulation
and let us know in case of other doubts.

Best regards,
Andrea

> On 2017-09-15 20:10, Andrea Fontana wrote:
>> Dear Arghya,
>>   what about choosing randomly among the 5 sphere centers?
>> Let us say with a code like:
>>
>>       REAL*4 CENTERS(5), X0
>>       DATA CENTERS/-10.,-5.,0.,5.,10./
>>
>>       X0 = CENTERS(FLOOR(6*FLRNDM(XDUMMY)))
>>
>> where X0 is the center of your current sphere and then:
>>
>>     CALL RACO(TXX, TYY, TZZ)
>>     RADIUS = R*FLRNDM(XDUMMY)
>>     XFLK (NPFLKA) = X0 + RADIUS*TXX
>>     YFLK (NPFLKA) = RADIUS*TYY
>>     ZFLK (NPFLKA) = RADIUS*TZZ
>>
>> You have to generate 5 times histories, but the result should be
>> the one you are looking for. I hope this helps.
>>
>> Kind regards,
>> Andrea
>>
>> Il 15/09/2017 14:15, arghyac_at_barc.gov.in ha scritto:
>>> Dear Experts,
>>>
>>>    I need to simulate 5 spherical sources with different spatial
>>> co-ordinate in a single source.f card.
>>>
>>>    I model one sphere (centre at (0,0,0) in source.f card as follows
>>>
>>> *particle corodinate
>>>     CALL RACO(TXX, TYY, TZZ)
>>>     RADIUS = R*FLRNDM(XDUMMY)
>>>     XFLK (NPFLKA) = RADIUS*TXX
>>>     YFLK (NPFLKA) = RADIUS*TYY
>>>     ZFLK (NPFLKA) = RADIUS*TZZ
>>>
>>> I guess I need to edit  XFLK (NPFLKA), YFLK (NPFLKA), ZFLK (NPFLKA) to
>>> sample 5 spherical sources in single subroutine.
>>> Co-ordinate of other 4 sphere's centre are (-10,0,0), (-5,0,0),(5,0,0)
>>> and (10,0,0). radius of each = 1.5 cm.
>>>
>>> Now how to sample other spheres here or how to edit it to accommodate
>>> all the 5 sources at the same time.
>>>
>>> Kindly give some suggestions.
>>>
>>> Thanking you in advance.
>>>
>>> With regards,
>>> Arghya
>>>
>>> __________________________________________________________________________
>>> You can manage unsubscription from this mailing list at
>>> https://www.fluka.org/fluka.php?id=acc_info
>>>
> Thank you very much for quick reply.
> I am beginner and not much excellence in Fortran programming. So I
> have few doubts. Kindly reply me.
>
> I need to choose all 5 sources randomly with equal probability i.e as
> if detector are exposed by all 5 sources simultaneously.
>
> Since I am using 64 bit computer,
> can I use REAL*8 instead of REAL*4
> CENTERS(5) and below that declared centers values as DATA
> CENTERS/-10.,-5.,0.,5.,10./
>
> Then use X0 = CENTERS(FLOOR(6*FLRNDM(XDUMMY)))
> here FLOOR(6*FLRNDM(XDUMMY) will produce integer number 0,1,2,3,4,5,6
> I am not getting how it will produce -5 and -10 and 10 co-ordinates ?
> and why FLRNDM(XDUMMY) is multiplied by 6 only.
>
> Thanking you in advance
>
> __________________________________________________________________________
> You can manage unsubscription from this mailing list at
> https://www.fluka.org/fluka.php?id=acc_info
>
>

```--
========================================================================
Dr. Andrea Fontana                    tel: +39 0382 987991
Istituto Nazionale                    fax: +39 0382 423241
di Fisica Nucleare
Sezione di Pavia                      e-mail: andrea.fontana_at_pv.infn.it
Via Bassi 6                           web   : www.pv.infn.it/~fontana
27100 PAVIA, Italy
========================================================================
__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info
```
Received on Sat Sep 16 2017 - 11:50:37 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 16 2017 - 11:50:38 CEST