Plotting DAGMC Geometry to Verify Source Geometry

Hi, I’ve got a simple DAGMC tokamak model I built using Cubit and the DAGMC plugin which I’ve been able to load into OpenMC without issue. Its a 180 degree model, and for my source geometry I’m just trying to have an isotropic line source on the magnetic axis. I’ve been able to define one of these sources easily using the CylindricalIndependent function but I’m not entirely sure I’ve got the source where I want it in the model. I have been trying to plot the DAGMC geometry inside of OpenMC but keep running into either blank plots or the following error:

AttributeError: ‘DAGMCUniverse’ object has no attribute ‘find’

I defined the simulation boundary in Cubit by creating an enclosing shell of material tagged with the Graveyard material. To plot the geometry I have been creating a cell, setting the fill to be the DAGMC universe then trying to use universe.plot().

I’m also curious about the coordinate system in OpenMC which I seem to have had a tough time getting information on - I assume that the XYZ axes in Cubit map correctly to the XYZ axes in OpenMC? and that the z direction in the CylindricalIndependent function is the same as the z direction in the cartesian coordinate system?


I would recommend using openmc-plotter for interactively visualizing geometries (including DAGMC geometries). In the current release of OpenMC, universe.plot does not work for DAGMC geometries as you’ve discovered. That will be fixed in the next release in OpenMC, but I still think you’ll have a better experience using openmc-plotter.

I haven’t personally used Cubit so someone else (@pshriwise @Shimwell) will have to confirm.

Yes, the z direction does line up with the Cartesian coordinate system.

Yes the XYZ axes in Cubit map correctly to the XYZ axes in OpenMC

One option for viewing everything together in 3d would be to convert the dagmc file to a vtk file using the terminal command mbconvert. This is installed with Moab which I guess you have if you are simulating DAGMC geometry.

mbconvert dagmc.h5m dagmc.vtk

Then run OpenMC in track mode and export the tracks to vtk files. The load up the vtk geometry and track files in paraview.

Example tracks script here and paraview track viewing towards the end of this video here

One last thing, you might also be interested in slice plots of your dagmc geometry with this package or plotting the OpenMC source with this package. I hope to bring these two packages together at some point to allow source plotting on slices of DAGMC geometry.

1 Like

Oh also you no longer have to define a graveyard cell thanks to this PR it can be automatically added

Thanks so much for the help! I didn’t realize that openmc-plotter existed for DAGMC geometries, that’s proven to be very handy. I will definitely be taking a look into the tools herein referenced to solve this issue.

I’ve given openmc_source_plotter a try but ran into the following error :slight_smile:

AttributeError: module ‘openmc.lib’ has no attribute ‘sample_external_source’

I’m currently running the 0.13.0 version of openmc, should I be using the latest development version to get this functionality?

Yes, you would need the latest development version as that capability was added very recently. We should have a new release (0.13.1) out within the next week that will also include this capability.

1 Like

Yep this particular function was just put on the development branch 16 days ago
Add C API function for sampling external source and Python binding by paulromano · Pull Request #2119 · openmc-dev/openmc (

Yep I just recompiled with the latest dev version of OpenMC and all is working well! Thanks again