Closed lewisgross1296 closed 1 year ago
So I was at least able to recompile / create an h5 library by changing the two occurrences of str(int(np.round(temperature)))
in lines 1982 -1990 of mgxs_library.py
to the following :
for temperature in self.temperatures:
temp_label = str(np.round(float(temperature),5)) + "K"
print(temp_label)
kT = temperature * openmc.data.K_BOLTZMANN
ktg.create_dataset(temp_label, data=kT)
# Create the temperature datasets
for i, temperature in enumerate(self.temperatures):
xs_grp = grp.create_group(str(np.round(float(temperature),5)) + "K")
Inspecting the library with h5ls
seems to indicate success (only showing the first two temp results)
lgross@ulam:~ $ h5ls -r one_gxs.h5
/ Group
/slab_xs Group
/slab_xs/308.0K Group
/slab_xs/308.0K/absorption Dataset {1}
/slab_xs/308.0K/scatter_data Group
/slab_xs/308.0K/scatter_data/g_max Dataset {1}
/slab_xs/308.0K/scatter_data/g_min Dataset {1}
/slab_xs/308.0K/scatter_data/scatter_matrix Dataset {1}
/slab_xs/308.0K/total Dataset {1}
/slab_xs/308.34247K Group
/slab_xs/308.34247K/absorption Dataset {1}
/slab_xs/308.34247K/scatter_data Group
/slab_xs/308.34247K/scatter_data/g_max Dataset {1}
/slab_xs/308.34247K/scatter_data/g_min Dataset {1}
/slab_xs/308.34247K/scatter_data/scatter_matrix Dataset {1}
/slab_xs/308.34247K/total Dataset {1}
My next task will be to run a simulation using this library. Instead of using the above, I want to attempt to use one a more meaningful to my application. Likely will give it a go, either over the weekend or next week.
If this seems to work and people are generally okay with my choice of a float with five decimals, then this could be a quick two-line PR. Though maybe we'd want to add some tests as well?
A few thoughts:
Although I understand the motivation, in what practical situation would the difference between cross sections that are less than 1 K apart ever matter?
I was also expecting that resolution smaller than 1K wouldn't make much of a difference. However, for this analytical benchmark I've been working on with @aprilnovak, @pshriwise, and @gonuke, we are experiencing error behavior that is not expected and are interested to see if refining the temperature library further helps.
Our geometry uses N=[50,100,250,500,1000]
cells, but in each case the temperature library uses 50 temperatures. Each case also uses the same number of particles/batches. The flux's error norm is not decreasing monotonically as we refine the mesh.
Maybe the finer cases need more particles than the coarser ones, but I'm not sure how to scientifically decide how many particles to run in each case. While I do want to see if refining the temperature library further would help, some other options include
Extending to a float with a few decimal places seems reasonable. However, make sure you don't break existing libraries.
Is this something GH Actions would catch? I'm using a patched branch for S2 transport, so the tests wont pass locally for me anyways
It seems like this does break other libraries, when I tried to run, I saw
ERROR: Object "308K" does not exist in object /slab_xs/kTs
application called MPI_Abort(MPI_COMM_WORLD, -1) - process 1
This feature probably isn't worth it, especially once #2296 is eventually resolved
In #2296, I provided an MWE that shows multi-group mode (
settings.energy_mode=multi-group
) is currently incompatible withsettings.temperature[method]=interpolation
. For multiphysics simulations (e.g. Cardinal) that need multi-group mode, we are then are restricted to usingsettings.temperature[method]=nearest.
To remedy this, I wanted to use a large number of temperatures in the data library so that nearest mode essentially becomes a "quasi-interpolation." However, I ran into an issue with HDF5 when I attempted to set more temperatures in the data library than there were integer numbers between my min and max. Below is an MWE that causes an error:The error:
There was some discussion in this slack thread. @pshriwise did some digging and found that this line in
mgxs_library.py
, among some other places, causes the above.He suggested a work-around: use a float (with a few places) instead of an int when converting the temperature name to a string. I plan to test this tomorrow to see if it succeeds, but I think, in general, a user should be allowed to have more temperatures in their library than the number of integers between their min and max temp. We are unsure if anywhere else in the code assumes an int format for the name, so I will report back once I try this work around to see if I can create the library / run a simulation.