I wanted to do a demo to show the slowing of neutrons in a moderator, by plotting the energy of the neutrons as a function of the number of collisions that the neutron has. The problem is I cannot tally the energy at each collision of the neutrons.
A way that could be done would be by returning also the energy of the outgoing neutron, apart from the location of the neutron when tracking the particle. This way I could easily get the energy at each collision (although it would be very time consuming to track each particle and extract (energy, collision) data). However, I don’t know Fortran to try and adapt the source code so that it outputs also the energy when tracking a particle. I’m assuming I would have to modify the tracking.F90 and the track_output.F90 and maybe the collision subroutine in the physics.F90 files.
Any ideas if it’s possible to do it, or if it is too complicated/unadvisable to change the source?
It would be relatively simple if all you need is the energy and number of collisions. I’ve attached a diff (compared against the source for v0.9.0) showing that you’d need to add only two lines in tracking.F90. After running, you should see a file named fort.10 with two columns, one that has the number of collisions for a given particle and the other that has the energy in eV. From there, you could write a script to process the data in that file and make the plot that you desire.
I changed the two lines in the tracking.F90 in the src directory in my installation path folder, but I don’t get the file fort.10 when i run the simulation (while tracking particles). What’s confusing me is that even if i write something syntactically incorrect in the tracking.F90 file, I get no error when running OpenMC, as if the file isn’t even read when running the simulation. I also tried writing something syntactically incorrect in the physics.F90 and simulation.F90 modules, but I still get no errors.
So, are the fortran files located also elsewhere or only in my installation/src folder? Or do I have to reinstall OpenMC, with the edited files?
Just came across this post as I was thinking that it might be useful to add the neutron energy to the current tracks.h5 files produced by modifying the track_output.cpp file. Wondering if anyone might have done this for the new c++ version of the code as the previous answer was for the older Fortran version and no longer works for the c++ version
@khurrum I’m planning on doing this soon. If you want to stay up to date, I would recommend subscribing to notifications on the corresponding issue on GitHub that tracks this feature request.