# Cosmic neutron ray energy spectrum data calculation problem?

**URL:** <https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407>\
**Category:** Advanced Features and User Routines\
**Created:** [20 July 2022 16:14 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407 "2022-07-20T16:14:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fengfengxu](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/fengfengxu/32/3529_2.png) [@fengfengxu](https://fluka-forum.web.cern.ch/u/fengfengxu)\
**Post date:** [20 July 2022 16:14 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/1 "2022-07-20T16:14:07Z")

</div>

Dear experts,

I simplified the computational model, using the air layer as the neutron source,the soil thickness is 6 m.The calculations were made using the cosmic neutron ray energy spectrum, but the resulting trend seems to be problematic.I can only calculate single-energy neutrons.

My calculations turn out to be such a trend：

 ![12](https://fluka-forum.web.cern.ch/uploads/default/original/2X/a/a6ee890645efd513759859cc1b7e160a430b8497.png)

The flux result trend of the relevant paper is:

 ![屏幕截图 2022-07-20 235144](https://fluka-forum.web.cern.ch/uploads/default/original/2X/b/b9d76d6068e94c68023c98cd000881d99649bbc9.png)

How do I implement the following energy spectrum calculations?At the moment it seems that there is something wrong with the program.Please help me！

[Cosmic.inp](https://fluka-forum.web.cern.ch/uploads/short-url/69UwzrftMDPVN58Xn6jjfOHsEAu.inp) (2.9 KB)  
[cydnp.txt](https://fluka-forum.web.cern.ch/uploads/short-url/qfl0nW6I4zOBHrG2igT0KW0zjUd.txt) (7.2 KB)  
[source\_spectrum.f](https://fluka-forum.web.cern.ch/uploads/short-url/gJcb8bSci4kiiFPjtoJpDV1gSHD.f) (10.5 KB)

Fengfeng Xu  
Thanks in advance！

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [21 July 2022 07:31 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/2 "2022-07-21T07:31:52Z")

</div>

Dear Fengfeng,

I could not reproduce your first plot, with the user routine you provided. Also, to make it run I had to remove the first line from the spectrum file.

Furthermore, what is the quantity of the second column? For me it seems, that the numbers are the values of a lethargy plot (dN/d(logE) = E\*dN/dE), while the source routine expects dN/dE values.

With my assumption I get the following source spectrum:

![neutron](https://fluka-forum.web.cern.ch/uploads/default/original/2X/3/3b2f21aa24f8976bc089431858cfc25cf56284d2.png)

Which resembles the ones on your second figure.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [21 July 2022 07:58 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/4 "2022-07-21T07:58:48Z")

</div>

Dear Fengfeng,

more meaningful error messages can be found in the _.out_, _.log_ and/or _.err_ files, located next to the input file or in the _fluka\_xxxx_ directories.

In this case the problem is with the character encoding of the spectrum file. See:

> [@Fortran runtime error( End of file) when using source.f to read a file with OPEN card](https://fluka-forum.web.cern.ch/t/fortran-runtime-error-end-of-file-when-using-source-f-to-read-a-file-with-open-card/2476/2):
>
> Dear Jingfang, the issue seems to be with the encoding of the file. According to my editor it is UTF-16 LE. When I change it to UTF-8, then the Fortran code can read the lines, but there are other errors in the code which prevents FLUKA to run. Cheers, David

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [21 July 2022 11:17 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/6 "2022-07-21T11:17:20Z")

</div>

Dear Fengfeng,

I don’t see any changes in your spectrum file or source routine, also the attached Flair project file has different plot settings compared to the figure you posted last.

For these reasons I couldn’t reproduce you last result.

My spectrum was scored immediately after the starting location of the neutrons, so that is maybe the reason you see a different result.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![fengfengxu](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/fengfengxu/32/3529_2.png) [@fengfengxu](https://fluka-forum.web.cern.ch/u/fengfengxu)\
**Post date:** [21 July 2022 13:41 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/7 "2022-07-21T13:41:01Z")

</div>

Dear Teacher David，

Dear David, your judgment is correct. I gained a lot from this exchange and thank you again.This post can be closed.

Fengfeng

---

<div class="post-metadata">

**Author:** ![horvathd](https://fluka-forum.web.cern.ch/user_avatar/fluka-forum.web.cern.ch/horvathd/32/10584_2.png) [@horvathd](https://fluka-forum.web.cern.ch/u/horvathd)\
**Post date:** [21 July 2022 13:42 UTC](https://fluka-forum.web.cern.ch/t/cosmic-neutron-ray-energy-spectrum-data-calculation-problem/3407/8 "2022-07-21T13:42:14Z")

</div>

Closed on 21 July 2022 13:42 UTC


