[fluka-discuss]: Re: Question about user routine for gauss distribution

From: Santana, Mario <msantana_at_slac.stanford.edu>
Date: Wed, 10 Feb 2021 04:54:10 +0000

radius = FLNRRN(RGAUSS)
DO WHILE (radius.lt.2.0D0.or.radius.gt.3.0D0)
radius = FLNRRN(RGAUSS)
END DO
...
...
...


________________________________
From: lzf neu <lzfneu_at_live.com>
Sent: Tuesday, February 9, 2021 8:32 PM
To: Santana, Mario <msantana_at_slac.stanford.edu>; Fluka Discuss <fluka-discuss_at_fluka.org>; Paola Sala <paola.sala_at_mi.infn.it>
Cc: lzf neu <lzfneu_at_live.com>
Subject: 回复: Question about user routine for gauss distribution


Sorry to disturb you again, I have no idea where the following code is wrong, it still could not plot an annular gaussian profile with radius from 2 σ to 3 σ in 2D projection. I have attatched my source and flair files in the attachment. Could you please help me. Thank you.

* Particle coordinates
      sigma=ONEONE
      Z2=0.0
      Z1=0.0
      DO WHILE (.TRUE.)
       IF (FLNRRN(RGAUSS)>=2 .AND. FLNRRN(RGAUSS)<=3) THEN
         radius=sigma*FLNRRN(RGAUSS)
         angle=TWOPIP*FLRNDM(DUMY)
         XFLK(NPFLKA) = radius*sin(angle)
         YFLK(NPFLKA) = radius*cos(angle)
         ZFLK(NPFLKA) = Z1+(Z2-Z1)*BB
         EXIT
       END IF
      END DO

________________________________
发件人: Santana, Mario <msantana_at_slac.stanford.edu>
发送时间: 2021年2月10日 3:20
收件人: lzf neu <lzfneu_at_live.com>; Fluka Discuss <fluka-discuss_at_fluka.org>; Paola Sala <paola.sala_at_mi.infn.it>
主题: Re: Question about user routine for gauss distribution

In your implementation most of the time (95.4%) the condition is not fulfilled and XFLK,YFLK are not defined, thus the issues.
An (inefficient) variation of your algorithm would need to include a DO LOOP, DO WHILE, or GOTO statement, to keep sampling radii until your condition is verified.

-M


________________________________
From: lzf neu <lzfneu_at_live.com>
Sent: Tuesday, February 9, 2021 7:13 PM
To: Santana, Mario <msantana_at_slac.stanford.edu>; Fluka Discuss <fluka-discuss_at_fluka.org>; Paola Sala <paola.sala_at_mi.infn.it>
Cc: lzf neu <lzfneu_at_live.com>
Subject: 回复: Question about user routine for gauss distribution

Dear Dr. Santana, Mario,

Thanks for your reply.
I have one more question to consult you:

If my beam has an annular gaussian profile, its radius is from 2 σ to 3 σ and is there a method to confine the probability of FLNRRN(RGAUSS) to get |numbers| between 2 to 3.
I modify your code and try to write the following in source.f :

      IF (FLNRRN(RGAUSS)>=2 .AND. FLNRRN(RGAUSS)<=3) THEN
      radius=sigma*FLNRRN(RGAUSS)
      angle=TWOPIP*FLRNDM()
      XFLK(NPFLKA) = radius*sin(angle)
      YFLK(NPFLKA) = radius*cos(angle)
      END IF

However, the program cannot be run and the following error messages in xxx.out file is:
0 !!! Exit being called from Flklkz !!!
 **** Particle in position X = -1.00000000E+30, Y = -1.00000000E+30, Z = 1.91956648E+18
 **** with energy 0.000000E+00 GeV, discarded ****

Thank you.

Zhefu
________________________________
发件人: Santana, Mario <msantana_at_slac.stanford.edu>
发送时间: 2021年2月9日 21:36
收件人: lzf neu <lzfneu_at_live.com>; Fluka Discuss <fluka-discuss_at_fluka.org>; Paola Sala <paola.sala_at_mi.infn.it>
主题: Re: Question about user routine for gauss distribution

Hi,

See answers below
________________________________

>>I have two quesitons to consult you:

>>1) what is the value range of the gaussian-distributed random numbers: FLNRRN(RGAUSS)

Technically the range is "+/-infinite' although the probability to get |numbers| above 10 is very small, which you can compute from the usual gauss function tables. Please see the attached figure for 10000 tests.
(You might be interested to check the Box-Muller transform, to obtain gaussian distributed numbers from uniform distributions)


>2) If σ=1cm and I try to plot fluence of electron beam spot with gauss distribution from 2 σ to 3 σ, how to write X, Y position in source file. I try to write the >following commands, but it doesn't work correctly;
>I expect that an annular circle of gauss distribution should be plotted from 2 σ to 3 σ, but the following commands show me a circle. I have no idea how to do.

>sigma=1
>XFLK(NPFLKA) = sigma*FLNRRN(RGAUSS)
>YFLK(NPFLKA) = sigma*FLNRRN(RGAUSS)
>ZFLK(NPFLKA) = ZBEAM

First off, you should write 'sigma=1.0D+00', or 'sigma=ONEONE'.
If your beam has a circular gaussian profile, I would go somewhere like:
radius = sigma*FLNRRN(RGAUSS)
angle = TWOPIP * FLRNDM()
XFLK(NPFLKA) = radius * sin(angle)
YFLK(NPFLKA) = radius * cos(angle)
...

-M

Thank you very much.


__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info
Received on Wed Feb 10 2021 - 07:07:52 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 10 2021 - 07:07:54 CET