Re: [fluka-discuss]: Question about source.f file

From: Santana, Mario <msantana_at_SLAC.Stanford.EDU>
Date: Fri, 13 Dec 2013 10:00:38 -0800

Hi,

The first path (the maths) seems OK to me, but I have one question regarding the language you used: You said that the particles are INCIDENT at an angle 'THERTA0' INTO the cylinder, but then you sample within the full 2PI surface of a cone of angle THERTA0 measured from the cylinder axis. So just a marginally infinitesimal portion of particles will actually be INCIDENT INTO the cylinder with an angle THERTA0, the rest may be incident with smaller angle or they may be going OUTWARDS with an angle up to THERTA0. Maybe this is what you wanted, I am not sure, it is probably just a question of language.

The second part (implementation) could be improved:

 * You are not defining the type of variables Z1, Z2, R0,… etc. so fortran will assume that they are real, but then you use NINT functions to convert your source values into integers.
 * You divide by '1000' (I guess to get mrad), but you should be dividing by a real number, not an integer, e.g. 1000.0
 * You use 3.1415926. Replace that by parameter PIPIPI, which contains a more exact number
 * Your definition of angle risks to not be normalized to 1.0. It would be preferable that TZFLK was defined as 1 – SQRT(TXFLK…**2 + TYFLK..**2)
 * I don't think that you need any argument in FLRNDM function.
 * Note also that since you are using variable ZBEAM you could spare using Z0 (define ZBEAM as Z0).

Mario

From: lzfneu <lzfneu_at_live.com<mailto:lzfneu_at_live.com>>
Date: Thursday, December 12, 2013 11:12 PM
To: fluka-discuss <fluka-discuss_at_fluka.org<mailto:fluka-discuss_at_fluka.org>>
Subject: [fluka-discuss]: Question about source.f file

Dear all,
  My problem required a linear source uniformly distributed along Z between Z1 and Z2, and the particles emitted from the linear source and incident at an angle of THERTA0 into the cylinder surface whose radius is R0.
My sampling formulas are as follows:

1) sampling formulars of particle location:

     X=R0*cos(2*pi*X1);
     Y=R0*sin(2*pi*X1);
     Z=Z1+X2*(Z2-Z1);
where X1 and X2 are random numbers. R0 is the Cylinder radius.

2) sampling formulars of particle direction:

      U=sin(THERTA0)*cos(2*pi*X1);
      V=sin(THERTA0)*sin(2*pi*X1);
      W=cos(THERTA0);
 where THERTA0 is the particle incident angle. X1 is the random number.

  I rewrite part of the source.f file according to my sampling formulars and the compilation was passed. Part of my source.f file is as follows. I also have attatched full source.f file in the attachment. I wonder whether my source.f file is correct. Thanks in advance.

*** User initialization ***
      Z1 = NINT(WHASOU(1))
      Z2 = NINT(WHASOU(2))
      R0 = NINT(WHASOU(3))
      THERTA0 = NINT(WHASOU(4))/1000

* Cosines (tx,ty,tz)
      X1 = FLRNDM(DUMMY)
      X2 = FLRNDM(UGH)
      TXFLK (NPFLKA) = SIN ( THERTA0 ) * COS ( 2 * 3.1415926 * X1 )
      TYFLK (NPFLKA) = SIN ( THERTA0 ) * SIN ( 2 * 3.1415926 * X1 )
      TZFLK (NPFLKA) = COS ( THERTA0 )

* Particle coordinates
      XFLK (NPFLKA) = R0 * COS ( 2 * 3.1415926 * X1 )
      YFLK (NPFLKA) = R0 * SIN ( 2 * 3.1415926 * X1 )
      ZFLK (NPFLKA) = ZBEAM + Z1 + X2 * (Z2 - Z1)
Received on Fri Dec 13 2013 - 19:55:59 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 13 2013 - 19:55:59 CET