Re: [fluka-discuss]: Writting SOURCE user routine generating from file with mixture of particles?

From: Alfredo Ferrari <alfredo.ferrari_at_cern.ch>
Date: Wed, 13 Nov 2013 09:35:09 +0100

Dear Mina

obviosuly if wone wants to reuse cosines in that way, one should write
them with the full 16 digits, if not it will sooner or later occur that
because of rounding their squared sum is > 1

              Alfredo


+----------------------------------------------------------------------+
| Alfredo Ferrari || Tel.: +41.22.76.76119 |
| CERN-EN/STI || Fax.: +41.22.76.69474 |
| 1211 Geneva 23 || e-mail: Alfredo.Ferrari_at_cern.ch |
| Switzerland || |
+----------------------------------------------------------------------+

On Tue, 12 Nov 2013, Mina Nozar wrote:

> Here is the first few lines from the data file written out by FLUKA, containg
> x,y,z, cosx,cosy,cosz, E, weight of neutrons and photons.
>
>
> 8 -.2635E+03 0.6864E+02 0.2944E+04 -.6333E+00 -.3722E+00 -.6785E+00
> 0.6606E-06 0.6400E-05
> 7 -.2635E+03 0.6589E+02 0.2946E+04 -.4823E+00 -.8048E+00 0.3460E+00
> 0.8389E-03 0.2133E-06
> 7 -.2635E+03 0.7252E+02 0.2941E+04 -.7275E+00 0.1437E+00 -.6709E+00
> 0.1702E-03 0.2133E-06
> 8 -.2635E+03 0.7615E+02 0.2963E+04 -.6198E+00 0.3405E+00 0.7071E+00
> 0.4350E-04 0.6400E-05
> 8 -.2635E+03 0.8386E+02 0.2965E+04 -.9698E+00 -.2337E+00 0.7025E-01
> 0.7173E-04 0.6400E-05
> 7 -.2635E+03 0.7403E+02 0.2909E+04 -.9050E+00 0.4251E+00 0.1854E-01
> 0.2451E-02 0.1030E-07
> 7 -.2635E+03 0.6947E+02 0.2910E+04 -.6588E+00 0.4806E+00 0.5788E+00
> 0.8012E-03 0.1031E-07
> 7 -.2635E+03 0.7410E+02 0.2914E+04 -.8432E+00 -.2508E+00 0.4755E+00
> 0.5228E-03 0.1840E-07
> ...
> ...
> ...
>
> and sqrt(cosx^2 + cosy^2 + cosz^2):
>
> sqrt(.6333E+00^2 + .3722E+00^2 + .6785E+00^2) = 0.99998198...
> sqrt(.4823E+00^2 + .8048E+00^2 + .3460E+00^2) = 1.00000161648...
> sqrt(.7275E+00^2 + .1437E+00^2 + .6709E+00^2) = 1.00000637497...
> sqrt(.6198E+00^2 + .3405E+00^2 + .7071E+00^2) = 1.000041349...
> sqrt(.9698E+00^2 + .2337E+00^2 + .7025E-01^2) = 1.0000313957...
> sqrt(.9050E+00^2 + .4251E+00^2 + .1854E-01^2) = 1.000003937...
> sqrt(.6588E+00^2 + .4806E+00^2 + .5788E+00^2) = 1.000001619...
> sqrt(.8432E+00^2 + .2508E+00^2 + .4755E+00^2) = 0.99999356...
>
>
> Mina
>
> On 13-11-12 04:57 PM, Mina Nozar wrote:
>> Hello Andrea,
>>
>> But I get the same problem with an output file writtin by FLUKA (through
>> usrdump and mgdraw.f). What is the solution then?
>>
>> thanks,
>> Mina
>>
>>
>> On 13-11-12 12:41 PM, Andrea.Mairani_at_mi.infn.it wrote:
>>> Dear Vahan,
>>> What are the columns #5,6 and 7?
>>> As Mina wrote,
>>>> The problem seems to be in the following line:
>>>>
>>>> * TZFLK (NPFLKA) = SQRT ( ONEONE - TXFLK (NPFLKA)**2
>>>> * & - TYFLK (NPFLKA)**2 )
>>> but you should NOT change it, the problem is that TXFLK (NPFLKA)**2 +
>>> TYFLK (NPFLKA)**2 is greater than 1 (!) in your case and you have the
>>> floating exception....
>>> Cheers,
>>> Andrea
>>>
>>>
>>>
>>>
>>>
>>>> I commented it out and added:
>>>>
>>>> TZFLK (NPFLKA) = COSZ(I)
>>>>
>>>>
>>>> The above fix gets rid of the core dump but again, I don't know why the
>>>> original line causes a core dump. I have run into this problem before.
>>>> I am sending this response to the list. Maybe someone has an
>>>> explanation (I am neither a FLUKA nor a FORTRAN expert).
>>>>
>>>>
>>>> I ran your project with the 'test.dat' file and produced output files
>>>> (please check the numbers, I didn't look at the source file in detail).
>>>> 3 0.2 0.3 -0.9 -0.2 -0.4 -0.9 0.003
>>>> 1 0.3 -0.3 -0.6 0.5 0.5 -0.3 0.007
>>>> 3 -0.3 -0.3 -0.5 -0.5 -0.9 0.8 0.006
>>>>
>>>>
>>>> I don't think you need the data file to be in the D+/-xx format (from
>>>> your 'test-correct.dat' file). FLUKA itself doesn't write output from
>>>> the first step (scoring particles crossing a boundary (boundaries) in
>>>> this format.
>>>> 1 20D-01 1D-02 -1D+00 -1D-01 1D-01 1D-01 1D-04
>>>> 3 10.2D-01 1.3D-02 -14D+00 -8D-01 1.2D-01 1D-01 1D-03
>>>> 8 20D-01 1D-02 -1D+00 -1.1D-01 1D-01 1D-01 200D-04
>>>> 3 19D-01 10D-02 -18D+00 -1D-01 -1D-01 -1D-01 1D-04
>>>>
>>>> Again, I am not an expert, so I'll leave it to the experts to comment.
>>>>
>>>> Best wishes,
>>>> Mina
>>>>
>>>>
>>>> On 13-11-09 06:36 AM, Vahan Petrosyan wrote:
>>>>> Thanks for reply your answer helped me very much.
>>>>> But I revised my source code and found many LOGICAL mistakes because
>>>>> of which my source routine didn't work at all. Yes it run but it
>>>>> didn't take beam from data file. So.... I corrected my mistakes and
>>>>> now it works as I want.
>>>>>
>>>>> But I have SMALL Problem! Can you help me please?
>>>>> I have DATA FILE in this format: 3 0.2 0.3 -0.9 -0.2
>>>>> -0.4 -0.9 0.003
>>>>> but when I run it crashes with ERROR: "Floating point exception (core
>>>>> dumped)"
>>>>> I read the the lecture
>>>>> https://www.fluka.org/free_download/course/triumf2012/Lectures/AdvancedFluka2012.pdf
>>>>>
>>>>> Where it SAYS:
>>>>> "The code works under IMPLICIT DOUBLE PRECISION for variables in the
>>>>> range (A-H,O-Z). Donít forget ..D+/-xx (eg
>>>>> 2.3D+00, 7.8D-03) in all numerical settings in user routines, and be
>>>>> careful in passing variables to/from Fluka"
>>>>> ie passed number should be in this form "2.3D+00".
>>>>> So...... I manually crated DATA FILE with this format: 1 20D-01
>>>>> 1D-02 -1D+00 -1D-01 1D-01 1D-01 1D-04
>>>>> and my code worked as I expected.
>>>>> ..................
>>>>> I tried to use DBLE() function in order to convert my array elements
>>>>> to DOUBlE PRECISION when I assign it to the FLUKA variables but it
>>>>> doesn't help...... again the same error appears.
>>>>> ....I do like this....
>>>>> TXFLK (NPFLKA) = DBLE(COSX(I))
>>>>> .....................
>>>>> When I use another DATA FILE where numbers are like this "2.3D+00"
>>>>> format My code WORKS JUST FINE!!!
>>>>>
>>>>> Now I try to convert data in form "2.3D+00" myself using this doc.
>>>>> http://docs.oracle.com/cd/E19957-01/805-4939/z40007437a2e/index.html
>>>>> but can't implement.... the same error appears.....
>>>>> So question how can I convert my DATA file numbers to this "2.3D+00"
>>>>> format using FORTRAN77?
>>>>>
>>>>> Thank You!
>>>>>
>>>>> On 11/8/2013 10:47 PM, nozarm_at_triumf.ca wrote:
>>>>>> Hello Vahan,
>>>>>>
>>>>>> I just tried compiling and running the executable and it worked just
>>>>>> fine.
>>>>>> I defined a new run in your flair project, named testroutine-A with
>>>>>> 1000
>>>>>> primaries per cycle and 5 cycles.
>>>>>>
>>>>>>
>>>>>> Cmd: /usr/bin/nohup /triumfcs/linux/fluka/fluka/default/flutil/rfluka
>>>>>> -M 5
>>>>>> testroutine-A
>>>>>>
>>>>>> produced:
>>>>>>
>>>>>>
>>>>>> -rw-rw-r-- 1 nozarm nozarm 4000238 Nov 8 10:39stroutine-A001.log
>>>>>> -rw-rw-r-- 1 nozarm nozarm 4000238 Nov 8 10:39
>>>>>> testroutine-A001_fort.32
>>>>>> -rw-rw-r-- 1 nozarm nozarm 114352 Nov 8 10:39 testroutine-A001.out
>>>>>> -rw-rw-r-- 1 nozarm nozarm 22470 Nov 8 10:39 testroutine-A001.err
>>>>>>
>>>>>> and similar files for A002 through A005.
>>>>>>
>>>>>> I even looked at your usrbin plot and it looks fine.
>>>>>>
>>>>>> I am attaching the flair project file with the run definition. I think
>>>>>> your problem was with the way you were running fluka at the end.
>>>>>>
>>>>>> Best wishes,
>>>>>> Mina
>>>>>>
>>>>>>
>>>>>>> Hi everyone!
>>>>>>> I am wrtitting a custom SOURCE routine that generates beam with
>>>>>>> mixture
>>>>>>> of particles for example electrons and protons from DATA FILE.
>>>>>>> I read the FLUKA help part 13.2.19 and fluka discuss thread from
>>>>>>> Alberto
>>>>>>> Fasso
>>>>>>> http://www.fluka.org/web_archive/earchive/new-fluka-discuss/2887.html.
>>>>>>> I was able to write the routine and compile it with success!!! But
>>>>>>> when
>>>>>>> I run FLUKA It starts to work in a moment and crashes with "Finished
>>>>>>> with ERRORS".
>>>>>>> In my source.f routine:
>>>>>>> 1) I read file using OPEN command
>>>>>>> 2) I use READ command inside DO loop in order to fill arrays of
>>>>>>> particle-ID, coordinates, cosines and energy.
>>>>>>> 3) I put particle intanialization from input file in DO loop.
>>>>>>> DO 20 I = 1, NLINES
>>>>>>> NPFLKA = NPFLKA + 1
>>>>>>> WTFLK (NPFLKA) = ONEONE
>>>>>>> WEIPRI = WEIPRI + WTFLK (NPFLKA)
>>>>>>> IJBEAM = PARTID(I)
>>>>>>> TXFLK (NPFLKA) = COSX(I)
>>>>>>> TYFLK (NPFLKA) = COSX(I)
>>>>>>>
>>>>>>> ****** etc. ******
>>>>>>> 20 CONTINUE
>>>>>>> RETURN
>>>>>>> CALL SOEVSV
>>>>>>>
>>>>>>> I can't undertand why it happens because in my nohup.out file there is
>>>>>>> only one single line
>>>>>>>
>>>>>>> ======================= Running FLUKA for cycle # 1
>>>>>>> =======================
>>>>>>> /usr/local/fluka/flutil/rfluka: line 358: 1926 Aborted
>>>>>>> (core dumped) "${EXE}" < "$INPN" 2> "$LOGF" > "$LOGF"
>>>>>>>
>>>>>>> If someone has time PLEASE take a look and say why my SOURCE doesn't
>>>>>>> work.......
>>>>>>> I am attached files that I got after run.
>>>>>>>
>>>>>>> Thank You.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>
>>
>
Received on Wed Nov 13 2013 - 10:33:18 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 13 2013 - 10:33:19 CET