[fluka-discuss]: Re: Modelling a polychromatic X-ray source

From: Fasso, Alberto <fasso_at_slac.stanford.edu>
Date: Thu, 3 Sep 2015 10:17:04 +0000

Dear Faith,
I apologize for the wrong answer I have given you in my previous message. As Francesco Cerutti has pointed out to me, it is perfectly legal
to use a variable which was the index of a DO loop: the variable keeps its last value if the DO loop has not been completed.?
Therefore, I have looked more carefully at your source, and I have found two things I don't understand: the way you calculate the cumulative
function, and how you sample the energy using it.
1) Calculating the cumulative function.
In your source you have:
?C Building cumulative spectrum
         DO I = 1, NMAX
            CUM(I) = (FLX(I - 1) + FLX(I)) * (ENE(I) - ENE(I - 1))
     & + CUM(I - 1)
         END DO
The cumulative spectrum is an integral. Using the simple integration by trapezoids I would have:
          DO I = 1, NMAX
               CUM(I) = CUM(I-1) + FLX(I) * (ENE(I) - ENE(I-1)) * 0.5D0
          END DO
Perhaps you are using a more sophisticated integration technique? But I don't understand it.

2) Sampling an energy from the cumulative spectrum.
You have:
C Sampling from cumulative spectrum
      XI = FLRNDM(XI)
      DO I = 1, NMAX
         IF ( XI .LT. CUM(I)) GOTO 1201
      END DO
      CALL FLABRT( 'SOURCE', 'SAMPLING SPECTRUM FAILED')
 1201 CONTINUE
C Determaining the energy inside bin I according to linear spectrum
      XI = (XI - CUM(I - 1)) / (CUM(I) - CUM(I - 1))
      IF (FLX(I) .EQ. FLX(I - 1)) THEN
         ENERGY = XI
      ELSE
         ENERGY = XI * (FLX(I) - FLX(I - 1)) * (FLX(I) + FLX(I - 1))
         ENERGY = SQRT(ENERGY + FLX(I - 1) ** 2) - FLX(I - 1)
         ENERGY = ENERGY / (FLX(I) - FLX(I - 1))
      END IF
      ENERGY = ENERGY * (ENE(I) - ENE(I - 1)) + ENE(I - 1)
I don't understand the last part (from ELSE on). The flux is already contained in the cumulative spectrum. Why are you
using it (squared!) to sample the energy?
I would do simply:

      ENERGY=(XI-CUM(I-1))*(ENE(I)-ENE(I-1))/(CUM(I)-CUM(I-1))+ENE(I-1)


Alberto



________________________________
From: owner-fluka-discuss_at_mi.infn.it <owner-fluka-discuss_at_mi.infn.it> on behalf of f.h.green_at_surrey.ac.uk <f.h.green_at_surrey.ac.uk>
Sent: Wednesday, September 2, 2015 4:05 AM
To: fluka-discuss_at_fluka.org
Subject: [fluka-discuss]: Modelling a polychromatic X-ray source


Hi all,


I had some help a while back with creating a polychromatic X-ray source using a modified source.f file and a .dat file with the spectrum info in.

This worked fine with the spectrum.dat file given to me but when i try to recreate this with a spectrum of my choosing the simulation won't run and just *times out*


I was wondering if any of you know what I am doing wrong?

I have attached the input file, modified source file and the spectrum data i am trying to use.


Faith


__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info
Received on Thu Sep 03 2015 - 13:49:53 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 03 2015 - 13:49:59 CEST