Fusion4Energy / F4Enix

API for parsing and post-processing many MC simulations related files
Other
12 stars 10 forks source link

[BUG] - shift of x,y,z coordinates of vts file created from a weight window #93

Closed Nafradi closed 2 months ago

Nafradi commented 2 months ago

Describe the bug The result of the export=ww.export_as_vtk("ww_exported_vtk") created a vts file but once this vts file is opened with paraview the weigh window appeared to be shifted in x,y,z directions by the min values of the x,y,z extent of the weight window.

To Reproduce Steps to reproduce the behavior: So I have a meshtal with F4 neutron flux tally basicly the same that in the radmaps with 1.00E-06, 1.00E-01, 1.00E+00, 1.00E+01, 2.00E+01 MeV upper bin boundaries the only modification is that I put out=ij card as well to set the output format.

from f4enix.input.ww_gvr.ww_parser import read_meshtally_file, write from f4enix.input.ww_gvr import WW

file_path = "C:\Users\nafradg\Work Folders\F4ENIX\meshtal"

tally_id = 14

result = read_meshtally_file(file_path, tally_id)

header = result.header # WWHeader object b2_vectors = result.b2_vectors # Vectors object (i.e., geometry data) energies = result.energies # List of energy bins values = result.values # List of values corresponding to energies

ww_file_path = "C:\Users\nafradg\Work Folders\F4ENIX\output_ww_file" write(ww_file_path, header, b2_vectors, energies, values)

ww = WW.load_from_ww_file("output_ww_file") print(ww)

So when I reread and print the ww I get: output_ww_file weight window ----From---- -----To----- --No. Bins-- I --> -5935.0 6025.0 124 J --> -3725.0 4612.0 107 K --> -1558.0 5920.0 84

Cartesian coordinates, 1114512 voxels.

The weight window contains 1 particle/s

---------------------Neutron---------------------- Energy bins: [100.0] Min value: 0.00E+00 Max value: 3.01E-07 No.Bins > 0 [%]: 40.3% Average ratio: 4.52E+08 Max ratio: 7.99E+13

The spatial boundaries of the weight window are matching with the meshtally dimensions. Then: export=ww.export_as_vtk("ww_exported_vtk")

created a vts file but it seemed that the entire mesh was shifted with the I,J,K values( I=-5935.0 J=-3725.0 K=-1558.0) at least that how it appeared in paraview 5.11.1.

I put here an image to show the offset in comparison to B2 level.

image

Expected behavior The white box should incorporate the B2 level.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

dodu94 commented 2 months ago

Thank you very much Gabor for the detailed issue! @AlvaroCubi when you are back can you have a look at this?

dodu94 commented 2 months ago

In the meantime, I see that you have an older version of F4Enix installed (0.5.2) can you confirm that you have the same problem whit the latest one (v0.9.0)?

you can upgrade it with:

pip install --upgrade f4enix
Nafradi commented 2 months ago

In the meantime, I see that you have an older version of F4Enix installed (0.5.2) can you confirm that you have the same problem whit the latest one (v0.9.0)?

you can upgrade it with:

pip install --upgrade f4enix

Done. The results below show that I had the lates, so it means maybe the import f4enix print(f4enix.version) is not the right way to get the version number of f4enix...

