[fluka-discuss]: Fw: Sampling direction cosines with SOURCE is buggy 5 times out of 10

From: Primidis, Thomas <Thomas.Primidis_at_liverpool.ac.uk>
Date: Tue, 29 Oct 2019 09:09:07 +0000

Hello Mario,


cz,cy,cz are double precision. I am using cx,cy,cz because I want to keep the original source.f code clean and have all my edits separate. So, at the end I can use a simple TXFLK{ NPFLKA} = CX etc.


My distributions are analytical, continuous functions.


Regards,

Thomas


________________________________
From: Primidis, Thomas
Sent: Tuesday, October 29, 2019 9:07 AM
To: Santana, Mario
Subject: Re: Sampling direction cosines with SOURCE is buggy 5 times out of 10


Hello Mario,


cz,cy,cz are double precision. I am using cx,cy,cz because I want to keep the original source.f code clean and have all my edits separate. So, at the end I can use a simple TXFLK{ NPFLKA} = CX etc.


My distributions are analytical, continuous functions.


Regards,

Thomas

________________________________
From: Santana, Mario <msantana_at_slac.stanford.edu>
Sent: Tuesday, October 29, 2019 6:49:06 AM
To: Primidis, Thomas
Subject: Re: Sampling direction cosines with SOURCE is buggy 5 times out of 10

Hi Thomas,

What is the type of cx, cy, cz variables that you are using? DOUBLE PRECISION? why aren't you using T{X/Y/K}FLK variables if within the source.f routine? Also, what kind of distribution are you sampling?

-M
________________________________
From: owner-fluka-discuss_at_mi.infn.it <owner-fluka-discuss_at_mi.infn.it> on behalf of Primidis, Thomas <Thomas.Primidis_at_liverpool.ac.uk>
Sent: Monday, October 28, 2019 6:46 PM
To: fluka-discuss <fluka-discuss_at_fluka.org>
Subject: [fluka-discuss]: Sampling direction cosines with SOURCE is buggy 5 times out of 10


Dear forum,


I am using source.f to describe an x-ray source. I am assigning x and y direction cosines and then I calculate z direction cosine by cz=sqrt(ONEONE-cx**2-cy**2). After that calculation, I test whether the final sum of squares is still .EQ. ONEONE and if not I repeat the sampling until the condition is satisfied. For the record, I sample the photon position (x,y,z) on the XY plane and I assume an x-ray virtual point origin at Z=-2mm thus the direction vector (cx,cy,cz)=(x,y,z)/sqrt(x**2+y**2+z**2), with cz actually calculated via sqrt(1-cx**2-cy**2) to force cx**2+cy**2+cz**2.EQ.ONEONE.


I am counting how many times the sampling is incorrect&repeated and I have seen that 50% of the time the initial sampling is incorrect. I believe this causes particular angles to not be sampled which might be the reason for a beam that looks like the one attached. I can confirm that the XY plane position is sampled correctly because if I force cz=ONEONE and the rest ZERZER, the figure is a smooth as expected (smaller) disk. But when I sample the angles, these radial steps emerge.


When the sampling is repeated its because the sum of the squares is slightly different than ONEONE. Repeating the normalisation (cx,cy,cz)=(cx,cy,cz)/sqrt(cx**2+cy**2+cz**2) and recalculating cz, results in infinite loops with this as the result of the sum of squares:

First calculation

0.99999999999999989
After renormalisations
0.99999999999999989
0.99999999999999989
0.99999999999999989
1.0000000000000002
1.0000000000000002
1.0000000000000002
1.0000000000000002
...
...
Is there a workaround for this issue?


Best regards,

Thomas


__________________________________________________________________________
You can manage unsubscription from this mailing list at https://www.fluka.org/fluka.php?id=acc_info
Received on Tue Oct 29 2019 - 11:22:27 CET

This archive was generated by hypermail 2.3.0 : Tue Oct 29 2019 - 11:22:30 CET