Skip to content

Update read_mod.py for mcnp5 and tally8 - #7

Open
hamed7ir wants to merge 9 commits into
dusankr:masterfrom
hamed7ir:master
Open

Update read_mod.py for mcnp5 and tally8#7
hamed7ir wants to merge 9 commits into
dusankr:masterfrom
hamed7ir:master

Conversation

@hamed7ir

@hamed7ir hamed7ir commented Jul 16, 2025

Copy link
Copy Markdown

Hi , i download release file and chose directory but it couldnt detect my mcnp5 outputs and tally 8 , and show me error like this "Name off processed file: o007.out Traceback (most recent call last):
File "D:\Downloads\Compressed\MCNP_TallyPlotter-0.8.4\MCNP_TallyPlotter-0.8.4\modules\read_mod.py", line 250, in read_tally
if energy[0] > cutoff_en:
^^^^^^^^^
UnboundLocalError: cannot access local variable 'cutoff_en' where it is not associated with a value Read process crash for this file: o007.out"
so with hlep of git copliot i solved this problem and now to works with my mcnp5 outputs but i dont know why original developer disabled some codes for tally 8 , i enabled one of them also so the fix work, the next codes for tally 8 can still be disabled. thank you for this great app.

ps: files that their name is pure number like 1.txt , cant be plotted.

hamed7ir added 2 commits July 16, 2025 21:44
Hi , i download release file and chose directory but it couldnt detect my mcnp5 outputs and tally 8 , and show me error like this "Name off processed file:  o007.out
Traceback (most recent call last):
  File "D:\Downloads\Compressed\MCNP_TallyPlotter-0.8.4\MCNP_TallyPlotter-0.8.4\modules\read_mod.py", line 250, in read_tally
    if energy[0] > cutoff_en:
                   ^^^^^^^^^
UnboundLocalError: cannot access local variable 'cutoff_en' where it is not associated with a value
Read process crash for this file: o007.out"
so with hlep of git copliot i solved this problem and now to works with my mcnp5 outputs but i dont know why original developer disabled some codes for tally 8 , i enabled one of them also so the fix work, the next codes for tally 8 still disabled.
@dusankr

dusankr commented Jul 17, 2025

Copy link
Copy Markdown
Owner

Hi,
I disabled the F8 tally because I had some concerns about the accuracy of the visualization, though in principle it works. I don’t have much experience with F8, and there are still a few uncertainties for me.

For example: do all F8 tallies include a zero bin and an epsilon bin? I believe these were originally subtracted during visualization, but I’m not entirely sure if that’s the correct approach. If you can give me a brief explanation, I’d be happy to revise that part accordingly.

Also, thank you for the info about the file names. I don’t think I’ve ever tested names like that before, so I’m not surprised it failed, but the fix should be straightforward.

@hamed7ir

hamed7ir commented Sep 9, 2025

Copy link
Copy Markdown
Author

Hi again , sorry for delay,
look f8 use case is mostly for spectrums, for example x-ray spectrum of a 150kev beam , has 150 bins from 0 to 150,
`1tally 8 nps = 100000000
tally type 8 pulse height distribution. units number
tally for photons
this tally is modified by ft geb

cell 7
energy
0.0000E+00 4.90000E-05 0.0143
1.0000E-03 9.54000E-06 0.0324
2.0000E-03 1.04300E-05 0.0310
3.0000E-03 1.04300E-05 0.0310
....`
and first bin is for nearly zero energy photons, so they are a few and happens during simulation, and its normal that first bins to be zero or epsilon, we dont need another zero for this , your code add a zero-zero point and no need it, you can make the first bin zero completely, nothing big would happen,

1.Fix the bug of one additional zero for tally f8 .
2. add new feature that generate separate excel files of outputs with their own name
1
1
@hamed7ir

Copy link
Copy Markdown
Author

Hi there.
Fix F8 tally reading and add per-output xlsx export
Bug fix — F8 pulse height tally extra zero
The F8 tally reader had a stray i = data_start line that immediately overwrote the skip logic (i = data_start + 2), causing the zero-energy epsilon bin to always be included. This produced a duplicate zero at the start of the energy array (the epsilon bin's 0.0 MeV value plus the 0 prepended by the cutoff logic), which showed up as an extra data point in both plots and Excel exports.

Fix: Removed the overwriting line and adjusted the skip from +2 to +1. This correctly skips only the zero-energy epsilon bin, while the existing cutoff-prepend logic provides the proper 0 MeV lower bound for the first bin. The same fix was applied to the multi-item tally loop. Both plot and Excel output now show one clean zero at the start of the spectrum as expected.

New feature — Export tallies to separate xlsx files
Previously, selecting tallies from multiple output files and clicking "Export tally to xlsx" merged everything into a single Excel file.

A new "Export to separate xlsx" button has been added. It asks for an output directory, groups the selected tallies by their source output file, and writes one .xlsx per output named after the original file (e.g. Anif5.xlsx). The original single-file export button is unchanged.

Files changed: modules/read_mod.py, modules/export_mod.py, mcnp_tally_plot_main.py

Added a new export feature that allows users to export selected tallies to separate .xlsx files based on their source output files, while keeping the original export functionality unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants