On 12.05.2015 12:47, f.h.green_at_surrey.ac.uk wrote:
>
> Dear Mikhail,
>
>
> Thank you for your reply, being able to see the files you used has
> been a real help!
>
>
> Is it possible for you to tell me what part of the source.f file you
> modified in order to simulate a 70kvP X-ray beam? I see that you
> generate the beam externally but how does the source.f file read the
> data and what does it do with it?
>
>
> Thank you
>
>
> Faith
>
> ------------------------------------------------------------------------
> *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:* 06 May 2015 13:25
> *To:* fluka-discuss_at_fluka.org
> *Subject:* [fluka-discuss]: Modelling a polychromatic X-ray source
>
> Hi All,
>
> I am trying to model a beam that has the spectroscopic shape like a
> conventional polychromatic X-ray source. I believe I need to use the
> SOURCE card but other than that I am unsure how to continue. I was
> wondering if anyone else has done this or if you have any thoughts on
> how I might achieve it?
>
> Faith Green
>
> PhD student
>
> University of Surrey
>
> Guildford
>
> UK
>
Dear Faith,
The principle of the sampling:
https://indico.cern.ch/event/334606/contribution/17/material/slides/0.pdf (slides
33-36)
The spectrum.dat file contains pairs of values of energy in keV and flux
in photons per second. The are about 689 of these pairs in the file and
that is the dimension which will be used further in source.f.
It's much easier to use data from file, rather add them into SOURCE
routine as builtin data arrays.
In input:
*
..+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
* Set the defaults for precision simulations
DEFAULTS PRECISIO
* Define the beam characteristics
BEAM -7E-05 0.1 0.0 -1.0PHOTON
* Define the beam position
BEAMPOS -10.
SOURCE
OPEN 18. READONLY
spectrum.dat
I define maximum energy of the photons as 70keV, round beam shape with 1
mm radius (XSPOT variable in BEAMCM common).
Beam direction along z-axis in a positive direction.
The OPEN card opens spectrum.dat with unit 18, which is equal LUNRD2 in
(IOUNIT) file, so there is no need to open file in a source routine.
in source_mod.f:
1.
Explicit definition of variables:
*
c Maximum dimension of the spectrum
PARAMETER ( NDIMMAX = 1000 )
c defining and saving spectrum arrays and dimension
DIMENSION ENE(0:NDIMMAX), FLX(0:NDIMMAX), CUM(0:NDIMMAX)
INTEGER NMAX
NDIMMAX is maximum dimension or number of pairs in the spectrum file.
ENE, FLX, CUM are arrays to store data of energy and flux respectively,
and cumulative possibility.
NMAX is a maximum dimension
2. The user initiation part reads the data from the file until it
reaches the end of the file and fills ENE and FLX arrays.
* | *** user initialization ***
WRITE( LUNOUT, *)
WRITE( LUNOUT, *) 'READING X-RAY SPECTRUM'
C Reading the spectrum
DO I = 0, NDIMMAX
READ( LUNRD2, *, END = 1200) ENE(I), FLX(I)
NMAX = I
END DO
CALL FLABRT( 'SOURCE', 'SPECTRUM READING FAILED')
1200 CONTINUE
WRITE( LUNOUT, *) 'SPECTRUM DIMENTION: ', NMAX
3. This part calculates a cumulative sum and normalize it.
CUM(0) = ZERZER
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
C Normalizing cumulative spectrum
DO I = 1, NMAX
CUM(I) = CUM(I) / CUM(NMAX)
END DO
4.This part selects a random cumulative value and finds a value of "I" bin.
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
5.This part calculates an energy of the random value XI as a linear
dependency inside the "I" bin.
C Calculating the energy inside the 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)
6. Transforms energy of the photon to GeV and put it into stack
TKEFLK (NPFLKA) = 1.D-6 * ENERGY
7. Put the photon momentum into stack.
PMOFLK (NPFLKA) = TKEFLK (NPFLKA)
8. The round beam shape. XSPOT and ZBEAM from BEAMCM common.
C Annular (round) beam
CALL SFECFE( SFE, CFE)
RADIUS = XSPOT * SQRT( FLRNDM(XDUMMY) )
XFLK (NPFLKA) = RADIUS * SFE
YFLK (NPFLKA) = RADIUS * CFE
ZFLK (NPFLKA) = ZBEAM
Best regards,
__________________________________________________________________________
You can manage unsubscription from this mailing list at
https://www.fluka.org/fluka.php?id=acc_info
Received on Tue May 12 2015 - 15:51:02 CEST