openmc-dev / openmc

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

Display geometric models in "three views" mode #3008

Open shenbo opened 3 months ago

shenbo commented 3 months ago

Description

we can display geometric models in three views. like below:

image

just add a Geometry.plot() method like Geometry.plot( basis='xyz' ) or Geometry.plot( basis='3views' )?

a simple code as below:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 2, sharex='all', sharey='all', figsize=(12, 12))
ax1, ax2, ax3, ax4 = axes[0][0], axes[0][1], axes[1][0], axes[1][1]

my_geometry.plot(basis='xz', color_by='cell', colors=color_assignment, axes=ax1)
ax1.set_xlabel('x')
ax1.set_ylabel('z')
my_geometry.plot(basis='yz', color_by='cell', colors=color_assignment, axes=ax2)
ax2.set_xlabel('y')
ax2.set_ylabel('z')
my_geometry.plot(basis='xy', color_by='cell', colors=color_assignment, axes=ax3)
ax3.set_xlabel('x')
ax3.set_ylabel('y')
ax4.set_visible(False)
plt.show()
plt.savefig('xyz.png')

Alternatives

Compatibility

MicahGale commented 3 months ago

In engineering drawings this is commonly called an orthographic projection. One of the most important things in this set of views is that features always line up in their perpendicular views.

I like this idea but I think some more thought on the basis name is needed because it might be nice sometimes to change which is the base projection.