Requirement already satisfied: f4enix in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (0.9.0) Requirement already satisfied: numpy<=1.26.4 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (1.26.4) Requirement already satisfied: numjuggler in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (2.42.36) Requirement already satisfied: pyvista>=0.39.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (0.44.1) Requirement already satisfied: pandas in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (2.2.2) Requirement already satisfied: numba in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (0.60.0) Requirement already satisfied: scipy in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (1.14.1) Requirement already satisfied: tqdm in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (4.66.2) Requirement already satisfied: python-docx in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (1.1.2) Requirement already satisfied: openpyxl in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (3.1.5) Requirement already satisfied: tables in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from f4enix) (3.10.1) Requirement already satisfied: matplotlib>=3.0.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (3.9.2) Requirement already satisfied: pillow in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (10.4.0) Requirement already satisfied: pooch in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (1.8.2) Requirement already satisfied: scooby>=0.5.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (0.10.0) Requirement already satisfied: vtk in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (9.3.1) Requirement already satisfied: typing-extensions in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pyvista>=0.39.1->f4enix) (4.12.2) Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from numba->f4enix) (0.43.0) Requirement already satisfied: six in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from numjuggler->f4enix) (1.16.0) Requirement already satisfied: pathlib2 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from numjuggler->f4enix) (2.3.7.post1) Requirement already satisfied: et-xmlfile in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from openpyxl->f4enix) (1.1.0) Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pandas->f4enix) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pandas->f4enix) (2024.1) Requirement already satisfied: tzdata>=2022.7 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pandas->f4enix) (2024.1) Requirement already satisfied: lxml>=3.1.0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from python-docx->f4enix) (5.3.0) Requirement already satisfied: numexpr>=2.6.2 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from tables->f4enix) (2.10.1) Requirement already satisfied: packaging in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from tables->f4enix) (24.0) Requirement already satisfied: py-cpuinfo in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from tables->f4enix) (9.0.0) Requirement already satisfied: blosc2>=2.3.0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from tables->f4enix) (2.7.1) Requirement already satisfied: colorama in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from tqdm->f4enix) (0.4.6) Requirement already satisfied: ndindex>=1.4 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from blosc2>=2.3.0->tables->f4enix) (1.8) Requirement already satisfied: msgpack in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from blosc2>=2.3.0->tables->f4enix) (1.0.8) Requirement already satisfied: contourpy>=1.0.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from matplotlib>=3.0.1->pyvista>=0.39.1->f4enix) (1.3.0) Requirement already satisfied: cycler>=0.10 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from matplotlib>=3.0.1->pyvista>=0.39.1->f4enix) (0.12.1) Requirement already satisfied: fonttools>=4.22.0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from matplotlib>=3.0.1->pyvista>=0.39.1->f4enix) (4.53.1) Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from matplotlib>=3.0.1->pyvista>=0.39.1->f4enix) (1.4.7) Requirement already satisfied: pyparsing>=2.3.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from matplotlib>=3.0.1->pyvista>=0.39.1->f4enix) (3.1.4) Requirement already satisfied: platformdirs>=2.5.0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pooch->pyvista>=0.39.1->f4enix) (4.2.0) Requirement already satisfied: requests>=2.19.0 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from pooch->pyvista>=0.39.1->f4enix) (2.31.0) Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from requests>=2.19.0->pooch->pyvista>=0.39.1->f4enix) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from requests>=2.19.0->pooch->pyvista>=0.39.1->f4enix) (3.6) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from requests>=2.19.0->pooch->pyvista>=0.39.1->f4enix) (2.2.1) Requirement already satisfied: certifi>=2017.4.17 in c:\users\nafradg\appdata\local\miniforge3\lib\site-packages (from requests>=2.19.0->pooch->pyvista>=0.39.1->f4enix) (2024.7.4)

AlvaroCubi commented 2 months ago

Hello @Nafradi, thank you for spotting this. I am sorry for the delay in solving this, I was o.o.o. Would it be possible that you send me the resulting FMESH file and the FMESH card that was used? One thing to take into account is that if the FMESH card has a TR card, this information is lost in the FMESH file as no info on the TR card is printed there but if I recall correctly this may depend on the MCNP/D1SUNED version. If the problem is due to a TR card then this issue cant be solved on our side and the best thing would be to redefine the FMESH card so it doesnt use a TR. I am also curious about the out=ij, maybe this format is not read properly by the MESHTAL reader.

Radiation-Transport commented 2 months ago

I am quite sure that the fmesh parser can read the column format as it is based on the https://github.com/Radiation-Transport/mesh2vtk.

Indeed this highlighted in the readme of https://github.com/Radiation-Transport/mesh2vtk

Nafradi commented 2 months ago

FMESH14:N origin -5935 -3725 -1558 imesh -5835 -3625 -3475 3475 3625 5860 5925 6025 iints 1 22 2 72 2 23 1 1 jmesh -3625 -3475 4305 4455 4512 4612 jints 1 2 100 2 1 1
kmesh -1458 -1308 -753 -723 -673 -238 -198 -148 310 340 390 828 848 908 1508 1608 1651 1708 1851 5920 kints 1 2 6 1 1 5 1 1 5 1 1 5 1 1 6 1 1 1 2 41 emesh 1e-6 0.1 1 10 20 eints 1 1 1 1 1 out=ij This was the tally definition...The meshtal file is quite large about 180 MB zipped so I can't attach it here.

AlvaroCubi commented 2 months ago

Fixed in c1175b761401b0a446874b70331e22065c1e43a3