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

From: Giuseppe Battistoni <giuseppe.battistoni_at_mi.infn.it>
Date: Mon, 23 Apr 2018 15:32:26 +0200

Dear ArghyaC
there were two problems:
1) all DIMENSION and DATA statements have to be placed
before any other operative instructions, i.e. at the beginning of the
routine.
2) starting from DIMENSION CENTERS(5) there were a few lines
which were not correctly indented. In fortran the instruction
has to begin in column 7

In attachment the corrected routine
G.B.

On 23/04/2018 14:43, arghyac_at_barc.gov.in wrote:
> On 2017-09-16 14:15, Andrea Fontana wrote:
>> 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
>>
>> 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.
>>>>>
>>>>>
>>>>> 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.
>>>
>>>
>>> __________________________________________________________________________
>>>
>>> You can manage unsubscription from this mailing list at
>>> https://www.fluka.org/fluka.php?id=acc_info
>>>
>>>
>
>
> Dear FLUKA experts,
>
>     As discussed earlier, I am trying to model 5 spherical source using
> source.f card but not able to compile it.
>
>   During compilation, it is giving following error
>
>
> tarted 2018.04.23 18:19:50
>>>> Compiling: /home/arghya/fluka/flutil/fff -b -N multi.f
> multi.f:204:24:
>
>       DIMENSION CENTERS(5)
>                         1
> Error: Invalid character in name at (1)
> Ended: 2018.04.23 18:19:50
>
> Error compiling
> Error: compiling file: multi.f
> No object generated
>
>
>
> Please find attached source.f card also.
>
> Kindly suggest me some solutions.
>
>
> with regards
> ArghyaC

```--
INFN Sezione di Milano
via Celoria 16, 20133 Milano
tel: +39 02 50317307
fax: +39 02 50317617

```

__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info

Received on Mon Apr 23 2018 - 17:01:01 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 23 2018 - 17:23:06 CEST