openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
724 stars 461 forks source link

Color attribute for materials/cells/universes #2506

Open pshriwise opened 1 year ago

pshriwise commented 1 year ago

Similar to #2503, I have a plotting query for the community.

The assignment of material/cell colors in a dictionary when creating a plotting object has always felt a little clunky to me. Serpent allows users to associate a color with a cell or material that will be applied in any plots or visualization. At first, it felt odd to me to mix something non-physical into the object description, but having the color assigned to the object would make it straightforward to keep colors consistent in plots generated by the Python API, the openmc executable, and the plotting utility.

Thoughts @paulromano @kkiesling @gridley?

kkiesling commented 1 year ago

I agree this would be a very useful feature. I assume this would be added as an attribute on the material or cell object that could be read across these different utilities.

yrrepy commented 1 year ago

Yes, I've recently discovered there was the Python API plotting, it's a bit confusing having 3 diff. ways to plot, but I guess each has it's merit. It'd be nice to keep things more constant/consistent across the three methods.

gridley commented 1 year ago

Sounds nice, but I think rather than putting a color attribute on the cell or material class, it would be better to keep two hashmaps somewhere that map cell/material IDs into color values. That way we're not inflating the memory consumption of large models at all.

In the python API, it should appear as an attribute of cell/material/whatever though.

pshriwise commented 1 year ago

@gridley We should definitely keep large models in mind for cell/material attributes 👍🏻 I'll keep that in mind should I find some time to submit a PR for this soon.

tjlaboss commented 1 year ago

This would be a nice feature! I've been guilty of trying to set Material.color more than once.

tjlaboss commented 6 months ago

Partly addressed by PR #2826 (Material and Cell only, not Universe)