PyNE r2s source density shape and value discrepency when using subvoxel

22 views
Skip to first unread message

Jin whan Bae

unread,
Jan 7, 2022, 4:52:49 PM1/7/22
to PyNE Users
Hello, I'm using the PyNE r2s.py to generate a photon emission mesh.

Upon getting the `source_1.h5m` (and _2, _3,...) file, I used the pyne.mesh.Mesh to read the h5m file to get the source density matrix, since I can't use the h5m file directly (I'm using Shift). However, I find that the shape of the `source_density` matrix is (110592, 216). 110592 is the number of subvoxels, which is consistent with the other data in the h5m file. However, the 216 number is the number of energy groups (24) multiplied by 9. The number 9, upon some digging, is the `max_num_cells` value, which I'm not entirely sure what it is.
Also, the summation of the entire matrix is not equal to the value in `total_photon_source_intensity.txt`, which is the case for non-subvoxel calculations. Can someone explain why this is?

Thank you

Paul Wilson

unread,
Jan 11, 2022, 9:09:25 PM1/11/22
to nucle...@gmail.com, PyNE Users, zha...@ipp.ac.cn

Hi there Jin Whan,

 

I’d have to dig a little into the code to be sure (and I’ve copied Xiaokang who implemented this).

 

For the subvoxel method, there can be many different materials in each voxel.  It seems that in your case, there can be up to 9 different cells/materials in any voxel.  We then generate a different source for each cell in each voxel.  Some of the entries will be zero since some voxels will have fewer than 9 cells (perhaps only 1).

 

I’m not sure how this gets processed when you use pyne.mesh.Mesh to unpack it.  Can you share your code snippet that did this?

 

Paul

 

-- 
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ --
Paul P.H. Wilson (he/him/his)
Grainger Professor of Nuclear Engineering
Chair, Department of Engineering Physics
o: 608-263-0807, c: 608-469-9615
paul....@wisc.edu
153 Engineering Research Bldg
1500 Engineering Dr, Madison, WI 53706
Zoom Meeting Room: https://uwmadison.zoom.us/j/6082630807
Zoom Phone Access: +1-929-205-6099, Access code: 6082630807

Computational Nuclear Engineering Research Group

--
You received this message because you are subscribed to the Google Groups "PyNE Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyne-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyne-users/6f8dec38-f0c0-442d-b33b-245fb849998bn%40googlegroups.com.

Jin whan Bae

unread,
Jan 11, 2022, 9:34:33 PM1/11/22
to PyNE Users
Hi Paul, thank you for the reply.

The script used to get those shapes and values are below:
```
from pyne.mesh import Mesh
import numpy as np
import matplotlib.pyplot as plt

m = Mesh('source_1.h5m')

source_density = np.array(m.source_density[:])
print(m.__dict__)
print('cell number')
ve0 = next(m.iter_ve())
num_vol_elements = len(m)
max_num_cells = len(np.atleast_1d(m.cell_number[ve0]))
print(max_num_cells)



sd = m.source_density[:]
print('source density array shape:', source_density.shape)
# outputs (110592, 216)

print(sum(source_density.flatten()))
# outputs 253187415063866.7
# source_1 on 'total_photon_source_intensities.txt'
# is 1.209216584403693e+18
```
I wasn't sure how to do it properly, so it was mostly trial and error, if there's a better way or an example script, do let me know! I'd like to get the 1) location / volume of the subvoxel, 2) the photon emission rate for each energy group. I'd imagine that should be a shape of (110592, 24).

here's also the source_1.h5m file just in case:

So the shape of the source_density is the (number of subvoxels, number_of_energy_groups * number_of_maximum_cells)? I'm not entirely sure if I understand how to understand that and how there's a discrepancy between the total value and the sum of the array..

Thank you so much for the help!

Thanks,
Jin Whan Bae
Oak Ridge National Laboratory

Xiaokang Zhang

unread,
Jan 11, 2022, 10:36:10 PM1/11/22
to Paul Wilson, nucle...@gmail.com, PyNE Users

Hi Jin Whan,

Let's clear up some concept first. Every mesh element (voxel) may overlap with multiple cells, and the intersection of a cell and a voxel is the so-called sub-voxel. The PyNE R2S supports both voxel and sub-voxel mode. The voxel mode uses homogenized material for each mesh element (24 groups photon source for each voxel). The sub-voxel mode deal with the sub-voxel individually (24*max_num_cells photon source data for each voxel).

In your case, the 'max_num_cells' is 9, and the 216 number is the number of energy groups (24) multiplied by 9. This indicating that you are use "sub-voxel" mode, i.e., the value for 'sub-voxel' is True in your "config.ini" file.

You mentioned that "the summation of the entire matrix is not equal to the value in `total_photon_source_intensity.txt`, which is the case for non-subvoxel calculations". This is because the data in `source_x.h5m` is the 'source density', in unit of particle per second per cubit centimeter [p/s/cm3]. Well, the data in `total_photon_source_intensity.txt` is the emit rate, in unit of particle per second [p/s]. You need to multiply the volume of each sub-voxel to get the total photon emitting rate. You can refer to the corresponding source code to deal with the volume is in line 392 to 400 in 'pyne/src/source_sampling.cpp' for more detail.

By the way, you can set the 'sub-voxel' in "config.ini" to False to use voxel mode, then there will be only 24 data for each voxel.

Best regards,

Xiaokang

Jin whan Bae

unread,
Jan 12, 2022, 11:17:07 AM1/12/22
to PyNE Users
Hi Xiaokang, thank you for the reply. I think that clears up a lot of things. The tutorial on the website had the same total photon source intensity as the sum of source densities, but I'm guessing it had a total volume of 1 g/cc. My mistake.

So is there a way to get the volume and the centroids of the subvoxels from the h5m file? I tried looking at the docs and am having a hard time finding it.

for the non subvoxel mode, I tried doing that and got a segmentation fault. I uploaded the alara files in the same google drive folder in the directory just_alara.

Also this might be a silly question, but is there a reason why the h5m files are not viewable through h5py? I feel like that'd make viewing and understanding the data structure easier.

Sorry for asking so many questions. Thank you so much!
Best,
Jin Whan Bae

Paul Wilson

unread,
Jan 12, 2022, 1:33:36 PM1/12/22
to nucle...@gmail.com, PyNE Users

Hi again,

 

The sub-voxel data includes:

  • the ID of each cell that appears in the voxel
  • the volume fraction of each of those cells

 

The volume of the whole voxel can be calculated from its bounding planes.

 

We do not know (and therefore record) the centroids of the sub-voxels.  Instead, we have schemes for sampling the photon source from the subvoxels that is probably best described in code.  So the sampling scheme preserves the correct location of each sub-voxel.

Reply all
Reply to author
Forward
0 new messages