RE: [fluka-discuss]: how to include the divergence in the source.f / photons

From: Paola Sala <paola.sala_at_mi.infn.it>
Date: Mon, 2 Mar 2020 09:06:53 +0100

Hello
sorry but maybe I do not understand your question:
yes, you will have a beam that is rectangular in shape, and has a uniform
angular distribution within costheta<.02, uniform in phi, that means that
for aech point in your x-y rectangle the beam will be uniform within a
cone.
This is not what you want?
Paola

> Dear experts
>
> I managed to found the mistake and now the source routine for circular
> divergent beam is working as expected.
>
> However, I still have a big problem with the one for rectangular divergent
> beam. I will try to split this in the parts as I understand it (very
> minimal) - if someone is able, kindly please help with the necessary
> corrections. If I understand correctly, I am having rectangular beam but
> with circular divergence in this case, if I am not mistaken
>
>
> **************Initialization , the reading, building and normalizing the
> spectrum from the file *******
> WRITE( LUNOUT, *)
> WRITE( LUNOUT, *) 'READING X-RAY SPECTRUM'
> DO I = 0, 700
> READ( LUNRD2, *, END = 1200) ENE(I), FLX(I)
> NMAX = I
> END DO
> CALL FLABRT( 'SOURCE', 'SPECTRUM READING FAILED')
> 1200 CONTINUE
> CUM(0) = ZERZER
> DO I = 1, NMAX
> CUM(I) = (FLX(I - 1) + FLX(I)) * (ENE(I) - ENE(I - 1))
> & + CUM(I - 1)
> END DO
> DO I = 1, NMAX
> CUM(I) = CUM(I) / CUM(NMAX)
> END DO
> END IF
> ************ Sampling from the spectrum, determination of the energy
> inside bin
> XI = FLRNDM(XI)
> DO I = 1, NMAX
> IF ( XI .LT. CUM(I)) GOTO 1201
> END DO
> CALL FLABRT( 'SOURCE', 'SAMPLING SPECTRUM FAILED')
> 1201 CONTINUE
> 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)
> ************************************************Cosines
> (tx,ty,tz)*************
> COSTH = ONEONE-(1-.98)*FLRNDM(TTT) **setting the divergence in
> rad**
> IF(COSTH.GT.ONEONE) COSTH=ONEONE
> IF(COSTH.LT.-ONEONE) COSTH=-ONEONE
> PHI = TWOPIP*FLRNDM(SSS)
> UBEAM=SQRT(ONEONE-COSTH*COSTH)*COS(PHI)
> VBEAM=SQRT(ONEONE-COSTH*COSTH)*SIN(PHI)
> WBEAM=COSTH
> TXFLK (NPFLKA) = UBEAM
> TYFLK (NPFLKA) = VBEAM
> * TZFLK (NPFLKA) = WBEAM
> TZFLK (NPFLKA) = SQRT ( ONEONE - TXFLK (NPFLKA)**2
> & - TYFLK (NPFLKA)**2 )
>
> ************Shape of the beam*************************
> CALL SFECFE( SFE, CFE)
> RADIUS = XSPOT * SQRT( FLRNDM(XDUMMY) )
> XFLK (NPFLKA) = XBEAM + (TWOTWO * FLRNDM(XDUMMY) - ONEONE)
> & * XSPOT
> YFLK (NPFLKA) = YBEAM + (TWOTWO * FLRNDM(YDUMMY) - ONEONE)
> & * YSPOT
> ZFLK (NPFLKA) = ZBEAM
>
>
>
>
> -----Original Message-----
> From: Ševik Aleksandras
> Sent: Thursday, February 27, 2020 17:32
> To: 'Answers' <answers_at_pcfluka.mi.infn.it>
> Cc: fluka-discuss_at_fluka.org
> Subject: RE: [fluka-discuss]: how to include the divergence in the
> source.f / photons
>
> Hello
>
> Thank you. I have updated FLUKA to the newest release, and tried to
> rewrite the old source.f routine for the new one (sampling from the
> provided spectra the annular beam with divergence), however, I am getting
> the error when compiling:
>
> --- /usr/bin/ld: nsource_c_div.o: in function `source_':
> /home/user/Documents/simplified_linac/nsource_c_div.f:203: undefined
> reference to `cum_'
>
> As I understand this mean that the mistake is here:
>
> C Determining the energy inside bin according to linear spectrum
> XI = (XI - CUM(I - 1)) / (CUM(I) - CUM(I - 1))
> IF (FLX(I) .EQ. FLX(I - 1)) THEN
> ENERGY = XI
>
> I have attached the routine. Kindly please help with this as it stopped
> all my work,
>
> Regards
> Alex
>
> -----Original Message-----
> From: Answers <answers_at_pcfluka.mi.infn.it>
> Sent: Thursday, February 27, 2020 12:41
> To: Ševik Aleksandras <aleksandras.sevcik_at_ktu.edu>
> Cc: fluka-discuss_at_fluka.org
> Subject: RE: [fluka-discuss]: how to include the divergence in the
> source.f / photons
>
> Dear Alex,
> here you can find an additional example for both a rectangular and a
> gaussian beam width.
>
> http://www.fluka.org/web_archive/earchive/new-fluka-discuss/1948.html
>
> Moreover, be aware that with the new FLUKA version 2020.0 beta, some
> changes in the source.f rotuine are needed, as reported in the release
> notes. In particular three new variables have to be initialized in the
> stack: EEXSTK, TMNSTK, ILVSTK.
>
> Furthermore, the following lines
> LCHFLK (NPFLKA) = .FALSE.
> DCHFLK (NPFLKA) = ZERZER
>
> have to be converted into
>
> KCHFLK (NPFLKA) = 0
> ECRFLK (NPFLKA) = ZERZER
>
> You can find an updated template in $FLUPRO/usermvax I encourage you to
> download the latest FLUKA version as soon as possible.
>
> If you have further questions let us know.
> G
>
> On Tue, 25 Feb 2020, Ševik Aleksandras wrote:
>
>> Hello again
>>
>> Unfortunately my lack of skill in programming and deeper understanding
>> prevented me from implementing the divergence into source.f for
>> rectangular beam cases. In cases anyone has used/developed similar or is
>> able to provide step-by-step (literally) solution I would be insanely
>> grateful.
>>
>> Rgds
>> Alex
>>
>> -----Original Message-----
>> From: Francesc Salvat-Pujol <francesc.salvat.pujol_at_cern.ch>
>> Sent: Thursday, July 25, 2019 20:29
>> To: Ševik Aleksandras <aleksandras.sevcik_at_ktu.edu>
>> Cc: fluka-discuss_at_fluka.org; owner-fluka-discuss_at_mi.infn.it
>> Subject: Re: [fluka-discuss]: how to include the divergence in the
>> source.f / photons
>>
>> Hey Alex,
>>
>> If I get you right, you want to sample beam particle initial
>> directions with a rectangular divergence (i.e. cosine uniformly
>> sampled in a given
>> interval) around an arbitrary direction theta_f and phi_f in your
>> modified source.f.
>>
>> On paper, what one would ordinarily do is first sample the initial
>> direction with the desired rectangular divergence around the z axis and,
>> then, apply a rotation onto the final direction. So you're almost there.
>>
>> - I believe for a rectangular beam the divergence is to be understood
>> as a full width. Thus, to sample the (cosine of the) polar angle one
>> would rather do
>>
>> CDH = COS ( HLFHLF * DIV )
>> COSTH = ONEONE - ( ONEONE - CDH ) * FLRNDM ( TTT )
>>
>> alternatively
>>
>> COSTH = CDH + ( ONEONE - CDH ) * FLRNDM ( TTT )
>>
>> where DIV is the divergence in radians, and the azimuthal angle you
>> sample uniformly from 0 to 2*pi like you already do. By the way, the
>> DIVBM variable should still have the value you passed in WHAT(3) of
>> your BEAM card, already converted to radians, but double check in your
>> particular case.
>>
>> - You then construct T{X,Y,Z}FLK and ensure it is unit normalized. If
>> you chose to do smth a la TZFLK(NPFLKA) =SQRT(...) keep an eye on its
>> sign (for big DIV).
>>
>> - The resulting T{X,Y,Z}FLK should be fine, but they are still sampled
>> around the z axis. Let d_i=(tx,ty,tz). To get the "final" direction,
>> d_f=(tx',ty',tz'), one would apply on d_i a rotation of angle theta_f
>> around the y axis, R(theta_f,y), and, next, a rotation of angle phi_f
>> around the z axis, R(phi_f,z).
>>
>> To be explicit, see the (hopefully not too far off) attached recipe,
>> without any particular effort to be numerically robust (which is a bad
>> idea... and exactly the reason why director cosines are preferrable
>> instead of angles...), but it will get you started. At the very least,
>> make sure that the final T{X,Y,Z}FLK components are normalized (such
>> that the sum of their squares is ONEONE).
>>
>> Cesc
>>
>> On Tue, Jul 23 2019, at 18:36 +0000, Ševik Aleksandras wrote:
>>>
>>> Thank You, Sougata,
>>>
>>> I meant BEAMPOS WHAT(4) & (5) , i.e. the ones which gives the direction
>>> cosines of the beam itself.
>>> The divergence works itself great when beam is straight, with BEAMPOS
>>> WHAT(4)&(5) = 0...
>>>
>>> In case anyone can help with this question, also with the coding for
>>> the rectangular beam divergence, kindly please,
>>>
>>> Regards
>>> Alex
>>>
>>> -----Original Message-----
>>> From: Sougata <sougata_at_barc.gov.in>
>>> Sent: Tuesday, July 23, 2019 13:02
>>> To: Ševik Aleksandras <aleksandras.sevcik_at_ktu.edu>
>>> Cc: fluka-discuss_at_fluka.org; owner-fluka-discuss_at_mi.infn.it
>>> Subject: RE: [fluka-discuss]: how to include the divergence in the
>>> source.f / photons
>>>
>>> Dear Alex,
>>>
>>> For your query (1).
>>> Any parameter from source card may be passed to source.f file through
>>> whasou(#).
>>>
>>> e.g
>>> Coding for 200 mrad divergence beam where WHAT(3)=0.98007 im source
>>> card.
>>>
>>> * Cosines (tx,ty,tz)
>>> COSTH = ONEONE-(1-whasou(3))*FLRNDM(TTT)
>>> IF(COSTH.GT.ONEONE) COSTH=ONEONE
>>> IF(COSTH.LT.-ONEONE) COSTH=-ONEONE
>>> PHI = TWOPIP*FLRNDM(SSS)
>>> UBEAM=SQRT(ONEONE-COSTH*COSTH)*COS(PHI)
>>> VBEAM=SQRT(ONEONE-COSTH*COSTH)*SIN(PHI)
>>> WBEAM=COSTH
>>> TXFLK (NPFLKA) = UBEAM
>>> TYFLK (NPFLKA) = VBEAM
>>> * TZFLK (NPFLKA) = WBEAM
>>> TZFLK (NPFLKA) = SQRT ( ONEONE - TXFLK (NPFLKA)**2
>>> & - TYFLK (NPFLKA)**2 )
>>>
>>> Please check.
>>>
>>> Regarding your query (2). I am not so experienced. Better consult some
>>> expert person.
>>>
>>> Regards,
>>> --
>>> SOUGATA RAKSHIT / सŒ—त र•षित
>>> Scientific Officer(D) / वˆœžानि•
>>> †धि•ार€•(D) RSSD / †र स स डि
>>> Bhabha Atomic Research Centre / भाभा परमान
>>> …नस‚धान •‡‚दर
>>> Mumbai-400 085 / म‚बˆ-400 085
>>> Tel: +91-022-2559 2214/ द‚रभाष: +91-022-2559 2214
>>>
>>> On 2019-07-23 12:57, Ševik Aleksandras wrote:
>>>> Dear Sougata Rakshit,
>>>>
>>>> Wonderful, it works indeed!
>>>> But may I ask two more moments here:
>>>>
>>>> 1) I need to set up the certain values ( 0.2 ) for BEAMPOS WHAT(4) &
>>>> (5) - direction cosine of the beam with respect to the x & y-axis.
>>>> It does not take values from the card now when I use this modified
>>>> routine. What additional line should be included for this?
>>>> 2) also this code works for angular flat beam only, but not for
>>>> rectangular flat beam - does the code differs much in such case?
>>>>
>>>> If you or anybody else could find an opportunity to help with this,
>>>> I will greatly appreciate such help,
>>>>
>>>> Regards
>>>> Alex
>>>>
>>>> -----Original Message-----
>>>> From: Sougata <sougata_at_barc.gov.in>
>>>> Sent: Tuesday, July 23, 2019 07:47
>>>> To: Ševik Aleksandras <aleksandras.sevcik_at_ktu.edu>
>>>> Cc: fluka-discuss_at_fluka.org; owner-fluka-discuss_at_mi.infn.it
>>>> Subject: Re: [fluka-discuss]: how to include the divergence in the
>>>> source.f / photons
>>>>
>>>>
>>>> Dear Alex,
>>>>
>>>> Please note following if it can help you.
>>>>
>>>> cos 200 mrad=0.98007
>>>> So we have to randomize direction cosine along beam axis from
>>>> 0.98007 to 1 (i.e. cos (0 degree) to cos (200 mrad))
>>>>
>>>> you can try following code as
>>>>
>>>> * Cosines (tx,ty,tz)
>>>> COSTH = ONEONE-(1-0.98007)*FLRNDM(TTT)
>>>> IF(COSTH.GT.ONEONE) COSTH=ONEONE
>>>> IF(COSTH.LT.-ONEONE) COSTH=-ONEONE
>>>> PHI = TWOPIP*FLRNDM(SSS)
>>>> UBEAM=SQRT(ONEONE-COSTH*COSTH)*COS(PHI)
>>>> VBEAM=SQRT(ONEONE-COSTH*COSTH)*SIN(PHI)
>>>> WBEAM=COSTH
>>>> TXFLK (NPFLKA) = UBEAM
>>>> TYFLK (NPFLKA) = VBEAM
>>>> * TZFLK (NPFLKA) = WBEAM
>>>> TZFLK (NPFLKA) = SQRT ( ONEONE - TXFLK (NPFLKA)**2
>>>> & - TYFLK (NPFLKA)**2 )
>>>>
>>>> I think it will work.
>>>>
>>>> Regards,
>>>> --
>>>> SOUGATA RAKSHIT / सŒ—त र•षित
>>>> Scientific Officer(D) / वˆœžानि•
>>>> †धि•ार€•(D) RSSD / †र स स डि
>>>> Bhabha Atomic Research Centre / भाभा परमान
>>>> …नस‚धान •‡‚दर
>>>> Mumbai-400 085 / म‚बˆ-400 085
>>>> Tel: +91-022-2559 2214/ द‚रभाष: +91-022-2559 2214
>>>>
>>>>
>>>> On 2019-07-23 00:21, Ševik Aleksandras wrote:
>>>>> Dear experts,
>>>>>
>>>>> I am using the attached source.f to sample the designed photon
>>>>> spectrum, however, I noticed that BEAM WHAT(3) does not respond to
>>>>> the values if source routine is activated - just as stated in the
>>>>> manual.
>>>>>
>>>>> Is there any "simple" way to make my source beam with divergence
>>>>> 200 mrad, or only additional piece of code must be included in the
>>>>> source.f?
>>>>>
>>>>> Looking through old forum archives I found similar code for that
>>>>> purpose:
>>>>>
>>>>> Divbm_Sigma = Divbm*0.2
>>>>>
>>>>> CALL FLNRR2 (RGAUSSDIVX,RGAUSSDIVY)
>>>>>
>>>>> DIV_VECTORX = RGAUSSDIVX*Divbm_Sigma
>>>>>
>>>>> DIV_VECTORY = RGAUSSDIVY*Divbm_Sigma
>>>>>
>>>>> TXHLP = TAN( DIV_VECTORX )
>>>>>
>>>>> TYHLP = TAN( DIV_VECTORY )
>>>>>
>>>>> THELP = SQRT( TXHLP*TXHLP + TYHLP*TYHLP + ONEONE )
>>>>>
>>>>> TXFLK (NPFLKA) = TXHLP / THELP
>>>>>
>>>>> TYFLK (NPFLKA) = TYHLP / THELP
>>>>>
>>>>> TZFLK (NPFLKA) = SQRT ( ONEONE - LTXFLK (NPFLKA)**2 - TYFLK
>>>>> (NPFLKA)**2 )
>>>>>
>>>>> TXFLK (NPFLKA) = UBEAM
>>>>>
>>>>> TYFLK (NPFLKA) = VBEAM
>>>>>
>>>>> TZFLK (NPFLKA) = WBEAM
>>>>>
>>>>> TZFLK (NPFLKA) = SQRT ( ONEONE - TXFLK (NPFLKA)**2
>>>>>
>>>>> & - TYFLK (NPFLKA)**2 )
>>>>>
>>>>> But simply applying it the code is not compiled, and my lack of
>>>>> experience with user routines is a big obstacle to move forward
>>>>> from this point. In addition, my BEAMPOS is defined with
>>>>> WHAT(1)-(WHAT(3) and also rotation value for WHAT(5) is used. Also
>>>>> the beam is directed to positive Z direction.
>>>>>
>>>>> Could anyone share a similar working source.f file which would
>>>>> directly use BEAM WhHAT(3) value, or maybe guide me through this
>>>>> coding problem?
>>>>>
>>>>> Both source.f routines - the original and the one I tried to modify
>>>>> - are attached.
>>>>>
>>>>> Thank you very much,
>>>>>
>>>>> Rgds
>>>>>
>>>>> Alex
>>>>
>>>>
>>>>
>>>> ____________________________________________________________________
>>>> _ _ ____ You can manage unsubscription from this mailing list at
>>>> https://www.fluka.org/fluka.php?id=acc_info
>>>
>>>
>>>
>>> _____________________________________________________________________
>>> __ ___ You can manage unsubscription from this mailing list at
>>> https://www.fluka.org/fluka.php?id=acc_info
>>>
>>
>> --
>> Francesc Salvat Pujol
>> CERN-EN/STI
>> CH-1211 Geneva 23
>> Switzerland
>> Tel: +41 22 76 64011
>> Fax: +41 22 76 69474
>>
>
> __________________________________________________________________________
> You can manage unsubscription from this mailing list at
> https://www.fluka.org/fluka.php?id=acc_info
>


Paola Sala
INFN Milano
tel. Milano +39-0250317374
tel. CERN +41-227679148

__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info
Received on Mon Mar 02 2020 - 10:16:20 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 02 2020 - 10:16:23 CET