fusion-energy / neutronics-workshop

A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools
MIT License
118 stars 51 forks source link

viewing VTK files in jupyter #291

Open shimwell opened 2 weeks ago

shimwell commented 2 weeks ago

I accidentally stumbled on this today while trying to view a vtk from within a container and thought the workshop could benefit from this.

Currently we ask users to install paraview locally. However we could view the vtk files directly in julyter lab.

We could include pyvista with pip install 'pyvista[jupyter]' in the docker image and then plot mesh tally results like this one from task 8

import pyvista as pv
mesh = pv.read('heating_tally_on_reg_mesh.vtk')
mesh.set_active_scalars(name='mean')
clipped = mesh.clip(normal='y')
# clipped_and_thresholded = clipped.threshold(0.1e-21)
clipped_and_thresholded = clipped.threshold_percent(0.01)
clipped_and_thresholded.plot()

:video_camera: vtk-openmc-pyvist-jupyter.webm :video_camera: vtk-openmc-jupyter-pyvista