Closed shimwell closed 7 months ago
@shimwell you can also just call Path.resolve
on the h5m file name and it should get exported to model.xml
in a way that works in the temp directory with no changes to run_kwargs
Good point Ethan
adding resolve and changing these two lines
universe = openmc.DAGMCUniverse("dagmc.h5m").bounded_universe()
umesh = openmc.UnstructuredMesh("umesh.h5m", library="moab")
to this
from pathlib import Path
universe = openmc.DAGMCUniverse(Path("dagmc.h5m").resolve()).bounded_universe()
umesh = openmc.UnstructuredMesh(Path("umesh.h5m").resolve(), library="moab")
Solves the issue 🎉
I had a look into the get_microxs_and_flux
and I think it would be difficult to make the function work for relative paths. So I think resolve is the best solution we will get.
I shall close this now but if anyone wants to reopen that is also fine.
We could sneak in a check when the DAGMCUniverse and UnstructuredMesh objects are made. The check could be something like this ...
if Path(filename).is_relative()
warnings.warn(f"path to DAGMC file {filename} is relative. It is recommended to use absolute / resolved paths when creating DAGMCUniverse to avoid potential errors when openmc runs using temporary directories")
What do people think is it worth adding a check like this to DAGMCUniverse and UnstructuredMesh?
Bug Description
When running
openmc.deplete.get_microxs_and_flux
with a geometry that uses dagmc the dagmc h5m can't be found by the get_microxs_and_flux. I believe this is because get_microxs_and_flux runs in a tmp directory by default.Steps to Reproduce
Alternative work around
we can add a key word to the get_microxs_and_flux method call
run_kwargs={'cwd':os.path.dirname(__file__)},
Environment
openmc dev (updated yesterday)